Hi Jason,
That would be great, thanks (if it doesn't cost you too much time that
is).
About the Xerces-C-3.0-beta, do I need to download this from
http://xml.apache.org/dist/xerces-c/experimental/archives/tru64/xerces-c
-src1_3_0-OSF1.tar.gz and build it ?
Thanks for all your help,
Ben
-----Oorspronkelijk bericht-----
Van: Jason Stewart [mailto:jason.e.stewart@xxxxxxxxx]
Verzonden: woensdag 16 augustus 2006 10:04
Aan: c-users@xxxxxxxxxxxxxxxxx
Onderwerp: Re: Accessing Xerces Perl object's from C++.
Hi Ben,
On 8/16/06, Ben Meijering <ben@xxxxxxxxxxx> wrote:
> I am building an XML parser in C++. The manner in which a document is
> parsed is defined in a XML document, where handler functions are
> defined for certain tags and attributes.
>
> These functions are registered in a function repository beforehand and
> can be of any kind, for now only C++ and Perl. These functions have
> Xerces objects as arguments. I could stick solely to C++ functions,
> but I figured if Xerces had a similar construction just like wxPerl
> has, this could be a nice addition to my application.
OK, I got a better picture of what you're doing, thanks.
No one has asked for this feature before. It is relatively trivial -
since Xerces-Perl has to do this same action at ever method invocation,
but there isn't a simple method for it. The reason for this is that you
have to know what type the object is - and that type is given as a SWIG
type_info struct (since Xerces-Perl is created by wrapping Xerces-C
using SWIG). That type_info struct is very version dependent and would
not work across different releases of Xerces-Perl.
So for example:
res3 = SWIG_ConvertPtr(ST(1), &argp3, SWIGTYPE_p__XMLGrammarPool, 0
| 0 );
if (!SWIG_IsOK(res3)) {
SWIG_exception_fail(SWIG_ArgError(res3), "in method '"
"new_XercesDOMParser" "', argument " "3"" of type '" "XMLGrammarPool
*const""'");
}
arg3 = reinterpret_cast<XMLGrammarPool * >(argp3);
would take the the perl SV* sitting in ST(1) - the second var on the
stack - and convert it to an void* into the var argp3. If res3 is OK -
meaning all the error checking worked, then you can safely do the cast
of argp3 to arg3 with all the type information.
but you see - you need access to that 'SWIGTYPE_p__XMLGrammarPool'
pointer, which at the moment is compiled into Xerces.cpp and not
accessible from a header file.
I have wanting to do that for many years, but I have never had the
reason to spend the time to make it work. If you are sufficiently
motivated, I will put aside some time and get it working if you are will
to test it with Xerces-C-3.0-beta (I'm no longer updating older versions
of Xerces-Perl).
Cheers, jas.
|