Added wrap support for char as a argument or return value type
parent
6c75407f98
commit
a8607d284d
2
gtsam.h
2
gtsam.h
|
@ -9,7 +9,7 @@
|
|||
* Only one Method/Constructor per line
|
||||
* Methods can return
|
||||
* - Eigen types: Matrix, Vector
|
||||
* - C/C++ basic types: string, bool, size_t, int, double
|
||||
* - C/C++ basic types: string, bool, size_t, int, double, char
|
||||
* - void
|
||||
* - Any class with which be copied with boost::make_shared()
|
||||
* - boost::shared_ptr of any object type
|
||||
|
|
|
@ -73,7 +73,7 @@ Module::Module(const string& interfacePath,
|
|||
// http://www.boost.org/doc/libs/1_37_0/libs/spirit/classic/doc/directives.html
|
||||
|
||||
Rule basisType_p =
|
||||
(str_p("string") | "bool" | "size_t" | "int" | "double");
|
||||
(str_p("string") | "bool" | "size_t" | "int" | "double" | "char");
|
||||
|
||||
Rule keywords_p =
|
||||
(str_p("const") | "static" | "namespace" | basisType_p);
|
||||
|
@ -304,6 +304,7 @@ void Module::matlab_code(const string& toolboxPath,
|
|||
validTypes.push_back("string");
|
||||
validTypes.push_back("int");
|
||||
validTypes.push_back("bool");
|
||||
validTypes.push_back("char");
|
||||
validTypes.push_back("size_t");
|
||||
validTypes.push_back("double");
|
||||
validTypes.push_back("Vector");
|
||||
|
|
|
@ -97,6 +97,14 @@ mxArray* wrap<string>(string& value) {
|
|||
return mxCreateString(value.c_str());
|
||||
}
|
||||
|
||||
// specialization to char
|
||||
template<>
|
||||
mxArray* wrap<char>(char& value) {
|
||||
mxArray *result = scalar(mxUINT32OR64_CLASS);
|
||||
*(char*)mxGetData(result) = value;
|
||||
return result;
|
||||
}
|
||||
|
||||
// specialization to bool
|
||||
template<>
|
||||
mxArray* wrap<bool>(bool& value) {
|
||||
|
@ -204,6 +212,13 @@ bool unwrap<bool>(const mxArray* array) {
|
|||
return mxGetScalar(array) != 0.0;
|
||||
}
|
||||
|
||||
// specialization to bool
|
||||
template<>
|
||||
char unwrap<char>(const mxArray* array) {
|
||||
checkScalar(array,"unwrap<char>");
|
||||
return (char)mxGetScalar(array);
|
||||
}
|
||||
|
||||
// specialization to size_t
|
||||
template<>
|
||||
size_t unwrap<size_t>(const mxArray* array) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# automatically generated by wrap on 2012-Jan-15
|
||||
# automatically generated by wrap on 2012-Jan-23
|
||||
|
||||
MEX = mex
|
||||
MEXENDING = mexa64
|
||||
|
@ -17,10 +17,14 @@ new_Point2_dd.$(MEXENDING): new_Point2_dd.cpp
|
|||
$(MEX) $(mex_flags) @Point2/y.cpp -output @Point2/y
|
||||
@Point2/dim.$(MEXENDING): @Point2/dim.cpp
|
||||
$(MEX) $(mex_flags) @Point2/dim.cpp -output @Point2/dim
|
||||
@Point2/returnChar.$(MEXENDING): @Point2/returnChar.cpp
|
||||
$(MEX) $(mex_flags) @Point2/returnChar.cpp -output @Point2/returnChar
|
||||
@Point2/argChar.$(MEXENDING): @Point2/argChar.cpp
|
||||
$(MEX) $(mex_flags) @Point2/argChar.cpp -output @Point2/argChar
|
||||
@Point2/vectorConfusion.$(MEXENDING): @Point2/vectorConfusion.cpp
|
||||
$(MEX) $(mex_flags) @Point2/vectorConfusion.cpp -output @Point2/vectorConfusion
|
||||
|
||||
Point2: new_Point2_.$(MEXENDING) new_Point2_dd.$(MEXENDING) @Point2/x.$(MEXENDING) @Point2/y.$(MEXENDING) @Point2/dim.$(MEXENDING) @Point2/vectorConfusion.$(MEXENDING)
|
||||
Point2: new_Point2_.$(MEXENDING) new_Point2_dd.$(MEXENDING) @Point2/x.$(MEXENDING) @Point2/y.$(MEXENDING) @Point2/dim.$(MEXENDING) @Point2/returnChar.$(MEXENDING) @Point2/argChar.$(MEXENDING) @Point2/vectorConfusion.$(MEXENDING)
|
||||
|
||||
# Point3
|
||||
new_Point3_ddd.$(MEXENDING): new_Point3_ddd.cpp
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
% automatically generated by wrap on 2012-Jan-15
|
||||
% automatically generated by wrap on 2012-Jan-23
|
||||
echo on
|
||||
|
||||
toolboxpath = mfilename('fullpath');
|
||||
|
@ -16,6 +16,8 @@ cd @Point2
|
|||
mex -O5 x.cpp
|
||||
mex -O5 y.cpp
|
||||
mex -O5 dim.cpp
|
||||
mex -O5 returnChar.cpp
|
||||
mex -O5 argChar.cpp
|
||||
mex -O5 vectorConfusion.cpp
|
||||
|
||||
%% Point3
|
||||
|
|
|
@ -12,6 +12,8 @@ class Point2 {
|
|||
double x() const;
|
||||
double y() const;
|
||||
int dim() const;
|
||||
char returnChar() const;
|
||||
void argChar(char a) const;
|
||||
VectorNotEigen vectorConfusion();
|
||||
};
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ TEST( wrap, parse ) {
|
|||
Class cls = module.classes.at(0);
|
||||
EXPECT(assert_equal("Point2", cls.name));
|
||||
EXPECT_LONGS_EQUAL(2, cls.constructors.size());
|
||||
EXPECT_LONGS_EQUAL(4, cls.methods.size());
|
||||
EXPECT_LONGS_EQUAL(6, cls.methods.size());
|
||||
EXPECT_LONGS_EQUAL(0, cls.static_methods.size());
|
||||
EXPECT_LONGS_EQUAL(0, cls.namespaces.size());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue