My problem was, that the importet class contains properties of the unsupported type void* (property named "d" in the example).
I can not edit the source library file as it is owned by a third party.
%in shared library
...
struct data
{
void* d;
};
When i pass this object to c++ code using the c++ mex interface i retrieve an input argument of type HANDLE_OBJ_REF.
%in example.cpp C++-mex source file
...
class MexFunction : public matlab::mex::Function
{
public:
void operator()(ArgumentList outputArgs, ArgumentList inputArgs)
{
std::shared_ptr<matlab::engine::MATLABEngine> engine = getEngine();
...
if (inputArgs[0].getType() != ArrayType::HANDLE_OBJECT_REF)
{
sprintf(errorStr, "wrong type (%d)", (int)(inputArgs[1].getType()));
matlabPtr->feval(u"error", 0, std::vector<Array>({ factory.createScalar(errorStr) }));
}
matlab::data::Array obj = std::move(inputArgs[0]);
matlab::data::Array dataPropertyArray = engine.getProperty(obj, std::string("d"));
void* dataProperty = TypedArray<void*>(std::move(deviceArray))[0];
}
}
obviously this does not work since matlab did not support the property of type void* when converting "data". obj does not have a property named "d".
Also there is no typedArray of unsupported types.
However in my case i could pass the pointer "d" of the element "data" to MATLAB as an unsigned 64 bit integer and work my way around that way.
Maybe one could also work with a pointer to "data" itself in a similar way to make MATLAB able to communicate unsupported types.