From: <mrm...@we...> - 2011-02-22 21:25:29
|
Am 22.02.2011, 19:05 Uhr, schrieb David Nadlinger <co...@kl...>: > On 2/22/11 4:37 PM, mrm...@we... wrote: >> I want to wrap some code that uses a struct Vector3f: >> >> #include <Vector3.hpp> >> class Listener >> { >> public: >> static void SetPosition(const Vector3f& position); >> } >> >> But I have my own hand-written Vector struct for the target language (D) >> so I don't want SWIG to wrap the C++ one. > > Is your Vector struct in D »bit-compatible« with the Vector3f struct in > C++ so that you want SWIG to just »replace« the C++ struct in the API > with the D one without performing any conversions? > > Or do you just want to be able to use your D struct in the API when > accessing the library from D, but use SWIG to generate the appropriate > glue code to convert the data to its C++ representation before passing > it to the library? It is bit-compatible, so I'd like SWIG to only generate a proxy module with "SetPosition(ref Vector3f position)" or whatever and maybe an "import vector;" via some %{ %} magic, but no wrapper for the C++ version of Vector3f. But I guess this interferes with another issue: What if I want a C++ struct that is in fact used as POD to be mapped to a struct in D (which is always POD)? |