Fixed wrap support for unsigned char

release/4.3a0
Alex Cunningham 2012-05-31 15:06:21 +00:00
parent 3c694e25f7
commit 8bcd2da2f0
2 changed files with 17 additions and 2 deletions

View File

@ -19,7 +19,7 @@
* Arguments to functions any of
* - Eigen types: Matrix, Vector
* - Eigen types and classes as an optionally const reference
* - C/C++ basic types: string, bool, size_t, int, double
* - C/C++ basic types: string, bool, size_t, int, double, char
* - Any class with which be copied with boost::make_shared() (except Eigen)
* - boost::shared_ptr of any object type (except Eigen)
* Comments can use either C++ or C style, with multiple lines

View File

@ -106,6 +106,14 @@ mxArray* wrap<char>(char& value) {
return result;
}
// specialization to unsigned char
template<>
mxArray* wrap<unsigned char>(unsigned char& value) {
mxArray *result = scalar(mxUINT32OR64_CLASS);
*(unsigned char*)mxGetData(result) = value;
return result;
}
// specialization to bool
template<>
mxArray* wrap<bool>(bool& value) {
@ -227,13 +235,20 @@ bool unwrap<bool>(const mxArray* array) {
return myGetScalar<bool>(array);
}
// specialization to bool
// specialization to char
template<>
char unwrap<char>(const mxArray* array) {
checkScalar(array,"unwrap<char>");
return myGetScalar<char>(array);
}
// specialization to unsigned char
template<>
unsigned char unwrap<unsigned char>(const mxArray* array) {
checkScalar(array,"unwrap<unsigned char>");
return myGetScalar<unsigned char>(array);
}
// specialization to int
template<>
int unwrap<int>(const mxArray* array) {