From e40ce8b44d671dff3f0a6a1af7febd0d4f3d35d0 Mon Sep 17 00:00:00 2001 From: Andrew Melim Date: Tue, 3 Jul 2012 01:28:41 +0000 Subject: [PATCH] Fixed class issue calling destructor --- wrap/Class.cpp | 4 ++-- wrap/Constructor.cpp | 21 ++++----------------- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/wrap/Class.cpp b/wrap/Class.cpp index e57a85884..aae97de37 100644 --- a/wrap/Class.cpp +++ b/wrap/Class.cpp @@ -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; diff --git a/wrap/Constructor.cpp b/wrap/Constructor.cpp index 323223a19..978516b18 100644 --- a/wrap/Constructor.cpp +++ b/wrap/Constructor.cpp @@ -102,25 +102,12 @@ void Constructor::matlab_wrapper(const string& toolboxPath, file.oss << "static std::set 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::iterator iter = collector.begin(); iter != collector.end(); ) {\n"; - file.oss << " delete *iter;\n"; - file.oss << " collector.erase(iter++);\n"; - file.oss << " }\n"; + file.oss << " for(std::set::iterator iter = collector.begin(); iter != collector.end(); ) {\n"; + file.oss << " delete *iter;\n"; + file.oss << " collector.erase(iter++);\n"; + file.oss << " }\n"; file.oss << "}" << endl; file.oss << "void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])" << endl;