From ce12f3d255f744f8fbecd333e09cd3eee6565257 Mon Sep 17 00:00:00 2001 From: Richard Roberts Date: Thu, 12 Jul 2012 22:28:28 +0000 Subject: [PATCH] Code cleanup and comments --- wrap/Argument.cpp | 1 + wrap/Argument.h | 1 + wrap/Class.cpp | 11 +- wrap/Class.h | 4 +- wrap/Constructor.cpp | 1 + wrap/Constructor.h | 1 + wrap/Deconstructor.cpp | 1 + wrap/Deconstructor.h | 1 + wrap/Method.cpp | 5 +- wrap/Method.h | 6 +- wrap/Module.cpp | 237 ++++++++++++++++++----------------------- wrap/Module.h | 24 ++--- wrap/ReturnValue.cpp | 1 + wrap/ReturnValue.h | 10 +- wrap/StaticMethod.cpp | 5 +- wrap/StaticMethod.h | 6 +- wrap/matlab.h | 3 + wrap/utilities.cpp | 1 + wrap/utilities.h | 1 + 19 files changed, 151 insertions(+), 169 deletions(-) diff --git a/wrap/Argument.cpp b/wrap/Argument.cpp index 35f20169b..279050e25 100644 --- a/wrap/Argument.cpp +++ b/wrap/Argument.cpp @@ -13,6 +13,7 @@ * @file Argument.ccp * @author Frank Dellaert * @author Andrew Melim + * @author Richard Roberts **/ #include diff --git a/wrap/Argument.h b/wrap/Argument.h index b4c3fe4a7..4dcf6b563 100644 --- a/wrap/Argument.h +++ b/wrap/Argument.h @@ -14,6 +14,7 @@ * @brief arguments to constructors and methods * @author Frank Dellaert * @author Andrew Melim + * @author Richard Roberts **/ #pragma once diff --git a/wrap/Class.cpp b/wrap/Class.cpp index 43258da61..7034ebb3a 100644 --- a/wrap/Class.cpp +++ b/wrap/Class.cpp @@ -13,6 +13,7 @@ * @file Class.cpp * @author Frank Dellaert * @author Andrew Melim + * @author Richard Roberts **/ #include @@ -34,7 +35,7 @@ using namespace wrap; /* ************************************************************************* */ void Class::matlab_proxy(const string& classFile, const string& wrapperName, - const ReturnValue::TypeAttributesTable& typeAttributes, + const TypeAttributesTable& typeAttributes, FileWriter& wrapperFile, vector& functionNames) const { // open destination classFile FileWriter proxyFile(classFile, verbose_, "%"); @@ -68,7 +69,7 @@ void Class::matlab_proxy(const string& classFile, const string& wrapperName, // Regular constructors BOOST_FOREACH(ArgumentList a, constructor.args_list) { - const int id = functionNames.size(); + const int id = (int)functionNames.size(); constructor.proxy_fragment(proxyFile, wrapperName, matlabName, matlabBaseName, id, a); const string wrapFunctionName = constructor.wrapper_fragment(wrapperFile, cppName, matlabName, cppBaseName, id, using_namespaces, a); @@ -85,7 +86,7 @@ void Class::matlab_proxy(const string& classFile, const string& wrapperName, // Deconstructor { - const int id = functionNames.size(); + const int id = (int)functionNames.size(); deconstructor.proxy_fragment(proxyFile, wrapperName, matlabName, id); proxyFile.oss << "\n"; const string functionName = deconstructor.wrapper_fragment(wrapperFile, cppName, matlabName, id, using_namespaces); @@ -134,14 +135,14 @@ void Class::pointer_constructor_fragments(FileWriter& proxyFile, FileWriter& wra const string baseMatlabName = wrap::qualifiedName("", qualifiedParent); const string baseCppName = wrap::qualifiedName("::", qualifiedParent); - const int collectorInsertId = functionNames.size(); + const int collectorInsertId = (int)functionNames.size(); const string collectorInsertFunctionName = matlabName + "_collectorInsertAndMakeBase_" + boost::lexical_cast(collectorInsertId); functionNames.push_back(collectorInsertFunctionName); int upcastFromVoidId; string upcastFromVoidFunctionName; if(isVirtual) { - upcastFromVoidId = functionNames.size(); + upcastFromVoidId = (int)functionNames.size(); upcastFromVoidFunctionName = matlabName + "_upcastFromVoid_" + boost::lexical_cast(upcastFromVoidId); functionNames.push_back(upcastFromVoidFunctionName); } diff --git a/wrap/Class.h b/wrap/Class.h index 4626a901a..beee2c29f 100644 --- a/wrap/Class.h +++ b/wrap/Class.h @@ -14,6 +14,7 @@ * @brief describe the C++ class that is being wrapped * @author Frank Dellaert * @author Andrew Melim + * @author Richard Roberts **/ #pragma once @@ -25,6 +26,7 @@ #include "Deconstructor.h" #include "Method.h" #include "StaticMethod.h" +#include "TypeAttributesTable.h" namespace wrap { @@ -52,7 +54,7 @@ struct Class { bool verbose_; ///< verbose flag // And finally MATLAB code is emitted, methods below called by Module::matlab_code - void matlab_proxy(const std::string& classFile, const std::string& wrapperName, const ReturnValue::TypeAttributesTable& typeAttributes, + void matlab_proxy(const std::string& classFile, const std::string& wrapperName, const TypeAttributesTable& typeAttributes, FileWriter& wrapperFile, std::vector& functionNames) const; ///< emit proxy class std::string qualifiedName(const std::string& delim = "") const; ///< creates a namespace-qualified name, optional delimiter diff --git a/wrap/Constructor.cpp b/wrap/Constructor.cpp index aaa7f1c8e..afb35f62d 100644 --- a/wrap/Constructor.cpp +++ b/wrap/Constructor.cpp @@ -13,6 +13,7 @@ * @file Constructor.ccp * @author Frank Dellaert * @author Andrew Melim + * @author Richard Roberts **/ #include diff --git a/wrap/Constructor.h b/wrap/Constructor.h index 46f5c5db9..50d0c41f5 100644 --- a/wrap/Constructor.h +++ b/wrap/Constructor.h @@ -13,6 +13,7 @@ * @file Constructor.h * @brief class describing a constructor + code generation * @author Frank Dellaert + * @author Richard Roberts **/ #pragma once diff --git a/wrap/Deconstructor.cpp b/wrap/Deconstructor.cpp index aa4969af5..c02ab0e93 100644 --- a/wrap/Deconstructor.cpp +++ b/wrap/Deconstructor.cpp @@ -13,6 +13,7 @@ * @file Deconstructor.ccp * @author Frank Dellaert * @author Andrew Melim + * @author Richard Roberts **/ #include diff --git a/wrap/Deconstructor.h b/wrap/Deconstructor.h index ca44700fc..1ef5b80b0 100644 --- a/wrap/Deconstructor.h +++ b/wrap/Deconstructor.h @@ -14,6 +14,7 @@ * @brief class describing a constructor + code generation * @author Frank Dellaert * @author Andrew Melim + * @author Richard Roberts **/ #pragma once diff --git a/wrap/Method.cpp b/wrap/Method.cpp index f44a08a73..f7ee5c71c 100644 --- a/wrap/Method.cpp +++ b/wrap/Method.cpp @@ -12,6 +12,7 @@ /** * @file Method.ccp * @author Frank Dellaert + * @author Richard Roberts **/ #include @@ -41,7 +42,7 @@ void Method::proxy_wrapper_fragments(FileWriter& proxyFile, FileWriter& wrapperF const string& matlabClassName, const string& wrapperName, const vector& using_namespaces, - const ReturnValue::TypeAttributesTable& typeAttributes, + const TypeAttributesTable& typeAttributes, vector& functionNames) const { proxyFile.oss << " function varargout = " << name << "(this, varargin)\n"; @@ -102,7 +103,7 @@ string Method::wrapper_fragment(FileWriter& file, int overload, int id, const vector& using_namespaces, - const ReturnValue::TypeAttributesTable& typeAttributes) const { + const TypeAttributesTable& typeAttributes) const { // generate code diff --git a/wrap/Method.h b/wrap/Method.h index 936b3812d..c23fd7c3d 100644 --- a/wrap/Method.h +++ b/wrap/Method.h @@ -13,6 +13,7 @@ * @file Method.h * @brief describes and generates code for methods * @author Frank Dellaert + * @author Richard Roberts **/ #pragma once @@ -22,6 +23,7 @@ #include "Argument.h" #include "ReturnValue.h" +#include "TypeAttributesTable.h" namespace wrap { @@ -50,7 +52,7 @@ struct Method { void proxy_wrapper_fragments(FileWriter& proxyFile, FileWriter& wrapperFile, const std::string& cppClassName, const std::string& matlabClassName, const std::string& wrapperName, const std::vector& using_namespaces, - const ReturnValue::TypeAttributesTable& typeAttributes, + const TypeAttributesTable& typeAttributes, std::vector& functionNames) const; private: @@ -60,7 +62,7 @@ private: int overload, int id, const std::vector& using_namespaces, - const ReturnValue::TypeAttributesTable& typeAttributes) const; ///< cpp wrapper + const TypeAttributesTable& typeAttributes) const; ///< cpp wrapper }; } // \namespace wrap diff --git a/wrap/Module.cpp b/wrap/Module.cpp index d1e502bac..707d91dc4 100644 --- a/wrap/Module.cpp +++ b/wrap/Module.cpp @@ -14,10 +14,12 @@ * @author Frank Dellaert * @author Alex Cunningham * @author Andrew Melim + * @author Richard Roberts **/ #include "Module.h" #include "FileWriter.h" +#include "TypeAttributesTable.h" #include "utilities.h" #include "spirit_actors.h" @@ -88,7 +90,7 @@ Module::Module(const string& interfacePath, string templateArgument; vector templateInstantiationNamespace; vector > templateInstantiations; - TemplateSingleInstantiation singleInstantiation, singleInstantiation0; + TemplateInstantiationTypedef singleInstantiation, singleInstantiation0; string include_path = ""; const string null_str = ""; @@ -167,7 +169,7 @@ Module::Module(const string& interfacePath, className_p[assign_a(singleInstantiation.name)] >> ';') [assign_a(singleInstantiation.namespaces, namespaces)] - [push_back_a(singleInstantiations, singleInstantiation)] + [push_back_a(templateInstantiationTypedefs, singleInstantiation)] [assign_a(singleInstantiation, singleInstantiation0)]; Rule templateList_p = @@ -335,7 +337,7 @@ Module::Module(const string& interfacePath, parse_info info = parse(contents.c_str(), module_p, space_p); if(!info.full) { printf("parsing stopped at \n%.20s\n",info.stop); - throw ParseFailed(info.length); + throw ParseFailed((int)info.length); } } @@ -413,49 +415,19 @@ void Module::matlab_code(const string& toolboxPath, const string& headerPath) co wrapperFile.oss << "#include \n"; wrapperFile.oss << "\n"; - // Expand templates - vector expandedClasses = expandTemplates(); + // Expand templates - This is done first so that template instantiations are + // counted in the list of valid types, have their attributes and dependencies + // checked, etc. + vector expandedClasses = ExpandTypedefInstantiations(classes, templateInstantiationTypedefs); // Dependency check list - vector validTypes; - BOOST_FOREACH(const ForwardDeclaration& fwDec, forward_declarations) { - validTypes.push_back(fwDec.name); - } - validTypes.push_back("void"); - validTypes.push_back("string"); - validTypes.push_back("int"); - validTypes.push_back("bool"); - validTypes.push_back("char"); - validTypes.push_back("unsigned char"); - validTypes.push_back("size_t"); - validTypes.push_back("double"); - validTypes.push_back("Vector"); - validTypes.push_back("Matrix"); - //Create a list of parsed classes for dependency checking - BOOST_FOREACH(const Class& cls, expandedClasses) { - validTypes.push_back(cls.qualifiedName("::")); - } + vector validTypes = GenerateValidTypes(expandedClasses, forward_declarations); - // Create type attributes table - ReturnValue::TypeAttributesTable typeAttributes; - BOOST_FOREACH(const ForwardDeclaration& fwDec, forward_declarations) { - if(!typeAttributes.insert(make_pair(fwDec.name, ReturnValue::TypeAttributes(fwDec.isVirtual))).second) - throw DuplicateDefinition("class " + fwDec.name); - } - BOOST_FOREACH(const Class& cls, expandedClasses) { - if(!typeAttributes.insert(make_pair(cls.qualifiedName("::"), ReturnValue::TypeAttributes(cls.isVirtual))).second) - throw DuplicateDefinition("class " + cls.qualifiedName("::")); - } - // Check attributes - BOOST_FOREACH(const Class& cls, expandedClasses) { - // Check that class is virtual if it has a parent - if(!cls.qualifiedParent.empty() && !cls.isVirtual) - throw AttributeError(cls.qualifiedName("::"), "Has a base class so needs to be declared virtual, change to 'virtual class "+cls.name+" ...'"); - // Check that parent is virtual as well - if(!cls.qualifiedParent.empty() && !typeAttributes.at(wrap::qualifiedName("::", cls.qualifiedParent)).isVirtual) - throw AttributeError(wrap::qualifiedName("::", cls.qualifiedParent), - "Is the base class of " + cls.qualifiedName("::") + ", so needs to be declared virtual"); - } + // Create type attributes table and check validity + TypeAttributesTable typeAttributes; + typeAttributes.addClasses(expandedClasses); + typeAttributes.addForwardDeclarations(forward_declarations); + typeAttributes.checkValidity(expandedClasses); // Check that all classes have been defined somewhere BOOST_FOREACH(const Class& cls, expandedClasses) { @@ -472,69 +444,18 @@ void Module::matlab_code(const string& toolboxPath, const string& headerPath) co // Generate includes while avoiding redundant includes generateIncludes(wrapperFile); - // create typedef classes + // create typedef classes - we put this at the top of the wrap file so that collectors and method arguments can use these typedefs BOOST_FOREACH(const Class& cls, expandedClasses) { if(!cls.typedefName.empty()) wrapperFile.oss << cls.getTypedef() << "\n"; } wrapperFile.oss << "\n"; - // Generate all collectors - BOOST_FOREACH(const Class& cls, expandedClasses) { - const string matlabName = cls.qualifiedName(), cppName = cls.qualifiedName("::"); - wrapperFile.oss << "typedef std::set*> " - << "Collector_" << matlabName << ";\n"; - wrapperFile.oss << "static Collector_" << matlabName << - " collector_" << matlabName << ";\n"; - } - - // generate mexAtExit cleanup function - wrapperFile.oss << "\nvoid _deleteAllObjects()\n"; - wrapperFile.oss << "{\n"; - BOOST_FOREACH(const Class& cls, expandedClasses) { - const string matlabName = cls.qualifiedName(); - const string cppName = cls.qualifiedName("::"); - const string collectorType = "Collector_" + matlabName; - const string collectorName = "collector_" + matlabName; - wrapperFile.oss << " for(" << collectorType << "::iterator iter = " << collectorName << ".begin();\n"; - wrapperFile.oss << " iter != " << collectorName << ".end(); ) {\n"; - wrapperFile.oss << " delete *iter;\n"; - wrapperFile.oss << " " << collectorName << ".erase(iter++);\n"; - wrapperFile.oss << " }\n"; - } - wrapperFile.oss << "}\n\n"; + // Generate collectors and cleanup function to be called from mexAtExit + WriteCollectorsAndCleanupFcn(wrapperFile, name, expandedClasses); // generate RTTI registry (for returning derived-most types) - { - wrapperFile.oss << - "static bool _RTTIRegister_" << name << "_done = false;\n" - "void _" << name << "_RTTIRegister() {\n" - " std::map types;\n"; - BOOST_FOREACH(const Class& cls, expandedClasses) { - if(cls.isVirtual) - wrapperFile.oss << - " types.insert(std::make_pair(typeid(" << cls.qualifiedName("::") << ").name(), \"" << cls.qualifiedName() << "\"));\n"; - } - wrapperFile.oss << "\n"; - - wrapperFile.oss << - " mxArray *registry = mexGetVariable(\"global\", \"gtsamwrap_rttiRegistry\");\n" - " if(!registry)\n" - " registry = mxCreateStructMatrix(1, 1, 0, NULL);\n" - " typedef std::pair StringPair;\n" - " BOOST_FOREACH(const StringPair& rtti_matlab, types) {\n" - " int fieldId = mxAddField(registry, rtti_matlab.first.c_str());\n" - " if(fieldId < 0)\n" - " mexErrMsgTxt(\"gtsam wrap: Error indexing RTTI types, inheritance will not work correctly\");\n" - " mxArray *matlabName = mxCreateString(rtti_matlab.second.c_str());\n" - " mxSetFieldByNumber(registry, 0, fieldId, matlabName);\n" - " }\n" - " if(mexPutVariable(\"global\", \"gtsamwrap_rttiRegistry\", registry) != 0)\n" - " mexErrMsgTxt(\"gtsam wrap: Error indexing RTTI types, inheritance will not work correctly\");\n" - " mxDestroyArray(registry);\n" - "}\n" - "\n"; - } + WriteRTTIRegistry(wrapperFile, name, expandedClasses); // create proxy class and wrapper code BOOST_FOREACH(const Class& cls, expandedClasses) { @@ -573,43 +494,13 @@ void Module::matlab_code(const string& toolboxPath, const string& headerPath) co } /* ************************************************************************* */ -vector Module::expandTemplates() const { +vector Module::ExpandTypedefInstantiations(const vector& classes, const vector instantiations) { vector expandedClasses = classes; - BOOST_FOREACH(const TemplateSingleInstantiation& inst, singleInstantiations) { - // Find matching class - std::vector::iterator clsIt = expandedClasses.end(); - for(std::vector::iterator it = expandedClasses.begin(); it != expandedClasses.end(); ++it) { - if(it->name == inst.className && it->namespaces == inst.classNamespaces && it->templateArgs.size() == inst.typeList.size()) { - clsIt = it; - break; - } - } - - if(clsIt == expandedClasses.end()) - throw DependencyMissing(wrap::qualifiedName("::", inst.classNamespaces, inst.className), - "instantiation into typedef name " + wrap::qualifiedName("::", inst.namespaces, inst.name) + - ". Ensure that the typedef provides the correct number of template arguments."); - - // Instantiate it - Class classInst = *clsIt; - for(size_t i = 0; i < inst.typeList.size(); ++i) - classInst = classInst.expandTemplate(classInst.templateArgs[i], inst.typeList[i]); - - // Fix class properties - classInst.name = inst.name; - classInst.templateArgs.clear(); - classInst.typedefName = clsIt->qualifiedName("::") + "<"; - if(inst.typeList.size() > 0) - classInst.typedefName += wrap::qualifiedName("::", inst.typeList[0]); - for(size_t i = 1; i < inst.typeList.size(); ++i) - classInst.typedefName += (", " + wrap::qualifiedName("::", inst.typeList[i])); - classInst.typedefName += ">"; - classInst.namespaces = inst.namespaces; - + BOOST_FOREACH(const TemplateInstantiationTypedef& inst, instantiations) { // Add the new class to the list - expandedClasses.push_back(classInst); + expandedClasses.push_back(inst.findAndExpand(classes)); } // Remove all template classes @@ -623,3 +514,87 @@ vector Module::expandTemplates() const { } /* ************************************************************************* */ +vector Module::GenerateValidTypes(const vector& classes, const vector forwardDeclarations) { + vector validTypes; + BOOST_FOREACH(const ForwardDeclaration& fwDec, forwardDeclarations) { + validTypes.push_back(fwDec.name); + } + validTypes.push_back("void"); + validTypes.push_back("string"); + validTypes.push_back("int"); + validTypes.push_back("bool"); + validTypes.push_back("char"); + validTypes.push_back("unsigned char"); + validTypes.push_back("size_t"); + validTypes.push_back("double"); + validTypes.push_back("Vector"); + validTypes.push_back("Matrix"); + //Create a list of parsed classes for dependency checking + BOOST_FOREACH(const Class& cls, classes) { + validTypes.push_back(cls.qualifiedName("::")); + } + + return validTypes; +} + +/* ************************************************************************* */ +void Module::WriteCollectorsAndCleanupFcn(FileWriter& wrapperFile, const std::string& moduleName, const std::vector& classes) { + // Generate all collectors + BOOST_FOREACH(const Class& cls, classes) { + const string matlabName = cls.qualifiedName(), cppName = cls.qualifiedName("::"); + wrapperFile.oss << "typedef std::set*> " + << "Collector_" << matlabName << ";\n"; + wrapperFile.oss << "static Collector_" << matlabName << + " collector_" << matlabName << ";\n"; + } + + // generate mexAtExit cleanup function + wrapperFile.oss << "\nvoid _deleteAllObjects()\n"; + wrapperFile.oss << "{\n"; + BOOST_FOREACH(const Class& cls, classes) { + const string matlabName = cls.qualifiedName(); + const string cppName = cls.qualifiedName("::"); + const string collectorType = "Collector_" + matlabName; + const string collectorName = "collector_" + matlabName; + wrapperFile.oss << " for(" << collectorType << "::iterator iter = " << collectorName << ".begin();\n"; + wrapperFile.oss << " iter != " << collectorName << ".end(); ) {\n"; + wrapperFile.oss << " delete *iter;\n"; + wrapperFile.oss << " " << collectorName << ".erase(iter++);\n"; + wrapperFile.oss << " }\n"; + } + wrapperFile.oss << "}\n\n"; +} + +/* ************************************************************************* */ +void Module::WriteRTTIRegistry(FileWriter& wrapperFile, const std::string& moduleName, const std::vector& classes) { + wrapperFile.oss << + "static bool _RTTIRegister_" << moduleName << "_done = false;\n" + "void _" << moduleName << "_RTTIRegister() {\n" + " std::map types;\n"; + BOOST_FOREACH(const Class& cls, classes) { + if(cls.isVirtual) + wrapperFile.oss << + " types.insert(std::make_pair(typeid(" << cls.qualifiedName("::") << ").name(), \"" << cls.qualifiedName() << "\"));\n"; + } + wrapperFile.oss << "\n"; + + wrapperFile.oss << + " mxArray *registry = mexGetVariable(\"global\", \"gtsamwrap_rttiRegistry\");\n" + " if(!registry)\n" + " registry = mxCreateStructMatrix(1, 1, 0, NULL);\n" + " typedef std::pair StringPair;\n" + " BOOST_FOREACH(const StringPair& rtti_matlab, types) {\n" + " int fieldId = mxAddField(registry, rtti_matlab.first.c_str());\n" + " if(fieldId < 0)\n" + " mexErrMsgTxt(\"gtsam wrap: Error indexing RTTI types, inheritance will not work correctly\");\n" + " mxArray *matlabName = mxCreateString(rtti_matlab.second.c_str());\n" + " mxSetFieldByNumber(registry, 0, fieldId, matlabName);\n" + " }\n" + " if(mexPutVariable(\"global\", \"gtsamwrap_rttiRegistry\", registry) != 0)\n" + " mexErrMsgTxt(\"gtsam wrap: Error indexing RTTI types, inheritance will not work correctly\");\n" + " mxDestroyArray(registry);\n" + "}\n" + "\n"; +} + +/* ************************************************************************* */ diff --git a/wrap/Module.h b/wrap/Module.h index 42089291c..403f2f32d 100644 --- a/wrap/Module.h +++ b/wrap/Module.h @@ -13,6 +13,7 @@ * @file Module.h * @brief describes module to be wrapped * @author Frank Dellaert + * @author Richard Roberts **/ #pragma once @@ -22,6 +23,8 @@ #include #include "Class.h" +#include "TemplateInstantiationTypedef.h" +#include "ForwardDeclaration.h" namespace wrap { @@ -30,23 +33,9 @@ namespace wrap { */ struct Module { - struct ForwardDeclaration { - std::string name; - bool isVirtual; - ForwardDeclaration() : isVirtual(false) {} - }; - - struct TemplateSingleInstantiation { - std::vector classNamespaces; - std::string className; - std::vector namespaces; - std::string name; - std::vector > typeList; - }; - std::string name; ///< module name std::vector classes; ///< list of classes - std::vector singleInstantiations; ///< list of template instantiations + std::vector templateInstantiationTypedefs; ///< list of template instantiations bool verbose; ///< verbose flag // std::vector using_namespaces; ///< all default namespaces std::vector forward_declarations; @@ -66,7 +55,10 @@ struct Module { void generateIncludes(FileWriter& file) const; private: - std::vector expandTemplates() const; + static std::vector ExpandTypedefInstantiations(const std::vector& classes, const std::vector instantiations); + static std::vector GenerateValidTypes(const std::vector& classes, const std::vector forwardDeclarations); + static void WriteCollectorsAndCleanupFcn(FileWriter& wrapperFile, const std::string& moduleName, const std::vector& classes); + static void WriteRTTIRegistry(FileWriter& wrapperFile, const std::string& moduleName, const std::vector& classes); }; } // \namespace wrap diff --git a/wrap/ReturnValue.cpp b/wrap/ReturnValue.cpp index 21baf3af9..a3efb094e 100644 --- a/wrap/ReturnValue.cpp +++ b/wrap/ReturnValue.cpp @@ -4,6 +4,7 @@ * @date Dec 1, 2011 * @author Alex Cunningham * @author Andrew Melim + * @author Richard Roberts */ #include diff --git a/wrap/ReturnValue.h b/wrap/ReturnValue.h index 7d30578b2..8ff5d712b 100644 --- a/wrap/ReturnValue.h +++ b/wrap/ReturnValue.h @@ -5,12 +5,14 @@ * * @date Dec 1, 2011 * @author Alex Cunningham + * @author Richard Roberts */ #include #include #include "FileWriter.h" +#include "TypeAttributesTable.h" #pragma once @@ -18,14 +20,6 @@ namespace wrap { struct ReturnValue { - struct TypeAttributes { - bool isVirtual; - TypeAttributes() : isVirtual(false) {} - TypeAttributes(bool isVirtual) : isVirtual(isVirtual) {} - }; - - typedef std::map TypeAttributesTable; - typedef enum { CLASS, EIGEN, diff --git a/wrap/StaticMethod.cpp b/wrap/StaticMethod.cpp index 75456b6b7..19dcd375e 100644 --- a/wrap/StaticMethod.cpp +++ b/wrap/StaticMethod.cpp @@ -13,6 +13,7 @@ * @file StaticMethod.ccp * @author Frank Dellaert * @author Andrew Melim + * @author Richard Roberts **/ #include @@ -42,7 +43,7 @@ void StaticMethod::proxy_wrapper_fragments(FileWriter& proxyFile, FileWriter& wr const string& matlabClassName, const string& wrapperName, const vector& using_namespaces, - const ReturnValue::TypeAttributesTable& typeAttributes, + const TypeAttributesTable& typeAttributes, vector& functionNames) const { string upperName = name; upperName[0] = std::toupper(upperName[0], std::locale()); @@ -105,7 +106,7 @@ string StaticMethod::wrapper_fragment(FileWriter& file, int overload, int id, const vector& using_namespaces, - const ReturnValue::TypeAttributesTable& typeAttributes) const { + const TypeAttributesTable& typeAttributes) const { // generate code diff --git a/wrap/StaticMethod.h b/wrap/StaticMethod.h index 8a739665d..8951f965b 100644 --- a/wrap/StaticMethod.h +++ b/wrap/StaticMethod.h @@ -14,6 +14,7 @@ * @brief describes and generates code for static methods * @author Frank Dellaert * @author Alex Cunningham + * @author Richard Roberts **/ #pragma once @@ -23,6 +24,7 @@ #include "Argument.h" #include "ReturnValue.h" +#include "TypeAttributesTable.h" namespace wrap { @@ -50,7 +52,7 @@ struct StaticMethod { void proxy_wrapper_fragments(FileWriter& proxyFile, FileWriter& wrapperFile, const std::string& cppClassName, const std::string& matlabClassName, const std::string& wrapperName, const std::vector& using_namespaces, - const ReturnValue::TypeAttributesTable& typeAttributes, + const TypeAttributesTable& typeAttributes, std::vector& functionNames) const; private: @@ -60,7 +62,7 @@ private: int overload, int id, const std::vector& using_namespaces, - const ReturnValue::TypeAttributesTable& typeAttributes) const; ///< cpp wrapper + const TypeAttributesTable& typeAttributes) const; ///< cpp wrapper }; } // \namespace wrap diff --git a/wrap/matlab.h b/wrap/matlab.h index a3a2f0147..d3fb9f926 100644 --- a/wrap/matlab.h +++ b/wrap/matlab.h @@ -14,6 +14,9 @@ * @brief header file to be included in MATLAB wrappers * @date 2008 * @author Frank Dellaert + * @author Alex Cunningham + * @author Andrew Melim + * @author Richard Roberts * * wrapping and unwrapping is done using specialized templates, see * http://www.cplusplus.com/doc/tutorial/templates.html diff --git a/wrap/utilities.cpp b/wrap/utilities.cpp index 5f0db4248..9c5d93c76 100644 --- a/wrap/utilities.cpp +++ b/wrap/utilities.cpp @@ -13,6 +13,7 @@ * @file utilities.ccp * @author Frank Dellaert * @author Andrew Melim + * @author Richard Roberts **/ #include diff --git a/wrap/utilities.h b/wrap/utilities.h index dced5808c..0a252484f 100644 --- a/wrap/utilities.h +++ b/wrap/utilities.h @@ -13,6 +13,7 @@ * @file utilities.h * @author Frank Dellaert * @author Andrew Melim + * @author Richard Roberts **/ #pragma once