Fixed instance variable naming convention
parent
0fd12d9a05
commit
307fd2737a
|
|
@ -78,7 +78,7 @@ void Class::matlab_make_fragment(ofstream& ofs,
|
|||
ofs << mex << c.matlab_wrapper_name(name) << ".cpp" << endl;
|
||||
ofs << endl << "cd @" << name << endl;
|
||||
BOOST_FOREACH(Method m, methods)
|
||||
ofs << mex << m.name << ".cpp" << endl;
|
||||
ofs << mex << m.name_ << ".cpp" << endl;
|
||||
ofs << endl;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,32 +36,32 @@ string maybe_shared_ptr(bool add, const string& type) {
|
|||
|
||||
/* ************************************************************************* */
|
||||
string Method::return_type(bool add_ptr, pairing p) {
|
||||
if (p==pair && returns_pair) {
|
||||
if (p==pair && returns_pair_) {
|
||||
string str = "pair< " +
|
||||
maybe_shared_ptr(add_ptr && returns_ptr, returns ) + ", " +
|
||||
maybe_shared_ptr(add_ptr && returns_ptr, returns2) + " >";
|
||||
maybe_shared_ptr(add_ptr && returns_ptr_, returns_) + ", " +
|
||||
maybe_shared_ptr(add_ptr && returns_ptr_, returns2_) + " >";
|
||||
return str;
|
||||
} else
|
||||
return maybe_shared_ptr(add_ptr && returns_ptr, (p==arg2)? returns2 : returns);
|
||||
return maybe_shared_ptr(add_ptr && returns_ptr_, (p==arg2)? returns2_ : returns_);
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
void Method::matlab_mfile(const string& classPath) {
|
||||
|
||||
// open destination m-file
|
||||
string wrapperFile = classPath + "/" + name + ".m";
|
||||
string wrapperFile = classPath + "/" + name_ + ".m";
|
||||
ofstream ofs(wrapperFile.c_str());
|
||||
if(!ofs) throw CantOpenFile(wrapperFile);
|
||||
if(verbose_) cerr << "generating " << wrapperFile << endl;
|
||||
|
||||
// generate code
|
||||
emit_header_comment(ofs, "%");
|
||||
ofs << "% usage: obj." << name << "(" << args.names() << ")" << endl;
|
||||
string returnType = returns_pair? "[first,second]" : "result";
|
||||
ofs << "function " << returnType << " = " << name << "(obj";
|
||||
if (args.size()) ofs << "," << args.names();
|
||||
ofs << "% usage: obj." << name_ << "(" << args_.names() << ")" << endl;
|
||||
string returnType = returns_pair_? "[first,second]" : "result";
|
||||
ofs << "function " << returnType << " = " << name_ << "(obj";
|
||||
if (args_.size()) ofs << "," << args_.names();
|
||||
ofs << ")" << endl;
|
||||
ofs << " error('need to compile " << name << ".cpp');" << endl;
|
||||
ofs << " error('need to compile " << name_ << ".cpp');" << endl;
|
||||
ofs << "end" << endl;
|
||||
|
||||
// close file
|
||||
|
|
@ -74,7 +74,7 @@ void Method::matlab_wrapper(const string& classPath,
|
|||
const string& nameSpace)
|
||||
{
|
||||
// open destination wrapperFile
|
||||
string wrapperFile = classPath + "/" + name + ".cpp";
|
||||
string wrapperFile = classPath + "/" + name_ + ".cpp";
|
||||
ofstream ofs(wrapperFile.c_str());
|
||||
if(!ofs) throw CantOpenFile(wrapperFile);
|
||||
if(verbose_) cerr << "generating " << wrapperFile << endl;
|
||||
|
|
@ -95,7 +95,7 @@ void Method::matlab_wrapper(const string& classPath,
|
|||
// check arguments
|
||||
// extra argument obj -> nargin-1 is passed !
|
||||
// example: checkArguments("equals",nargout,nargin-1,2);
|
||||
ofs << " checkArguments(\"" << name << "\",nargout,nargin-1," << args.size() << ");\n";
|
||||
ofs << " checkArguments(\"" << name_ << "\",nargout,nargin-1," << args_.size() << ");\n";
|
||||
|
||||
// get class pointer
|
||||
// example: shared_ptr<Test> = unwrap_shared_ptr< Test >(in[0], "Test");
|
||||
|
|
@ -103,30 +103,30 @@ void Method::matlab_wrapper(const string& classPath,
|
|||
<< " >(in[0],\"" << className << "\");" << endl;
|
||||
|
||||
// unwrap arguments, see Argument.cpp
|
||||
args.matlab_unwrap(ofs,1);
|
||||
args_.matlab_unwrap(ofs,1);
|
||||
|
||||
// call method
|
||||
// example: bool result = self->return_field(t);
|
||||
ofs << " ";
|
||||
if (returns!="void")
|
||||
if (returns_!="void")
|
||||
ofs << return_type(true,pair) << " result = ";
|
||||
ofs << "self->" << name << "(" << args.names() << ");\n";
|
||||
ofs << "self->" << name_ << "(" << args_.names() << ");\n";
|
||||
|
||||
// wrap result
|
||||
// example: out[0]=wrap<bool>(result);
|
||||
if (returns_pair) {
|
||||
if (returns_ptr)
|
||||
ofs << " out[0] = wrap_shared_ptr(result.first,\"" << returns << "\");\n";
|
||||
if (returns_pair_) {
|
||||
if (returns_ptr_)
|
||||
ofs << " out[0] = wrap_shared_ptr(result.first,\"" << returns_ << "\");\n";
|
||||
else
|
||||
ofs << " out[0] = wrap< " << return_type(true,arg1) << " >(result.first);\n";
|
||||
if (returns_ptr2)
|
||||
ofs << " out[1] = wrap_shared_ptr(result.second,\"" << returns2 << "\");\n";
|
||||
if (returns_ptr2_)
|
||||
ofs << " out[1] = wrap_shared_ptr(result.second,\"" << returns2_ << "\");\n";
|
||||
else
|
||||
ofs << " out[1] = wrap< " << return_type(true,arg2) << " >(result.second);\n";
|
||||
}
|
||||
else if (returns_ptr)
|
||||
ofs << " out[0] = wrap_shared_ptr(result,\"" << returns << "\");\n";
|
||||
else if (returns!="void")
|
||||
else if (returns_ptr_)
|
||||
ofs << " out[0] = wrap_shared_ptr(result,\"" << returns_ << "\");\n";
|
||||
else if (returns_!="void")
|
||||
ofs << " out[0] = wrap< " << return_type(true,arg1) << " >(result);\n";
|
||||
|
||||
// finish
|
||||
|
|
|
|||
|
|
@ -27,15 +27,15 @@ struct Method {
|
|||
|
||||
/// Constructor creates empty object
|
||||
Method(bool verbose = true) :
|
||||
returns_ptr(false), returns_ptr2(false), returns_pair(false), verbose_(
|
||||
returns_ptr_(false), returns_ptr2_(false), returns_pair_(false), verbose_(
|
||||
verbose) {
|
||||
}
|
||||
|
||||
// Then the instance variables are set directly by the Module constructor
|
||||
bool is_const;
|
||||
ArgumentList args;
|
||||
std::string returns, returns2, name;
|
||||
bool returns_ptr, returns_ptr2, returns_pair;
|
||||
bool is_const_;
|
||||
ArgumentList args_;
|
||||
std::string returns_, returns2_, name_;
|
||||
bool returns_ptr_, returns_ptr2_, returns_pair_;
|
||||
bool verbose_;
|
||||
|
||||
enum pairing {
|
||||
|
|
|
|||
|
|
@ -97,30 +97,30 @@ Module::Module(const string& interfacePath,
|
|||
[assign_a(constructor,constructor0)];
|
||||
|
||||
Rule returnType1_p =
|
||||
basisType_p[assign_a(method.returns)] |
|
||||
((className_p | "Vector" | "Matrix")[assign_a(method.returns)] >>
|
||||
!ch_p('*') [assign_a(method.returns_ptr,true)]);
|
||||
basisType_p[assign_a(method.returns_)] |
|
||||
((className_p | "Vector" | "Matrix")[assign_a(method.returns_)] >>
|
||||
!ch_p('*') [assign_a(method.returns_ptr_,true)]);
|
||||
|
||||
Rule returnType2_p =
|
||||
basisType_p[assign_a(method.returns2)] |
|
||||
((className_p | "Vector" | "Matrix")[assign_a(method.returns2)] >>
|
||||
!ch_p('*') [assign_a(method.returns_ptr2,true)]);
|
||||
basisType_p[assign_a(method.returns2_)] |
|
||||
((className_p | "Vector" | "Matrix")[assign_a(method.returns2_)] >>
|
||||
!ch_p('*') [assign_a(method.returns_ptr2_,true)]);
|
||||
|
||||
Rule pair_p =
|
||||
(str_p("pair") >> '<' >> returnType1_p >> ',' >> returnType2_p >> '>')
|
||||
[assign_a(method.returns_pair,true)];
|
||||
[assign_a(method.returns_pair_,true)];
|
||||
|
||||
Rule void_p = str_p("void")[assign_a(method.returns)];
|
||||
Rule void_p = str_p("void")[assign_a(method.returns_)];
|
||||
|
||||
Rule returnType_p = void_p | returnType1_p | pair_p;
|
||||
|
||||
Rule methodName_p = lexeme_d[lower_p >> *(alnum_p | '_')];
|
||||
|
||||
Rule method_p =
|
||||
(returnType_p >> methodName_p[assign_a(method.name)] >>
|
||||
(returnType_p >> methodName_p[assign_a(method.name_)] >>
|
||||
'(' >> argumentList_p >> ')' >>
|
||||
!str_p("const")[assign_a(method.is_const,true)] >> ';')
|
||||
[assign_a(method.args,args)]
|
||||
!str_p("const")[assign_a(method.is_const_,true)] >> ';')
|
||||
[assign_a(method.args_,args)]
|
||||
[assign_a(args,args0)]
|
||||
[push_back_a(cls.methods, method)]
|
||||
[assign_a(method,method0)];
|
||||
|
|
|
|||
Loading…
Reference in New Issue