logo       

Re: Dispatch function (for function overloading) does not use typemap s: msg#00162

programming.swig

Subject: Re: Dispatch function (for function overloading) does not use typemap s


On Nov 27, 2003, at 3:50 AM, Sluis, Minto van der wrote:

Hi,

I use swig 1.3.19 to create a Tcl wrapper for my C++ libaries.

However When I combine overloaded functions and typemaps the wrapper does
not work properly. I am not sure whether this is bug or not.

I have a C++ class to represent an ID (sample code snippet follows below).
Typemaps convert references to this class to plain strings in Tcl. The
typemaps I use are pretty straight forward.

%typemap(in) ID {
$1 = ID(Tcl_GetStringFromObj($input,NULL));
}

%typemap(in) const ID & (ID temp) {
temp = ID(Tcl_GetStringFromObj($input,NULL));
$1 = &temp;
}


[ snip ]

If you are going to use typemaps and overloading together, you need to be aware that there is an additional typemap that is used to perform the typechecking needed during dispatch. In the case of the example above, you can probably insert something like this into your program:

%typecheck(SWIG_TYPECHECK_STRING) ID, ID & = char *;

Take a look at the file Lib/tcl/tcl8.swg for more examples of using %typecheck.

This doesn't appear to be documented very well (if at all) in 1.3.19. I'm going to take a look at the pending 1.3.20 release to make sure this is described.

Cheers,
Dave

_______________________________________________
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