Concatenating an external pointer into a SWIG data structure
I am using Lua with two C libraries, one using SWIG and one using manually.
The library, which is manually wrapped, is the interface to Freetype; it creates pointers FT_Face
in C which it returns as lightuserdata.
Now I need to pass this FT_Face
as a parameter to one of the functions that are wrapped by SWIG. However, SWIG certainly does not accept normal user data as parameters, but expects every C pointer to be created by SWIG - even though I have a pointer FT_Face
, SWIG wants to see SWIGTYPE_p_FT_Face
which one is under swig_lua_userdata
.
Is there a way to include Lua userdata in swig_lua_userdata
? How do I get SWIG to "recognize" my user data FT_Face
as a valid parameter to a function?
The answer looks like "typemaps":
%typemap(in) FT_Face {
$1 = (FT_Face)lua_touserdata(L,$input);
}
%typemap(typecheck) FT_Face = void*;