Fixed class issue calling destructor
parent
b163d26d5e
commit
e40ce8b44d
|
@ -53,7 +53,7 @@ void Class::matlab_proxy(const string& classFile) const {
|
||||||
id++;
|
id++;
|
||||||
}
|
}
|
||||||
//Static constructor collect call
|
//Static constructor collect call
|
||||||
file.oss << " if nargin ==14, new_" << matlabName << "_(varargin{1},0); end" << endl;
|
file.oss << " if nargin ==14, new_" << matlabName << "(varargin{1},0); end" << endl;
|
||||||
file.oss << " if nargin ~= 13 && nargin ~= 14 && obj.self == 0, error('" << matlabName << " constructor failed'); end" << endl;
|
file.oss << " if nargin ~= 13 && nargin ~= 14 && obj.self == 0, error('" << matlabName << " constructor failed'); end" << endl;
|
||||||
file.oss << " end" << endl;
|
file.oss << " end" << endl;
|
||||||
// deconstructor
|
// deconstructor
|
||||||
|
@ -61,7 +61,7 @@ void Class::matlab_proxy(const string& classFile) const {
|
||||||
file.oss << " if obj.self ~= 0" << endl;
|
file.oss << " if obj.self ~= 0" << endl;
|
||||||
//TODO: Add verbosity flag
|
//TODO: Add verbosity flag
|
||||||
//file.oss << " fprintf(1,'MATLAB class deleting %x',obj.self);" << endl;
|
//file.oss << " fprintf(1,'MATLAB class deleting %x',obj.self);" << endl;
|
||||||
file.oss << " new_" << matlabName << "_(obj.self);" << endl;
|
file.oss << " new_" << matlabName << "(obj.self);" << endl;
|
||||||
file.oss << " obj.self = 0;" << endl;
|
file.oss << " obj.self = 0;" << endl;
|
||||||
file.oss << " end" << endl;
|
file.oss << " end" << endl;
|
||||||
file.oss << " end" << endl;
|
file.oss << " end" << endl;
|
||||||
|
|
|
@ -102,25 +102,12 @@ void Constructor::matlab_wrapper(const string& toolboxPath,
|
||||||
file.oss << "static std::set<Shared*> collector;" << endl;
|
file.oss << "static std::set<Shared*> collector;" << endl;
|
||||||
file.oss << endl;
|
file.oss << endl;
|
||||||
|
|
||||||
//TODO: Remove
|
|
||||||
//Generate the destructor function
|
|
||||||
/*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;*/
|
|
||||||
|
|
||||||
//Generate cleanup function
|
//Generate cleanup function
|
||||||
file.oss << "void cleanup(void) {" << endl;
|
file.oss << "void cleanup(void) {" << endl;
|
||||||
//TODO: Remove
|
file.oss << " for(std::set<Shared*>::iterator iter = collector.begin(); iter != collector.end(); ) {\n";
|
||||||
//file.oss << " std::for_each( collector.begin(), collector.end(), Destruct() );" << endl;
|
file.oss << " delete *iter;\n";
|
||||||
file.oss << " for(std::set<Shared*>::iterator iter = collector.begin(); iter != collector.end(); ) {\n";
|
file.oss << " collector.erase(iter++);\n";
|
||||||
file.oss << " delete *iter;\n";
|
file.oss << " }\n";
|
||||||
file.oss << " collector.erase(iter++);\n";
|
|
||||||
file.oss << " }\n";
|
|
||||||
file.oss << "}" << endl;
|
file.oss << "}" << endl;
|
||||||
|
|
||||||
file.oss << "void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])" << endl;
|
file.oss << "void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])" << endl;
|
||||||
|
|
Loading…
Reference in New Issue