SWIG - How to convert primitive types that are passed by reference?

Asked

Viewed 29 times

0

I’m using SWIG to be able to use a C++ code in C# (Ogre3d for the curious)
I have the following method in C++:

bool suggestTangentVectorBuildParams(VertexElementSemantic targetSemantic,
            unsigned short& outSourceCoordSet, unsigned short& outIndex)

But SWIG cannot convert the type unsigned short&, then on C# it’s like this:

public bool suggestTangentVectorBuildParams(VertexElementSemantic targetSemantic, 
                SWIGTYPE_p_unsigned_short outSourceCoordSet, SWIGTYPE_p_unsigned_short outIndex)

Where is SWIGTYPE_p_unsigned_short was meant to be out ushort.

I tried to touch the SWIG interface putting this line to try to convert but it did not work, still continues SWIGTYPE_p_unsigned_short:

%typemap(cstype) unsigned short& "out ushort"

Where am I going wrong?

1 answer

0


After a lot of research and help from the paroj of Ogre3d, got!

What I did to fix it was this, I used the %apply and stayed like this:

%apply unsigned short& OUTPUT { unsigned short& outSourceCoordSet, unsigned short& outIndex };

If someone is experiencing the same problem with the method suggestTangentVectorBuildParams, just download the latest version of ogre repository, because it’s been fixed with the pull request I made.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.