Changeset cb54527 for perl/lib


Ignore:
Timestamp:
Mar 26, 2007, 9:04:54 PM (17 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, barnowl_perlaim, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
4c2ec6c
Parents:
18a99d2
git-author:
Nelson Elhage <nelhage@mit.edu> (03/26/07 21:04:37)
git-committer:
Nelson Elhage <nelhage@mit.edu> (03/26/07 21:04:54)
Message:
Getting rid of indirect object syntax new calls. Quoting perlobj:

> But what if there are no arguments? In that case, Perl must guess what
> you want. Even worse, it must make that guess *at compile time*. Usually
> Perl gets it right, but when it doesn't you get a function call compiled
> as a method, or vice versa. This can introduce subtle bugs that are hard
> to detect.
> 
> For example, a call to a method "new" in indirect notation -- as C++
> programmers are wont to make -- can be miscompiled into a subroutine
> call if there's already a "new" function in scope. You'd end up calling
> the current package's "new" as a subroutine, rather than the desired
> class's method. The compiler tries to cheat by remembering bareword
> "require"s, but the grief when it messes up just isn't worth the years
> of debugging it will take you to track down such subtle bugs.
    
Location:
perl/lib
Files:
26 edited

Legend:

Unmodified
Added
Removed
  • perl/lib/Net/Jabber.pm

    r0ff8d110 rcb54527  
    6161    For a client:
    6262      use Net::Jabber;
    63       my $client = new Net::Jabber::Client();
     63      my $client = Net::Jabber::Client->new();
    6464
    6565    For a component:
    6666      use Net::Jabber;
    67       my $component = new Net::Jabber::Component();
     67      my $component = Net::Jabber::Component->new();
    6868
    6969=head1 METHODS
  • perl/lib/Net/Jabber/Component.pm

    r0ff8d110 rcb54527  
    5454    use Net::Jabber;
    5555
    56     $Con = new Net::Jabber::Component();
     56    $Con = Net::Jabber::Component->new();
    5757
    5858    $Con->Execute(hostname=>"jabber.org",
  • perl/lib/Net/Jabber/Data.pm

    r0ff8d110 rcb54527  
    5656  Net::Jabber::Client module.
    5757
    58     my $xdb = new Net::Jabber::XDB(%hash);
     58    my $xdb = Net::Jabber::XDB->new(%hash);
    5959
    6060  There has been a change from the old way of handling the callbacks.
     
    8383    use Net::Jabber;
    8484
    85     my $xdb = new Net::Jabber::XDB();
     85    my $xdb = Net::Jabber::XDB->new();
    8686    $data = $xdb->NewData("jabber:iq:auth");
    8787
  • perl/lib/Net/Jabber/Dialback.pm

    r0ff8d110 rcb54527  
    3838  the XML::Stream hash.  For example:
    3939
    40     my $dialback = new Net::Jabber::Dialback(%hash);
     40    my $dialback = Net::Jabber::Dialback->new(%hash);
    4141
    4242  You now have access to all of the retrieval functions available.
     
    4646    use Net::Jabber qw(Server);
    4747
    48     $DB = new Net::Jabber::Dialback("verify");
    49     $DB = new Net::Jabber::Dialback("result");
     48    $DB = Net::Jabber::Dialback->new("verify");
     49    $DB = Net::Jabber::Dialback->new("result");
    5050
    5151  Please see the specific documentation for Net::Jabber::Dialback::Result
     
    9898        {
    9999            my ($temp) = @_;
    100             return new Net::Jabber::Dialback::Result()
     100            return Net::Jabber::Dialback::Result->new()
    101101                if ($temp eq "result");
    102             return new Net::Jabber::Dialback::Verify()
     102            return Net::Jabber::Dialback::Verify->new()
    103103                if ($temp eq "verify");
    104104
    105105            my @temp = @{$temp};
    106             return new Net::Jabber::Dialback::Result(@temp)
     106            return Net::Jabber::Dialback::Result->new(@temp)
    107107                if ($temp[0] eq "db:result");
    108             return new Net::Jabber::Dialback::Verify(@temp)
     108            return Net::Jabber::Dialback::Verify->new(@temp)
    109109                if ($temp[0] eq "db:verify");
    110110        }
  • perl/lib/Net/Jabber/Dialback/Result.pm

    r0ff8d110 rcb54527  
    3838  the XML::Stream hash.  For example:
    3939
    40     my $dialback = new Net::Jabber::Dialback::Result(%hash);
     40    my $dialback = Net::Jabber::Dialback::Result->new(%hash);
    4141
    4242  There has been a change from the old way of handling the callbacks.
     
    6363    use Net::Jabber qw(Server);
    6464
    65     $Result = new Net::Jabber::Dialback::Result();
     65    $Result = Net::Jabber::Dialback::Result->new();
    6666
    6767  Now you can call the creation functions below to populate the tag before
  • perl/lib/Net/Jabber/Dialback/Verify.pm

    r0ff8d110 rcb54527  
    3838  the XML::Stream hash.  For example:
    3939
    40     my $dialback = new Net::Jabber::Dialback::Verify(%hash);
     40    my $dialback = Net::Jabber::Dialback::Verify->new(%hash);
    4141
    4242  There has been a change from the old way of handling the callbacks.
     
    6363    use Net::Jabber qw(Server);
    6464
    65     $Verify = new Net::Jabber::Dialback::Verify();
     65    $Verify = Net::Jabber::Dialback::Verify->new();
    6666
    6767  Now you can call the creation functions below to populate the tag before
  • perl/lib/Net/Jabber/IQ.pm

    r0ff8d110 rcb54527  
    6363sub RemoveX  { my $self = shift; $self->RemoveChild(@_);  }
    6464
    65 sub _new_jid    { my $self = shift; return new Net::Jabber::JID(@_);    }
    66 sub _new_packet { my $self = shift; return new Net::Jabber::Stanza(@_); }
    67 sub _iq         { my $self = shift; return new Net::Jabber::IQ(@_);     }
     65sub _new_jid    { my $self = shift; return Net::Jabber::JID->new(@_);    }
     66sub _new_packet { my $self = shift; return Net::Jabber::Stanza->new(@_); }
     67sub _iq         { my $self = shift; return Net::Jabber::IQ->new(@_);     }
    6868
    69691;
  • perl/lib/Net/Jabber/Key.pm

    r0ff8d110 rcb54527  
    4141=head2 Basic Functions
    4242
    43     $Key = new Net::Jabber::Key();
     43    $Key = Net::Jabber::Key->new();
    4444
    4545    $key = $Key->Generate();
     
    9797    my $self = { };
    9898
    99     $self->{DEBUG} = new Net::Jabber::Debug(usedefault=>1,
    100                       header=>"NJ::Key");
     99    $self->{DEBUG} = Net::Jabber::Debug->new(usedefault=>1,
     100                                             header=>"NJ::Key");
    101101
    102102    $self->{VERSION} = $VERSION;
  • perl/lib/Net/Jabber/Log.pm

    r0ff8d110 rcb54527  
    3838  XML::Parser Tree array.  For example:
    3939
    40     my $log = new Net::Jabber::Log(@tree);
     40    my $log = Net::Jabber::Log->new(@tree);
    4141
    4242  There has been a change from the old way of handling the callbacks.
     
    5959    use Net::Jabber;
    6060
    61     $Log = new Net::Jabber::Log();
     61    $Log = Net::Jabber::Log->new();
    6262
    6363  Now you can call the creation functions below to populate the tag before
     
    176176    bless($self, $proto);
    177177
    178     $self->{DEBUG} = new Net::Jabber::Debug(usedefault=>1,
    179                                                     header=>"NJ::Log");
     178    $self->{DEBUG} = Net::Jabber::Debug->new(usedefault=>1,
     179                                             header=>"NJ::Log");
    180180
    181181    if ("@_" ne (""))
  • perl/lib/Net/Jabber/Message.pm

    r0ff8d110 rcb54527  
    5858sub RemoveX  { my $self = shift; $self->RemoveChild(@_); }
    5959
    60 sub _new_jid    { my $self = shift; return new Net::Jabber::JID(@_);     }
    61 sub _new_packet { my $self = shift; return new Net::Jabber::Stanza(@_);  }
    62 sub _message    { my $self = shift; return new Net::Jabber::Message(@_); }
     60sub _new_jid    { my $self = shift; return Net::Jabber::JID->new(@_);     }
     61sub _new_packet { my $self = shift; return Net::Jabber::Stanza->new(@_);  }
     62sub _message    { my $self = shift; return Net::Jabber::Message->new(@_); }
    6363
    64641;
  • perl/lib/Net/Jabber/Presence.pm

    r0ff8d110 rcb54527  
    5858sub RemoveX  { my $self = shift; $self->RemoveChild(@_); }
    5959
    60 sub _new_jid    { my $self = shift; return new Net::Jabber::JID(@_);      }
    61 sub _new_packet { my $self = shift; return new Net::Jabber::Stanza(@_);   }
    62 sub _presence   { my $self = shift; return new Net::Jabber::Presence(@_); }
     60sub _new_jid    { my $self = shift; return Net::Jabber::JID->new(@_);      }
     61sub _new_packet { my $self = shift; return Net::Jabber::Stanza->new(@_);   }
     62sub _presence   { my $self = shift; return Net::Jabber::Presence->new(@_); }
    6363
    64641;
  • perl/lib/Net/Jabber/Protocol.pm

    r0ff8d110 rcb54527  
    7878
    7979    use Net::Jabber qw( Client );
    80     $Con = new Net::Jabber::Client();                # From
     80    $Con = Net::Jabber::Client->new();                # From
    8181    $status = $Con->Connect(hostname=>"jabber.org"); # Net::Jabber::Client
    8282
     
    8484
    8585    use Net::Jabber qw( Component );
    86     $Con = new Net::Jabber::Component();             #
     86    $Con = Net::Jabber::Component->new();             #
    8787    $status = $Con->Connect(hostname=>"jabber.org",  # From
    8888                            secret=>"bob");          # Net::Jabber::Component
     
    16601660        if exists($Net::Jabber::Query::TAGS{'http://jabber.org/protocol/feature-neg'});
    16611661   
    1662     my $query = new Net::Jabber::Query($tag);
     1662    my $query = Net::Jabber::Query->new($tag);
    16631663    $query->SetXMLNS("http://jabber.org/protocol/feature-neg");
    16641664    my $xdata = $query->NewX("jabber:x:data");
     
    21832183    while($#_ >= 0) { $args{ lc pop(@_) } = pop(@_); }
    21842184
    2185     my $query = new Net::Jabber::Stanza("query");
     2185    my $query = Net::Jabber::Stanza->new("query");
    21862186    $query->SetXMLNS("jabber:iq:rpc");
    21872187
  • perl/lib/Net/Jabber/Server.pm

    r0ff8d110 rcb54527  
    5454    use Net::Jabber qw(Server);
    5555
    56     $Server = new Net::Jabber::Server();
     56    $Server = Net::Jabber::Server->new();
    5757
    5858    $Server->Start();
     
    155155    bless($self, $proto);
    156156
    157     $self->{KEY} = new Net::Jabber::Key();
     157    $self->{KEY} = Net::Jabber::Key->new();
    158158
    159159    $self->{DEBUG} =
    160         new Net::Jabber::Debug(level=>exists($args{debuglevel}) ? $args{debuglevel} : -1,
    161                                file=>exists($args{debugfile}) ? $args{debugfile} : "stdout",
    162                                time=>exists($args{debugtime}) ? $args{debugtime} : 0,
    163                                setdefault=>1,
    164                                header=>"NJ::Server"
    165                               );
     160        Net::Jabber::Debug->new(level=>exists($args{debuglevel}) ? $args{debuglevel} : -1,
     161                                file=>exists($args{debugfile}) ? $args{debugfile} : "stdout",
     162                                time=>exists($args{debugtime}) ? $args{debugtime} : 0,
     163                                setdefault=>1,
     164                                header=>"NJ::Server"
     165                               );
    166166
    167167    $self->{SERVER} = { hostname => "localhost",
     
    329329    $self->{DEBUG}->Log2("dbresultHandler: dbresult(",$dbresult->GetXML(),")");
    330330
    331     my $dbverify = new Net::Jabber::Dialback::Verify();
     331    my $dbverify = Net::Jabber::Dialback::Verify->new();
    332332    $dbverify->SetVerify(to=>$dbresult->GetFrom(),
    333333                         from=>$dbresult->GetTo(),
  • perl/lib/Net/Jabber/Stanza.pm

    r0ff8d110 rcb54527  
    17381738sub RemoveQuery  { my $self = shift; $self->RemoveChild(@_);  }
    17391739
    1740 sub _new_jid    { my $self = shift; return new Net::Jabber::JID(@_);    }
    1741 sub _new_packet { my $self = shift; return new Net::Jabber::Stanza(@_); }
     1740sub _new_jid    { my $self = shift; return Net::Jabber::JID->new(@_);    }
     1741sub _new_packet { my $self = shift; return Net::Jabber::Stanza->new(@_); }
    17421742
    17431743
  • perl/lib/Net/Jabber/XDB.pm

    r0ff8d110 rcb54527  
    4444  XML::Parser Tree array.  For example:
    4545
    46     my $xdb = new Net::Jabber::XDB(@tree);
     46    my $xdb = Net::Jabber::XDB->new(@tree);
    4747
    4848  There has been a change from the old way of handling the callbacks.
     
    6565    use Net::Jabber;
    6666
    67     $XDB = new Net::Jabber::XDB();
     67    $XDB = Net::Jabber::XDB->new();
    6868    $XDBType = $XDB->NewData( type );
    6969    $XDBType->SetXXXXX("yyyyy");
     
    418418    while($#_ >= 0) { $args{ lc pop(@_) } = pop(@_); }
    419419
    420     my $reply = new Net::Jabber::XDB();
     420    my $reply = Net::Jabber::XDB->new();
    421421
    422422    $reply->SetID($self->GetID()) if ($self->GetID() ne "");
  • perl/lib/Net/XMPP.pm

    r0ff8d110 rcb54527  
    6161
    6262      use Net::XMPP;
    63       my $client = new Net::XMPP::Client();
     63      my $client = Net::XMPP::Client->new();
    6464
    6565=head1 METHODS
  • perl/lib/Net/XMPP/Client.pm

    r0ff8d110 rcb54527  
    5454    use Net::XMPP;
    5555
    56     $Con = new Net::XMPP::Client();
     56    $Con = Net::XMPP::Client->new();
    5757
    5858    $Con->SetCallbacks(...);
  • perl/lib/Net/XMPP/Debug.pm

    r0ff8d110 rcb54527  
    3939=head2 Basic Functions
    4040
    41     $Debug = new Net::XMPP::Debug();
     41    $Debug = Net::XMPP::Debug->new();
    4242
    4343    $Debug->Init(level=>2,
     
    8686=head1 EXAMPLE
    8787
    88   $Debug = new Net::XMPP:Debug(level=>2,
     88  $Debug = Net::XMPP:Debug->new(level=>2,
    8989                               header=>"Example");
    9090
  • perl/lib/Net/XMPP/IQ.pm

    r0ff8d110 rcb54527  
    6262    use Net::XMPP;
    6363
    64     $IQ = new Net::XMPP::IQ();
     64    $IQ = Net::XMPP::IQ->new();
    6565    $IQType = $IQ->NewChild( type );
    6666    $IQType->SetXXXXX("yyyyy");
     
    291291}
    292292
    293 sub _iq { my $self = shift; return new Net::XMPP::IQ(); }
     293sub _iq { my $self = shift; return Net::XMPP::IQ->new(); }
    294294
    295295$FUNCTIONS{Error}->{path} = 'error/text()';
  • perl/lib/Net/XMPP/JID.pm

    r0ff8d110 rcb54527  
    4242
    4343    sub foo {
    44       my $foo = new Net::XMPP::Foo(@_);
     44      my $foo = Net::XMPP::Foo->new(@_);
    4545      my $from = $foo->GetFrom();
    46       my $JID = new Net::XMPP::JID($from);
     46      my $JID = Net::XMPP::JID->new($from);
    4747      .
    4848      .
     
    5656    use Net::XMPP;
    5757
    58     $JID = new Net::XMPP::JID();
     58    $JID = Net::XMPP::JID->new();
    5959
    6060  Now you can call the creation functions below to populate the tag
  • perl/lib/Net/XMPP/Message.pm

    r0ff8d110 rcb54527  
    5555    use Net::XMPP;
    5656
    57     $Mess = new Net::XMPP::Message();
     57    $Mess = Net::XMPP::Message->new();
    5858
    5959  Now you can call the creation functions below to populate the tag
     
    315315}
    316316
    317 sub _message { my $self = shift; return new Net::XMPP::Message(); }
     317sub _message { my $self = shift; return Net::XMPP::Message->new(); }
    318318
    319319
  • perl/lib/Net/XMPP/Presence.pm

    r0ff8d110 rcb54527  
    5555    use Net::XMPP;
    5656
    57     $Pres = new Net::XMPP::Presence();
     57    $Pres = Net::XMPP::Presence->new();
    5858
    5959  Now you can call the creation functions below to populate the tag
     
    270270}
    271271
    272 sub _presence { my $self = shift; return new Net::XMPP::Presence(); }
     272sub _presence { my $self = shift; return Net::XMPP::Presence->new(); }
    273273
    274274
  • perl/lib/Net/XMPP/Protocol.pm

    r3405394 rcb54527  
    7474
    7575    use Net::XMPP qw( Client );
    76     $Con = new Net::XMPP::Client();                  # From
     76    $Con = Net::XMPP::Client->new();                  # From
    7777    $status = $Con->Connect(hostname=>"jabber.org"); # Net::XMPP::Client
    7878
     
    20492049    my $self = shift;
    20502050
    2051     return new Net::XMPP::PrivacyLists(connection=>$self);
     2051    return Net::XMPP::PrivacyLists->new(connection=>$self);
    20522052}
    20532053
     
    23722372    my $self = shift;
    23732373
    2374     return new Net::XMPP::Roster(connection=>$self);
     2374    return Net::XMPP::Roster->new(connection=>$self);
    23752375}
    23762376
  • perl/lib/Net/XMPP/Roster.pm

    r91bf213 rcb54527  
    4141=head2 Basic Functions
    4242
    43   my $Client = new Net::XMPP::Client(...);
    44 
    45   my $Roster = new Net::XMPP::Roster(connection=>$Client);
     43  my $Client = Net::XMPP::Client->new(...);
     44
     45  my $Roster = Net::XMPP::Roster->new(connection=>$Client);
    4646    or
    4747  my $Roster = $Client->Roster();
  • perl/lib/Net/XMPP/Stanza.pm

    r0ff8d110 rcb54527  
    216216use vars qw( $AUTOLOAD %FUNCTIONS $DEBUG );
    217217
    218 $DEBUG = new Net::XMPP::Debug(usedefault=>1,
    219                               header=>"XMPP");
     218$DEBUG = Net::XMPP::Debug->new(usedefault=>1,
     219                               header=>"XMPP");
    220220
    221221# XXX need to look at evals and $@
     
    14121412{
    14131413    my $self = shift;
    1414     return new Net::XMPP::JID(@_);
     1414    return Net::XMPP::JID->new(@_);
    14151415}
    14161416
     
    14241424{
    14251425    my $self = shift;
    1426     return new Net::XMPP::Stanza(@_);
     1426    return Net::XMPP::Stanza->new(@_);
    14271427}
    14281428
  • perl/lib/XML/Stream.pm

    ra75309a rcb54527  
    681681        if ($NETDNS)
    682682        {
    683             my $res = new Net::DNS::Resolver();
     683            my $res = Net::DNS::Resolver->new();
    684684            my $query = $res->query($self->{SIDS}->{newconnection}->{srv}.".".$self->{SIDS}->{newconnection}->{hostname},"SRV");
    685685           
Note: See TracChangeset for help on using the changeset viewer.