diff --git a/gtsam.h b/gtsam.h index 120d585aa..04d6b7e9b 100644 --- a/gtsam.h +++ b/gtsam.h @@ -48,6 +48,10 @@ * - All includes will be collected and added in a single file * - All namespaces must have angle brackets: * - No default includes will be added + * Global/Namespace functions + * - Functions specified outside of a class are global + * - Can be overloaded with different arguments + * - Can have multiple functions of the same name in different namespaces * Using classes defined in other modules * - If you are using a class 'OtherClass' not wrapped in this definition file, add "class OtherClass;" to avoid a dependency error * Virtual inheritance @@ -74,7 +78,6 @@ /** * Status: - * - TODO: global functions * - TODO: default values for arguments * - TODO: Handle gtsam::Rot3M conversions to quaternions */ diff --git a/wrap/Class.cpp b/wrap/Class.cpp index 749a61707..5110ab6cd 100644 --- a/wrap/Class.cpp +++ b/wrap/Class.cpp @@ -308,7 +308,7 @@ std::string Class::getTypedef() const { result += ("namespace " + namesp + " { "); } result += ("typedef " + typedefName + " " + name + ";"); - BOOST_FOREACH(const string& namesp, namespaces) { + for (size_t i = 0; i Shared" << returnVal.type1 << ";"<< endl; - if(returnVal.category2 == ReturnValue::CLASS) - wrapperFile.oss << " typedef boost::shared_ptr<" << returnVal.qualifiedType2("::") << "> Shared" << returnVal.type2 << ";"<< endl; - } - else { - if (returnVal.category1 == ReturnValue::CLASS) - wrapperFile.oss << " typedef boost::shared_ptr<" << returnVal.qualifiedType1("::") << "> Shared" << returnVal.type1 << ";"<< endl; - } + returnVal.wrapTypeUnwrap(wrapperFile); // check arguments // NOTE: for static functions, there is no object passed diff --git a/wrap/GlobalFunction.h b/wrap/GlobalFunction.h index e281e6a6d..37a70df2a 100644 --- a/wrap/GlobalFunction.h +++ b/wrap/GlobalFunction.h @@ -24,7 +24,7 @@ struct GlobalFunction { // each overload, regardless of namespace std::vector argLists; ///< arugments for each overload std::vector returnVals; ///< returnVals for each overload - std::vector namespaces; ///< Stack of namespaces + std::vector namespaces; ///< Stack of namespaces // Constructor only used in Module GlobalFunction(bool verbose = true) : verbose_(verbose) {} diff --git a/wrap/Module.h b/wrap/Module.h index a2c77bc9e..ca8b0bb1a 100644 --- a/wrap/Module.h +++ b/wrap/Module.h @@ -40,7 +40,6 @@ struct Module { std::vector classes; ///< list of classes std::vector templateInstantiationTypedefs; ///< list of template instantiations bool verbose; ///< verbose flag -// std::vector using_namespaces; ///< all default namespaces std::vector forward_declarations; std::vector includes; ///< Include statements GlobalFunctions global_functions; diff --git a/wrap/ReturnValue.cpp b/wrap/ReturnValue.cpp index c209a3131..37e6b15ff 100644 --- a/wrap/ReturnValue.cpp +++ b/wrap/ReturnValue.cpp @@ -122,5 +122,19 @@ void ReturnValue::wrap_result(const string& result, FileWriter& file, const Type } /* ************************************************************************* */ +void ReturnValue::wrapTypeUnwrap(FileWriter& wrapperFile) const { + if(isPair) + { + if(category1 == ReturnValue::CLASS) + wrapperFile.oss << " typedef boost::shared_ptr<" << qualifiedType1("::") << "> Shared" << type1 << ";"<< endl; + if(category2 == ReturnValue::CLASS) + wrapperFile.oss << " typedef boost::shared_ptr<" << qualifiedType2("::") << "> Shared" << type2 << ";"<< endl; + } + else { + if (category1 == ReturnValue::CLASS) + wrapperFile.oss << " typedef boost::shared_ptr<" << qualifiedType1("::") << "> Shared" << type1 << ";"<< endl; + } +} +/* ************************************************************************* */ diff --git a/wrap/ReturnValue.h b/wrap/ReturnValue.h index 8ff5d712b..2bffef680 100644 --- a/wrap/ReturnValue.h +++ b/wrap/ReturnValue.h @@ -52,6 +52,8 @@ struct ReturnValue { void wrap_result(const std::string& result, FileWriter& file, const TypeAttributesTable& typeAttributes) const; + void wrapTypeUnwrap(FileWriter& wrapperFile) const; + }; } // \namespace wrap diff --git a/wrap/StaticMethod.cpp b/wrap/StaticMethod.cpp index f123a31ac..ed80d7890 100644 --- a/wrap/StaticMethod.cpp +++ b/wrap/StaticMethod.cpp @@ -123,16 +123,7 @@ string StaticMethod::wrapper_fragment(FileWriter& file, file.oss << "{\n"; generateUsingNamespace(file, using_namespaces); - if(returnVal.isPair) - { - if(returnVal.category1 == ReturnValue::CLASS) - file.oss << " typedef boost::shared_ptr<" << returnVal.qualifiedType1("::") << "> Shared" << returnVal.type1 << ";"<< endl; - if(returnVal.category2 == ReturnValue::CLASS) - file.oss << " typedef boost::shared_ptr<" << returnVal.qualifiedType2("::") << "> Shared" << returnVal.type2 << ";"<< endl; - } - else - if(returnVal.category1 == ReturnValue::CLASS) - file.oss << " typedef boost::shared_ptr<" << returnVal.qualifiedType1("::") << "> Shared" << returnVal.type1 << ";"<< endl; + returnVal.wrapTypeUnwrap(file); file.oss << " typedef boost::shared_ptr<" << cppClassName << "> Shared;" << endl;