Fixed class issue calling destructor

release/4.3a0
Andrew Melim 2012-07-03 01:28:41 +00:00
parent b163d26d5e
commit e40ce8b44d
2 changed files with 6 additions and 19 deletions

View File

@ -53,7 +53,7 @@ void Class::matlab_proxy(const string& classFile) const {
id++;
}
//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 << " end" << endl;
// deconstructor
@ -61,7 +61,7 @@ void Class::matlab_proxy(const string& classFile) const {
file.oss << " if obj.self ~= 0" << endl;
//TODO: Add verbosity flag
//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 << " end" << endl;
file.oss << " end" << endl;

View File

@ -102,21 +102,8 @@ 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 << "{" << 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
file.oss << "void cleanup(void) {" << endl;
//TODO: Remove
//file.oss << " std::for_each( collector.begin(), collector.end(), Destruct() );" << endl;
file.oss << " for(std::set<Shared*>::iterator iter = collector.begin(); iter != collector.end(); ) {\n";
file.oss << " delete *iter;\n";
file.oss << " collector.erase(iter++);\n";