"John Utz" <[EMAIL PROTECTED]> writes:
> really? i am working from the example of the DOM stuff, and the methods
> that are listed in the @dom_node_methods all end up in Xerces.pm with
> the following line added:
>
> # automatically convert to base class
> $result = $result->actual_cast();
My mistake. You are correct, you have to go through the code, and find
all functions that return a XML::Xerces::Grammar instance and add in
the actual_cast() call.
> sub actual_cast {
> return undef unless _isa( ref($_[0]), 'XML::Xerces::Grammar' );
> return $_[0] if $_[0]->isNull;
Like I mentioned yesterday, get rid of the isNull() line, there is no
such method for Grammar, and get rid of _isa() and just use the
following:
sub actual_cast {
my ($self) = @_
return undef unless $self->isa('XML::Xerces::Grammar' );
> but i dont think this is sufficient, because it appears to me that the
> call to actual_cast has to be inserted in the methods in the pm
> file.
correct.
> thats what i assume this code is doing:
>
> # I?DOM_Node: automatically convert to base class
> if (grep {/$CURR_CLASS/} @dom_node_methods) {
> if (my ($sub) = /^sub\s+([\w_]+)/) {
> $sub = "$ {CURR_CLASS}::$sub";
> if (grep {/$sub$/} @dom_node_methods) {
> my $fix = <<'EOT';
> # automatically convert to base class
> $result = $result->actual_cast();
> EOT
> fix_method(\*FILE,
> \*TEMP,
> qr/return undef/,
> $fix,
> 1);
> next;
> }
> }
> }
>
> so, am i still wrong? i am content to be wrong. :-)
You are most definately correct, I wasn't taking time to read your
email.
You'll need to have a @grammar_methods array that you populate with
the names of methods that return grammars. and then use:
# Grammar: automatically convert to base class
if (grep {/$CURR_CLASS/} @dom_node_methods) {
if (my ($sub) = /^sub\s+([\w_]+)/) {
$sub = "$ {CURR_CLASS}::$sub";
if (grep {/$sub$/} @grammar_methods) {
my $fix = <<'EOT';
# automatically convert to base class
$result = $result->actual_cast();
EOT
fix_method(\*FILE,
\*TEMP,
qr/return undef/,
$fix,
1);
next;
}
}
The fix_method() call goes through the text of the method and
substitutes your code (in $fix) for the code inside the regular
expression (qr/return undef/).
> 10 days ago i knew zip about SWIG, and this was probably not the project i
> would have picked for getting my tootsies wet :-)
>
> but the help you've provided has more than made up for the steepness of
> the learning curve...
Glad I've helped. Getting other people to help with the development of
XML::Xerces has been a dream of mine for quite a while.
Keep up the good work,
jas.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]