Re: DJabberd and Perl 5.10

2008-06-22 Thread Daniel Ruoso
Dom, 2008-06-22 às 00:13 +0200, Michael Scherer escreveu:
 Do you have a patch ?

Well, I thought it wouldn't be worth posting because I'm simply
commenting out the 'use fields' directive in both files and replacing
the calls to fields::new($class) for bless {}, $class.

As I said before, I understand this is not a proper fix, only a
work-around. I think there should be a way to implement a proper-OO fix.

Anyway, there the patch goes

daniel
--- XMLElement.pm	2007-05-08 18:41:45.0 -0300
+++ XMLElement.pm.patched	2008-06-22 10:13:34.0 -0300
@@ -1,13 +1,13 @@
 package DJabberd::XMLElement;
 use strict;
-use fields (
-'ns',# namespace name
-'element',   # element name
-'attrs', # hashref of {namespace}attr = value.  NOTE: used by Stanza.pm directly.
-'children',  # arrayref of child elements of this same type, or scalars for text nodes
-'raw',   # in some cases we have the raw xml and we have to create a fake XMLElement object
- # business logic is that as_xml returns the raw stuff if it is exists, children has to be empty -- sky
-);
+#use fields (
+#'ns',# namespace name
+#'element',   # element name
+#'attrs', # hashref of {namespace}attr = value.  NOTE: used by Stanza.pm directly.
+#'children',  # arrayref of child elements of this same type, or scalars for text nodes
+#'raw',   # in some cases we have the raw xml and we have to create a fake XMLElement object
+# # business logic is that as_xml returns the raw stuff if it is exists, children has to be empty -- sky
+#);
 
 use DJabberd::Util;
 
@@ -19,7 +19,7 @@
 }
 
 # constructing a new XMLElement:
-my DJabberd::XMLElement $self = fields::new($class);
+my DJabberd::XMLElement $self = bless {}, $class;
 ($self-{ns},
  $self-{element},
  $self-{attrs},
@@ -164,7 +164,7 @@
 
 sub clone {
 my $self = shift;
-my $clone = fields::new(ref($self));
+my $clone = bless {}, ref($self);
 $clone-{ns}   = $self-{ns};
 $clone-{element}  = $self-{element};
 $clone-{attrs}= { %{ $self-{attrs} } };
--- Stanza.pm	2006-09-27 17:57:47.0 -0300
+++ Stanza.pm.patched	2008-06-22 10:13:43.0 -0300
@@ -2,24 +2,24 @@
 use strict;
 use base qw(DJabberd::XMLElement);
 use Carp qw(croak);
-use fields (
-'connection',   # Store the connection the stanza came in on so we can respond.
-# may be undef, as it's a weakref.  if you want to mess with the
-# structure, you can't do so unless you're the owner, so clone
-# it first otherwise.
-'_memo_tojid',   # memoized to jid
-'_memo_fromjid', # memoized from jid
-);
+#use fields (
+#'connection',   # Store the connection the stanza came in on so we can respond.
+## may be undef, as it's a weakref.  if you want to mess with the
+## structure, you can't do so unless you're the owner, so clone
+## it first otherwise.
+#'_memo_tojid',   # memoized to jid
+#'_memo_fromjid', # memoized from jid
+#);
 
 sub downbless {
 my $class = shift;
 if (ref $_[0]) {
 my ($self, $conn) = @_;
 # 'fields' hackery.  this will break in Perl 5.10
-{
-no strict 'refs';
-$self-[0] = \%{$class . ::FIELDS }
-}
+#{
+#no strict 'refs';
+#$self-[0] = \%{$class . ::FIELDS }
+#}
 bless $self, $class;
 if ($conn) {
 $self-{connection} = $conn;


DJabberd and Perl 5.10

2008-06-21 Thread Daniel Ruoso
Hello,


Today I had an unfortunate discovery. DJabberd seems to fail on Perl
5.10. At first, I couldn't really figure out what the problem is, so,
before I dig into the code, did anyone solved that problem already? is
there an unreleased version that works with Perl 5.10?

daniel



Re: DJabberd and Perl 5.10

2008-06-21 Thread Jacob Burkhart
I seem to remember some comments in the code saying something like This
will break with perl 5.10... might want to search the code base for things
like that.

On Sat, Jun 21, 2008 at 4:29 PM, Daniel Ruoso [EMAIL PROTECTED] wrote:

 Hello,


 Today I had an unfortunate discovery. DJabberd seems to fail on Perl
 5.10. At first, I couldn't really figure out what the problem is, so,
 before I dig into the code, did anyone solved that problem already? is
 there an unreleased version that works with Perl 5.10?

 daniel




Re: DJabberd and Perl 5.10

2008-06-21 Thread Michael Scherer


Le 21 juin 08 à 22:46, Jacob Burkhart a écrit :

I seem to remember some comments in the code saying something like  
This will break with perl 5.10... might want to search the code  
base for things like that.


On Sat, Jun 21, 2008 at 4:29 PM, Daniel Ruoso [EMAIL PROTECTED]  
wrote:

Hello,


Today I had an unfortunate discovery. DJabberd seems to fail on Perl
5.10. At first, I couldn't really figure out what the problem is, so,
before I dig into the code, did anyone solved that problem already? is
there an unreleased version that works with Perl 5.10?

daniel



in stanza.pm, method downbless all tests fails.

I do not understand what the code does.

--
Michael Scherer






Re: DJabberd and Perl 5.10

2008-06-21 Thread Daniel Ruoso
Sáb, 2008-06-21 às 16:46 -0400, Jacob Burkhart escreveu:
 I seem to remember some comments in the code saying something like
 This will break with perl 5.10... might want to search the code base
 for things like that.

Ok, the problem is in a hackish break of OO encapsulation in XMLElement
and Stanza. The downbless method is not compatible with OO implemented
by fields. The solution to that was to remove fields support in
XMLElement and Stanza, this seems to solve the problems, all tests pass
then.

The correct fix would be to correctly replace 'downbless' by a proper OO
implementation of what it does (which I'm not sure I understood).

daniel