From 95aaeab42f4c4bf0626b8a6332fc7f5362da047a Mon Sep 17 00:00:00 2001 From: Jason Edward Stewart <jasons@apache.org> Date: Fri, 13 Oct 2006 21:34:15 +0000 Subject: [PATCH] updated for sub-module reorg git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@463845 13f79535-47bb-0310-9956-ffa450edef68 --- swig/interfaces/Perl/Xerces-extra.pm | 157 ++------ swig/interfaces/Perl/Xerces_DOM-extra.pm | 99 +++++ swig/interfaces/Perl/callback.i | 7 +- swig/interfaces/Perl/defines.i | 89 ----- swig/interfaces/Perl/dom-callback.i | 45 +-- swig/interfaces/Perl/dom-shadow.i | 40 +- swig/interfaces/Perl/includes.i | 5 +- swig/interfaces/Perl/shadow.i | 84 ++-- swig/interfaces/Perl/typemaps-xmlch.i | 73 +--- swig/interfaces/Perl/typemaps.i | 73 +--- swig/interfaces/SAX.i | 7 +- swig/interfaces/SAX2.i | 2 +- swig/interfaces/Xerces.i | 150 +------ swig/interfaces/Xerces_DOM.i | 205 +++++----- swig/interfaces/defines.i | 44 --- swig/interfaces/dom-includes.i | 7 +- swig/interfaces/dom/DOMImplementation.i | 2 + .../dom/DOMImplementationRegistry.i | 3 + swig/interfaces/dom/DOMLSParserFilter.i | 2 +- swig/interfaces/dom/DOMXPathResult.i | 1 + .../framework/Wrapper4InputSource.i | 4 + swig/interfaces/framework/XMLFormatter.i | 2 +- swig/interfaces/grammars.i | 53 +++ swig/interfaces/ignore.i | 172 +------- swig/interfaces/includes.i | 43 +- swig/interfaces/parsers.i | 127 +++--- swig/interfaces/parsers/AbstractDOMParser.i | 7 + swig/interfaces/typemaps-dom.i | 374 ++++++++++++++++-- swig/interfaces/typemaps-general.i | 60 ++- swig/interfaces/util.i | 8 +- 30 files changed, 909 insertions(+), 1036 deletions(-) diff --git a/swig/interfaces/Perl/Xerces-extra.pm b/swig/interfaces/Perl/Xerces-extra.pm index 170abca04..a62a8bca2 100644 --- a/swig/interfaces/Perl/Xerces-extra.pm +++ b/swig/interfaces/Perl/Xerces-extra.pm @@ -3,8 +3,8 @@ package XML::Xerces; use strict; use Carp; use vars qw(@EXPORT_OK $VERSION %REMEMBER); -@EXPORT_OK = qw(error); -$VERSION = 300.060829; +@EXPORT_OK = qw(fatal_error error); +$VERSION = 300.061003; # # Cleanup removes all objects being remembered by an object @@ -23,9 +23,16 @@ sub cleanup { # } } +sub fatal_error { + my $error = shift; + my $context = shift; + error($error,$context, my $fatal = 1); +} + sub error { my $error = shift; my $context = shift; + my $fatal = defined (shift) ? 1 : 0; my $msg = "Error in eval: "; if (ref $error) { if ($error->isa('XML::Xerces::DOMException')) { @@ -41,29 +48,13 @@ sub error { } $msg .= ", Context: $context" if defined $context; - croak($msg); + if ($fatal) { + croak($msg); + } else { + carp($msg); + } } -package XML::Xerces::DOMException; -use vars qw(@CODES); -@CODES = qw(__NONEXISTENT__ - INDEX_SIZE_ERR - DOMSTRING_SIZE_ERR - HIERARCHY_REQUEST_ERR - WRONG_DOCUMENT_ERR - INVALID_CHARACTER_ERR - NO_DATA_ALLOWED_ERR - NO_MODIFICATION_ALLOWED_ERR - NOT_FOUND_ERR - NOT_SUPPORTED_ERR - INUSE_ATTRIBUTE_ERR - INVALID_STATE_ERR - SYNTAX_ERR - INVALID_MODIFICATION_ERR - NAMESPACE_ERR - INVALID_ACCESS_ERR - ); - package XML::Xerces::XMLExcepts; use vars qw(@CODES); @CODES = qw(NoError @@ -472,53 +463,10 @@ use vars qw(@CODES); E_HighBounds ); -############# Class : XML::Xerces::PerlContentHandler ############## -package XML::Xerces::PerlContentHandler; -use vars qw(@ISA); -@ISA = qw(); -sub new { - my $class = shift; - return bless {}, $class; -} - -sub start_element {} -sub end_element {} -sub start_prefix_mapping {} -sub end_prefix_mapping {} -sub skipped_entity {} -sub start_document {} -sub end_document {} -sub reset_document {} -sub characters {} -sub processing_instruction {} -sub set_document_locator {} -sub ignorable_whitespace {} - - -############# Class : XML::Xerces::PerlDocumentHandler ############## -package XML::Xerces::PerlDocumentHandler; -use vars qw(@ISA); -@ISA = qw(); -sub new { - my $class = shift; - return bless {}, $class; -} - -sub start_element {} -sub end_element {} -sub start_document {} -sub end_document {} -sub reset_document {} -sub characters {} -sub processing_instruction {} -sub set_document_locator {} -sub ignorable_whitespace {} - - ############# Class : XML::Xerces::PerlEntityResolver ############## package XML::Xerces::PerlEntityResolver; use vars qw(@ISA); -@ISA = qw(); +@ISA = qw(XML::Xerces::XMLEntityResolver XML::Xerces::EntityResolver); sub new { my $class = shift; return bless {}, $class; @@ -529,20 +477,6 @@ sub resolve_entity { } -############# Class : XML::Xerces::PerlNodeFilter ############## -package XML::Xerces::PerlNodeFilter; -use vars qw(@ISA); -@ISA = qw(); -sub new { - my $class = shift; - return bless {}, $class; -} - -sub acceptNode { - return undef; -} - - ############# Class : XML::Xerces::PerlErrorHandler ############## package XML::Xerces::PerlErrorHandler; use Carp; @@ -598,6 +532,20 @@ EOT sub reset_errors {} +package XML::Xerces::XMLChVector; +# convert the XMLChVector to a perl list +sub to_list { + my $self = shift; + my @list; + my $count = $self->size(); + if ($count) { + for (my $i=0;$i<$count;$i++) { + push(@list,$self->elementAt($i)); + } + } + return @list; +} + package XML::Xerces::XMLAttDefList; # # This class is both a list and a hash, so at the moment we @@ -609,9 +557,10 @@ package XML::Xerces::XMLAttDefList; sub to_list { my $self = shift; my @list; - if ($self->hasMoreElements()) { - while ($self->hasMoreElements()) { - push(@list,$self->nextElement()); + my $count = $self->getAttDefCount(); + if ($count) { + for (my $i=0;$i<$count;$i++) { + push(@list,$self->getAttDef($i)); } } return @list; @@ -621,39 +570,16 @@ sub to_list { sub to_hash { my $self = shift; my %hash; - if ($self->hasMoreElements()) { - while ($self->hasMoreElements()) { - my $attr = $self->nextElement(); + my $count = $self->getAttDefCount(); + if ($count) { + for (my $i=0;$i<$count;$i++) { + my $attr = $self->getAttDef($i); $hash{$attr->getFullName()} = $attr; } } return %hash; } -package XML::Xerces::Attributes; -sub to_hash { - my $self = shift; - my %hash; - for (my $i=0; $i < $self->getLength(); $i++) { - my $qname = $self->getQName($i); - $hash{$qname}->{localName} = $self->getLocalName($i); - $hash{$qname}->{URI} = $self->getURI($i); - $hash{$qname}->{value} = $self->getValue($i); - $hash{$qname}->{type} = $self->getType($i); - } - return %hash; -} - -package XML::Xerces::AttributeList; -sub to_hash { - my $self = shift; - my %hash; - for (my $i=0;$i<$self->getLength();$i++) { - $hash{$self->getName($i)} = $self->getValue($i) - } - return %hash; -} - package XML::Xerces::XMLCatalogResolver; use strict; use Carp; @@ -680,7 +606,7 @@ sub new { sub initialize { my $self = shift; my $CATALOG = $self->catalog(); - XML::Xerces::error (__PACKAGE__ . ": Must set catalog before calling initialize") + XML::Xerces::fatal_error(__PACKAGE__ . ": Must set catalog before calling initialize") unless defined $CATALOG; my $DOM = XML::Xerces::XercesDOMParser->new(); @@ -689,7 +615,7 @@ sub initialize { # we parse the example XML Catalog eval{$DOM->parse($CATALOG)}; - XML::Xerces::error ($@, __PACKAGE__ . ": Couldn't parse catalog: $CATALOG") + XML::Xerces::fatal_error($@, __PACKAGE__ . ": Couldn't parse catalog: $CATALOG") if $@; # now retrieve the mappings and store them @@ -733,7 +659,10 @@ sub resolve_entity { # print STDERR "Got PUBLIC: $pub\n"; # print STDERR "Got SYSTEM: $sys\n"; - XML::Xerces::error (__PACKAGE__ . ": Must call initialize before using the resolver") + # + # FIXME - this should be creating and throwing an exception + # + XML::Xerces::fatal_error(__PACKAGE__ . ": Must call initialize before using the resolver") unless defined $self->maps or defined $self->remaps; # now check which one we were asked for diff --git a/swig/interfaces/Perl/Xerces_DOM-extra.pm b/swig/interfaces/Perl/Xerces_DOM-extra.pm index 4e119502f..265a0e6a1 100644 --- a/swig/interfaces/Perl/Xerces_DOM-extra.pm +++ b/swig/interfaces/Perl/Xerces_DOM-extra.pm @@ -1,3 +1,23 @@ +package XML::Xerces::DOMException; +use vars qw(@CODES); +@CODES = qw(__NONEXISTENT__ + INDEX_SIZE_ERR + DOMSTRING_SIZE_ERR + HIERARCHY_REQUEST_ERR + WRONG_DOCUMENT_ERR + INVALID_CHARACTER_ERR + NO_DATA_ALLOWED_ERR + NO_MODIFICATION_ALLOWED_ERR + NOT_FOUND_ERR + NOT_SUPPORTED_ERR + INUSE_ATTRIBUTE_ERR + INVALID_STATE_ERR + SYNTAX_ERR + INVALID_MODIFICATION_ERR + NAMESPACE_ERR + INVALID_ACCESS_ERR + ); + package XML::Xerces::DOMNodeList; # convert the NodeList to a perl list sub to_list { @@ -200,3 +220,82 @@ sub get_text { return $self->getTextContent(@_); } +############# Class : XML::Xerces::PerlNodeFilter ############## +package XML::Xerces::PerlNodeFilter; +use vars qw(@ISA); +@ISA = qw(XML::Xerces::DOMNodeFilter + XML::Xerces::DOMLSParserFilter + XML::Xerces::DOMLSSerializerFilter); + +sub new { + my $class = shift; + + # support copy constructor syntax + $class = ref($class) if ref($class); + + return bless {}, $class; +} + +sub acceptNode { + my $self = shift; + return $self->accept_node(@_); +} + +sub getWhatToShow { + my $self = shift; + return $self->get_what_to_show(); +} + +sub startElement { + my $self = shift; + return $self->start_element(@_); +} + +# +# support alternate Perl-friendly syntax +# +sub accept_node { + return undef; +} + +sub get_what_to_whow { + return undef; +} + +sub start_element { + return undef; +} + + +############# Class : XML::Xerces::PerlDOMErrorHandler ############## +package XML::Xerces::PerlDOMErrorHandler; +use Carp; +use vars qw(@ISA); +@ISA = qw(XML::Xerces::DOMErrorHandler); + +sub new { + my $class = shift; + + # support copy constructor syntax + $class = ref($class) if ref($class); + + return bless {}, $class; +} + +sub handleError { + my $self = shift; + return $self->handle_error(@_); +} + +# +# support alternate Perl-friendly syntax +# +sub handle_error { + my $severity = $_[1]->getSeverity; + my $msg = $_[1]->getMessage; + croak(<<EOT); +ERROR: +SEVERITY: $severity +MESSAGE: $msg +EOT +} diff --git a/swig/interfaces/Perl/callback.i b/swig/interfaces/Perl/callback.i index 51006ff68..871924e3b 100644 --- a/swig/interfaces/Perl/callback.i +++ b/swig/interfaces/Perl/callback.i @@ -21,11 +21,10 @@ %include "PerlCallbackHandler.hpp" %include "PerlErrorCallbackHandler.hpp" -%include "PerlEntityResolverHandler.hpp" -%include "PerlDocumentCallbackHandler.hpp" -%include "PerlContentCallbackHandler.hpp" -// %include "PerlNodeFilterCallbackHandler.hpp" +%import "xercesc/sax/EntityResolver.hpp" + +%include "PerlEntityResolverHandler.hpp" /* * PerlCallbackHandler* - this is broken and useless diff --git a/swig/interfaces/Perl/defines.i b/swig/interfaces/Perl/defines.i index c3f6fe25a..467470ac5 100644 --- a/swig/interfaces/Perl/defines.i +++ b/swig/interfaces/Perl/defines.i @@ -21,93 +21,4 @@ %{ -static void -SWIG_Disown(SV *sv) { - - if (SvGMAGICAL(sv)) { - mg_get(sv); - } - - - /* Check to see if this is an object */ - if (sv_isobject(sv)) { - SV *tsv = (SV*) SvRV(sv); - if ((SvTYPE(tsv) == SVt_PVHV)) { - MAGIC *mg; - if (SvMAGICAL(tsv)) { - mg = mg_find(tsv,'P'); - if (mg) { - sv = mg->mg_obj; - if (sv_isobject(sv)) { - fprintf(stderr,"Found object for disown\n"); - - HV *stash; - stash=SvSTASH(SvRV(sv)); - - if (stash != 0) - { - fprintf(stderr,"Found stash: %x\n",stash); - HV *hv; - GV *gv=*(GV**)hv_fetch(stash, "OWNER", 5, TRUE); - if (isGV(gv)) - { - fprintf(stderr,"Found OWNER glob: %x\n",gv); - fprintf(stderr,"Found object: %x\n",sv); - fprintf(stderr,"Found ref object: %x\n",SvRV(sv)); - hv=GvHVn(gv); - - HE *entry; - char *key; - I32 klen; - SV *hval; - - (void)hv_iterinit(hv); - while ((entry = hv_iternext(hv))) { - key = hv_iterkey(entry, &klen); - fprintf(stderr,"Found hash entry: %s\n",key); - } - - if (hv_exists_ent(hv, sv, 0)) - { - fprintf(stderr,"Found key in OWNER hash!\n"); - if (hv_delete_ent(hv,sv,0,0)) - { - fprintf(stderr,"Deleted key in OWNER hash!\n"); - } - else - { - SWIG_SetError("Couldn't delete key from OWNER hash :-<\n"); - } - } - else - { - SWIG_SetError("no key in OWNER hash :-<\n"); - } - } - else - { - SWIG_SetError("no GV\n"); - } - } - else - { - SWIG_SetError("no stash found\n"); - } - } else { - SWIG_SetError("SWIG_Disown: mg is not object"); - } - } else { - SWIG_SetError("SWIG_Disown: no mg"); - } - } else { - SWIG_SetError("SWIG_Disown: not magical"); - } - } else { - SWIG_SetError("SWIG_Disown: not PVHV"); - } - } else { /* not an object */ - SWIG_SetError("SWIG_Disown: not an object"); - } -} - %} diff --git a/swig/interfaces/Perl/dom-callback.i b/swig/interfaces/Perl/dom-callback.i index 1e6003953..e9e4f749b 100644 --- a/swig/interfaces/Perl/dom-callback.i +++ b/swig/interfaces/Perl/dom-callback.i @@ -15,51 +15,10 @@ */ /* - * Perl/callback.i - an experimental typecheck for returning callback subclasses + * Perl/dom-callback.i - callback handlers for the DOM * */ %import "PerlCallbackHandler.hpp" %include "PerlNodeFilterCallbackHandler.hpp" - -/* - * PerlCallbackHandler* - this is broken and useless - */ - -/* -%typemap(out) XERCES_CPP_NAMESPACE::PerlCallbackHandler * = SWIGTYPE *DYNAMIC; - -DYNAMIC_CAST(SWIGTYPE_p_PerlCallbackHandler, PerlCallbackHandler_dynamic_cast); - -%{ - -static swig_type_info * -PerlCallbackHandler_dynamic_cast(void **ptr) { - PerlCallbackHandler **nptr = (PerlCallbackHandler **) ptr; - if (*nptr == NULL) { - return NULL; - } - short int type = (*nptr)->type(); - if (type == PERLCALLBACKHANDLER_BASE_TYPE) { - die("Can't cast a PerlCallbackHandler base type node\n"); - } - if (type == PERLCALLBACKHANDLER_ERROR_TYPE) { - return SWIGTYPE_p_PerlErrorCallbackHandler; - } - if (type == PERLCALLBACKHANDLER_ENTITY_TYPE) { - return SWIGTYPE_p_PerlEntityResolverHandler; - } - if (type == PERLCALLBACKHANDLER_CONTENT_TYPE) { - return SWIGTYPE_p_PerlContentCallbackHandler; - } - if (type == PERLCALLBACKHANDLER_DOCUMENT_TYPE) { - return SWIGTYPE_p_PerlDocumentCallbackHandler; - } - if (type == PERLCALLBACKHANDLER_NODE_TYPE) { - return SWIGTYPE_p_PerlNodeFilterCallbackHandler; - } - return NULL; -} - -%} -*/ \ No newline at end of file +%include "PerlDOMCallbackHandler.hpp" diff --git a/swig/interfaces/Perl/dom-shadow.i b/swig/interfaces/Perl/dom-shadow.i index 74ec9d447..83864e778 100644 --- a/swig/interfaces/Perl/dom-shadow.i +++ b/swig/interfaces/Perl/dom-shadow.i @@ -19,20 +19,26 @@ * */ -%feature("shadow") XERCES_CPP_NAMESPACE::DOMConfiguration::setParameter { - sub setParameter { - my ($self,$name,$value) = @_; - - if ($name eq $XML::Xerces::XMLUni::fgDOMErrorHandler) { - $value = XML::Xerces::PerlErrorCallbackHandler->new($_[2]); - $XML::Xerces::REMEMBER{tied(% {$self})}->{__ERROR_HANDLER} = $value; - } elsif ($name eq $XML::Xerces::XMLUni::fgXercesEntityResolver) { - $value = XML::Xerces::PerlEntityResolverHandler->new($_[2]); - $XML::Xerces::REMEMBER{tied(% {$self})}->{__ENTITY_RESOLVER} = $value; - } - return XML::Xercesc::DOMConfiguration_setParameter($self,$name,$value); +%feature("shadow") XERCES_CPP_NAMESPACE::DOMConfiguration::setParameter %{ +sub setParameter { + my ($self,$name,$value) = @_; + + # we allow undef to unset existing values + if (defined $value) { + if ($name eq $XML::Xerces::XMLUni::fgDOMErrorHandler) { + $value = XML::Xerces::PerlDOMCallbackHandler->new($value); + $XML::Xerces::REMEMBER{tied(% {$self})}->{__ERROR_HANDLER} = $value; + } elsif ($name eq $XML::Xerces::XMLUni::fgDOMResourceResolver) { + $value = XML::Xerces::PerlDOMCallbackHandler->new($value); + $XML::Xerces::REMEMBER{tied(% {$self})}->{__ENTITY_RESOLVER} = $value; + } elsif ($name eq $XML::Xerces::XMLUni::fgXercesEntityResolver) { + $value = XML::Xerces::PerlEntityResolverHandler->new($value); + $XML::Xerces::REMEMBER{tied(% {$self})}->{__ENTITY_RESOLVER} = $value; } + } + return XML::Xercesc::DOMConfiguration_setParameter($self,$name,$value); } +%} // Define a macro to rewrite all methods that return a list of DOMNodes @@ -158,11 +164,12 @@ sub createDocument { } %} -%feature("shadow") ~DOMDocument %{ +%define CLEANUP(class) +%feature("shadow") ~class %{ sub DESTROY { return unless $_[0]->isa('HASH'); my $self = tied(%{$_[0]}); - return unless defined $self; + return unless defined ## $self; if ($self->can('cleanup')) { $_[0]->cleanup(); @@ -170,9 +177,12 @@ sub DESTROY { delete $ITERATORS{$self}; if (exists $OWNER{$self}) { - XML::Xercesc::delete_DOMDocument($self); + XML::Xercesc::delete_##class($self); delete $OWNER{$self}; } } %} +%enddef +CLEANUP(DOMDocument) +CLEANUP(DOMConfiguration) \ No newline at end of file diff --git a/swig/interfaces/Perl/includes.i b/swig/interfaces/Perl/includes.i index 0834305b0..662d6707b 100644 --- a/swig/interfaces/Perl/includes.i +++ b/swig/interfaces/Perl/includes.i @@ -15,7 +15,7 @@ */ /* - * Perl/includes.i - all #includes needed for Xerces.cpp + * Perl/includes.i - all Perl #includes needed for Xerces.cpp * */ @@ -26,8 +26,7 @@ #include "PerlCallbackHandler.hpp" #include "PerlErrorCallbackHandler.hpp" -#include "PerlDocumentCallbackHandler.hpp" -#include "PerlContentCallbackHandler.hpp" +#include "PerlDOMCallbackHandler.hpp" #include "PerlEntityResolverHandler.hpp" %} \ No newline at end of file diff --git a/swig/interfaces/Perl/shadow.i b/swig/interfaces/Perl/shadow.i index dd53fb27f..551956e07 100644 --- a/swig/interfaces/Perl/shadow.i +++ b/swig/interfaces/Perl/shadow.i @@ -27,13 +27,17 @@ %define SET_ERRORHANDLER(class) %feature("shadow") XERCES_CPP_NAMESPACE::class::setErrorHandler { - sub setErrorHandler { - my ($self,$handler) = @_; - my $callback = XML::Xerces::PerlErrorCallbackHandler->new($handler); - $XML::Xerces::REMEMBER{tied(% {$self})}->{__ERROR_HANDLER} = $callback; - - return XML::Xercesc::class ##_setErrorHandler($self,$callback); - } +sub setErrorHandler { + my ($self,$handler) = @_; + + # allow undef to unset current value + my $callback; + if (defined ## $handler) { + $callback = XML::Xerces::PerlErrorCallbackHandler->new($handler); + $XML::Xerces::REMEMBER{tied(% {$self})}->{__ERROR_HANDLER} = $callback; + } + return XML::Xercesc::class ##_setErrorHandler($self,$callback); +} } %enddef @@ -46,13 +50,17 @@ SET_ERRORHANDLER(XercesDOMParser) %define SET_ENTITYRESOLVER(class) %feature("shadow") XERCES_CPP_NAMESPACE::class::setEntityResolver { - sub setEntityResolver { - my ($self,$handler) = @_; - my $callback = XML::Xerces::PerlEntityResolverHandler->new($handler); - $XML::Xerces::REMEMBER{tied(% {$self})}->{__ENTITY_RESOLVER} = $callback; - - return XML::Xercesc::class ##_setEntityResolver($self,$callback); - } +sub setEntityResolver { + my ($self,$handler) = @_; + + # allow undef to unset current value + my $callback; + if (defined ## $handler) { + $callback = XML::Xerces::PerlEntityResolverHandler->new($handler); + $XML::Xerces::REMEMBER{tied(% {$self})}->{__ENTITY_RESOLVER} = $callback; + } + return XML::Xercesc::class ##_setEntityResolver($self,$callback); +} } %enddef @@ -82,24 +90,40 @@ sub new { } %} -%feature("shadow") XERCES_CPP_NAMESPACE::SAXParser::setDocumentHandler %{ -sub setDocumentHandler { - my ($self,$handler) = @_; - my $callback = XML::Xerces::PerlDocumentCallbackHandler->new($handler); - $XML::Xerces::REMEMBER{tied(% {$self})}->{__DOCUMENT_HANDLER} = $callback; +// Define a macro to rewrite all methods that return a list - my @args = ($self,$callback); - return XML::Xercesc::SAXParser_setDocumentHandler(@args); +// we need the "defined ## $result hack because defined is a cpp operator +%define LIST_METHOD(class,method) + %feature("shadow") XERCES_CPP_NAMESPACE::class::method { +sub method { + my $result = XML::Xercesc:: ## class ## _ ## method (@_); + unless (defined ## $result) { + return () if wantarray; + return undef; # if *not* wantarray + } + return $result->to_list() if wantarray; + return $result; # if *not* wantarray } -%} + } +%enddef -%feature("shadow") XERCES_CPP_NAMESPACE::SAX2XMLReader::setContentHandler %{ -sub setContentHandler { - my ($self,$handler) = @_; - my $callback = XML::Xerces::PerlContentCallbackHandler->new($handler); - $XML::Xerces::REMEMBER{tied(% {$self})}->{__CONTENT_HANDLER} = $callback; +// Define a macro to rewrite all methods that return a map - my @args = ($self,$callback); - return XML::Xercesc::SAX2XMLReader_setContentHandler(@args); +// we need the "defined ## $result hack because defined is a cpp operator +%define MAP_METHOD(class,method) + %feature("shadow") XERCES_CPP_NAMESPACE::class::method { +sub method { + my $result = XML::Xercesc:: ## class ## _ ## method (@_); + unless (defined ## $result) { + return () if wantarray; + return undef; # if *not* wantarray + } + return $result->to_hash() if wantarray; + return $result; # if *not* wantarray } -%} + } +%enddef + +LIST_METHOD(XMLElementDecl,getAttDefList) +LIST_METHOD(XMLSchemaDescription,getLocationHints) +// MAP_METHOD(XMLElementDecl,getAttDefList) \ No newline at end of file diff --git a/swig/interfaces/Perl/typemaps-xmlch.i b/swig/interfaces/Perl/typemaps-xmlch.i index 782ff330d..046a9565c 100644 --- a/swig/interfaces/Perl/typemaps-xmlch.i +++ b/swig/interfaces/Perl/typemaps-xmlch.i @@ -14,88 +14,19 @@ * limitations under the License. */ -/***********/ -/* */ -/* XMLCh * */ -/* */ -/***********/ - -/************************************************************************/ -/* */ -/* FOR FUNCTIONS TAKING XMLCh * (I.E AN XMLCh STRING) AS AN ARGUMENT -- */ -/* NOW YOU CAN JUST SUPPLY A STRING. THIS TYPEMAP CONVERTS */ -/* PERL-STRINGS TO XMLCh STRINGS AUTOMATICALLY */ -/* */ -/************************************************************************/ - -/************************************************************************/ -/* */ -/* CAVEAT: */ -/* TO CONVERT STRINGS TO XMLCh STRINGS, A TEMPORARY POINTER MUST BE */ -/* CREATED IN THE in TYPEMAP TO POINT TO MEMORY THAT HOLDS THE */ -/* CONVERSION. THE MEMORY IS DYNAMIC, SO IT MUST BE FREED AFTER THE C */ -/* FUNCTION THAT USES IT IS CALLED. THIS IS DONE VIA A "freearg" */ -/* TYPEMAP. */ -/* */ -/************************************************************************/ - -// in typemap -%typemap(in) XMLCh * %{ - if ($input == &PL_sv_undef) { - SWIG_Perl_NullRef("perl-string",$argnum,"$symname"); - goto fail; - } else { - // we convert *everything* into a string that isn't undef - $1 = UTF8_TRANSCODER->Perl2XMLString($input); - } -%} - -%typemap(freearg) XMLCh * %{ - delete[] $1; -%} - -// out typemap -%typemap(out) XMLCh * %{ - $result = UTF8_TRANSCODER->XMLString2Perl($1); - ++argvi; -%} - // varout typemap (for global variables) // useful for XMLUni constants %typemap(varout) XMLCh[] %{ - sv_setsv((SV*)$result, UTF8_TRANSCODER->XMLString2Perl($1)); + sv_setsv((SV*)$result, UTF8_TRANSCODER->XMLString2Local($1)); %} // fgBooleanValueSpace is an array of XMLCh* %typemap(varout) XMLCh[][8] %{ AV *myav = newAV(); for (int i=0;i<4;i++) { - av_push(myav, UTF8_TRANSCODER->XMLString2Perl($1[i])); + av_push(myav, UTF8_TRANSCODER->XMLString2Local($1[i])); } SV* rv = newRV((SV*)myav); sv_setsv((SV*)$result, rv); %} - -/* - * Enable conversion of void* => XMLCh* in setProperty() - * - * The in typemap converts the void* to an XMLCh* - * - * The freearg typemap deletes the transcoded string - * - */ -%typemap(in) (void* value) { - // now check the value - if ($input == &PL_sv_undef) { - SWIG_Perl_NullRef("perl-string",$argnum,"$symname"); - goto fail; - } else { - // we convert *everything* into a string that isn't undef - $1 = UTF8_TRANSCODER->Perl2XMLString($input); - } -} -%typemap(freearg) void * %{ - delete[] $1; -%} - diff --git a/swig/interfaces/Perl/typemaps.i b/swig/interfaces/Perl/typemaps.i index 43122ddb2..315cff943 100644 --- a/swig/interfaces/Perl/typemaps.i +++ b/swig/interfaces/Perl/typemaps.i @@ -1,73 +1,38 @@ -// -// FOR Perl*Handler MEMBER FUNCTIONS, SO PERL SCALAR DOESN'T GET WRAPPED -// -%typemap(in) SV * { - $1 = $input; -} - -// For setProperty() - store the SV* directly -%typemap(in) void * { - $1 = (void*) $input; -} - -%typemap(in) (const XMLByte* const srcDocBytes, - unsigned int byteCount) { - if (SvPOK($input)||SvIOK($input)||SvNOK($input)) { - STRLEN len; - XMLByte *xmlbytes = (XMLByte *)SvPV($input, len); - $2 = len; - $1 = new XMLByte[len]; - memcpy($1, xmlbytes, len); - } else { - SWIG_croak("Type error in argument 2 of $symname, Expected perl-string."); - } -} - -// XMLByte arrays are just unisgned char*'s -// force loading of FromCharPtr fragment - needed for DOM -%typemap(out, noblock=1, fragment="SWIG_FromCharPtr") const XMLByte* getRawBuffer() { - %set_output(SWIG_FromCharPtr((char*)$1)); -} - /* * Adopting a validator * * we have to disown the validator, because Xerces will adopt it - * first we create a temp variable to store it's value in the - * 'in' typemap, and the after all conversion has succeeded - * the 'check' typemap will disown it. + * after all conversion has succeeded + * the SWIG_POINTER_DISOWN flag makes sure it is disowned. */ -%typemap(in) XERCES_CPP_NAMESPACE::XMLValidator* valToAdopt (SV *temp) +%typemap(in) XERCES_CPP_NAMESPACE::XMLValidator* valToAdopt { - temp = $input; - if (SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor,0) < 0) { - SWIG_Perl_TypeError("$1_mangle",$argnum,"$symname"); + if ($input != &PL_sv_undef) { + int rc = SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor, SWIG_POINTER_DISOWN | 0); + if (!SWIG_IsOK(rc)) { + %argument_fail(SWIG_TypeError, "$type", $symname, $argnum); } + } } -%typemap(check) XERCES_CPP_NAMESPACE::XMLValidator* valToAdopt -{ - SWIG_Disown(temp$argnum); +// +// FOR Perl*Handler MEMBER FUNCTIONS, SO PERL SCALAR DOESN'T GET WRAPPED +// +%typemap(in) SV * { + $1 = $input; } -// The typecheck functions are for use by SWIG's auto-overloading support -%typemap(typecheck, precedence=60) -SV* -{ - $1 = SvOK($input) ? 1 : 0; +// For setProperty() - store the SV* directly +%typemap(in) void * { + $1 = (void*) $input; } // The typecheck functions are for use by SWIG's auto-overloading support +// we must set a *really* low precedence on this because it will return +// true for *everything* %typemap(typecheck, precedence=60) SV* { - $1 = SvOK($input) ? 1 : 0; + $1 = 1; } -// %typemap(typecheck, precedence=70) -// as long as the SV is not undef, convert it to a string -%typecheck(SWIG_TYPECHECK_UNISTRING) -XMLCh*, const XMLCh* -{ - $1 = SvOK($input) ? 1 : 0; -} \ No newline at end of file diff --git a/swig/interfaces/SAX.i b/swig/interfaces/SAX.i index 6a2c7012f..1b18e92f4 100644 --- a/swig/interfaces/SAX.i +++ b/swig/interfaces/SAX.i @@ -1,9 +1,8 @@ -%include "xercesc/sax/SAXException.hpp" -%include "xercesc/sax/SAXParseException.hpp" -%include "xercesc/sax/ErrorHandler.hpp" +%import "xercesc/sax/ErrorHandler.hpp" + %include "xercesc/sax/DTDHandler.hpp" %include "xercesc/sax/DocumentHandler.hpp" -%include "xercesc/sax/EntityResolver.hpp" +%import "xercesc/sax/EntityResolver.hpp" %include "xercesc/sax/AttributeList.hpp" %include "xercesc/sax/HandlerBase.hpp" %include "xercesc/sax/Locator.hpp" diff --git a/swig/interfaces/SAX2.i b/swig/interfaces/SAX2.i index b8cb97ae8..be12646b7 100644 --- a/swig/interfaces/SAX2.i +++ b/swig/interfaces/SAX2.i @@ -2,5 +2,5 @@ %include "xercesc/sax2/ContentHandler.hpp" %include "xercesc/sax2/LexicalHandler.hpp" %include "xercesc/sax2/DeclHandler.hpp" -%include "xercesc/sax2/DefaultHandler.hpp" +// %include "xercesc/sax2/DefaultHandler.hpp" diff --git a/swig/interfaces/Xerces.i b/swig/interfaces/Xerces.i index 0127b3e04..057a7ea03 100644 --- a/swig/interfaces/Xerces.i +++ b/swig/interfaces/Xerces.i @@ -29,84 +29,32 @@ %module "XML::Xerces" #endif -%include "includes.i" - /* - * Import the language specific macros - not namespace dependent - * we place these first so that they can define any master - * macros needed by the language-independent interface files + * Import the common macros */ - -#ifdef SWIGPERL -%include "Perl/shadow.i" -// %include "Perl/dom-shadow.i" -%include "Perl/defines.i" -%include "Perl/errors.i" -%include "Perl/includes.i" -%include "Perl/typemaps.i" -%include "Perl/typemaps-xmlch.i" -#endif +%include "Xerces_common.i" /* - * Start the XERCES_CPP_NAMESPACE * after this everything will be in Xerces namespace */ -%include "defines.i" - -/* - * language dependent features that are namespace dependent - * such as the transcoders - * - */ -#ifdef SWIGPERL -// %include "Perl/transcode.i" -#endif - - -%include typemaps-general.i - -// %include "typemaps-dom.i" - -/*****************************/ -/* */ -/* Platforms and Compilers */ -/* */ -/*****************************/ +%{ -// we seem to need these defs loaded before parsing XercesDefs.hpp -// as of Xerces-3.0 -%import "xercesc/util/Xerces_autoconf_config.hpp" // for XMLSize_t and namespaces +XERCES_CPP_NAMESPACE_USE -%import "xercesc/util/XercesDefs.hpp" +%} -/******************/ -/* */ -/* General code */ -/* */ -/******************/ +// This prevents a million warnings +%ignore XSerializable; +class XSerializable { +private: +XSerializable::XSerializable(); +}; /* - * The generic exception handler - * 'goto fail' must be called - either explicitly, or via SWIG_croak() - * to ensure that any variable cleanup is done - to avoid memory leaks. - * By making these macros, it reduces the code *file* size dramatically - * (but doesn't reduce the compiled file size at all...) + * Define exception handlers + * */ -%{ -#define CATCH_XML_EXCEPTION \ - catch (const XMLException& e) \ - { \ - makeXMLException(e); \ - goto fail; \ - } \ - catch (...) \ - { \ - SWIG_croak("Handling Unknown exception"); \ - goto fail; \ - } -%} - %exception { try { @@ -116,31 +64,15 @@ } /* - * Have the scripting language manage the memory for objects created - * in factory methods SWIG will automatically handle objects created - * in constructors but it must be told what methods are factory - * methods - */ -// %newobject createDOMWriter; -// %newobject createDocumentType; -// %newobject createDocument; -// %newobject getDOMImplementation; -%newobject createXMLReader; - -/* - * All %ignore directives + * Module specific classes + * */ -%include "ignore.i" - /* - * Operator support + * Unicode contants */ -// Operators we do want -// %rename(operator_assignment) operator=; -%rename(operator_equal_to) operator==; -%rename(operator_not_equal_to) operator!=; +%include "unicode.i" /* * Utility Classes @@ -154,56 +86,12 @@ %include "grammars.i" -/* - * InputSource - */ - -%include "input-source.i" - -/* - * DOM - */ - -// %include "DOM.i" - -// %include "xercesc/dom/DOMNode.hpp" - -/* - * SAX1 - */ - -%include "SAX.i" - -/* - * SAX2 - */ - -%include "SAX2.i" - /* - * Parsers + * Auxiliary classes need for both DOM and SAX parsers */ %include "parsers.i" -/* - * Include extra verbatim C code in the initialization function - */ -%init { - // we create the global transcoder for UTF-8 to UTF-16 - // must initialize the Xerces-C transcoding service - XMLPlatformUtils::Initialize(); - UTF8_TRANSCODER = Transcoder::getInstance(); - if (! UTF8_TRANSCODER) { - croak("ERROR: XML::Xerces: INIT: Could not create UTF-8 transcoder"); - } - - XML_EXCEPTION_HANDLER = XMLExceptionHandler::getInstance(); - if (! XML_EXCEPTION_HANDLER) { - croak("ERROR: XML::Xerces: INIT: Could not create XMLExceptionHandler"); - } -} - #ifdef SWIGPERL /* @@ -211,6 +99,8 @@ * so that SWIG can wrap the superclass methods properly */ +// must %include this or getErrorHandler() fails to return proper type +%include "xercesc/sax/ErrorHandler.hpp" %include "Perl/callback.i" /* diff --git a/swig/interfaces/Xerces_DOM.i b/swig/interfaces/Xerces_DOM.i index 1247138a6..b79e72f9a 100644 --- a/swig/interfaces/Xerces_DOM.i +++ b/swig/interfaces/Xerces_DOM.i @@ -23,30 +23,14 @@ * the namespace */ #ifdef SWIGPERL -%module(package="XML::Xerces") "DOM" -// %module "XML::Xerces::DOM" +%module(package="XML::Xerces") "XML::Xerces::DOM" #endif - -%include "includes.i" - -%include "dom-includes.i" - -/* - * Import the language specific macros - */ - -#ifdef SWIGPERL -%include "Perl/errors.i" -%include "Perl/defines.i" -%include "Perl/dom-shadow.i" -%include "Perl/typemaps.i" -%include "Perl/typemaps-xmlch.i" -%include "Perl/includes.i" -%include "Perl/dom-includes.i" +#ifdef SWIGXML +%module(package="XML::Xerces") "XML::Xerces::DOM" #endif -// Get the type information -%import "Xerces.i" +%include "io-includes.i" +%include "dom-includes.i" /* * After this we will be under the Xerces namespace @@ -57,60 +41,47 @@ XERCES_CPP_NAMESPACE_USE -// we initialize the static UTF-8 transcoding info -// these are used by the typemaps to convert between -// Xerces internal UTF-16 and Perl's internal UTF-8 -static Transcoder* UTF8_TRANSCODER = NULL; - -static XMLExceptionHandler* XML_EXCEPTION_HANDLER = NULL; - -void -makeXMLException(const XMLException& e){ - SV *error = ERRSV; - SWIG_MakePtr(error, (void *) XML_EXCEPTION_HANDLER->copyXMLException(e), SWIGTYPE_p_XERCES_CPP_NAMESPACE__XMLException, SWIG_SHADOW|0); -} - void makeDOMException(const DOMException& e){ SV *error = ERRSV; SWIG_MakePtr(error, (void *) new DOMException(e), SWIGTYPE_p_XERCES_CPP_NAMESPACE__DOMException, SWIG_SHADOW|0); } -%} - -// %include "make-xml-exception.i" - -%include "typemaps-dom.i" +// void +// makeDOMXPathException(const DOMXPathException& e){ +// SV *error = ERRSV; +// SWIG_MakePtr(error, (void *) new DOMXPathException(e), SWIGTYPE_p_XERCES_CPP_NAMESPACE__DOMXPathException, SWIG_SHADOW|0); +// } -%include "typemaps-general.i" +%} -/*****************************/ -/* */ -/* Platforms and Compilers */ -/* */ -/*****************************/ +/* + * Import the common macros + */ +%include "Xerces_common.i" -// we seem to need these defs loaded before parsing XercesDefs.hpp -// as of Xerces-3.0 -%import "xercesc/util/Xerces_autoconf_config.hpp" // for XMLSize_t and namespaces +/* + * Import the language-specific macros + */ -%import "xercesc/util/XercesDefs.hpp" +#ifdef SWIGPERL +%include "Perl/dom-shadow.i" +%include "Perl/dom-includes.i" +#endif -/* - * All %ignore directives +/* + * Import the module-specific typemaps */ -%include "ignore.i" +%include "typemaps-dom.i" +%include "typemaps-domnode.i" /* - * Operator support + * Import the type information from other modules */ -// Operators we do want -// %rename(operator_assignment) operator=; -%rename(operator_equal_to) operator==; -%rename(operator_not_equal_to) operator!=; - +%import "Xerces.i" +%import "Xerces_IO.i" /* * the DOM classes gets a special exception handler @@ -137,6 +108,23 @@ makeDOMException(const DOMException& e){ SWIG_croak("Handling Unknown exception"); \ goto fail; \ } + +#define CATCH_DOMXPATH_EXCEPTION \ + catch (const XMLException& e) \ + { \ + makeXMLException(e); \ + goto fail; \ + } \ + catch (const DOMXPathException& e) \ + { \ + makeDOMXPathException(e); \ + goto fail; \ + } \ + catch (...) \ + { \ + SWIG_croak("Handling Unknown exception"); \ + goto fail; \ + } %} %exception { @@ -147,6 +135,25 @@ makeDOMException(const DOMException& e){ CATCH_DOM_EXCEPTION } +%define XPATH_METHOD(class,method) +%exception XERCES_CPP_NAMESPACE::class::method %{ + try + { + $action + } + CATCH_DOMXPATH_EXCEPTION +%} +%enddef + +%define XPATH_CLASS(class) +%exception XERCES_CPP_NAMESPACE::class %{ + try + { + $action + } + CATCH_DOMXPATH_EXCEPTION +%} +%enddef // Introduced in DOM Level 1 %include "dom/DOMException.i" @@ -170,18 +177,12 @@ makeDOMException(const DOMException& e){ %include "dom/DOMTypeInfo.i" %include "dom/DOMPSVITypeInfo.i" -// XPath -%include "dom/DOMXPathEvaluator.i" -%include "dom/DOMXPathException.i" -%include "dom/DOMXPathExpression.i" -%include "dom/DOMXPathNamespace.i" -%include "dom/DOMXPathNSResolver.i" -%include "dom/DOMXPathResult.i" - // Introduced in DOM Level 2 %include "dom/DOMDocumentRange.i" %include "dom/DOMDocumentTraversal.i" %include "dom/DOMNodeIterator.i" + +%feature("notabstract", 1) DOMNodeFilter; %include "dom/DOMNodeFilter.i" %include "dom/DOMRange.i" %include "dom/DOMRangeException.i" @@ -190,62 +191,56 @@ makeDOMException(const DOMException& e){ /* * Introduced in DOM Level 3 */ +%include "dom/DOMStringList.i" %include "dom/DOMUserDataHandler.i" %include "dom/DOMConfiguration.i" -%include "dom/DOMStringList.i" %include "dom/DOMImplementationLS.i" %include "dom/DOMImplementation.i" %include "dom/DOMImplementationList.i" -%include "dom/DOMImplementationSource.i" %include "dom/DOMImplementationRegistry.i" +// XPath - currently unimplemented +%import "dom/DOMXPathEvaluator.i" +%import "dom/DOMXPathException.i" +%import "dom/DOMXPathExpression.i" +%import "dom/DOMXPathNamespace.i" +%import "dom/DOMXPathNSResolver.i" +%import "dom/DOMXPathResult.i" + +// Interfaces not useful for scripting languages +// %include "dom/DOMImplementationSource.i" + %include "dom/DOMError.i" %include "dom/DOMErrorHandler.i" + +// from Level 1, but with extensions from Level 3 %include "dom/DOMDocument.i" + %include "dom/DOMLocator.i" %include "dom/DOMLSResourceResolver.i" -// DOMLSParser -%include "dom/DOMLSInput.i" -%include "framework/Wrapper4InputSource.i" -%include "framework/Wrapper4DOMLSInput.i" -%include "dom/DOMLSParserFilter.i" -%include "dom/DOMLSParser.i" - -// DOMWriter +// DOMLSSerializer %include "dom/DOMLSOutput.i" -%include "framework/XMLFormatter.i" -%include "framework/StdOutFormatTarget.i" -%include "framework/LocalFileFormatTarget.i" -%include "framework/MemBufFormatTarget.i" %include "dom/DOMLSException.i" -%include "dom/DOMLSSerializer.i" -%include "dom/DOMLSSerializerFilter.i" -%import "xercesc/framework/XMLPScanToken.hpp" -%import "xercesc/framework/psvi/PSVIHandler.hpp" +%feature("notabstract", 1) DOMLSSerializerFilter; +%include "dom/DOMLSSerializerFilter.i" +%include "dom/DOMLSSerializer.i" +// Base class for DOMLSParser and XercesDOMParser %include "parsers/AbstractDOMParser.i" -%include "parsers/XercesDOMParser.i" -/* - * Include extra verbatim C code in the initialization function - */ -%init { - // we create the global transcoder for UTF-8 to UTF-16 - // must initialize the Xerces-C transcoding service - XMLPlatformUtils::Initialize(); - UTF8_TRANSCODER = Transcoder::getInstance(); - if (! UTF8_TRANSCODER) { - croak("ERROR: XML::Xerces: INIT: Could not create UTF-8 transcoder"); - } +// DOMLSParser +%include "dom/DOMLSInput.i" +%include "framework/Wrapper4InputSource.i" +%include "framework/Wrapper4DOMLSInput.i" +%include "dom/DOMLSParserFilter.i" +%include "dom/DOMLSParser.i" - XML_EXCEPTION_HANDLER = XMLExceptionHandler::getInstance(); - if (! XML_EXCEPTION_HANDLER) { - croak("ERROR: XML::Xerces: INIT: Could not create XMLExceptionHandler"); - } -} +// XercesDOMParser +%feature("notabstract", 1) XercesDOMParser; +%include "parsers/XercesDOMParser.i" #ifdef SWIGPERL @@ -261,12 +256,4 @@ makeDOMException(const DOMException& e){ */ %pragma(perl5) include="../../interfaces/Perl/Xerces_DOM-extra.pm" -/* - * Include extra verbatim Perl code immediately after Module header - */ - -%pragma(perl5) code="package XML::Xerces::DOM; -use XML::Xerces; -use vars qw($VERSION @EXPORT);" - #endif diff --git a/swig/interfaces/defines.i b/swig/interfaces/defines.i index e552412c0..2469e95f5 100644 --- a/swig/interfaces/defines.i +++ b/swig/interfaces/defines.i @@ -19,47 +19,3 @@ * verbatim into the C++ output file */ -%{ - -XERCES_CPP_NAMESPACE_USE - -// we initialize the static UTF-8 transcoding info -// these are used by the typemaps to convert between -// Xerces internal UTF-16 and Perl's internal UTF-8 -static Transcoder* UTF8_TRANSCODER = NULL; - -static XMLExceptionHandler* XML_EXCEPTION_HANDLER = NULL; - -static bool DEBUG_UTF8_OUT = 0; -static bool DEBUG_UTF8_IN = 0; - -%} - -// These get wrapped by SWIG so that we can modify them from the scripting language -bool DEBUG_UTF8_OUT; -bool DEBUG_UTF8_IN; - - -%{ - -void -makeXMLException(const XMLException& e){ - SV *error = ERRSV; - SWIG_MakePtr(error, (void *) XML_EXCEPTION_HANDLER->copyXMLException(e), SWIGTYPE_p_XERCES_CPP_NAMESPACE__XMLException, SWIG_SHADOW|0); -} - -void -makeSAXNotRecognizedException(const SAXNotRecognizedException& e){ - SV *error = ERRSV; - SWIG_MakePtr(error, (void *) new SAXNotRecognizedException(e), SWIGTYPE_p_XERCES_CPP_NAMESPACE__SAXNotRecognizedException, SWIG_SHADOW|0); -} - -void -makeSAXNotSupportedException(const SAXNotSupportedException& e){ - SV *error = ERRSV; - SWIG_MakePtr(error, (void *) new SAXNotSupportedException(e), SWIGTYPE_p_XERCES_CPP_NAMESPACE__SAXNotSupportedException, SWIG_SHADOW|0); -} - -%} - -// %include "make-xml-exception.i" diff --git a/swig/interfaces/dom-includes.i b/swig/interfaces/dom-includes.i index 1c3d5544c..eaa91a382 100644 --- a/swig/interfaces/dom-includes.i +++ b/swig/interfaces/dom-includes.i @@ -16,15 +16,14 @@ %{ #include "xercesc/dom/DOM.hpp" + #include "xercesc/util/XMLException.hpp" + #include "xercesc/framework/Wrapper4InputSource.hpp" #include "xercesc/framework/Wrapper4DOMLSInput.hpp" + #include "xercesc/parsers/AbstractDOMParser.hpp" #include "xercesc/parsers/XercesDOMParser.hpp" -#include "xercesc/framework/MemBufFormatTarget.hpp" -#include "xercesc/framework/LocalFileFormatTarget.hpp" -#include "xercesc/framework/StdOutFormatTarget.hpp" -#include "xercesc/util/XMLUni.hpp" %} diff --git a/swig/interfaces/dom/DOMImplementation.i b/swig/interfaces/dom/DOMImplementation.i index 7d188da4b..1736c47a7 100644 --- a/swig/interfaces/dom/DOMImplementation.i +++ b/swig/interfaces/dom/DOMImplementation.i @@ -1 +1,3 @@ +%ignore XERCES_CPP_NAMESPACE::DOMImplementation::loadDOMExceptionMsg; + %include "xercesc/dom/DOMImplementation.hpp" \ No newline at end of file diff --git a/swig/interfaces/dom/DOMImplementationRegistry.i b/swig/interfaces/dom/DOMImplementationRegistry.i index 69dc2543d..ab6bff961 100644 --- a/swig/interfaces/dom/DOMImplementationRegistry.i +++ b/swig/interfaces/dom/DOMImplementationRegistry.i @@ -1 +1,4 @@ +// we cannot create DOMImplementationSource +%ignore XERCES_CPP_NAMESPACE::DOMImplementationRegistry::addSource; + %include "xercesc/dom/DOMImplementationRegistry.hpp" \ No newline at end of file diff --git a/swig/interfaces/dom/DOMLSParserFilter.i b/swig/interfaces/dom/DOMLSParserFilter.i index 6d060bc07..d58f7b185 100644 --- a/swig/interfaces/dom/DOMLSParserFilter.i +++ b/swig/interfaces/dom/DOMLSParserFilter.i @@ -1 +1 @@ -%import "xercesc/dom/DOMLSParserFilter.hpp" \ No newline at end of file +%include "xercesc/dom/DOMLSParserFilter.hpp" \ No newline at end of file diff --git a/swig/interfaces/dom/DOMXPathResult.i b/swig/interfaces/dom/DOMXPathResult.i index 90f20dd76..bb606b608 100644 --- a/swig/interfaces/dom/DOMXPathResult.i +++ b/swig/interfaces/dom/DOMXPathResult.i @@ -1 +1,2 @@ +XPATH_CLASS(DOMXPathResult) %include "xercesc/dom/DOMXPathResult.hpp" \ No newline at end of file diff --git a/swig/interfaces/framework/Wrapper4InputSource.i b/swig/interfaces/framework/Wrapper4InputSource.i index d9a39d0fb..ccff28140 100644 --- a/swig/interfaces/framework/Wrapper4InputSource.i +++ b/swig/interfaces/framework/Wrapper4InputSource.i @@ -1 +1,5 @@ +// The API currently blocks these +%ignore XERCES_CPP_NAMESPACE::Wrapper4InputSource::setStringData; +%ignore XERCES_CPP_NAMESPACE::Wrapper4InputSource::setByteStream; + %include "xercesc/framework/Wrapper4InputSource.hpp" \ No newline at end of file diff --git a/swig/interfaces/framework/XMLFormatter.i b/swig/interfaces/framework/XMLFormatter.i index e23068d1c..c2bccc942 100644 --- a/swig/interfaces/framework/XMLFormatter.i +++ b/swig/interfaces/framework/XMLFormatter.i @@ -1 +1 @@ -%import "xercesc/framework/XMLFormatter.hpp" \ No newline at end of file +%include "xercesc/framework/XMLFormatter.hpp" \ No newline at end of file diff --git a/swig/interfaces/grammars.i b/swig/interfaces/grammars.i index 9eb297598..c90b9a74f 100644 --- a/swig/interfaces/grammars.i +++ b/swig/interfaces/grammars.i @@ -2,6 +2,51 @@ * XML Schema Grammar support (DTD and W3C XML Schema) */ +/* + * methods not needed by the XMLValidator interfaces + */ +%ignore XERCES_CPP_NAMESPACE::XMLValidator::emitError; +%ignore XERCES_CPP_NAMESPACE::XMLValidator::reinitMsgMutex; +%ignore XERCES_CPP_NAMESPACE::XMLValidator::reinitMsgLoader; +%ignore XERCES_CPP_NAMESPACE::XMLValidator::setErrorReporter; +%ignore XERCES_CPP_NAMESPACE::XMLValidator::setScannerInfo; +%ignore XERCES_CPP_NAMESPACE::XMLValidator::validateElement; +%ignore XERCES_CPP_NAMESPACE::XMLValidator::validateAttrValue; +%ignore XERCES_CPP_NAMESPACE::XMLValidator::reset; +%ignore XERCES_CPP_NAMESPACE::XMLValidator::postParseValidation; +%ignore XERCES_CPP_NAMESPACE::XMLValidator::preContentValidation; +%ignore XERCES_CPP_NAMESPACE::XMLValidator::faultInAttr; +%ignore XERCES_CPP_NAMESPACE::XMLValidator::checkContent; + +// ignore all the constructors for the Grammar components +%ignore XERCES_CPP_NAMESPACE::DTDAttDef::DTDAttDef; +%ignore XERCES_CPP_NAMESPACE::DTDElementDecl::DTDElementDecl; +%ignore XERCES_CPP_NAMESPACE::DTDEntityDecl::DTDEntityDecl; +%ignore XERCES_CPP_NAMESPACE::SchemaElementDecl::SchemaElementDecl; +%ignore XERCES_CPP_NAMESPACE::SchemaAttDef::SchemaAttDef; +%ignore XERCES_CPP_NAMESPACE::DTDAttDefList::DTDAttDefList; +%ignore XERCES_CPP_NAMESPACE::SchemaAttDefList::SchemaAttDefList; + +// these methods are useless until we implement the XSerialize interface +%ignore XERCES_CPP_NAMESPACE::Grammar::loadGrammar; +%ignore XERCES_CPP_NAMESPACE::Grammar::storeGrammar; + +// these methods are useless +%ignore XERCES_CPP_NAMESPACE::Grammar::findOrAddElemDecl; + +// these methods I'm not sure about +%ignore XERCES_CPP_NAMESPACE::Grammar::getElemId; +%ignore XERCES_CPP_NAMESPACE::Grammar::getElemDecl; +%ignore XERCES_CPP_NAMESPACE::Grammar::getNotationDecl; +%ignore XERCES_CPP_NAMESPACE::Grammar::putElemDecl; +%ignore XERCES_CPP_NAMESPACE::Grammar::putNotationDecl; +%ignore XERCES_CPP_NAMESPACE::Grammar::reset; +// %ignore XERCES_CPP_NAMESPACE::Grammar::setGrammarDescription; +// %ignore XERCES_CPP_NAMESPACE::Grammar::getGrammarDescription; +%ignore XERCES_CPP_NAMESPACE::Grammar::setValidated; + +%ignore XERCES_CPP_NAMESPACE::XMLGrammarDescription::getMemoryManager; + // for now these have no methods we need, and are only imported %import "xercesc/framework/XMLContentModel.hpp" @@ -13,9 +58,17 @@ %include "xercesc/framework/XMLAttDefList.hpp" %include "xercesc/framework/XMLAttDef.hpp" %include "xercesc/framework/XMLValidator.hpp" + %include "xercesc/validators/common/Grammar.hpp" %include "xercesc/framework/XMLGrammarDescription.hpp" %include "xercesc/framework/XMLDTDDescription.hpp" + +%import "xercesc/util/BaseRefVectorOf.hpp"; +%import "xercesc/util/RefArrayVectorOf.hpp"; +namespace XERCES_CPP_NAMESPACE { + %template(BaseXMLChVector) BaseRefVectorOf<XMLCh>; + %template(XMLChVector) RefArrayVectorOf<XMLCh>; +} %include "xercesc/framework/XMLSchemaDescription.hpp" // these are needed for both the DTD and Schema templates diff --git a/swig/interfaces/ignore.i b/swig/interfaces/ignore.i index 7c7d6b987..7e88e5f04 100644 --- a/swig/interfaces/ignore.i +++ b/swig/interfaces/ignore.i @@ -5,62 +5,6 @@ %ignore createXMLReader(const XMLCh *); -// Operators we don't want to wrap -%ignore operator =; -%ignore operator new; -%ignore operator delete; -%ignore operator <<; - - -// both of these static variables cause trouble -// the transcoding service is only useful to C++ anyway. -%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::fgTransService; -%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::fgNetAccessor; - -// these are other static variables that are useless to Perl -%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::fgUserPanicHandler; -%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::fgDefaultPanicHandler; -%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::fgMemoryManager; -%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::fgDefaulPanicHandler; -%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::fgArrayMemoryManager; -%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::fgAtomicMutex; - -// these are methods that are useless in Perl -%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::curFilePos; -%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::closeFile; -%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::fileSize; -%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::openFile; -%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::openFileToWrite; -%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::openStdInHandle; -%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::readFileBuffer; -%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::writeBufferToFile; -%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::resetFile; -%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::getFullPath; -%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::getCurrentDirectory; -%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::isAnySlash; -%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::removeDotSlash; -%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::removeDotDotSlash; -%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::isRelative; -%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::weavePaths; -%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::getCurrentMillis; -%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::closeMutex; -%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::lockMutex; -%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::makeMutex; -%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::unlockMutex; -%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::loadMsgSet; -%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::compareAndSwap; -%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::atomicIncrement; -%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::atomicDecrement; -%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::recognizeNEL; -%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::isNELRecognized; -%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::strictIANAEncoding; -%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::isStrictIANAEncoding; -%ignore XERCES_CPP_NAMESPACE::XMLPlatformUtils::alignPointerForNewBlockAllocation; - -%ignore PerlErrorCallbackHandler::warning(const SAXParseException&); -%ignore PerlErrorCallbackHandler::error(const SAXParseException&); -%ignore PerlErrorCallbackHandler::fatalError(const SAXParseException&); - // ignore the char* versions of ALL constructors %ignore XERCES_CPP_NAMESPACE::DOMLSParser::parseURI(const char *const ); %ignore MemBufInputSource(const XMLByte* const, const unsigned int, const char* const, @@ -93,19 +37,6 @@ , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); %ignore XERCES_CPP_NAMESPACE::AttributeList::getValue(const char* const) const; -%ignore setExternalSchemaLocation(const char* const); -%ignore setExternalNoNamespaceSchemaLocation(const char* const); - -/* - * Ignore these char* methods for all Parsers - */ -%ignore loadGrammar(const char* const systemId, - const short grammarType, - const bool toCache = false); - - -%ignore parse(const char* const); -%ignore parseFirst(const char *const,XMLPScanToken&,const bool); /* * We need these constructors to always adopt the input strings @@ -129,17 +60,6 @@ DOMLSInput* const , DOMLSResourceResolver*); -// These are odd cases. We want access to skip the method with the -// memory manager argument, but we want access to the optional argument -// *after* the memory manager. So we just ignore the method that doesn't -// include the memory manager - since our typemap defaults that argument -// they are redundant -%ignore createLSParser(short const,const XMLCh* const); -%ignore SAXParser(XMLValidator* const); - -// FIXME SWIG-1.3.30 broke this -// %ignore createXMLReader(); - /* * ignore the constructors which set the MemoryManager */ @@ -209,16 +129,6 @@ ); -// changing the locale and the NLS home is probably useful -// but changing the panic manager and memory manager is not -%ignore Initialize(const char* const - , const char* const - , PanicHandler* const - , MemoryManager* const); -%ignore Initialize(const char* const - , const char* const - , PanicHandler* const); - // this constructor has a single XMLCh that interfers with another bool constructor %ignore DTDEntityDecl( const XMLCh* const @@ -226,10 +136,8 @@ , const bool fromIntSubset = false , const bool specialChar = false); -%ignore XERCES_CPP_NAMESPACE::DOMImplementation::loadDOMExceptionMsg; - /* - * Perl won't need to create exceptions -- FIXME -- not true + * Scripting languages won't need to create exceptions -- FIXME -- not true * callbacks should be able to call exceptions */ @@ -282,84 +190,6 @@ ); %ignore SAXParseException(const SAXParseException& toCopy); -/* - * methods not needed by the XMLValidator interfaces - */ -%ignore XERCES_CPP_NAMESPACE::XMLValidator::emitError; -%ignore XERCES_CPP_NAMESPACE::XMLValidator::checkRootElement; -%ignore XERCES_CPP_NAMESPACE::XMLValidator::reinitMsgMutex; -%ignore XERCES_CPP_NAMESPACE::XMLValidator::reinitMsgLoader; -%ignore XERCES_CPP_NAMESPACE::XMLValidator::setErrorReporter; -%ignore XERCES_CPP_NAMESPACE::XMLValidator::setScannerInfo; -%ignore XERCES_CPP_NAMESPACE::XMLValidator::handlesSchema; -%ignore XERCES_CPP_NAMESPACE::XMLValidator::handlesDTD; -%ignore XERCES_CPP_NAMESPACE::XMLValidator::validateElement; -%ignore XERCES_CPP_NAMESPACE::XMLValidator::validateAttrValue; -%ignore XERCES_CPP_NAMESPACE::XMLValidator::requiresNamespaces; -%ignore XERCES_CPP_NAMESPACE::XMLValidator::reset; -%ignore XERCES_CPP_NAMESPACE::XMLValidator::postParseValidation; -%ignore XERCES_CPP_NAMESPACE::XMLValidator::preContentValidation; -%ignore XERCES_CPP_NAMESPACE::XMLValidator::faultInAttr; -%ignore XERCES_CPP_NAMESPACE::XMLValidator::checkContent; - -// ignore all the constructors for the Grammar components -%ignore XERCES_CPP_NAMESPACE::DTDAttDef::DTDAttDef; -%ignore XERCES_CPP_NAMESPACE::DTDElementDecl::DTDElementDecl; -%ignore XERCES_CPP_NAMESPACE::DTDEntityDecl::DTDEntityDecl; -%ignore XERCES_CPP_NAMESPACE::SchemaElementDecl::SchemaElementDecl; -%ignore XERCES_CPP_NAMESPACE::SchemaAttDef::SchemaAttDef; -%ignore XERCES_CPP_NAMESPACE::DTDAttDefList::DTDAttDefList; -%ignore XERCES_CPP_NAMESPACE::SchemaAttDefList::SchemaAttDefList; - -/* - * methods not needed by the public Parser interfaces - * - * this is probably because I'm not using AdvDocHandlers and things - * that want to control the parsing process, but until someone asks - * for them, I'm going to leave them out. - */ - -// XMLEntityHandler interface -%ignore endInputSource; -%ignore expandSystemId; -%ignore resetEntities; -%ignore resolveEntity; -%ignore startInputSource; - -// XMLDocumentHandler interface. -%ignore docCharacters; -%ignore docComment; -%ignore docPI; -%ignore endDocument; -%ignore endElement; -%ignore endEntityReference; -%ignore ignorableWhitespace; -%ignore resetDocument; -%ignore startDocument; -%ignore startElement; -%ignore startEntityReference; -%ignore XMLDecl; - -// depricated methods - don't ask me to include these -%ignore getDoValidation; -%ignore setDoValidation; -%ignore attDef; -%ignore doctypeComment; -%ignore doctypeDecl; -%ignore doctypePI; -%ignore doctypeWhitespace; -%ignore elementDecl; -%ignore endAttList; -%ignore endIntSubset; -%ignore endExtSubset; -%ignore entityDecl; -%ignore resetDocType; -%ignore notationDecl; -%ignore startAttList; -%ignore startIntSubset; -%ignore startExtSubset; -%ignore TextDecl; - // const methods %ignore getDocumentHandler() const; %ignore getErrorHandler() const; diff --git a/swig/interfaces/includes.i b/swig/interfaces/includes.i index 61de84915..6c10a55c6 100644 --- a/swig/interfaces/includes.i +++ b/swig/interfaces/includes.i @@ -19,35 +19,36 @@ */ %{ -#include "xercesc/sax/InputSource.hpp" #include "xercesc/sax/SAXException.hpp" #include "xercesc/sax/SAXParseException.hpp" -#include "xercesc/sax/Locator.hpp" -#include "xercesc/sax/HandlerBase.hpp" -#include "xercesc/sax2/Attributes.hpp" -#include "xercesc/sax2/ContentHandler.hpp" -#include "xercesc/sax2/LexicalHandler.hpp" -#include "xercesc/sax2/DefaultHandler.hpp" -#include "xercesc/sax2/SAX2XMLReader.hpp" -#include "xercesc/sax2/XMLReaderFactory.hpp" +#include "xercesc/sax/EntityResolver.hpp" + #include "xercesc/util/PlatformUtils.hpp" -#include "xercesc/util/TransService.hpp" #include "xercesc/util/XMLString.hpp" #include "xercesc/util/XMLUri.hpp" #include "xercesc/util/QName.hpp" #include "xercesc/util/HexBin.hpp" #include "xercesc/util/Base64.hpp" -#include "xercesc/parsers/SAXParser.hpp" -#include "xercesc/framework/LocalFileInputSource.hpp" -#include "xercesc/framework/MemBufInputSource.hpp" -#include "xercesc/framework/StdInInputSource.hpp" -#include "xercesc/framework/URLInputSource.hpp" -#include "xercesc/framework/XMLGrammarDescription.hpp" -#include "xercesc/framework/XMLDTDDescription.hpp" -#include "xercesc/framework/XMLSchemaDescription.hpp" #include "xercesc/util/NameIdPool.hpp" #include "xercesc/util/XMLEnumerator.hpp" +#include "xercesc/util/SecurityManager.hpp" +#include "xercesc/util/XMLException.hpp" +#include "xercesc/util/XMLEntityResolver.hpp" + #include "xercesc/framework/XMLValidator.hpp" +#include "xercesc/framework/XMLDocumentHandler.hpp" +#include "xercesc/framework/XMLPScanToken.hpp" + +#include "xercesc/framework/psvi/PSVIHandler.hpp" +#include "xercesc/framework/psvi/PSVIItem.hpp" +#include "xercesc/framework/psvi/PSVIElement.hpp" +#include "xercesc/framework/psvi/PSVIAttribute.hpp" +#include "xercesc/framework/psvi/PSVIAttributeList.hpp" + +#include "xercesc/framework/XMLGrammarDescription.hpp" +#include "xercesc/framework/XMLDTDDescription.hpp" +#include "xercesc/framework/XMLSchemaDescription.hpp" + #include "xercesc/validators/common/Grammar.hpp" #include "xercesc/validators/DTD/DTDAttDef.hpp" #include "xercesc/validators/DTD/DTDAttDefList.hpp" @@ -57,11 +58,7 @@ #include "xercesc/validators/schema/SchemaValidator.hpp" #include "xercesc/validators/schema/SchemaAttDefList.hpp" #include "xercesc/validators/schema/SchemaAttDef.hpp" -#include "xercesc/framework/XMLFormatter.hpp" -#include "xercesc/framework/MemBufFormatTarget.hpp" -#include "xercesc/framework/LocalFileFormatTarget.hpp" -#include "xercesc/framework/StdOutFormatTarget.hpp" -#include "xercesc/framework/psvi/PSVIHandler.hpp" +#include "PSVIWriter/PSVIUni.hpp" %} diff --git a/swig/interfaces/parsers.i b/swig/interfaces/parsers.i index 321afb1df..4ccd977ef 100644 --- a/swig/interfaces/parsers.i +++ b/swig/interfaces/parsers.i @@ -1,57 +1,80 @@ +/* + * methods not needed by the public Parser interfaces + * + */ + +// XMLEntityHandler interface +%ignore endInputSource; +%ignore expandSystemId; +%ignore resetEntities; +%ignore resolveEntity; +%ignore startInputSource; + +// depricated methods - don't ask me to include these +%ignore attDef; +%ignore doctypeComment; +%ignore doctypeDecl; +%ignore doctypePI; +%ignore doctypeWhitespace; +%ignore elementDecl; +%ignore endAttList; +%ignore endIntSubset; +%ignore endExtSubset; +%ignore entityDecl; +%ignore resetDocType; +%ignore notationDecl; +%ignore startAttList; +%ignore startIntSubset; +%ignore startExtSubset; +%ignore TextDecl; + +/* + * Ignore these char* methods for all Parsers + */ +%ignore loadGrammar(const char* const systemId, + const short grammarType, + const bool toCache = false); + + +%ignore parse(const char* const); +%ignore parseFirst(const char *const,XMLPScanToken&,const bool); + +%ignore setExternalSchemaLocation(const char* const); +%ignore setExternalNoNamespaceSchemaLocation(const char* const); + +// These are odd cases. We want access to skip the method with the +// memory manager argument, but we want access to the optional argument +// *after* the memory manager. So we just ignore the method that doesn't +// include the memory manager - since our typemap defaults that argument +// they are redundant +%ignore createLSParser(short const,const XMLCh* const); +%ignore SAXParser(XMLValidator* const); +%ignore XercesDOMParser(XMLValidator* const); + +// FIXME SWIG-1.3.30 broke this +// %ignore createXMLReader(); + +// exceptions needed by SAXParser and XercesDOMParser +%include "xercesc/sax/SAXException.hpp" +%include "xercesc/sax/SAXParseException.hpp" + // scan token helper class for progressive parsing %include "xercesc/framework/XMLPScanToken.hpp" -%include "xercesc/framework/psvi/PSVIHandler.hpp" -// these want to be removed to a separate DOM module -// %include "parsers/AbstractDOMParser.i" -// %include "parsers/XercesDOMParser.i" +// advanced document handler interface +%include "framework/XMLDocumentHandler.i" -%include "xercesc/sax/Parser.hpp" -%include "xercesc/parsers/SAXParser.hpp" +// old entity resolver interface +%include "xercesc/sax/EntityResolver.hpp" + +// new entity resolver interface +%include "util/XMLResourceIdentifier.i" +%include "util/XMLEntityResolver.i" + +// PSVI +%include "xercesc/framework/psvi/PSVIItem.hpp" +%include "xercesc/framework/psvi/PSVIElement.hpp" +%include "xercesc/framework/psvi/PSVIAttribute.hpp" +%include "xercesc/framework/psvi/PSVIAttributeList.hpp" +%include "xercesc/framework/psvi/PSVIHandler.hpp" -/* - * the SAX2XMLReader methods gets a special exception handler - * 'goto fail' must be called - either explicitly, or via SWIG_croak() - * to ensure that any variable cleanup is done - to avoid memory leaks. - * We make this a macro to be similar to the other exception handlers. - */ -%{ -#define CATCH_SAX_EXCEPTION \ - catch (const XMLException& e) \ - { \ - makeXMLException(e); \ - goto fail; \ - } \ - catch (const SAXNotSupportedException& e) \ - { \ - makeSAXNotSupportedException(e); \ - goto fail; \ - } \ - catch (const SAXNotRecognizedException& e) \ - { \ - makeSAXNotRecognizedException(e); \ - goto fail; \ - } \ - catch (...) \ - { \ - SWIG_croak("Handling Unknown exception"); \ - goto fail; \ - } -%} - -%define SAXEXCEPTION(method) -%exception method { - try { - $action - } - CATCH_SAX_EXCEPTION -} -%enddef - -SAXEXCEPTION(XERCES_CPP_NAMESPACE::SAX2XMLReader::getFeature) -SAXEXCEPTION(XERCES_CPP_NAMESPACE::SAX2XMLReader::setFeature) -SAXEXCEPTION(XERCES_CPP_NAMESPACE::SAX2XMLReader::setProperty) -SAXEXCEPTION(XERCES_CPP_NAMESPACE::SAX2XMLReader::getProperty) - -%include "xercesc/sax2/SAX2XMLReader.hpp" -%include "xercesc/sax2/XMLReaderFactory.hpp" diff --git a/swig/interfaces/parsers/AbstractDOMParser.i b/swig/interfaces/parsers/AbstractDOMParser.i index 768682d7b..b9f81d8c2 100644 --- a/swig/interfaces/parsers/AbstractDOMParser.i +++ b/swig/interfaces/parsers/AbstractDOMParser.i @@ -1 +1,8 @@ +%ignore XERCES_CPP_NAMESPACE::AbstractDOMParser::parseFirst( + const char* const + , XMLPScanToken&); +%ignore XERCES_CPP_NAMESPACE::AbstractDOMParser::setExternalSchemaLocation(const char* const); +%ignore XERCES_CPP_NAMESPACE::AbstractDOMParser::setExternalNoNamespaceSchemaLocation(const char* const); +%ignore XERCES_CPP_NAMESPACE::AbstractDOMParser::parse(const char* const); + %include "xercesc/parsers/AbstractDOMParser.hpp" \ No newline at end of file diff --git a/swig/interfaces/typemaps-dom.i b/swig/interfaces/typemaps-dom.i index b649f618e..602c50751 100644 --- a/swig/interfaces/typemaps-dom.i +++ b/swig/interfaces/typemaps-dom.i @@ -14,58 +14,362 @@ * limitations under the License. */ -/* - * DOM_Node* - */ +// DOMConfiguration::canSetParameter() must handle certain args specially +%extend XERCES_CPP_NAMESPACE::DOMConfiguration { +%typemap(in) const void* value (void *argp, int res) { + if (XMLString::compareIStringASCII(arg2, XMLUni::fgDOMErrorHandler) == 0) { + res = SWIG_ConvertPtr($input, &argp,SWIGTYPE_p_XERCES_CPP_NAMESPACE__DOMErrorHandler, 0 | 0 ); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "$symname" "', argument " "$argnum"" of type '" "XERCES_CPP_NAMESPACE::DOMErrorHandler const *""'"); + } + $1 = reinterpret_cast< XERCES_CPP_NAMESPACE::DOMErrorHandler * >(argp); + + } else if (XMLString::compareIStringASCII(arg2, XMLUni::fgXercesEntityResolver) == 0) { + res = SWIG_ConvertPtr($input, &argp,SWIGTYPE_p_XERCES_CPP_NAMESPACE__XMLEntityResolver, 0 | 0 ); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "$symname" "', argument " "$argnum"" of type '" "XERCES_CPP_NAMESPACE::XMLEntityResolver const *""'"); + } + $1 = reinterpret_cast< XERCES_CPP_NAMESPACE::XMLEntityResolver * >(argp); + + } else if (XMLString::compareIStringASCII(arg2, XMLUni::fgDOMResourceResolver) == 0) { + res = SWIG_ConvertPtr($input, &argp,SWIGTYPE_p_XERCES_CPP_NAMESPACE__DOMLSResourceResolver, 0 | 0 ); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "$symname" "', argument " "$argnum"" of type '" "XERCES_CPP_NAMESPACE::DOMLSResourceResolver const *""'"); + } + $1 = reinterpret_cast< XERCES_CPP_NAMESPACE::DOMLSResourceResolver * >(argp); + + } else { + $1 = UTF8_TRANSCODER->Local2XMLString($input); + } +} + +%typemap(out) const void* { + if (XMLString::compareIStringASCII(arg2, XMLUni::fgDOMErrorHandler) == 0) { + $result = SWIG_NewPointerObj(SWIG_as_voidptr($1), SWIGTYPE_p_XERCES_CPP_NAMESPACE__DOMErrorHandler, 0 | SWIG_SHADOW); + } else if (XMLString::compareIStringASCII(arg2, XMLUni::fgXercesEntityResolver) == 0) { + $result = SWIG_NewPointerObj(SWIG_as_voidptr($1), SWIGTYPE_p_XERCES_CPP_NAMESPACE__XMLEntityResolver, 0 | SWIG_SHADOW); + } else if (XMLString::compareIStringASCII(arg2, XMLUni::fgDOMResourceResolver) == 0) { + $result = SWIG_NewPointerObj(SWIG_as_voidptr($1), SWIGTYPE_p_XERCES_CPP_NAMESPACE__DOMLSResourceResolver, 0 | SWIG_SHADOW); + } else if (isDOMConfigXMLChParameter(arg2)) { + $result = UTF8_TRANSCODER->XMLString2Local((XMLCh*)$1); + } else { + $result = SWIG_From_bool SWIG_PERL_CALL_ARGS_1(static_cast< bool >($1)); + } + argvi++; +} + +%typemap(freearg) void * %{ + if (isDOMConfigXMLChParameter(arg2)) { + delete (XMLCh*) $1; + } +%} + +%{ + +bool +isDOMConfigObjectParameter(const XMLCh* name) { + if (XMLString::compareIStringASCII(name, XMLUni::fgXercesEntityResolver) == 0) + { + return true; + } + else if (XMLString::compareIStringASCII(name, XMLUni::fgXercesSecurityManager) == 0) + { + return true; + } + else if (XMLString::compareIStringASCII(name, XMLUni::fgDOMResourceResolver) == 0) + { + return true; + } + else if (XMLString::compareIStringASCII(name, XMLUni::fgDOMErrorHandler) == 0) + { + return true; + } + else + { + return false; + } +} + +bool +isDOMConfigBoolParameter(const XMLCh* name) { + if (XMLString::compareIStringASCII(name, XMLUni::fgDOMCharsetOverridesXMLEncoding) == 0) + { + return true; + } + else if (XMLString::compareIStringASCII(name, XMLUni::fgDOMDisallowDoctype) == 0) + { + // TODO + return true; + } + else if (XMLString::compareIStringASCII(name, XMLUni::fgDOMIgnoreUnknownCharacterDenormalization) == 0) + { + // TODO + return true; + } + else if (XMLString::compareIStringASCII(name, XMLUni::fgDOMNamespaces) == 0) + { + return true; + } + else if (XMLString::compareIStringASCII(name, XMLUni::fgDOMSupportedMediatypesOnly) == 0) + { + return true; + } + else if (XMLString::compareIStringASCII(name, XMLUni::fgDOMValidate) == 0) + { + return true; + } + else if (XMLString::compareIStringASCII(name, XMLUni::fgDOMValidateIfSchema) == 0) + { + return true; + } + else if (XMLString::compareIStringASCII(name, XMLUni::fgDOMWellFormed) == 0) + { + return true; + } + else if (XMLString::compareIStringASCII(name, XMLUni::fgDOMCanonicalForm) == 0 ) + { + // TODO + return true; + } + else if (XMLString::compareIStringASCII(name, XMLUni::fgDOMCDATASections) == 0 ) + { + // TODO + return true; + } + else if (XMLString::compareIStringASCII(name, XMLUni::fgDOMCheckCharacterNormalization) == 0 ) + { + // TODO + return true; + } + else if (XMLString::compareIStringASCII(name, XMLUni::fgDOMComments) == 0) + { + return true; + } + else if (XMLString::compareIStringASCII(name, XMLUni::fgDOMDatatypeNormalization) == 0) + { + return true; + } + else if (XMLString::compareIStringASCII(name, XMLUni::fgDOMElementContentWhitespace) == 0) + { + return true; + } + else if (XMLString::compareIStringASCII(name, XMLUni::fgDOMEntities) == 0) + { + return true; + } + else if (XMLString::compareIStringASCII(name, XMLUni::fgDOMNamespaceDeclarations) == 0) + { + return true; + } + else if (XMLString::compareIStringASCII(name, XMLUni::fgDOMNormalizeCharacters) == 0) + { + return true; + } + else if (XMLString::compareIStringASCII(name, XMLUni::fgDOMSchemaLocation) == 0) + { + return true; + } + else if (XMLString::compareIStringASCII(name, XMLUni::fgDOMSchemaType) == 0) + { + return true; + } + else if (XMLString::compareIStringASCII(name, XMLUni::fgDOMSplitCDATASections) == 0) + { + return true; + } + else if (XMLString::compareIStringASCII(name, XMLUni::fgDOMInfoset) == 0) + { + return true; + } + else if (XMLString::compareIStringASCII(name, XMLUni::fgXercesSchema) == 0) + { + return true; + } + else if (XMLString::compareIStringASCII(name, XMLUni::fgXercesSchemaFullChecking) == 0) + { + return true; + } + else if (XMLString::compareIStringASCII(name, XMLUni::fgXercesIdentityConstraintChecking) == 0) + { + return true; + } + else if (XMLString::compareIStringASCII(name, XMLUni::fgXercesLoadExternalDTD) == 0) + { + return true; + } + else if (XMLString::compareIStringASCII(name, XMLUni::fgXercesContinueAfterFatalError) == 0) + { + return true; + } + else if (XMLString::compareIStringASCII(name, XMLUni::fgXercesValidationErrorAsFatal) == 0) + { + return true; + } + else if (XMLString::compareIStringASCII(name, XMLUni::fgXercesCacheGrammarFromParse) == 0) + { + return true; + } + else if (XMLString::compareIStringASCII(name, XMLUni::fgXercesUseCachedGrammarInParse) == 0) + { + return true; + } + else if (XMLString::compareIStringASCII(name, XMLUni::fgXercesCalculateSrcOfs) == 0) + { + return true; + } + else if (XMLString::compareIStringASCII(name, XMLUni::fgXercesStandardUriConformant) == 0) + { + return true; + } + else if(XMLString::compareIStringASCII(name, XMLUni::fgXercesUserAdoptsDOMDocument) == 0) + { + return true; + } + else if (XMLString::compareIStringASCII(name, XMLUni::fgXercesDOMHasPSVIInfo) == 0) + { + return true; + } + else if (XMLString::compareIStringASCII(name, XMLUni::fgXercesGenerateSyntheticAnnotations) == 0) + { + return true; + } + else if (XMLString::compareIStringASCII(name, XMLUni::fgXercesValidateAnnotations) == 0) + { + return true; + } + else if (XMLString::compareIStringASCII(name, XMLUni::fgXercesIgnoreCachedDTD) == 0) + { + return true; + } + else if (XMLString::compareIStringASCII(name, XMLUni::fgXercesIgnoreAnnotations) == 0) + { + return true; + } + else if (XMLString::compareIStringASCII(name, XMLUni::fgXercesDisableDefaultEntityResolution) == 0) + { + return true; + } + else if (XMLString::compareIStringASCII(name, XMLUni::fgXercesSkipDTDValidation) == 0) + { + return true; + } + else + { + return false; + } +} + +bool +isDOMConfigXMLChParameter(const XMLCh* name) { + if (XMLString::compareIStringASCII(name, XMLUni::fgXercesScannerName) == 0) + { + return true; + } + else if (XMLString::compareIStringASCII(name, XMLUni::fgXercesParserUseDocumentFromImplementation) == 0) + { + return true; + } + else if (XMLString::compareIStringASCII(name, XMLUni::fgXercesSchemaExternalSchemaLocation) == 0) + { + return true; + } + else if (XMLString::compareIStringASCII(name, XMLUni::fgXercesSchemaExternalNoNameSpaceSchemaLocation) == 0) + { + return true; + } + else + { + return false; + } +} + +%} + +%typecheck(SWIG_TYPECHECK_VOIDPTR) +void*, const void* +{ + int res = -1; + XMLCh *name = UTF8_TRANSCODER->Local2XMLString(ST(1)); + if (XMLString::compareIStringASCII(name, XMLUni::fgDOMErrorHandler) == 0) { + res = 1; + } else if (XMLString::compareIStringASCII(name, XMLUni::fgXercesEntityResolver) == 0) { + res = 1; + } else if (XMLString::compareIStringASCII(name, XMLUni::fgDOMSchemaLocation) == 0) { + res = 1; + } else if (XMLString::compareIStringASCII(name, XMLUni::fgDOMSchemaType) == 0) { + res = 1; + } else if (XMLString::compareIStringASCII(name, XMLUni::fgDOMResourceResolver) == 0) { + res = 1; + } else if (XMLString::compareIStringASCII(name, XMLUni::fgXercesSecurityManager) == 0) { + res = 1; + } else if (XMLString::compareIStringASCII(name, XMLUni::fgXercesScannerName) == 0) { + res = 1; + } else if (XMLString::compareIStringASCII(name, XMLUni::fgDOMSchemaType) == 0) { + res = 1; + } else if (XMLString::compareIStringASCII(name, XMLUni::fgXercesSchemaExternalSchemaLocation) == 0) { + res = 1; + } else if (XMLString::compareIStringASCII(name, XMLUni::fgXercesSchemaExternalNoNameSpaceSchemaLocation) == 0) { + res = 1; + } else if (XMLString::compareIStringASCII(name, XMLUni::fgXercesParserUseDocumentFromImplementation) == 0) { + res = 1; + } + _v = SWIG_CheckState(res); +} +} + -%typemap(out) XERCES_CPP_NAMESPACE::DOMNode * = SWIGTYPE *DYNAMIC; +%typemap(out) XERCES_CPP_NAMESPACE::XMLFormatTarget * = SWIGTYPE *DYNAMIC; -DYNAMIC_CAST(SWIGTYPE_p_XERCES_CPP_NAMESPACE__DOMNode, DOMNode_dynamic_cast); +DYNAMIC_CAST(SWIGTYPE_p_XERCES_CPP_NAMESPACE__XMLFormatTarget, XMLFormatTarget_dynamic_cast); %{ static swig_type_info * -DOMNode_dynamic_cast(void **ptr) { - DOMNode **nptr = (DOMNode **) ptr; +XMLFormatTarget_dynamic_cast(void **ptr) { + XMLFormatTarget **nptr = (XMLFormatTarget **) ptr; if (*nptr == NULL) { return NULL; } - short int type = (*nptr)->getNodeType(); - if (type == DOMNode::TEXT_NODE) { - return SWIGTYPE_p_XERCES_CPP_NAMESPACE__DOMText; - } - if (type == DOMNode::PROCESSING_INSTRUCTION_NODE) { - return SWIGTYPE_p_XERCES_CPP_NAMESPACE__DOMProcessingInstruction; - } - if (type == DOMNode::DOCUMENT_NODE) { - return SWIGTYPE_p_XERCES_CPP_NAMESPACE__DOMDocument; + if (dynamic_cast< XERCES_CPP_NAMESPACE::MemBufFormatTarget * >(*nptr)) { + return SWIGTYPE_p_XERCES_CPP_NAMESPACE__MemBufFormatTarget; } - if (type == DOMNode::ELEMENT_NODE) { - return SWIGTYPE_p_XERCES_CPP_NAMESPACE__DOMElement; + if (dynamic_cast< XERCES_CPP_NAMESPACE::LocalFileFormatTarget * >(*nptr)) { + return SWIGTYPE_p_XERCES_CPP_NAMESPACE__LocalFileFormatTarget; } - if (type == DOMNode::ENTITY_REFERENCE_NODE) { - return SWIGTYPE_p_XERCES_CPP_NAMESPACE__DOMEntityReference; + if (dynamic_cast< XERCES_CPP_NAMESPACE::StdOutFormatTarget * >(*nptr)) { + return SWIGTYPE_p_XERCES_CPP_NAMESPACE__StdOutFormatTarget; } - if (type == DOMNode::CDATA_SECTION_NODE) { - return SWIGTYPE_p_XERCES_CPP_NAMESPACE__DOMCDATASection; - } - if (type == DOMNode::CDATA_SECTION_NODE) { - return SWIGTYPE_p_XERCES_CPP_NAMESPACE__DOMCDATASection; + return NULL; +} +%} + +%typemap(out) XERCES_CPP_NAMESPACE::InputSource * = SWIGTYPE *DYNAMIC; + +DYNAMIC_CAST(SWIGTYPE_p_XERCES_CPP_NAMESPACE__InputSource, InputSource_dynamic_cast); + +%{ +static swig_type_info * +InputSource_dynamic_cast(void **ptr) { + InputSource **nptr = (InputSource **) ptr; + if (*nptr == NULL) { + return NULL; } - if (type == DOMNode::COMMENT_NODE) { - return SWIGTYPE_p_XERCES_CPP_NAMESPACE__DOMComment; + + if (dynamic_cast< XERCES_CPP_NAMESPACE::Wrapper4DOMLSInput * >(*nptr)) { + return SWIGTYPE_p_XERCES_CPP_NAMESPACE__Wrapper4DOMLSInput; } - if (type == DOMNode::DOCUMENT_TYPE_NODE) { - return SWIGTYPE_p_XERCES_CPP_NAMESPACE__DOMDocumentType; + if (dynamic_cast< XERCES_CPP_NAMESPACE::MemBufInputSource * >(*nptr)) { + return SWIGTYPE_p_XERCES_CPP_NAMESPACE__MemBufInputSource; } - if (type == DOMNode::ENTITY_NODE) { - return SWIGTYPE_p_XERCES_CPP_NAMESPACE__DOMEntity; + if (dynamic_cast< XERCES_CPP_NAMESPACE::LocalFileInputSource * >(*nptr)) { + return SWIGTYPE_p_XERCES_CPP_NAMESPACE__LocalFileInputSource; } - if (type == DOMNode::ATTRIBUTE_NODE) { - return SWIGTYPE_p_XERCES_CPP_NAMESPACE__DOMAttr; + if (dynamic_cast< XERCES_CPP_NAMESPACE::URLInputSource * >(*nptr)) { + return SWIGTYPE_p_XERCES_CPP_NAMESPACE__URLInputSource; } - if (type == DOMNode::NOTATION_NODE) { - return SWIGTYPE_p_XERCES_CPP_NAMESPACE__DOMNotation; + if (dynamic_cast< XERCES_CPP_NAMESPACE::StdInInputSource * >(*nptr)) { + return SWIGTYPE_p_XERCES_CPP_NAMESPACE__StdInInputSource; } return NULL; } %} + diff --git a/swig/interfaces/typemaps-general.i b/swig/interfaces/typemaps-general.i index ea7250d67..87396c9c9 100644 --- a/swig/interfaces/typemaps-general.i +++ b/swig/interfaces/typemaps-general.i @@ -23,44 +23,13 @@ */ %typemap(default,numinputs=0) XERCES_CPP_NAMESPACE::MemoryManager* const manager "$1 = XERCES_CPP_NAMESPACE::XMLPlatformUtils::fgMemoryManager;" -/* - * MemBufInputSource::MemBufInputSource() - * - * ALWAYS ADOPT BUFFER (I.E. MAKE A COPY OF IT) SINCE IT IS TAKEN FROM - * THE SCRIPTING LANGUAGE, AND WHO KNOWS WHAT WILL HAPPEN TO IT AFTER - * IT IS GIVEN TO THE - * CONSTRUCTOR - */ - -// %typemap(in,numinputs=0) (unsigned int byteCount) "$1 = 0;" - -/* - * These arguments are used to indicate that Xerces-C should - * adopt a resource being passed as an argument. We should - * *always* tell Xerces-C to adopt. - */ -%typemap(in,numinputs=0) const bool adoptFlag "$1 = true;" // for Wrapper4InputSource - // and Wrapper4DOMInputSource -%typemap(in,numinputs=0) const bool adoptBuffer "$1 = true;" // for MemBufInputSource - -// SAX2XMLReader::setProperty() should refuse the option to set the -// security manager -%extend XERCES_CPP_NAMESPACE::SAX2XMLReader { -%typemap(check) (const XMLCh* const name, void* value) { - if (XMLString::compareIStringASCII($1, XMLUni::fgXercesSecurityManager) == 0) { - makeSAXNotSupportedException(SAXNotSupportedException("Setting security manager not supported")); - goto fail; - } -} -} - /* * Dynamic Casts * * This very cool SWIG feature enables use to return the correct object - * type to Perl when a C++ method is defined as returning a base class - * object. We define a method that tells what type subclass the object - * is in. + * type to the scripting language when a C++ method is defined as + * returning a base class object. We define a method that tells what + * type subclass the object is in. */ /* @@ -88,3 +57,26 @@ Grammar_dynamic_cast(void **ptr) { return NULL; } %} + +%typemap(out) XERCES_CPP_NAMESPACE::XMLGrammarDescription * = SWIGTYPE *DYNAMIC; + +DYNAMIC_CAST(SWIGTYPE_p_XERCES_CPP_NAMESPACE__XMLGrammarDescription, XMLGrammarDescription_dynamic_cast); + +%{ +static swig_type_info * +XMLGrammarDescription_dynamic_cast(void **ptr) { + XMLGrammarDescription **nptr = (XMLGrammarDescription **) ptr; + if (*nptr == NULL) { + return NULL; + } + short int type = (*nptr)->getGrammarType(); + if (type == Grammar::DTDGrammarType) { + return SWIGTYPE_p_XERCES_CPP_NAMESPACE__XMLDTDDescription; + } + if (type == Grammar::SchemaGrammarType) { + return SWIGTYPE_p_XERCES_CPP_NAMESPACE__XMLSchemaDescription; + } + return NULL; +} +%} + diff --git a/swig/interfaces/util.i b/swig/interfaces/util.i index d57fd89c8..7987339c6 100644 --- a/swig/interfaces/util.i +++ b/swig/interfaces/util.i @@ -1,8 +1,10 @@ // we remove this macro for PlatformUtils and XMLURL #define MakeXMLException(theType, expKeyword) -%include "xercesc/util/PlatformUtils.hpp" +%include "util/PlatformUtils.i" + %import "xercesc/util/XMemory.hpp" + %include "xercesc/util/XMLURL.hpp" #define DECL_XSERIALIZABLE(XMLUri) @@ -13,8 +15,6 @@ %include "xercesc/util/XMLExceptMsgs.hpp" %include "xercesc/util/XMLException.hpp" -// Unicode string constants for XML Formatter -%include "xercesc/util/XMLUni.hpp" - %include "xercesc/util/QName.hpp" +%include "xercesc/util/SecurityManager.hpp" -- GitLab