Re: Howto override the argument names of certain class member functions
Rui Oliveira <[email protected]>
| Newsgroups | gmane.comp.programming.swig |
|---|---|
| Message-ID | <BYAPR12MB319155E4F0CB2F05C91D9F1CD4970@BYAPR12MB3191.namprd12.prod.outlook.com> |
Hey,
You're probably looking to do something like:
%apply (float complex *OUTPUT) {(liquid_float_complex *_y),
(liquid_float_complex *_x_hat)};
void modem_modulate(modem _q, unsigned int _s, liquid_float_complex *_y);
void modem_get_demodulator_sample(modem _q, liquid_float_complex *_x_hat);
%clear (liquid_float_complex *_y), (liquid_float_complex *_x_hat);
This is an example from code I've written. This is documented in:
http://www.swig.org/Doc4.0/SWIGDocumentation.html#Arguments_nn7
Basically you write typemaps with generic names and then apply them to
your particular function arguments.
Me personally, I like to clear %apply directives when I no longer need
them to avoid bugs to do "stray" typemaps.
Hope it helped.
Às 10:46 de 22/06/2020, Terry Barnaby escreveu:
> I am wrapping a relatively complex C++ class library to produce a
> Python interface. One thing I haven't worked out how to do is to tell
> SWIG to return certain function reference arguments on the lhs of the
> function call only, ie. assume them to be OUTPUT only references. For
> example (very simplified):
>
> class DataFile {
>
> public:
>
> Error setInfo(const Info& info); // Input only reference
>
> Error getInfo(Info& info); // Output only reference
>
> };
>
> Now I can rename the getInfo function in the C++ class library to
> "Error getInfo(Info& OUTPUT);" say and add the appropriate typemaps to
> match this and that works, but I really don't want to rename all of
> the C++'s API function arguments for all of the classes in this
> library (They are used for doxygen etc).
>
> This there a simple way in SWIG to override/rename the arguments of a
> particular function and/or particular classes member function ? So
> something like:
>
> %rename("getInfo(Info& OUTPUT)") "getInfo(Info& info)"
>
> %rename("DataFile::getInfo(Info& OUTPUT)") "DataFile::getInfo(Info&
> info)"
>
>
>
> _______________________________________________
> Swig-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/swig-user
_______________________________________________
Swig-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/swig-user