jasons 2002/10/19 16:05:20 Modified: perl postModule.pl Log: * postModule.pl (Repository): relocated createNodeIterator and createTreeWalker to DOMDocumentTraversal class removed all overload munging Revision Changes Path 1.29 +3 -317 xml-xerces/perl/postModule.pl Index: postModule.pl =================================================================== RCS file: /home/cvs/xml-xerces/perl/postModule.pl,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- postModule.pl 27 Aug 2002 19:42:56 -0000 1.28 +++ postModule.pl 19 Oct 2002 23:05:20 -0000 1.29 @@ -37,14 +37,9 @@ if (/^package/) { ($CURR_CLASS) = m/package\s+XML::Xerces::([\w_]+);/; print TEMP; - unless ($CURR_CLASS ne 'XML::Xerces' - and $CURR_CLASS ne 'XML::Xercesc' - and exists $VARS{$CURR_CLASS}) { - $VARS{$CURR_CLASS}++; - print TEMP 'use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);', "\n"; - } next; } + # for some reason (I don't want to figure out) SWIG puts a bunch of # methods directly in the XML::Xerces namespace that don't belong there # and are duplicated within their proper classes, so we delete them @@ -205,315 +200,6 @@ } } - ###################################################################### - # - # Method Overloads - - # don't print out SWIG's default overloaded methods, we'll make our own - next if /XML::Xerces.*__overload__/; - - if ($CURR_CLASS =~ /(AbstractDOMParser|SAXParser)/) { - my $parser = $1; - if (/XML::Xercesc::${parser}_parse;/) { - print TEMP <<"EOT"; -sub parse { - my \@args = \@_; - if (ref \$args[1]) { - XML::Xercesc::${parser}_parse__overload__is(\@args); - } else { - XML::Xercesc::${parser}_parse(\@args); - } -} -EOT - next; - } elsif (/XML::Xercesc::${parser}_parseFirst/) { - print TEMP <<"EOT"; -sub parseFirst { - my \@args = \@_; - if (ref \$args[1]) { - XML::Xercesc::${parser}_parseFirst__overload__is(\@args); - } else { - XML::Xercesc::${parser}_parseFirst(\@args); - } -} -EOT - next; - } - } - - if ($CURR_CLASS =~ /Attributes/) { - if (/XML::Xercesc::Attributes_getType;/) { - print TEMP <<'EOT'; -sub getType { - my @args = @_; - if (scalar @args == 2) { - if ($args[1] =~ /^\d+$/) { - return XML::Xercesc::Attributes_getType__overload__index(@args); - } else { - return XML::Xercesc::Attributes_getType__overload__qname(@args); - } - } else { - return XML::Xercesc::Attributes_getType(@args); - } -} -EOT - next; - } elsif (/XML::Xercesc::Attributes_getValue;/) { - print TEMP <<'EOT'; -sub getValue { - my @args = @_; - if (scalar @args == 2) { - if ($args[1] =~ /^\d+$/) { - return XML::Xercesc::Attributes_getValue__overload__index(@args); - } else { - return XML::Xercesc::Attributes_getValue__overload__qname(@args); - } - } else { - return XML::Xercesc::Attributes_getValue(@args); - } -} -EOT - next; - } elsif (/XML::Xercesc::Attributes_getIndex;/) { - print TEMP <<'EOT'; -sub getIndex { - my @args = @_; - if (scalar @args == 2) { - return XML::Xercesc::Attributes_getIndex__overload__qname(@args); - } else { - return XML::Xercesc::Attributes_getIndex(@args); - } -} -EOT - next; - } - } - - if ($CURR_CLASS =~ /AttributeList/) { - if (/XML::Xercesc::AttributeList_getType;/) { - print TEMP <<'EOT'; -sub getType { - my @args = @_; - if ($args[1] =~ /^\d+$/) { - return XML::Xercesc::AttributeList_getType__overload__index(@args); - } else { - return XML::Xercesc::AttributeList_getType(@args); - } -} -EOT - next; - } elsif (/XML::Xercesc::AttributeList_getValue;/) { - print TEMP <<'EOT'; -sub getValue { - my @args = @_; - if ($args[1] =~ /^\d+$/) { - return XML::Xercesc::AttributeList_getValue__overload__index(@args); - } else { - return XML::Xercesc::AttributeList_getValue(@args); - } -} -EOT - next; - } - } - - if ($CURR_CLASS =~ /URLInputSource/) { - if (/^sub.*__constructor__/) { - remove_method(\*FILE); - next; - } elsif (/^sub\s+new/) { - my $subst_func = sub {$_[0] = '' if $_[0] =~ /tied/;}; - my $new = <<'EOT'; - my $self; - if (ref $args[0]) { - $args[0] = tied(%{$args[0]}); - $self = XML::Xercesc::new_URLInputSource(@args); - } elsif (scalar @args == 2) { - $self = XML::Xercesc::new_URLInputSource__constructor__sys(@args); - } else { - $self = XML::Xercesc::new_URLInputSource__constructor__pub(@args); - } -EOT - fix_method(\*FILE, - \*TEMP, - qr/\$self = XML::Xercesc::new_/, - $new, - 0, - $subst_func, - ); - next; - } - } - - if ($CURR_CLASS =~ /XMLUri/) { - if (/^sub.*__constructor__/) { - remove_method(\*FILE); - next; - } elsif (/^sub\s+new/) { - my $subst_func = sub {$_[0] = '' if $_[0] =~ /tied/;}; - my $new = <<'EOT'; - my $self; - if (scalar @args == 1) { - $self = XML::Xercesc::new_XMLUri__constructor__uri(@args); - } else { - $args[0] = tied(%{$args[0]}); - $self = XML::Xercesc::new_XMLUri(@args); - } -EOT - fix_method(\*FILE, - \*TEMP, - qr/\$self = XML::Xercesc::new_/, - $new, - 0, - $subst_func, - ); - next; - } - } - - if (grep {/$CURR_CLASS/} @domcopy_methods) { - if (/^sub.*__constructor__/) { - remove_method(\*FILE); - next; - } elsif (/^sub\s+new/) { - my $new = <<"EOT"; - my \$self; - if (ref \$pkg) { - \$self = XML::Xercesc::new_${CURR_CLASS}__constructor__copy(\$pkg); - \$pkg = ref \$pkg; - } else { - \$self = XML::Xercesc::new_${CURR_CLASS}(); - } -EOT - fix_method(\*FILE, - \*TEMP, - qr/\$self = XML::Xercesc::new_/, - $new); - next; - } - } - - if ($CURR_CLASS =~ /LocalFileInputSource/) { - # this line assumed the first constructor, so we remove it - if (/^sub.*__constructor__/) { - remove_method(\*FILE); - next; - } elsif (/^sub\s+new/) { - my $new = <<'EOT'; - my $self; - if (scalar @args == 1) { - $self = XML::Xercesc::new_LocalFileInputSource(@args); - } else { - $self = XML::Xercesc::new_LocalFileInputSource__constructor__base(@args); - } -EOT - fix_method(\*FILE, - \*TEMP, - qr/\$self = XML::Xercesc::new_/, - $new); - next; - } - } - - if ($CURR_CLASS =~ /(Perl(\w+)Handler)/) { - my $class = $1; - # this line assumed the first constructor, so we remove it - if (/^sub.*__constructor__/) { - remove_method(\*FILE); - next; - } elsif (/^sub\s+new/) { - my $new = <<"EOT"; - my \$self; - if (scalar \@args == 1) { - \$self = XML::Xercesc::new_$ {class}__constructor__arg(\@args); - } else { - \$self = XML::Xercesc::new_$ {class}(); - } -EOT - fix_method(\*FILE, - \*TEMP, - qr/\$self = XML::Xercesc::new_/, - $new); - next; - } - } - - if (/XML::Xerces::XMLReaderFactory_createXMLReader/) { - print TEMP <<'EOT'; -sub createXMLReader { - my @args = @_; - if (scalar @args == 2) { - XML::Xercesc::XMLReaderFactory_createXMLReader__overload__1(@args); - } else { - XML::Xercesc::XMLReaderFactory_createXMLReader(@args); - } -} -EOT - # we don't print out the function - next; - } - - if ($CURR_CLASS =~ /XMLURL/) { - if (/^sub.*__constructor__/) { - remove_method(\*FILE); - next; - } elsif (/^sub\s+new/) { - my $new = <<'EOT'; - my $self; - if (ref($args[0])) { - if (scalar @args == 1) { - $self = XML::Xercesc::new_XMLURL__constructor__copy(@args); - } else { - $self = XML::Xercesc::new_XMLURL__constructor__url_base(@args); - } - } elsif (! scalar @args) { - $self = XML::Xercesc::new_XMLURL(); - } elsif (scalar @args == 1) { - $self = XML::Xercesc::new_XMLURL__constructor__text(@args); - } else { - $self = XML::Xercesc::new_XMLURL__constructor__base(@args); - } -EOT - fix_method(\*FILE, - \*TEMP, - qr/\$self = XML::Xercesc::new_/, - $new, - 0, - ); - next; - } - - if (/XML::Xercesc::XMLURL_makeRelativeTo/) { - print TEMP <<'EOT'; -sub makeRelativeTo { - my @args = @_; - if (ref($args[1])) { - XML::Xercesc::XMLURL_makeRelativeTo__overload__XMLURL(@args); - } else { - XML::Xercesc::XMLURL_makeRelativeTo(@args); - } -} -EOT - # we don't print out the function - next; - } elsif (/XML::Xercesc::XMLURL_setURL/) { - print TEMP <<'EOT'; -sub setURL { - my @args = @_; - if (scalar @args == 2) { - XML::Xercesc::XMLURL_setURL(@args); - } elsif (ref($args[1])) { - XML::Xercesc::XMLURL_setURL__overload__XMLURL(@args); - } else { - XML::Xercesc::XMLURL_setURL__overload__string(@args); - } -} -EOT - # we don't print out the function - next; - } - } - if ($CURR_CLASS =~ /DOMDOMException/) { if (/^sub\s+new/) { # add the reverse name lookup for the error codes @@ -643,7 +329,7 @@ next; } - if ($CURR_CLASS eq 'DOMDocument') { + if ($CURR_CLASS eq 'DOMDocumentTraversal') { if (/^sub\s+createTreeWalker/) { my $fix = <<'EOT'; my ($self,$root,$what,$filter,$expand) = @_; @@ -665,7 +351,7 @@ } } - if ($CURR_CLASS eq 'DOMDocument') { + if ($CURR_CLASS eq 'DOMDocumentTraversal') { if (/^sub\s+createNodeIterator/) { my $fix = <<'EOT'; my ($self,$root,$what,$filter,$expand) = @_;
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]