Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
0af81bb5
Commit
0af81bb5
authored
Feb 10, 2016
by
Davis King
Browse files
Fixed bug in 10 argument version of call_matlab() and also cleaned up a few
minor things.
parent
2dbb860b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
2 deletions
+16
-2
dlib/matlab/call_matlab.h
dlib/matlab/call_matlab.h
+4
-0
dlib/matlab/mex_wrapper.cpp
dlib/matlab/mex_wrapper.cpp
+10
-2
dlib/matrix/matrix_data_layout.h
dlib/matrix/matrix_data_layout.h
+2
-0
No files found.
dlib/matlab/call_matlab.h
View file @
0af81bb5
...
@@ -30,6 +30,9 @@ class matlab_struct
...
@@ -30,6 +30,9 @@ class matlab_struct
To get the values as C++ types you do something like this:
To get the values as C++ types you do something like this:
int val = mystruct["field"];
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.
See also example_mex_struct.cpp for an example that uses this part of the API.
!*/
!*/
...
@@ -53,6 +56,7 @@ private:
...
@@ -53,6 +56,7 @@ private:
sub
()
:
struct_handle
(
0
),
field_idx
(
-
1
)
{}
sub
()
:
struct_handle
(
0
),
field_idx
(
-
1
)
{}
template
<
typename
T
>
operator
T
()
const
;
template
<
typename
T
>
operator
T
()
const
;
template
<
typename
T
>
void
get
(
T
&
item
)
const
;
template
<
typename
T
>
sub
&
operator
=
(
const
T
&
new_val
);
template
<
typename
T
>
sub
&
operator
=
(
const
T
&
new_val
);
const
sub
operator
[]
(
const
std
::
string
&
name
)
const
;
const
sub
operator
[]
(
const
std
::
string
&
name
)
const
;
sub
operator
[]
(
const
std
::
string
&
name
);
sub
operator
[]
(
const
std
::
string
&
name
);
...
...
dlib/matlab/mex_wrapper.cpp
View file @
0af81bb5
...
@@ -2292,6 +2292,7 @@ void call_matlab (
...
@@ -2292,6 +2292,7 @@ void call_matlab (
setup_input_args
(
prhs
[
nrhs
],
A6
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A6
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A7
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A7
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A8
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A8
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A9
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A10
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A10
,
nrhs
);
const
int
nlhs
=
num_args
-
nrhs
;
const
int
nlhs
=
num_args
-
nrhs
;
...
@@ -2306,6 +2307,7 @@ void call_matlab (
...
@@ -2306,6 +2307,7 @@ void call_matlab (
setup_output_args
(
function_name
,
plhs
[
i
],
A6
,
i
);
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
],
A7
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A8
,
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
);
setup_output_args
(
function_name
,
plhs
[
i
],
A10
,
i
);
free_callback_resources
<
T1
>
(
nlhs
,
plhs
,
nrhs
,
prhs
);
free_callback_resources
<
T1
>
(
nlhs
,
plhs
,
nrhs
,
prhs
);
...
@@ -2316,6 +2318,14 @@ void call_matlab (
...
@@ -2316,6 +2318,14 @@ void call_matlab (
template
<
typename
T
>
template
<
typename
T
>
matlab_struct
::
sub
::
operator
T
()
const
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
)
if
(
struct_handle
==
0
)
throw
dlib
::
error
(
"Attempt to access data in an empty struct."
);
throw
dlib
::
error
(
"Attempt to access data in an empty struct."
);
...
@@ -2324,7 +2334,6 @@ matlab_struct::sub::operator T() const
...
@@ -2324,7 +2334,6 @@ matlab_struct::sub::operator T() const
if
(
temp
==
0
)
if
(
temp
==
0
)
throw
dlib
::
error
(
"Attempt to access data in an empty struct."
);
throw
dlib
::
error
(
"Attempt to access data in an empty struct."
);
T
item
;
try
try
{
{
mex_binding
::
validate_and_populate_arg
(
0
,
temp
,
item
);
mex_binding
::
validate_and_populate_arg
(
0
,
temp
,
item
);
...
@@ -2336,7 +2345,6 @@ matlab_struct::sub::operator T() const
...
@@ -2336,7 +2345,6 @@ matlab_struct::sub::operator T() const
<<
endl
<<
e
.
msg
;
<<
endl
<<
e
.
msg
;
throw
dlib
::
error
(
sout
.
str
());
throw
dlib
::
error
(
sout
.
str
());
}
}
return
item
;
}
}
const
matlab_struct
::
sub
matlab_struct
::
const
matlab_struct
::
sub
matlab_struct
::
...
...
dlib/matrix/matrix_data_layout.h
View file @
0af81bb5
...
@@ -1027,6 +1027,7 @@ namespace dlib
...
@@ -1027,6 +1027,7 @@ namespace dlib
void
_private_mark_non_persistent
()
void
_private_mark_non_persistent
()
{
{
DLIB_CASSERT
(
mem
==
0
,
"You can't convert a persistent matlab array to non-persistent."
);
make_persistent
=
false
;
make_persistent
=
false
;
}
}
...
@@ -1148,6 +1149,7 @@ namespace dlib
...
@@ -1148,6 +1149,7 @@ namespace dlib
void
_private_mark_non_persistent
()
void
_private_mark_non_persistent
()
{
{
DLIB_CASSERT
(
mem
==
0
,
"You can't convert a persistent matlab array to non-persistent."
);
make_persistent
=
false
;
make_persistent
=
false
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment