|
From: Alan W. I. <ir...@be...> - 2011-04-19 21:16:01
|
On 2011-04-19 13:49-0600 Eileen Wei wrote:
>
> Hi,
>
>
>
> I am wrapping a C++ header file to Python.
>
>
>
> In my .h file I have two functions defined like this:
>
>
>
> static bool foo1(
>
> const double& parm1,
>
> double& result1 );
>
> static bool foo2(
>
> const double& result1,
>
> double& result2 );
>
>
>
> So result1 is a return value in function foo1, but an input parameter in function foo2.
>
>
>
> If I do
>
> %apply double& OUTPUT { double& result1 };
>
>
>
> It will not only change the behaviour of foo1 to return 2 values, but it will also affect foo2, which I don’t want.
>
>
>
> My question is how can I specify that this typemap only applies to foo1 and not other functions in the .h file?
Hi Eileen:
Rename result1 to something else in the foo2 argument list so the two
qualitatively different kinds of arguments in your API that need
different swig treatments have different signatures.
For our project (PLplot), we take this approach to an extreme. We have
a special plplotcapi.i file which pretty much follows our principal
*.h header file for the PLplot library. But plplotcapi.i renames
arguments so that each specific kind of argument (there are not that
many of them) that we have in our API has a unique argument signature.
We then include the plplotcapi.i file for each of our swig-generated
language interfaces (Python, Java, Lua, and Octave), and for each
language specify appropriate typemaps (when necessary) for each
specific kind of argument signature that is mentioned in the
plplotcapi.i file.
Alan
__________________________
Alan W. Irwin
Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).
Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________
Linux-powered Science
__________________________
|