Changes to wrap requested by frank. Wrap now allows for multiple includes. Changes to wrap tests

release/4.3a0
Andrew Melim 2012-07-02 18:18:11 +00:00
parent 1d1fcecccf
commit ead88ae35a
71 changed files with 142 additions and 663 deletions

View File

@ -54,14 +54,14 @@ void Argument::matlab_unwrap(FileWriter& file, const string& matlabName) const {
file.oss << "boost::shared_ptr<" << cppType << "> " << name << " = unwrap_shared_ptr< ";
else if (is_ref)
// A reference: emit an "unwrap_shared_ptr" call and de-reference the pointer
file.oss << " " << cppType << "& " << name << " = *unwrap_shared_ptr< ";
file.oss << cppType << "& " << name << " = *unwrap_shared_ptr< ";
else
// Not a pointer or a reference: emit an "unwrap" call
// unwrap is specified in matlab.h as a series of template specializations
// that know how to unpack the expected MATLAB object
// example: double tol = unwrap< double >(in[2]);
// example: Vector v = unwrap< Vector >(in[1]);
file.oss << " " << cppType << " " << name << " = unwrap< ";
file.oss << cppType << " " << name << " = unwrap< ";
file.oss << cppType << " >(" << matlabName;
if (is_ptr || is_ref) file.oss << ", \"" << matlabType << "\"";

View File

@ -30,7 +30,7 @@ using namespace wrap;
/* ************************************************************************* */
string Constructor::matlab_wrapper_name(const string& className) const {
string str = "new_" + className + "_";
string str = "new_" + className;
return str;
}
@ -102,19 +102,23 @@ void Constructor::matlab_wrapper(const string& toolboxPath,
file.oss << "static std::set<Shared*> collector;" << endl;
file.oss << endl;
//TODO: Remove
//Generate the destructor function
file.oss << "struct Destruct" << endl;
/*file.oss << "struct Destruct" << endl;
file.oss << "{" << endl;
file.oss << " void operator() (Shared* p)" << endl;
file.oss << " {" << endl;
file.oss << " collector.erase(p);" << endl;
file.oss << " }" << endl;
file.oss << "};" << endl;
file.oss << endl;
file.oss << endl;*/
//Generate cleanup function
file.oss << "void cleanup(void) {" << endl;
file.oss << " std::for_each( collector.begin(), collector.end(), Destruct() );" << endl;
//TODO: Remove
//file.oss << " std::for_each( collector.begin(), collector.end(), Destruct() );" << endl;
file.oss << " BOOST_FOREACH(Shared* p, collector)" << endl;
file.oss << " collector.erase(p);" << endl;
file.oss << "}" << endl;
file.oss << "void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])" << endl;
@ -134,15 +138,24 @@ void Constructor::matlab_wrapper(const string& toolboxPath,
file.oss << " else if(collector.erase(self))" << endl;
file.oss << " delete self;" << endl;
file.oss << " } else {" << endl;
file.oss << " int nc = unwrap<int>(in[1]);" << endl;
file.oss << " int nc = unwrap<int>(in[1]);" << endl << endl;
int i = 0;
BOOST_FOREACH(ArgumentList al, args_list)
{
file.oss << " if(nc == " << i <<") {" << endl;
al.matlab_unwrap(file, 2); // unwrap arguments, start at 1
file.oss << " self = new Shared(new " << cppClassName << "(" << al.names() << "));" << endl;
file.oss << " }" << endl;
//Check to see if there will be any arguments and remove {} for consiseness
if(al.size())
{
file.oss << " if(nc == " << i <<") {" << endl;
al.matlab_unwrap(file, 2); // unwrap arguments, start at 1
file.oss << " self = new Shared(new " << cppClassName << "(" << al.names() << "));" << endl;
file.oss << " }" << endl;
}
else
{
file.oss << " if(nc == " << i <<")" << endl;
file.oss << " self = new Shared(new " << cppClassName << "(" << al.names() << "));" << endl;
}
i++;
}

View File

@ -85,9 +85,7 @@ void Method::matlab_wrapper(const string& classPath,
// get class pointer
// example: shared_ptr<Test> = unwrap_shared_ptr< Test >(in[0], "Test");
file.oss << " mxArray* mxh = mxGetProperty(in[0],0,\"self\");" << endl;
file.oss << " Shared* self = *reinterpret_cast<Shared**> (mxGetPr(mxh));" << endl;
file.oss << " Shared obj = *self;" << endl;
file.oss << " Shared obj = unwrap_shared_ptr<" << cppClassName << ">(in[0], \"" << cppClassName << "\");" << endl;
// unwrap arguments, see Argument.cpp
args.matlab_unwrap(file,1);

View File

@ -182,7 +182,7 @@ Module::Module(const string& interfacePath,
Rule include_p = str_p("#include") >> ch_p('<') >> (*(anychar_p - '>'))[assign_a(include_path)] >> ch_p('>');
Rule class_p =
(!include_p
(!*include_p
>> str_p("class")[push_back_a(cls.includes, include_path)][assign_a(include_path, null_str)]
>> className_p[assign_a(cls.name)]
>> '{'
@ -201,7 +201,7 @@ Module::Module(const string& interfacePath,
[assign_a(cls,cls0)];
Rule namespace_def_p =
(!include_p
(!*include_p
>> str_p("namespace")[push_back_a(namespace_includes, include_path)][assign_a(include_path, null_str)]
>> namespace_name_p[push_back_a(namespaces)]
>> ch_p('{')

View File

@ -21,15 +21,9 @@
#include <gtsam/base/Vector.h>
#include <gtsam/base/Matrix.h>
#include <gtsam/linear/NoiseModel.h>
using gtsam::Vector;
using gtsam::Matrix;
using gtsam::noiseModel::Base;
using gtsam::noiseModel::Gaussian;
using gtsam::noiseModel::Diagonal;
using gtsam::noiseModel::Isotropic;
using gtsam::noiseModel::Unit;
extern "C" {
#include <mex.h>
@ -37,6 +31,7 @@ extern "C" {
#include <boost/shared_ptr.hpp>
#include <boost/make_shared.hpp>
#include <boost/foreach.hpp>
#include <list>
#include <string>
@ -321,7 +316,6 @@ gtsam::Matrix unwrap< gtsam::Matrix >(const mxArray* array) {
dummy arguments to let the constructor know we want an object without
the self property initialized. We then assign the mexhandle to self.
*/
// TODO: think about memory
mxArray* create_object(const char *classname, mxArray* h) {
mxArray *result;
mxArray* dummy[13] = {h,h,h,h,h, h,h,h,h,h, h,h,h};

View File

@ -5,8 +5,8 @@ classdef Point2 < handle
end
methods
function obj = Point2(varargin)
if (nargin == 0), obj.self = new_Point2_(0,0); end
if (nargin == 2 && isa(varargin{1},'double') && isa(varargin{2},'double')), obj.self = new_Point2_(0,1,varargin{1},varargin{2}); end
if (nargin == 0), obj.self = new_Point2(0,0); end
if (nargin == 2 && isa(varargin{1},'double') && isa(varargin{2},'double')), obj.self = new_Point2(0,1,varargin{1},varargin{2}); end
if nargin ==14, new_Point2_(varargin{1},0); end
if nargin ~= 13 && nargin ~= 14 && obj.self == 0, error('Point2 constructor failed'); end
end

View File

@ -1,14 +1,11 @@
// automatically generated by wrap
#include <wrap/matlab.h>
#include <set>
#include <Point2.h>
typedef boost::shared_ptr<Point2> Shared;
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("argChar",nargout,nargin-1,1);
mxArray* mxh = mxGetProperty(in[0],0,"self");
Shared* self = *reinterpret_cast<Shared**> (mxGetPr(mxh));
Shared obj = *self;
char a = unwrap< char >(in[1]);
Shared obj = unwrap_shared_ptr<Point2>(in[0], "Point2");
char a = unwrap< char >(in[1]);
obj->argChar(a);
}

View File

@ -1,14 +1,11 @@
// automatically generated by wrap
#include <wrap/matlab.h>
#include <set>
#include <Point2.h>
typedef boost::shared_ptr<Point2> Shared;
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("argUChar",nargout,nargin-1,1);
mxArray* mxh = mxGetProperty(in[0],0,"self");
Shared* self = *reinterpret_cast<Shared**> (mxGetPr(mxh));
Shared obj = *self;
unsigned char a = unwrap< unsigned char >(in[1]);
Shared obj = unwrap_shared_ptr<Point2>(in[0], "Point2");
unsigned char a = unwrap< unsigned char >(in[1]);
obj->argUChar(a);
}

View File

@ -1,14 +1,11 @@
// automatically generated by wrap
#include <wrap/matlab.h>
#include <set>
#include <Point2.h>
typedef boost::shared_ptr<Point2> Shared;
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("dim",nargout,nargin-1,0);
mxArray* mxh = mxGetProperty(in[0],0,"self");
Shared* self = *reinterpret_cast<Shared**> (mxGetPr(mxh));
Shared obj = *self;
Shared obj = unwrap_shared_ptr<Point2>(in[0], "Point2");
int result = obj->dim();
out[0] = wrap< int >(result);
}

View File

@ -1,14 +1,11 @@
// automatically generated by wrap
#include <wrap/matlab.h>
#include <set>
#include <Point2.h>
typedef boost::shared_ptr<Point2> Shared;
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("returnChar",nargout,nargin-1,0);
mxArray* mxh = mxGetProperty(in[0],0,"self");
Shared* self = *reinterpret_cast<Shared**> (mxGetPr(mxh));
Shared obj = *self;
Shared obj = unwrap_shared_ptr<Point2>(in[0], "Point2");
char result = obj->returnChar();
out[0] = wrap< char >(result);
}

View File

@ -1,15 +1,12 @@
// automatically generated by wrap
#include <wrap/matlab.h>
#include <set>
#include <Point2.h>
typedef boost::shared_ptr<VectorNotEigen> SharedVectorNotEigen;
typedef boost::shared_ptr<Point2> Shared;
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("vectorConfusion",nargout,nargin-1,0);
mxArray* mxh = mxGetProperty(in[0],0,"self");
Shared* self = *reinterpret_cast<Shared**> (mxGetPr(mxh));
Shared obj = *self;
Shared obj = unwrap_shared_ptr<Point2>(in[0], "Point2");
VectorNotEigen result = obj->vectorConfusion();
SharedVectorNotEigen* ret = new SharedVectorNotEigen(new VectorNotEigen(result));
out[0] = wrap_collect_shared_ptr(ret,"VectorNotEigen");

View File

@ -1,14 +1,11 @@
// automatically generated by wrap
#include <wrap/matlab.h>
#include <set>
#include <Point2.h>
typedef boost::shared_ptr<Point2> Shared;
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("x",nargout,nargin-1,0);
mxArray* mxh = mxGetProperty(in[0],0,"self");
Shared* self = *reinterpret_cast<Shared**> (mxGetPr(mxh));
Shared obj = *self;
Shared obj = unwrap_shared_ptr<Point2>(in[0], "Point2");
double result = obj->x();
out[0] = wrap< double >(result);
}

View File

@ -1,14 +1,11 @@
// automatically generated by wrap
#include <wrap/matlab.h>
#include <set>
#include <Point2.h>
typedef boost::shared_ptr<Point2> Shared;
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("y",nargout,nargin-1,0);
mxArray* mxh = mxGetProperty(in[0],0,"self");
Shared* self = *reinterpret_cast<Shared**> (mxGetPr(mxh));
Shared obj = *self;
Shared obj = unwrap_shared_ptr<Point2>(in[0], "Point2");
double result = obj->y();
out[0] = wrap< double >(result);
}

View File

@ -5,7 +5,7 @@ classdef Point3 < handle
end
methods
function obj = Point3(varargin)
if (nargin == 3 && isa(varargin{1},'double') && isa(varargin{2},'double') && isa(varargin{3},'double')), obj.self = new_Point3_(0,0,varargin{1},varargin{2},varargin{3}); end
if (nargin == 3 && isa(varargin{1},'double') && isa(varargin{2},'double') && isa(varargin{3},'double')), obj.self = new_Point3(0,0,varargin{1},varargin{2},varargin{3}); end
if nargin ==14, new_Point3_(varargin{1},0); end
if nargin ~= 13 && nargin ~= 14 && obj.self == 0, error('Point3 constructor failed'); end
end

View File

@ -1,15 +1,12 @@
// automatically generated by wrap
#include <wrap/matlab.h>
#include <set>
#include <Point3.h>
using namespace geometry;
typedef boost::shared_ptr<Point3> Shared;
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("norm",nargout,nargin-1,0);
mxArray* mxh = mxGetProperty(in[0],0,"self");
Shared* self = *reinterpret_cast<Shared**> (mxGetPr(mxh));
Shared obj = *self;
Shared obj = unwrap_shared_ptr<Point3>(in[0], "Point3");
double result = obj->norm();
out[0] = wrap< double >(result);
}

View File

@ -5,8 +5,8 @@ classdef Test < handle
end
methods
function obj = Test(varargin)
if (nargin == 0), obj.self = new_Test_(0,0); end
if (nargin == 2 && isa(varargin{1},'double') && isa(varargin{2},'double')), obj.self = new_Test_(0,1,varargin{1},varargin{2}); end
if (nargin == 0), obj.self = new_Test(0,0); end
if (nargin == 2 && isa(varargin{1},'double') && isa(varargin{2},'double')), obj.self = new_Test(0,1,varargin{1},varargin{2}); end
if nargin ==14, new_Test_(varargin{1},0); end
if nargin ~= 13 && nargin ~= 14 && obj.self == 0, error('Test constructor failed'); end
end

View File

@ -1,15 +1,12 @@
// automatically generated by wrap
#include <wrap/matlab.h>
#include <set>
#include <folder/path/to/Test.h>
using namespace geometry;
typedef boost::shared_ptr<Test> Shared;
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("arg_EigenConstRef",nargout,nargin-1,1);
mxArray* mxh = mxGetProperty(in[0],0,"self");
Shared* self = *reinterpret_cast<Shared**> (mxGetPr(mxh));
Shared obj = *self;
Matrix& value = *unwrap_shared_ptr< Matrix >(in[1], "Matrix");
Shared obj = unwrap_shared_ptr<Test>(in[0], "Test");
Matrix& value = *unwrap_shared_ptr< Matrix >(in[1], "Matrix");
obj->arg_EigenConstRef(value);
}

View File

@ -1,6 +1,5 @@
// automatically generated by wrap
#include <wrap/matlab.h>
#include <set>
#include <folder/path/to/Test.h>
using namespace geometry;
typedef boost::shared_ptr<Test> SharedTest;
@ -9,9 +8,7 @@ typedef boost::shared_ptr<Test> Shared;
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("create_MixedPtrs",nargout,nargin-1,0);
mxArray* mxh = mxGetProperty(in[0],0,"self");
Shared* self = *reinterpret_cast<Shared**> (mxGetPr(mxh));
Shared obj = *self;
Shared obj = unwrap_shared_ptr<Test>(in[0], "Test");
pair< Test, SharedTest > result = obj->create_MixedPtrs();
SharedTest* ret = new SharedTest(new Test(result.first));
out[0] = wrap_collect_shared_ptr(ret,"Test");

View File

@ -1,6 +1,5 @@
// automatically generated by wrap
#include <wrap/matlab.h>
#include <set>
#include <folder/path/to/Test.h>
using namespace geometry;
typedef boost::shared_ptr<Test> SharedTest;
@ -9,9 +8,7 @@ typedef boost::shared_ptr<Test> Shared;
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("create_ptrs",nargout,nargin-1,0);
mxArray* mxh = mxGetProperty(in[0],0,"self");
Shared* self = *reinterpret_cast<Shared**> (mxGetPr(mxh));
Shared obj = *self;
Shared obj = unwrap_shared_ptr<Test>(in[0], "Test");
pair< SharedTest, SharedTest > result = obj->create_ptrs();
SharedTest* ret = new SharedTest(result.first);
out[0] = wrap_collect_shared_ptr(ret,"Test");

View File

@ -1,14 +1,11 @@
// automatically generated by wrap
#include <wrap/matlab.h>
#include <set>
#include <folder/path/to/Test.h>
using namespace geometry;
typedef boost::shared_ptr<Test> Shared;
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("print",nargout,nargin-1,0);
mxArray* mxh = mxGetProperty(in[0],0,"self");
Shared* self = *reinterpret_cast<Shared**> (mxGetPr(mxh));
Shared obj = *self;
Shared obj = unwrap_shared_ptr<Test>(in[0], "Test");
obj->print();
}

View File

@ -1,6 +1,5 @@
// automatically generated by wrap
#include <wrap/matlab.h>
#include <set>
#include <folder/path/to/Test.h>
using namespace geometry;
typedef boost::shared_ptr<Point2> SharedPoint2;
@ -8,10 +7,8 @@ typedef boost::shared_ptr<Test> Shared;
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("return_Point2Ptr",nargout,nargin-1,1);
mxArray* mxh = mxGetProperty(in[0],0,"self");
Shared* self = *reinterpret_cast<Shared**> (mxGetPr(mxh));
Shared obj = *self;
bool value = unwrap< bool >(in[1]);
Shared obj = unwrap_shared_ptr<Test>(in[0], "Test");
bool value = unwrap< bool >(in[1]);
SharedPoint2 result = obj->return_Point2Ptr(value);
SharedPoint2* ret = new SharedPoint2(result);
out[0] = wrap_collect_shared_ptr(ret,"Point2");

View File

@ -1,6 +1,5 @@
// automatically generated by wrap
#include <wrap/matlab.h>
#include <set>
#include <folder/path/to/Test.h>
using namespace geometry;
typedef boost::shared_ptr<Test> SharedTest;
@ -8,9 +7,7 @@ typedef boost::shared_ptr<Test> Shared;
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("return_Test",nargout,nargin-1,1);
mxArray* mxh = mxGetProperty(in[0],0,"self");
Shared* self = *reinterpret_cast<Shared**> (mxGetPr(mxh));
Shared obj = *self;
Shared obj = unwrap_shared_ptr<Test>(in[0], "Test");
boost::shared_ptr<Test> value = unwrap_shared_ptr< Test >(in[1], "Test");
Test result = obj->return_Test(value);
SharedTest* ret = new SharedTest(new Test(result));

View File

@ -1,6 +1,5 @@
// automatically generated by wrap
#include <wrap/matlab.h>
#include <set>
#include <folder/path/to/Test.h>
using namespace geometry;
typedef boost::shared_ptr<Test> SharedTest;
@ -8,9 +7,7 @@ typedef boost::shared_ptr<Test> Shared;
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("return_TestPtr",nargout,nargin-1,1);
mxArray* mxh = mxGetProperty(in[0],0,"self");
Shared* self = *reinterpret_cast<Shared**> (mxGetPr(mxh));
Shared obj = *self;
Shared obj = unwrap_shared_ptr<Test>(in[0], "Test");
boost::shared_ptr<Test> value = unwrap_shared_ptr< Test >(in[1], "Test");
SharedTest result = obj->return_TestPtr(value);
SharedTest* ret = new SharedTest(result);

View File

@ -1,16 +1,13 @@
// automatically generated by wrap
#include <wrap/matlab.h>
#include <set>
#include <folder/path/to/Test.h>
using namespace geometry;
typedef boost::shared_ptr<Test> Shared;
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("return_bool",nargout,nargin-1,1);
mxArray* mxh = mxGetProperty(in[0],0,"self");
Shared* self = *reinterpret_cast<Shared**> (mxGetPr(mxh));
Shared obj = *self;
bool value = unwrap< bool >(in[1]);
Shared obj = unwrap_shared_ptr<Test>(in[0], "Test");
bool value = unwrap< bool >(in[1]);
bool result = obj->return_bool(value);
out[0] = wrap< bool >(result);
}

View File

@ -1,16 +1,13 @@
// automatically generated by wrap
#include <wrap/matlab.h>
#include <set>
#include <folder/path/to/Test.h>
using namespace geometry;
typedef boost::shared_ptr<Test> Shared;
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("return_double",nargout,nargin-1,1);
mxArray* mxh = mxGetProperty(in[0],0,"self");
Shared* self = *reinterpret_cast<Shared**> (mxGetPr(mxh));
Shared obj = *self;
double value = unwrap< double >(in[1]);
Shared obj = unwrap_shared_ptr<Test>(in[0], "Test");
double value = unwrap< double >(in[1]);
double result = obj->return_double(value);
out[0] = wrap< double >(result);
}

View File

@ -1,16 +1,13 @@
// automatically generated by wrap
#include <wrap/matlab.h>
#include <set>
#include <folder/path/to/Test.h>
using namespace geometry;
typedef boost::shared_ptr<Test> Shared;
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("return_field",nargout,nargin-1,1);
mxArray* mxh = mxGetProperty(in[0],0,"self");
Shared* self = *reinterpret_cast<Shared**> (mxGetPr(mxh));
Shared obj = *self;
Test& t = *unwrap_shared_ptr< Test >(in[1], "Test");
Shared obj = unwrap_shared_ptr<Test>(in[0], "Test");
Test& t = *unwrap_shared_ptr< Test >(in[1], "Test");
bool result = obj->return_field(t);
out[0] = wrap< bool >(result);
}

View File

@ -1,16 +1,13 @@
// automatically generated by wrap
#include <wrap/matlab.h>
#include <set>
#include <folder/path/to/Test.h>
using namespace geometry;
typedef boost::shared_ptr<Test> Shared;
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("return_int",nargout,nargin-1,1);
mxArray* mxh = mxGetProperty(in[0],0,"self");
Shared* self = *reinterpret_cast<Shared**> (mxGetPr(mxh));
Shared obj = *self;
int value = unwrap< int >(in[1]);
Shared obj = unwrap_shared_ptr<Test>(in[0], "Test");
int value = unwrap< int >(in[1]);
int result = obj->return_int(value);
out[0] = wrap< int >(result);
}

View File

@ -1,16 +1,13 @@
// automatically generated by wrap
#include <wrap/matlab.h>
#include <set>
#include <folder/path/to/Test.h>
using namespace geometry;
typedef boost::shared_ptr<Test> Shared;
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("return_matrix1",nargout,nargin-1,1);
mxArray* mxh = mxGetProperty(in[0],0,"self");
Shared* self = *reinterpret_cast<Shared**> (mxGetPr(mxh));
Shared obj = *self;
Matrix value = unwrap< Matrix >(in[1]);
Shared obj = unwrap_shared_ptr<Test>(in[0], "Test");
Matrix value = unwrap< Matrix >(in[1]);
Matrix result = obj->return_matrix1(value);
out[0] = wrap< Matrix >(result);
}

View File

@ -1,16 +1,13 @@
// automatically generated by wrap
#include <wrap/matlab.h>
#include <set>
#include <folder/path/to/Test.h>
using namespace geometry;
typedef boost::shared_ptr<Test> Shared;
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("return_matrix2",nargout,nargin-1,1);
mxArray* mxh = mxGetProperty(in[0],0,"self");
Shared* self = *reinterpret_cast<Shared**> (mxGetPr(mxh));
Shared obj = *self;
Matrix value = unwrap< Matrix >(in[1]);
Shared obj = unwrap_shared_ptr<Test>(in[0], "Test");
Matrix value = unwrap< Matrix >(in[1]);
Matrix result = obj->return_matrix2(value);
out[0] = wrap< Matrix >(result);
}

View File

@ -1,17 +1,14 @@
// automatically generated by wrap
#include <wrap/matlab.h>
#include <set>
#include <folder/path/to/Test.h>
using namespace geometry;
typedef boost::shared_ptr<Test> Shared;
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("return_pair",nargout,nargin-1,2);
mxArray* mxh = mxGetProperty(in[0],0,"self");
Shared* self = *reinterpret_cast<Shared**> (mxGetPr(mxh));
Shared obj = *self;
Vector v = unwrap< Vector >(in[1]);
Matrix A = unwrap< Matrix >(in[2]);
Shared obj = unwrap_shared_ptr<Test>(in[0], "Test");
Vector v = unwrap< Vector >(in[1]);
Matrix A = unwrap< Matrix >(in[2]);
pair< Vector, Matrix > result = obj->return_pair(v,A);
out[0] = wrap< Vector >(result.first);
out[1] = wrap< Matrix >(result.second);

View File

@ -1,6 +1,5 @@
// automatically generated by wrap
#include <wrap/matlab.h>
#include <set>
#include <folder/path/to/Test.h>
using namespace geometry;
typedef boost::shared_ptr<Test> SharedTest;
@ -9,9 +8,7 @@ typedef boost::shared_ptr<Test> Shared;
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("return_ptrs",nargout,nargin-1,2);
mxArray* mxh = mxGetProperty(in[0],0,"self");
Shared* self = *reinterpret_cast<Shared**> (mxGetPr(mxh));
Shared obj = *self;
Shared obj = unwrap_shared_ptr<Test>(in[0], "Test");
boost::shared_ptr<Test> p1 = unwrap_shared_ptr< Test >(in[1], "Test");
boost::shared_ptr<Test> p2 = unwrap_shared_ptr< Test >(in[2], "Test");
pair< SharedTest, SharedTest > result = obj->return_ptrs(p1,p2);

View File

@ -1,16 +1,13 @@
// automatically generated by wrap
#include <wrap/matlab.h>
#include <set>
#include <folder/path/to/Test.h>
using namespace geometry;
typedef boost::shared_ptr<Test> Shared;
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("return_size_t",nargout,nargin-1,1);
mxArray* mxh = mxGetProperty(in[0],0,"self");
Shared* self = *reinterpret_cast<Shared**> (mxGetPr(mxh));
Shared obj = *self;
size_t value = unwrap< size_t >(in[1]);
Shared obj = unwrap_shared_ptr<Test>(in[0], "Test");
size_t value = unwrap< size_t >(in[1]);
size_t result = obj->return_size_t(value);
out[0] = wrap< size_t >(result);
}

View File

@ -1,16 +1,13 @@
// automatically generated by wrap
#include <wrap/matlab.h>
#include <set>
#include <folder/path/to/Test.h>
using namespace geometry;
typedef boost::shared_ptr<Test> Shared;
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("return_string",nargout,nargin-1,1);
mxArray* mxh = mxGetProperty(in[0],0,"self");
Shared* self = *reinterpret_cast<Shared**> (mxGetPr(mxh));
Shared obj = *self;
string value = unwrap< string >(in[1]);
Shared obj = unwrap_shared_ptr<Test>(in[0], "Test");
string value = unwrap< string >(in[1]);
string result = obj->return_string(value);
out[0] = wrap< string >(result);
}

View File

@ -1,16 +1,13 @@
// automatically generated by wrap
#include <wrap/matlab.h>
#include <set>
#include <folder/path/to/Test.h>
using namespace geometry;
typedef boost::shared_ptr<Test> Shared;
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("return_vector1",nargout,nargin-1,1);
mxArray* mxh = mxGetProperty(in[0],0,"self");
Shared* self = *reinterpret_cast<Shared**> (mxGetPr(mxh));
Shared obj = *self;
Vector value = unwrap< Vector >(in[1]);
Shared obj = unwrap_shared_ptr<Test>(in[0], "Test");
Vector value = unwrap< Vector >(in[1]);
Vector result = obj->return_vector1(value);
out[0] = wrap< Vector >(result);
}

View File

@ -1,16 +1,13 @@
// automatically generated by wrap
#include <wrap/matlab.h>
#include <set>
#include <folder/path/to/Test.h>
using namespace geometry;
typedef boost::shared_ptr<Test> Shared;
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("return_vector2",nargout,nargin-1,1);
mxArray* mxh = mxGetProperty(in[0],0,"self");
Shared* self = *reinterpret_cast<Shared**> (mxGetPr(mxh));
Shared obj = *self;
Vector value = unwrap< Vector >(in[1]);
Shared obj = unwrap_shared_ptr<Test>(in[0], "Test");
Vector value = unwrap< Vector >(in[1]);
Vector result = obj->return_vector2(value);
out[0] = wrap< Vector >(result);
}

View File

@ -8,8 +8,8 @@ mex_flags = -O5
all: Point2 Point3 Test
# Point2
new_Point2_.$(MEXENDING): new_Point2_.cpp $(PATH_TO_WRAP)/matlab.h
$(MEX) $(mex_flags) new_Point2_.cpp -output new_Point2_
new_Point2.$(MEXENDING): new_Point2.cpp $(PATH_TO_WRAP)/matlab.h
$(MEX) $(mex_flags) new_Point2.cpp -output new_Point2
@Point2/x.$(MEXENDING): @Point2/x.cpp $(PATH_TO_WRAP)/matlab.h
$(MEX) $(mex_flags) @Point2/x.cpp -output @Point2/x
@Point2/y.$(MEXENDING): @Point2/y.cpp $(PATH_TO_WRAP)/matlab.h
@ -25,11 +25,11 @@ new_Point2_.$(MEXENDING): new_Point2_.cpp $(PATH_TO_WRAP)/matlab.h
@Point2/vectorConfusion.$(MEXENDING): @Point2/vectorConfusion.cpp $(PATH_TO_WRAP)/matlab.h
$(MEX) $(mex_flags) @Point2/vectorConfusion.cpp -output @Point2/vectorConfusion
Point2: new_Point2_.$(MEXENDING) @Point2/x.$(MEXENDING) @Point2/y.$(MEXENDING) @Point2/dim.$(MEXENDING) @Point2/returnChar.$(MEXENDING) @Point2/argChar.$(MEXENDING) @Point2/argUChar.$(MEXENDING) @Point2/vectorConfusion.$(MEXENDING)
Point2: new_Point2.$(MEXENDING) @Point2/x.$(MEXENDING) @Point2/y.$(MEXENDING) @Point2/dim.$(MEXENDING) @Point2/returnChar.$(MEXENDING) @Point2/argChar.$(MEXENDING) @Point2/argUChar.$(MEXENDING) @Point2/vectorConfusion.$(MEXENDING)
# Point3
new_Point3_.$(MEXENDING): new_Point3_.cpp $(PATH_TO_WRAP)/matlab.h
$(MEX) $(mex_flags) new_Point3_.cpp -output new_Point3_
new_Point3.$(MEXENDING): new_Point3.cpp $(PATH_TO_WRAP)/matlab.h
$(MEX) $(mex_flags) new_Point3.cpp -output new_Point3
Point3_staticFunction.$(MEXENDING): Point3_staticFunction.cpp $(PATH_TO_WRAP)/matlab.h
$(MEX) $(mex_flags) Point3_staticFunction.cpp -output Point3_staticFunction
Point3_StaticFunctionRet.$(MEXENDING): Point3_StaticFunctionRet.cpp $(PATH_TO_WRAP)/matlab.h
@ -37,11 +37,11 @@ Point3_StaticFunctionRet.$(MEXENDING): Point3_StaticFunctionRet.cpp $(PATH_TO_WR
@Point3/norm.$(MEXENDING): @Point3/norm.cpp $(PATH_TO_WRAP)/matlab.h
$(MEX) $(mex_flags) @Point3/norm.cpp -output @Point3/norm
Point3: new_Point3_.$(MEXENDING) Point3_staticFunction.$(MEXENDING) Point3_StaticFunctionRet.$(MEXENDING) @Point3/norm.$(MEXENDING)
Point3: new_Point3.$(MEXENDING) Point3_staticFunction.$(MEXENDING) Point3_StaticFunctionRet.$(MEXENDING) @Point3/norm.$(MEXENDING)
# Test
new_Test_.$(MEXENDING): new_Test_.cpp $(PATH_TO_WRAP)/matlab.h
$(MEX) $(mex_flags) new_Test_.cpp -output new_Test_
new_Test.$(MEXENDING): new_Test.cpp $(PATH_TO_WRAP)/matlab.h
$(MEX) $(mex_flags) new_Test.cpp -output new_Test
@Test/return_pair.$(MEXENDING): @Test/return_pair.cpp $(PATH_TO_WRAP)/matlab.h
$(MEX) $(mex_flags) @Test/return_pair.cpp -output @Test/return_pair
@Test/return_bool.$(MEXENDING): @Test/return_bool.cpp $(PATH_TO_WRAP)/matlab.h
@ -81,7 +81,7 @@ new_Test_.$(MEXENDING): new_Test_.cpp $(PATH_TO_WRAP)/matlab.h
@Test/print.$(MEXENDING): @Test/print.cpp $(PATH_TO_WRAP)/matlab.h
$(MEX) $(mex_flags) @Test/print.cpp -output @Test/print
Test: new_Test_.$(MEXENDING) @Test/return_pair.$(MEXENDING) @Test/return_bool.$(MEXENDING) @Test/return_size_t.$(MEXENDING) @Test/return_int.$(MEXENDING) @Test/return_double.$(MEXENDING) @Test/return_string.$(MEXENDING) @Test/return_vector1.$(MEXENDING) @Test/return_matrix1.$(MEXENDING) @Test/return_vector2.$(MEXENDING) @Test/return_matrix2.$(MEXENDING) @Test/arg_EigenConstRef.$(MEXENDING) @Test/return_field.$(MEXENDING) @Test/return_TestPtr.$(MEXENDING) @Test/return_Test.$(MEXENDING) @Test/return_Point2Ptr.$(MEXENDING) @Test/create_ptrs.$(MEXENDING) @Test/create_MixedPtrs.$(MEXENDING) @Test/return_ptrs.$(MEXENDING) @Test/print.$(MEXENDING)
Test: new_Test.$(MEXENDING) @Test/return_pair.$(MEXENDING) @Test/return_bool.$(MEXENDING) @Test/return_size_t.$(MEXENDING) @Test/return_int.$(MEXENDING) @Test/return_double.$(MEXENDING) @Test/return_string.$(MEXENDING) @Test/return_vector1.$(MEXENDING) @Test/return_matrix1.$(MEXENDING) @Test/return_vector2.$(MEXENDING) @Test/return_matrix2.$(MEXENDING) @Test/arg_EigenConstRef.$(MEXENDING) @Test/return_field.$(MEXENDING) @Test/return_TestPtr.$(MEXENDING) @Test/return_Test.$(MEXENDING) @Test/return_Point2Ptr.$(MEXENDING) @Test/create_ptrs.$(MEXENDING) @Test/create_MixedPtrs.$(MEXENDING) @Test/return_ptrs.$(MEXENDING) @Test/print.$(MEXENDING)

View File

@ -1,6 +1,5 @@
// automatically generated by wrap
#include <wrap/matlab.h>
#include <set>
#include <Point3.h>
using namespace geometry;
typedef boost::shared_ptr<Point3> SharedPoint3;
@ -8,7 +7,7 @@ typedef boost::shared_ptr<Point3> Shared;
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("Point3_StaticFunctionRet",nargout,nargin,1);
double z = unwrap< double >(in[0]);
double z = unwrap< double >(in[0]);
Point3 result = Point3::StaticFunctionRet(z);
SharedPoint3* ret = new SharedPoint3(new Point3(result));
out[0] = wrap_collect_shared_ptr(ret,"Point3");

View File

@ -1,6 +1,5 @@
// automatically generated by wrap
#include <wrap/matlab.h>
#include <set>
#include <Point3.h>
using namespace geometry;
typedef boost::shared_ptr<double> Shareddouble;

View File

@ -9,7 +9,7 @@ addpath(toolboxpath);
%% Point2
cd(toolboxpath)
mex -O5 new_Point2_.cpp
mex -O5 new_Point2.cpp
cd @Point2
mex -O5 x.cpp
@ -22,7 +22,7 @@ mex -O5 vectorConfusion.cpp
%% Point3
cd(toolboxpath)
mex -O5 new_Point3_.cpp
mex -O5 new_Point3.cpp
mex -O5 Point3_staticFunction.cpp
mex -O5 Point3_StaticFunctionRet.cpp
@ -31,7 +31,7 @@ mex -O5 norm.cpp
%% Test
cd(toolboxpath)
mex -O5 new_Test_.cpp
mex -O5 new_Test.cpp
cd @Test
mex -O5 return_pair.cpp

View File

@ -1,47 +0,0 @@
// automatically generated by wrap
#include <wrap/matlab.h>
#include <set>
#include <Point2.h>
typedef boost::shared_ptr<Point2> Shared;
static std::set<Shared*> collector;
struct Destruct
{
void operator() (Shared* p)
{
collector.erase(p);
}
};
void cleanup(void) {
std::for_each( collector.begin(), collector.end(), Destruct() );
}
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
mexAtExit(cleanup);
const mxArray* input = in[0];
Shared* self = *(Shared**) mxGetData(input);
if(self) {
if(nargin > 1) {
collector.insert(self);
}
else if(collector.erase(self))
delete self;
} else {
int nc = unwrap<int>(in[1]);
if(nc == 0) {
self = new Shared(new Point2());
}
if(nc == 1) {
double x = unwrap< double >(in[2]);
double y = unwrap< double >(in[3]);
self = new Shared(new Point2(x,y));
}
collector.insert(self);
out[0] = mxCreateNumericMatrix(1, 1, mxUINT32OR64_CLASS, mxREAL);
*reinterpret_cast<Shared**> (mxGetPr(out[0])) = self;
}
}

View File

@ -1,4 +0,0 @@
% automatically generated by wrap
function result = new_Point2_(obj,x,y)
error('need to compile new_Point2_.cpp');
end

View File

@ -1,46 +0,0 @@
// automatically generated by wrap
#include <wrap/matlab.h>
#include <set>
#include <Point3.h>
using namespace geometry;
typedef boost::shared_ptr<Point3> Shared;
static std::set<Shared*> collector;
struct Destruct
{
void operator() (Shared* p)
{
collector.erase(p);
}
};
void cleanup(void) {
std::for_each( collector.begin(), collector.end(), Destruct() );
}
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
mexAtExit(cleanup);
const mxArray* input = in[0];
Shared* self = *(Shared**) mxGetData(input);
if(self) {
if(nargin > 1) {
collector.insert(self);
}
else if(collector.erase(self))
delete self;
} else {
int nc = unwrap<int>(in[1]);
if(nc == 0) {
double x = unwrap< double >(in[2]);
double y = unwrap< double >(in[3]);
double z = unwrap< double >(in[4]);
self = new Shared(new Point3(x,y,z));
}
collector.insert(self);
out[0] = mxCreateNumericMatrix(1, 1, mxUINT32OR64_CLASS, mxREAL);
*reinterpret_cast<Shared**> (mxGetPr(out[0])) = self;
}
}

View File

@ -1,4 +0,0 @@
% automatically generated by wrap
function result = new_Point3_(obj,x,y,z)
error('need to compile new_Point3_.cpp');
end

View File

@ -1,48 +0,0 @@
// automatically generated by wrap
#include <wrap/matlab.h>
#include <set>
#include <folder/path/to/Test.h>
using namespace geometry;
typedef boost::shared_ptr<Test> Shared;
static std::set<Shared*> collector;
struct Destruct
{
void operator() (Shared* p)
{
collector.erase(p);
}
};
void cleanup(void) {
std::for_each( collector.begin(), collector.end(), Destruct() );
}
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
mexAtExit(cleanup);
const mxArray* input = in[0];
Shared* self = *(Shared**) mxGetData(input);
if(self) {
if(nargin > 1) {
collector.insert(self);
}
else if(collector.erase(self))
delete self;
} else {
int nc = unwrap<int>(in[1]);
if(nc == 0) {
self = new Shared(new Test());
}
if(nc == 1) {
double a = unwrap< double >(in[2]);
Matrix b = unwrap< Matrix >(in[3]);
self = new Shared(new Test(a,b));
}
collector.insert(self);
out[0] = mxCreateNumericMatrix(1, 1, mxUINT32OR64_CLASS, mxREAL);
*reinterpret_cast<Shared**> (mxGetPr(out[0])) = self;
}
}

View File

@ -1,4 +0,0 @@
% automatically generated by wrap
function result = new_Test_(obj,a,b)
error('need to compile new_Test_.cpp');
end

View File

@ -5,7 +5,7 @@ classdef ClassD < handle
end
methods
function obj = ClassD(varargin)
if (nargin == 0), obj.self = new_ClassD_(0,0); end
if (nargin == 0), obj.self = new_ClassD(0,0); end
if nargin ==14, new_ClassD_(varargin{1},0); end
if nargin ~= 13 && nargin ~= 14 && obj.self == 0, error('ClassD constructor failed'); end
end

View File

@ -5,7 +5,7 @@ classdef ns1ClassA < handle
end
methods
function obj = ns1ClassA(varargin)
if (nargin == 0), obj.self = new_ns1ClassA_(0,0); end
if (nargin == 0), obj.self = new_ns1ClassA(0,0); end
if nargin ==14, new_ns1ClassA_(varargin{1},0); end
if nargin ~= 13 && nargin ~= 14 && obj.self == 0, error('ns1ClassA constructor failed'); end
end

View File

@ -5,7 +5,7 @@ classdef ns1ClassB < handle
end
methods
function obj = ns1ClassB(varargin)
if (nargin == 0), obj.self = new_ns1ClassB_(0,0); end
if (nargin == 0), obj.self = new_ns1ClassB(0,0); end
if nargin ==14, new_ns1ClassB_(varargin{1},0); end
if nargin ~= 13 && nargin ~= 14 && obj.self == 0, error('ns1ClassB constructor failed'); end
end

View File

@ -1,15 +1,12 @@
// automatically generated by wrap
#include <wrap/matlab.h>
#include <set>
#include <path/to/ns2.h>
#include <path/to/ns2/ClassA.h>
typedef boost::shared_ptr<ns2::ClassA> Shared;
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("memberFunction",nargout,nargin-1,0);
mxArray* mxh = mxGetProperty(in[0],0,"self");
Shared* self = *reinterpret_cast<Shared**> (mxGetPr(mxh));
Shared obj = *self;
Shared obj = unwrap_shared_ptr<ns2::ClassA>(in[0], "ns2::ClassA");
double result = obj->memberFunction();
out[0] = wrap< double >(result);
}

View File

@ -5,7 +5,7 @@ classdef ns2ClassA < handle
end
methods
function obj = ns2ClassA(varargin)
if (nargin == 0), obj.self = new_ns2ClassA_(0,0); end
if (nargin == 0), obj.self = new_ns2ClassA(0,0); end
if nargin ==14, new_ns2ClassA_(varargin{1},0); end
if nargin ~= 13 && nargin ~= 14 && obj.self == 0, error('ns2ClassA constructor failed'); end
end

View File

@ -1,16 +1,13 @@
// automatically generated by wrap
#include <wrap/matlab.h>
#include <set>
#include <path/to/ns2.h>
#include <path/to/ns2/ClassA.h>
typedef boost::shared_ptr<ns2::ClassA> Shared;
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("nsArg",nargout,nargin-1,1);
mxArray* mxh = mxGetProperty(in[0],0,"self");
Shared* self = *reinterpret_cast<Shared**> (mxGetPr(mxh));
Shared obj = *self;
ns1::ClassB& arg = *unwrap_shared_ptr< ns1::ClassB >(in[1], "ns1ClassB");
Shared obj = unwrap_shared_ptr<ns2::ClassA>(in[0], "ns2::ClassA");
ns1::ClassB& arg = *unwrap_shared_ptr< ns1::ClassB >(in[1], "ns1ClassB");
int result = obj->nsArg(arg);
out[0] = wrap< int >(result);
}

View File

@ -1,6 +1,5 @@
// automatically generated by wrap
#include <wrap/matlab.h>
#include <set>
#include <path/to/ns2.h>
#include <path/to/ns2/ClassA.h>
typedef boost::shared_ptr<ns2::ns3::ClassB> SharedClassB;
@ -8,10 +7,8 @@ typedef boost::shared_ptr<ns2::ClassA> Shared;
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("nsReturn",nargout,nargin-1,1);
mxArray* mxh = mxGetProperty(in[0],0,"self");
Shared* self = *reinterpret_cast<Shared**> (mxGetPr(mxh));
Shared obj = *self;
double q = unwrap< double >(in[1]);
Shared obj = unwrap_shared_ptr<ns2::ClassA>(in[0], "ns2::ClassA");
double q = unwrap< double >(in[1]);
ns2::ns3::ClassB result = obj->nsReturn(q);
SharedClassB* ret = new SharedClassB(new ns2::ns3::ClassB(result));
out[0] = wrap_collect_shared_ptr(ret,"ns2ns3ClassB");

View File

@ -5,7 +5,7 @@ classdef ns2ClassC < handle
end
methods
function obj = ns2ClassC(varargin)
if (nargin == 0), obj.self = new_ns2ClassC_(0,0); end
if (nargin == 0), obj.self = new_ns2ClassC(0,0); end
if nargin ==14, new_ns2ClassC_(varargin{1},0); end
if nargin ~= 13 && nargin ~= 14 && obj.self == 0, error('ns2ClassC constructor failed'); end
end

View File

@ -5,7 +5,7 @@ classdef ns2ns3ClassB < handle
end
methods
function obj = ns2ns3ClassB(varargin)
if (nargin == 0), obj.self = new_ns2ns3ClassB_(0,0); end
if (nargin == 0), obj.self = new_ns2ns3ClassB(0,0); end
if nargin ==14, new_ns2ns3ClassB_(varargin{1},0); end
if nargin ~= 13 && nargin ~= 14 && obj.self == 0, error('ns2ns3ClassB constructor failed'); end
end

View File

@ -8,20 +8,20 @@ mex_flags = -O5
all: ns1ClassA ns1ClassB ns2ClassA ns2ns3ClassB ns2ClassC ClassD
# ns1ClassA
new_ns1ClassA_.$(MEXENDING): new_ns1ClassA_.cpp $(PATH_TO_WRAP)/matlab.h
$(MEX) $(mex_flags) new_ns1ClassA_.cpp -output new_ns1ClassA_
new_ns1ClassA.$(MEXENDING): new_ns1ClassA.cpp $(PATH_TO_WRAP)/matlab.h
$(MEX) $(mex_flags) new_ns1ClassA.cpp -output new_ns1ClassA
ns1ClassA: new_ns1ClassA_.$(MEXENDING)
ns1ClassA: new_ns1ClassA.$(MEXENDING)
# ns1ClassB
new_ns1ClassB_.$(MEXENDING): new_ns1ClassB_.cpp $(PATH_TO_WRAP)/matlab.h
$(MEX) $(mex_flags) new_ns1ClassB_.cpp -output new_ns1ClassB_
new_ns1ClassB.$(MEXENDING): new_ns1ClassB.cpp $(PATH_TO_WRAP)/matlab.h
$(MEX) $(mex_flags) new_ns1ClassB.cpp -output new_ns1ClassB
ns1ClassB: new_ns1ClassB_.$(MEXENDING)
ns1ClassB: new_ns1ClassB.$(MEXENDING)
# ns2ClassA
new_ns2ClassA_.$(MEXENDING): new_ns2ClassA_.cpp $(PATH_TO_WRAP)/matlab.h
$(MEX) $(mex_flags) new_ns2ClassA_.cpp -output new_ns2ClassA_
new_ns2ClassA.$(MEXENDING): new_ns2ClassA.cpp $(PATH_TO_WRAP)/matlab.h
$(MEX) $(mex_flags) new_ns2ClassA.cpp -output new_ns2ClassA
ns2ClassA_afunction.$(MEXENDING): ns2ClassA_afunction.cpp $(PATH_TO_WRAP)/matlab.h
$(MEX) $(mex_flags) ns2ClassA_afunction.cpp -output ns2ClassA_afunction
@ns2ClassA/memberFunction.$(MEXENDING): @ns2ClassA/memberFunction.cpp $(PATH_TO_WRAP)/matlab.h
@ -31,25 +31,25 @@ ns2ClassA_afunction.$(MEXENDING): ns2ClassA_afunction.cpp $(PATH_TO_WRAP)/matlab
@ns2ClassA/nsReturn.$(MEXENDING): @ns2ClassA/nsReturn.cpp $(PATH_TO_WRAP)/matlab.h
$(MEX) $(mex_flags) @ns2ClassA/nsReturn.cpp -output @ns2ClassA/nsReturn
ns2ClassA: new_ns2ClassA_.$(MEXENDING) ns2ClassA_afunction.$(MEXENDING) @ns2ClassA/memberFunction.$(MEXENDING) @ns2ClassA/nsArg.$(MEXENDING) @ns2ClassA/nsReturn.$(MEXENDING)
ns2ClassA: new_ns2ClassA.$(MEXENDING) ns2ClassA_afunction.$(MEXENDING) @ns2ClassA/memberFunction.$(MEXENDING) @ns2ClassA/nsArg.$(MEXENDING) @ns2ClassA/nsReturn.$(MEXENDING)
# ns2ns3ClassB
new_ns2ns3ClassB_.$(MEXENDING): new_ns2ns3ClassB_.cpp $(PATH_TO_WRAP)/matlab.h
$(MEX) $(mex_flags) new_ns2ns3ClassB_.cpp -output new_ns2ns3ClassB_
new_ns2ns3ClassB.$(MEXENDING): new_ns2ns3ClassB.cpp $(PATH_TO_WRAP)/matlab.h
$(MEX) $(mex_flags) new_ns2ns3ClassB.cpp -output new_ns2ns3ClassB
ns2ns3ClassB: new_ns2ns3ClassB_.$(MEXENDING)
ns2ns3ClassB: new_ns2ns3ClassB.$(MEXENDING)
# ns2ClassC
new_ns2ClassC_.$(MEXENDING): new_ns2ClassC_.cpp $(PATH_TO_WRAP)/matlab.h
$(MEX) $(mex_flags) new_ns2ClassC_.cpp -output new_ns2ClassC_
new_ns2ClassC.$(MEXENDING): new_ns2ClassC.cpp $(PATH_TO_WRAP)/matlab.h
$(MEX) $(mex_flags) new_ns2ClassC.cpp -output new_ns2ClassC
ns2ClassC: new_ns2ClassC_.$(MEXENDING)
ns2ClassC: new_ns2ClassC.$(MEXENDING)
# ClassD
new_ClassD_.$(MEXENDING): new_ClassD_.cpp $(PATH_TO_WRAP)/matlab.h
$(MEX) $(mex_flags) new_ClassD_.cpp -output new_ClassD_
new_ClassD.$(MEXENDING): new_ClassD.cpp $(PATH_TO_WRAP)/matlab.h
$(MEX) $(mex_flags) new_ClassD.cpp -output new_ClassD
ClassD: new_ClassD_.$(MEXENDING)
ClassD: new_ClassD.$(MEXENDING)

View File

@ -9,19 +9,19 @@ addpath(toolboxpath);
%% ns1ClassA
cd(toolboxpath)
mex -O5 new_ns1ClassA_.cpp
mex -O5 new_ns1ClassA.cpp
cd @ns1ClassA
%% ns1ClassB
cd(toolboxpath)
mex -O5 new_ns1ClassB_.cpp
mex -O5 new_ns1ClassB.cpp
cd @ns1ClassB
%% ns2ClassA
cd(toolboxpath)
mex -O5 new_ns2ClassA_.cpp
mex -O5 new_ns2ClassA.cpp
mex -O5 ns2ClassA_afunction.cpp
cd @ns2ClassA
@ -31,19 +31,19 @@ mex -O5 nsReturn.cpp
%% ns2ns3ClassB
cd(toolboxpath)
mex -O5 new_ns2ns3ClassB_.cpp
mex -O5 new_ns2ns3ClassB.cpp
cd @ns2ns3ClassB
%% ns2ClassC
cd(toolboxpath)
mex -O5 new_ns2ClassC_.cpp
mex -O5 new_ns2ClassC.cpp
cd @ns2ClassC
%% ClassD
cd(toolboxpath)
mex -O5 new_ClassD_.cpp
mex -O5 new_ClassD.cpp
cd @ClassD

View File

@ -1,42 +0,0 @@
// automatically generated by wrap
#include <wrap/matlab.h>
#include <set>
#include <ClassD.h>
typedef boost::shared_ptr<ClassD> Shared;
static std::set<Shared*> collector;
struct Destruct
{
void operator() (Shared* p)
{
collector.erase(p);
}
};
void cleanup(void) {
std::for_each( collector.begin(), collector.end(), Destruct() );
}
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
mexAtExit(cleanup);
const mxArray* input = in[0];
Shared* self = *(Shared**) mxGetData(input);
if(self) {
if(nargin > 1) {
collector.insert(self);
}
else if(collector.erase(self))
delete self;
} else {
int nc = unwrap<int>(in[1]);
if(nc == 0) {
self = new Shared(new ClassD());
}
collector.insert(self);
out[0] = mxCreateNumericMatrix(1, 1, mxUINT32OR64_CLASS, mxREAL);
*reinterpret_cast<Shared**> (mxGetPr(out[0])) = self;
}
}

View File

@ -1,4 +0,0 @@
% automatically generated by wrap
function result = new_ClassD_(obj)
error('need to compile new_ClassD_.cpp');
end

View File

@ -1,42 +0,0 @@
// automatically generated by wrap
#include <wrap/matlab.h>
#include <set>
#include <path/to/ns1.h>
typedef boost::shared_ptr<ns1::ClassA> Shared;
static std::set<Shared*> collector;
struct Destruct
{
void operator() (Shared* p)
{
collector.erase(p);
}
};
void cleanup(void) {
std::for_each( collector.begin(), collector.end(), Destruct() );
}
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
mexAtExit(cleanup);
const mxArray* input = in[0];
Shared* self = *(Shared**) mxGetData(input);
if(self) {
if(nargin > 1) {
collector.insert(self);
}
else if(collector.erase(self))
delete self;
} else {
int nc = unwrap<int>(in[1]);
if(nc == 0) {
self = new Shared(new ns1::ClassA());
}
collector.insert(self);
out[0] = mxCreateNumericMatrix(1, 1, mxUINT32OR64_CLASS, mxREAL);
*reinterpret_cast<Shared**> (mxGetPr(out[0])) = self;
}
}

View File

@ -1,4 +0,0 @@
% automatically generated by wrap
function result = new_ns1ClassA_(obj)
error('need to compile new_ns1ClassA_.cpp');
end

View File

@ -1,43 +0,0 @@
// automatically generated by wrap
#include <wrap/matlab.h>
#include <set>
#include <path/to/ns1.h>
#include <path/to/ns1/ClassB.h>
typedef boost::shared_ptr<ns1::ClassB> Shared;
static std::set<Shared*> collector;
struct Destruct
{
void operator() (Shared* p)
{
collector.erase(p);
}
};
void cleanup(void) {
std::for_each( collector.begin(), collector.end(), Destruct() );
}
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
mexAtExit(cleanup);
const mxArray* input = in[0];
Shared* self = *(Shared**) mxGetData(input);
if(self) {
if(nargin > 1) {
collector.insert(self);
}
else if(collector.erase(self))
delete self;
} else {
int nc = unwrap<int>(in[1]);
if(nc == 0) {
self = new Shared(new ns1::ClassB());
}
collector.insert(self);
out[0] = mxCreateNumericMatrix(1, 1, mxUINT32OR64_CLASS, mxREAL);
*reinterpret_cast<Shared**> (mxGetPr(out[0])) = self;
}
}

View File

@ -1,4 +0,0 @@
% automatically generated by wrap
function result = new_ns1ClassB_(obj)
error('need to compile new_ns1ClassB_.cpp');
end

View File

@ -1,43 +0,0 @@
// automatically generated by wrap
#include <wrap/matlab.h>
#include <set>
#include <path/to/ns2.h>
#include <path/to/ns2/ClassA.h>
typedef boost::shared_ptr<ns2::ClassA> Shared;
static std::set<Shared*> collector;
struct Destruct
{
void operator() (Shared* p)
{
collector.erase(p);
}
};
void cleanup(void) {
std::for_each( collector.begin(), collector.end(), Destruct() );
}
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
mexAtExit(cleanup);
const mxArray* input = in[0];
Shared* self = *(Shared**) mxGetData(input);
if(self) {
if(nargin > 1) {
collector.insert(self);
}
else if(collector.erase(self))
delete self;
} else {
int nc = unwrap<int>(in[1]);
if(nc == 0) {
self = new Shared(new ns2::ClassA());
}
collector.insert(self);
out[0] = mxCreateNumericMatrix(1, 1, mxUINT32OR64_CLASS, mxREAL);
*reinterpret_cast<Shared**> (mxGetPr(out[0])) = self;
}
}

View File

@ -1,4 +0,0 @@
% automatically generated by wrap
function result = new_ns2ClassA_(obj)
error('need to compile new_ns2ClassA_.cpp');
end

View File

@ -1,42 +0,0 @@
// automatically generated by wrap
#include <wrap/matlab.h>
#include <set>
#include <path/to/ns2.h>
typedef boost::shared_ptr<ns2::ClassC> Shared;
static std::set<Shared*> collector;
struct Destruct
{
void operator() (Shared* p)
{
collector.erase(p);
}
};
void cleanup(void) {
std::for_each( collector.begin(), collector.end(), Destruct() );
}
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
mexAtExit(cleanup);
const mxArray* input = in[0];
Shared* self = *(Shared**) mxGetData(input);
if(self) {
if(nargin > 1) {
collector.insert(self);
}
else if(collector.erase(self))
delete self;
} else {
int nc = unwrap<int>(in[1]);
if(nc == 0) {
self = new Shared(new ns2::ClassC());
}
collector.insert(self);
out[0] = mxCreateNumericMatrix(1, 1, mxUINT32OR64_CLASS, mxREAL);
*reinterpret_cast<Shared**> (mxGetPr(out[0])) = self;
}
}

View File

@ -1,4 +0,0 @@
% automatically generated by wrap
function result = new_ns2ClassC_(obj)
error('need to compile new_ns2ClassC_.cpp');
end

View File

@ -1,43 +0,0 @@
// automatically generated by wrap
#include <wrap/matlab.h>
#include <set>
#include <path/to/ns2.h>
#include <path/to/ns3.h>
typedef boost::shared_ptr<ns2::ns3::ClassB> Shared;
static std::set<Shared*> collector;
struct Destruct
{
void operator() (Shared* p)
{
collector.erase(p);
}
};
void cleanup(void) {
std::for_each( collector.begin(), collector.end(), Destruct() );
}
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
mexAtExit(cleanup);
const mxArray* input = in[0];
Shared* self = *(Shared**) mxGetData(input);
if(self) {
if(nargin > 1) {
collector.insert(self);
}
else if(collector.erase(self))
delete self;
} else {
int nc = unwrap<int>(in[1]);
if(nc == 0) {
self = new Shared(new ns2::ns3::ClassB());
}
collector.insert(self);
out[0] = mxCreateNumericMatrix(1, 1, mxUINT32OR64_CLASS, mxREAL);
*reinterpret_cast<Shared**> (mxGetPr(out[0])) = self;
}
}

View File

@ -1,4 +0,0 @@
% automatically generated by wrap
function result = new_ns2ns3ClassB_(obj)
error('need to compile new_ns2ns3ClassB_.cpp');
end

View File

@ -1,6 +1,5 @@
// automatically generated by wrap
#include <wrap/matlab.h>
#include <set>
#include <path/to/ns2.h>
#include <path/to/ns2/ClassA.h>
typedef boost::shared_ptr<double> Shareddouble;

View File

@ -220,18 +220,18 @@ TEST( wrap, matlab_code_namespaces ) {
string act_path = "actual_namespaces/";
module.matlab_code("mex", "actual_namespaces", "mexa64", headerPath, "-O5");
EXPECT(files_equal(exp_path + "new_ClassD_.cpp" , act_path + "new_ClassD_.cpp" ));
EXPECT(files_equal(exp_path + "new_ClassD_.m" , act_path + "new_ClassD_.m" ));
EXPECT(files_equal(exp_path + "new_ns1ClassA_.cpp" , act_path + "new_ns1ClassA_.cpp" ));
EXPECT(files_equal(exp_path + "new_ns1ClassA_.m" , act_path + "new_ns1ClassA_.m" ));
EXPECT(files_equal(exp_path + "new_ns1ClassB_.cpp" , act_path + "new_ns1ClassB_.cpp" ));
EXPECT(files_equal(exp_path + "new_ns1ClassB_.m" , act_path + "new_ns1ClassB_.m" ));
EXPECT(files_equal(exp_path + "new_ns2ClassA_.cpp" , act_path + "new_ns2ClassA_.cpp" ));
EXPECT(files_equal(exp_path + "new_ns2ClassA_.m" , act_path + "new_ns2ClassA_.m" ));
EXPECT(files_equal(exp_path + "new_ns2ClassC_.cpp" , act_path + "new_ns2ClassC_.cpp" ));
EXPECT(files_equal(exp_path + "new_ns2ClassC_.m" , act_path + "new_ns2ClassC_.m" ));
EXPECT(files_equal(exp_path + "new_ns2ns3ClassB_.cpp" , act_path + "new_ns2ns3ClassB_.cpp" ));
EXPECT(files_equal(exp_path + "new_ns2ns3ClassB_.m" , act_path + "new_ns2ns3ClassB_.m" ));
EXPECT(files_equal(exp_path + "new_ClassD.cpp" , act_path + "new_ClassD.cpp" ));
EXPECT(files_equal(exp_path + "new_ClassD.m" , act_path + "new_ClassD.m" ));
EXPECT(files_equal(exp_path + "new_ns1ClassA.cpp" , act_path + "new_ns1ClassA.cpp" ));
EXPECT(files_equal(exp_path + "new_ns1ClassA.m" , act_path + "new_ns1ClassA.m" ));
EXPECT(files_equal(exp_path + "new_ns1ClassB.cpp" , act_path + "new_ns1ClassB.cpp" ));
EXPECT(files_equal(exp_path + "new_ns1ClassB.m" , act_path + "new_ns1ClassB.m" ));
EXPECT(files_equal(exp_path + "new_ns2ClassA.cpp" , act_path + "new_ns2ClassA.cpp" ));
EXPECT(files_equal(exp_path + "new_ns2ClassA.m" , act_path + "new_ns2ClassA.m" ));
EXPECT(files_equal(exp_path + "new_ns2ClassC.cpp" , act_path + "new_ns2ClassC.cpp" ));
EXPECT(files_equal(exp_path + "new_ns2ClassC.m" , act_path + "new_ns2ClassC.m" ));
EXPECT(files_equal(exp_path + "new_ns2ns3ClassB.cpp" , act_path + "new_ns2ns3ClassB.cpp" ));
EXPECT(files_equal(exp_path + "new_ns2ns3ClassB.m" , act_path + "new_ns2ns3ClassB.m" ));
EXPECT(files_equal(exp_path + "ns2ClassA_afunction.cpp" , act_path + "ns2ClassA_afunction.cpp" ));
EXPECT(files_equal(exp_path + "ns2ClassA_afunction.m" , act_path + "ns2ClassA_afunction.m" ));
@ -265,12 +265,12 @@ TEST( wrap, matlab_code ) {
EXPECT(files_equal(epath + "Makefile" , apath + "Makefile" ));
EXPECT(files_equal(epath + "make_geometry.m" , apath + "make_geometry.m" ));
EXPECT(files_equal(epath + "new_Point2_.cpp" , apath + "new_Point2_.cpp" ));
EXPECT(files_equal(epath + "new_Point2_.m" , apath + "new_Point2_.m" ));
EXPECT(files_equal(epath + "new_Point3_.cpp" , apath + "new_Point3_.cpp" ));
EXPECT(files_equal(epath + "new_Point3_.m" , apath + "new_Point3_.m" ));
EXPECT(files_equal(epath + "new_Test_.cpp" , apath + "new_Test_.cpp" ));
EXPECT(files_equal(epath + "new_Test_.m" , apath + "new_Test_.m" ));
EXPECT(files_equal(epath + "new_Point2.cpp" , apath + "new_Point2.cpp" ));
EXPECT(files_equal(epath + "new_Point2.m" , apath + "new_Point2.m" ));
EXPECT(files_equal(epath + "new_Point3.cpp" , apath + "new_Point3.cpp" ));
EXPECT(files_equal(epath + "new_Point3.m" , apath + "new_Point3.m" ));
EXPECT(files_equal(epath + "new_Test.cpp" , apath + "new_Test.cpp" ));
EXPECT(files_equal(epath + "new_Test.m" , apath + "new_Test.m" ));
EXPECT(files_equal(epath + "Point3_staticFunction.cpp" , apath + "Point3_staticFunction.cpp" ));
EXPECT(files_equal(epath + "Point3_staticFunction.m" , apath + "Point3_staticFunction.m" ));

View File

@ -124,7 +124,6 @@ void generateUsingNamespace(FileWriter& file, const vector<string>& using_namesp
void generateIncludes(FileWriter& file, const string& class_name,
const vector<string>& includes) {
file.oss << "#include <wrap/matlab.h>" << endl;
file.oss << "#include <set>" << endl;
bool added_include = false;
BOOST_FOREACH(const string& s, includes) {
if (!s.empty()) {