I am attempting to wrap (where results is a structure of ints/typedef-ed ints):
ERROR_T get_result( const instance_t instance, result_t *results );
As the functional equivalent in java (which would raise an exception, rather than return error) :
result_t get_result(instance_t instance);
I have attempted to implement a solution a typemap fashion as described by: JNI wrapper for C function using SWIG - what should be the typemap?. However I hit a snag on this line:
// After the call copy the result back
%typemap(argout) cl_instance_t * %{
*($1_ltype)&$result = *$1;
%}
When doing this the function calls match, at least in the Java code running over the top, however this fails to work because the accessors that SWIG generates have signatures that do no match their function calls (additional cPtr
and this
).
I have attempted to follow the instructions in this answer: "Create a typemap for a function that returns through arguments", and the followup: "Resolving struct properties for SWIG interface file". However the swig preprocessor statements, e.g. %inline %{...%}
, appear to fail to be interpreted. Is there a dependency on SWIG version here? Currently on 2.04.
I have had a poke around in open source swig projects (e.g. LiquidFun- these appear to provide a much simpler interface, with fewer calls needed through the API- is there a suggested way to make sure you provide a clean API?