Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compile/customWrapper/classHandle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ template<class base> inline std::string convertPtr2String(base *ptr)
return std::to_string(handle);
}

template<class base> inline ClassHandle<base> *convertString2HandlePtr(const char* in)
template<class base> inline ClassHandle<base> *convertString2HandlePtr(const char* in, int size)
{
uint64_t value = stoull(std::string(in));
uint64_t value = stoull(std::string(in).substr(0, size));
ClassHandle<base> *ptr = reinterpret_cast<ClassHandle<base> *>(value);
if (!ptr->isValid())
throw std::invalid_argument("callback handle is not valid");
Expand Down
7 changes: 4 additions & 3 deletions compile/customWrapper/wrapperMex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ template<class base> inline mxArray *convertPtr2Mat(base *ptr)
return mxCreateString(convertPtr2String<base>(ptr).c_str());
}

template<class base> inline void destroyObject(const char* in)
template<class base> inline void destroyObject(const char* in, size_t size)
{
delete convertString2HandlePtr<base>(in);
delete convertString2HandlePtr<base>(in, size);
mexUnlock();
}

Expand Down Expand Up @@ -51,7 +51,8 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
if (!strcmp("delete", cmd)) {
if (nrhs != 2)
mexErrMsgTxt("Second input for delete command should be a class instance handle.");
destroyObject<CallbackInterface>(getStringFromMxArray(prhs[1], "class instance handle should a row vector char array"));
size_t size = mxGetNumberOfElements(prhs[1]);
destroyObject<CallbackInterface>(getStringFromMxArray(prhs[1], "class instance handle should be a row vector char array"), size);
if (nlhs != 0 || nrhs != 2)
mexWarnMsgTxt("Delete: Unexpected arguments ignored.");
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
coder.cinclude('classHandle.hpp')

callbackHandle = coder.opaque('ClassHandle<CallbackInterface> *','NULL');
callbackHandle = coder.ceval('convertString2HandlePtr<CallbackInterface>', pointer);
callbackHandle = coder.ceval('convertString2HandlePtr<CallbackInterface>', pointer, numel(pointer));

callback = coder.opaque('CallbackInterface *','NULL');
callback = coder.ceval('std::mem_fn(&ClassHandle<CallbackInterface>::ptr)', callbackHandle);
Expand Down