|
Re: Vector extensions: msg#00096programming.swig
At 01:20 PM 1/22/03 +0100, Kostyantyn Teplynskyy wrote: Hellow, please advice me. I am working with vectors. My task is to add my own functions to vectors. I have one decision: Kostyantyn, vector of built-ins are template specializations of the generic vector. My guess is that your %extend is only attached to the generic class. You'll have to attach it to the specializations as well---I think the less annoying way is to write: namespace std { %extend vector { char *myfunc{ ... }; } %define specialize_myfunc(T) %extend vector<T> { char *myfunc{ ... }; } %enddef specialize_myfunc(bool); specialize_myfunc(int); specialize_myfunc(short); specialize_myfunc(long); specialize_myfunc(unsigned int); specialize_myfunc(unsigned short); specialize_myfunc(unsigned long); specialize_myfunc(double); specialize_myfunc(float); specialize_myfunc(std::string); } which reduces to a minimum the amouont of duplication, even though it does not avoid it completely. If the body of myfunc is large, you might consider defining it as a function in a %{ }% block (so that it is added to the C++ wrappers) and call it from within the %extend-added methods. Hope this helps, Luigi _______________________________________________ Swig maillist - Swig@xxxxxxxxxxxxxxx http://mailman.cs.uchicago.edu/mailman/listinfo/swig |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Vector extensions: 00096, Kostyantyn Teplynskyy |
|---|---|
| Next by Date: | python "named arguments" swig: 00096, David Beazley |
| Previous by Thread: | Vector extensionsi: 00096, Kostyantyn Teplynskyy |
| Next by Thread: | SWIG/non-SWIG python modules: 00096, Jon Anderson |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |