logo       

Re: Is there a $xxx to specify the current function name ?: msg#00086

programming.swig

Subject: Re: Is there a $xxx to specify the current function name ?

David Benjamin-bdavid02 <Benjamin.David@xxxxxxxxxxxx> writes:

> I would like to use a $xxx to access the function/method name that this type
> map is used in.
>
> IF this were called $name I could use this as follows:
>
>
> %typemap(in) const uString & {
>
> printf ("Currently in %s ", uString ($name) );
>
> }
>
> This would be used for diagnostic purposes primarily.
> I could not find such a feature. Does this exist ?

>From Typemaps.html:

8.5.1 "in" typemap
The "in" typemap is used to convert function arguments from the target
language to C. For example:

%typemap(in) int {
$1 = PyInt_AsLong($input);
}

The following special variables are available:

$input - Input object holding value to be converted.
$symname - Name of function/method being wrapped

However, this doesn't really do what I expected it to do. For example,
the following typemap:

%typemap(in) XMLCh * {
if (SvPOK($input)||SvIOK($input)||SvNOK($input)) {
$1 = Perl2XMLString($input);
} else {
croak("Type error in argument 2 of $symname, Expected perl-string.");
XSRETURN(1);
}
}

produces this in the output file:

if (SvPOK(ST(2))||SvIOK(ST(2))||SvNOK(ST(2))) {
arg3 = Perl2XMLString(ST(2));
} else {
croak("Type error in argument 2 of XMLErrorReporter_error, Expected
perl-string.");
XSRETURN(1);
}

I would have liked $symname to read XMLErrorReporter::error, since
that's the method I'm wrapping, and not XMLErrorReporter_error. This
creates a fair amount of confusion when users see this type of error.

Even better, I'd like it to be fully qualified with the module
namespace, so XML::Xerces::XMLErrorReporter::error ... but I digress.

Or, perhaps one of the typemap gurus will (hopefully) show why I'm silly...

Cheers,
jas.
_______________________________________________
Swig maillist - Swig@xxxxxxxxxxxxxxx
http://mailman.cs.uchicago.edu/mailman/listinfo/swig



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise