Some additional cleanup in wrap

release/4.3a0
Alex Cunningham 2012-07-23 18:24:39 +00:00
parent 5d008d43fa
commit 79c9bc99ff
8 changed files with 24 additions and 25 deletions

View File

@ -48,6 +48,10 @@
* - All includes will be collected and added in a single file
* - All namespaces must have angle brackets: <path>
* - 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
*/

View File

@ -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<namespaces.size(); ++i) {
result += " }";
}
return result;

View File

@ -121,17 +121,7 @@ void GlobalFunction::generateSingleFunction(const std::string& toolboxPath, cons
// start
wrapperFile.oss << "{\n";
if(returnVal.isPair)
{
if(returnVal.category1 == ReturnValue::CLASS)
wrapperFile.oss << " typedef boost::shared_ptr<" << returnVal.qualifiedType1("::") << "> 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

View File

@ -40,7 +40,6 @@ struct Module {
std::vector<Class> classes; ///< list of classes
std::vector<TemplateInstantiationTypedef> templateInstantiationTypedefs; ///< list of template instantiations
bool verbose; ///< verbose flag
// std::vector<std::string> using_namespaces; ///< all default namespaces
std::vector<ForwardDeclaration> forward_declarations;
std::vector<std::string> includes; ///< Include statements
GlobalFunctions global_functions;

View File

@ -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;
}
}
/* ************************************************************************* */

View File

@ -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

View File

@ -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;