Commit 0af81bb5 authored by Davis King's avatar Davis King

Fixed bug in 10 argument version of call_matlab() and also cleaned up a few

minor things.
parent 2dbb860b
......@@ -30,6 +30,9 @@ class matlab_struct
To get the values as C++ types you do something like this:
int val = mystruct["field"];
or
int val;
mystruct["field"].get(val);
See also example_mex_struct.cpp for an example that uses this part of the API.
!*/
......@@ -53,6 +56,7 @@ private:
sub() : struct_handle(0), field_idx(-1) {}
template <typename T> operator T() const;
template <typename T> void get(T& item) const;
template <typename T> sub& operator= (const T& new_val);
const sub operator[] (const std::string& name) const;
sub operator[] (const std::string& name);
......
......@@ -2292,6 +2292,7 @@ void call_matlab (
setup_input_args(prhs[nrhs], A6, nrhs);
setup_input_args(prhs[nrhs], A7, nrhs);
setup_input_args(prhs[nrhs], A8, nrhs);
setup_input_args(prhs[nrhs], A9, nrhs);
setup_input_args(prhs[nrhs], A10, nrhs);
const int nlhs = num_args - nrhs;
......@@ -2306,6 +2307,7 @@ void call_matlab (
setup_output_args(function_name, plhs[i], A6, i);
setup_output_args(function_name, plhs[i], A7, i);
setup_output_args(function_name, plhs[i], A8, i);
setup_output_args(function_name, plhs[i], A9, i);
setup_output_args(function_name, plhs[i], A10, i);
free_callback_resources<T1>(nlhs,plhs,nrhs,prhs);
......@@ -2316,6 +2318,14 @@ void call_matlab (
template <typename T>
matlab_struct::sub::operator T() const
{
T item;
get(item);
return item;
}
template <typename T>
void matlab_struct::sub::get(T& item) const
{
if (struct_handle == 0)
throw dlib::error("Attempt to access data in an empty struct.");
......@@ -2324,7 +2334,6 @@ matlab_struct::sub::operator T() const
if (temp == 0)
throw dlib::error("Attempt to access data in an empty struct.");
T item;
try
{
mex_binding::validate_and_populate_arg(0,temp,item);
......@@ -2336,7 +2345,6 @@ matlab_struct::sub::operator T() const
<< endl << e.msg;
throw dlib::error(sout.str());
}
return item;
}
const matlab_struct::sub matlab_struct::
......
......@@ -1027,6 +1027,7 @@ namespace dlib
void _private_mark_non_persistent()
{
DLIB_CASSERT(mem == 0,"You can't convert a persistent matlab array to non-persistent.");
make_persistent = false;
}
......@@ -1148,6 +1149,7 @@ namespace dlib
void _private_mark_non_persistent()
{
DLIB_CASSERT(mem == 0,"You can't convert a persistent matlab array to non-persistent.");
make_persistent = false;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment