Simplified expand
parent
b8d9d5b6ca
commit
8ab83a7cff
|
@ -250,7 +250,7 @@ void Class::pointer_constructor_fragments(FileWriter& proxyFile,
|
||||||
vector<ArgumentList> expandArgumentListsTemplate(
|
vector<ArgumentList> expandArgumentListsTemplate(
|
||||||
const vector<ArgumentList>& argLists, const string& templateArg,
|
const vector<ArgumentList>& argLists, const string& templateArg,
|
||||||
const vector<string>& instName,
|
const vector<string>& instName,
|
||||||
const std::vector<string>& expandedClassNamespace,
|
const vector<string>& expandedClassNamespace,
|
||||||
const string& expandedClassName) {
|
const string& expandedClassName) {
|
||||||
vector<ArgumentList> result;
|
vector<ArgumentList> result;
|
||||||
BOOST_FOREACH(const ArgumentList& argList, argLists) {
|
BOOST_FOREACH(const ArgumentList& argList, argLists) {
|
||||||
|
@ -276,7 +276,7 @@ vector<ArgumentList> expandArgumentListsTemplate(
|
||||||
template<class METHOD>
|
template<class METHOD>
|
||||||
map<string, METHOD> expandMethodTemplate(const map<string, METHOD>& methods,
|
map<string, METHOD> expandMethodTemplate(const map<string, METHOD>& methods,
|
||||||
const string& templateArg, const vector<string>& instName,
|
const string& templateArg, const vector<string>& instName,
|
||||||
const std::vector<string>& expandedClassNamespace,
|
const vector<string>& expandedClassNamespace,
|
||||||
const string& expandedClassName) {
|
const string& expandedClassName) {
|
||||||
map<string, METHOD> result;
|
map<string, METHOD> result;
|
||||||
typedef pair<const string, METHOD> Name_Method;
|
typedef pair<const string, METHOD> Name_Method;
|
||||||
|
@ -312,30 +312,20 @@ map<string, METHOD> expandMethodTemplate(const map<string, METHOD>& methods,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
Class expandClassTemplate(const Class& cls, const string& templateArg,
|
Class Class::expandTemplate(const string& templateArg,
|
||||||
const vector<string>& instName,
|
const vector<string>& instName,
|
||||||
const std::vector<string>& expandedClassNamespace,
|
const vector<string>& expandedClassNamespace,
|
||||||
const string& expandedClassName) {
|
const string& expandedClassName) const {
|
||||||
Class inst;
|
Class inst = *this;
|
||||||
inst.name = cls.name;
|
inst.methods = expandMethodTemplate(methods, templateArg, instName,
|
||||||
inst.templateArgs = cls.templateArgs;
|
|
||||||
inst.typedefName = cls.typedefName;
|
|
||||||
inst.isVirtual = cls.isVirtual;
|
|
||||||
inst.isSerializable = cls.isSerializable;
|
|
||||||
inst.qualifiedParent = cls.qualifiedParent;
|
|
||||||
inst.methods = expandMethodTemplate(cls.methods, templateArg, instName,
|
|
||||||
expandedClassNamespace, expandedClassName);
|
expandedClassNamespace, expandedClassName);
|
||||||
inst.static_methods = expandMethodTemplate(cls.static_methods, templateArg,
|
inst.static_methods = expandMethodTemplate(static_methods, templateArg,
|
||||||
instName, expandedClassNamespace, expandedClassName);
|
instName, expandedClassNamespace, expandedClassName);
|
||||||
inst.namespaces = cls.namespaces;
|
|
||||||
inst.constructor = cls.constructor;
|
|
||||||
inst.constructor.args_list = expandArgumentListsTemplate(
|
inst.constructor.args_list = expandArgumentListsTemplate(
|
||||||
cls.constructor.args_list, templateArg, instName, expandedClassNamespace,
|
constructor.args_list, templateArg, instName, expandedClassNamespace,
|
||||||
expandedClassName);
|
expandedClassName);
|
||||||
inst.constructor.name = inst.name;
|
inst.constructor.name = inst.name;
|
||||||
inst.deconstructor = cls.deconstructor;
|
|
||||||
inst.deconstructor.name = inst.name;
|
inst.deconstructor.name = inst.name;
|
||||||
inst.verbose_ = cls.verbose_;
|
|
||||||
return inst;
|
return inst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,8 +335,8 @@ vector<Class> Class::expandTemplate(const string& templateArg,
|
||||||
vector<Class> result;
|
vector<Class> result;
|
||||||
BOOST_FOREACH(const vector<string>& instName, instantiations) {
|
BOOST_FOREACH(const vector<string>& instName, instantiations) {
|
||||||
const string expandedName = name + instName.back();
|
const string expandedName = name + instName.back();
|
||||||
Class inst = expandClassTemplate(*this, templateArg, instName,
|
Class inst = expandTemplate(templateArg, instName, namespaces,
|
||||||
this->namespaces, expandedName);
|
expandedName);
|
||||||
inst.name = expandedName;
|
inst.name = expandedName;
|
||||||
inst.templateArgs.clear();
|
inst.templateArgs.clear();
|
||||||
inst.typedefName = qualifiedName("::") + "<"
|
inst.typedefName = qualifiedName("::") + "<"
|
||||||
|
@ -357,16 +347,7 @@ vector<Class> Class::expandTemplate(const string& templateArg,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
Class Class::expandTemplate(const string& templateArg,
|
string Class::getTypedef() const {
|
||||||
const vector<string>& instantiation,
|
|
||||||
const std::vector<string>& expandedClassNamespace,
|
|
||||||
const string& expandedClassName) const {
|
|
||||||
return expandClassTemplate(*this, templateArg, instantiation,
|
|
||||||
expandedClassNamespace, expandedClassName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ************************************************************************* */
|
|
||||||
std::string Class::getTypedef() const {
|
|
||||||
string result;
|
string result;
|
||||||
BOOST_FOREACH(const string& namesp, namespaces) {
|
BOOST_FOREACH(const string& namesp, namespaces) {
|
||||||
result += ("namespace " + namesp + " { ");
|
result += ("namespace " + namesp + " { ");
|
||||||
|
@ -429,15 +410,15 @@ void Class::comment_fragment(FileWriter& proxyFile) const {
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
void Class::serialization_fragments(FileWriter& proxyFile,
|
void Class::serialization_fragments(FileWriter& proxyFile,
|
||||||
FileWriter& wrapperFile, const std::string& wrapperName,
|
FileWriter& wrapperFile, const string& wrapperName,
|
||||||
std::vector<std::string>& functionNames) const {
|
vector<string>& functionNames) const {
|
||||||
|
|
||||||
//void Point3_string_serialize_17(int nargout, mxArray *out[], int nargin, const mxArray *in[])
|
//void Point3_string_serialize_17(int nargout, mxArray *out[], int nargin, const mxArray *in[])
|
||||||
//{
|
//{
|
||||||
// typedef boost::shared_ptr<Point3> Shared;
|
// typedef boost::shared_ptr<Point3> Shared;
|
||||||
// checkArguments("string_serialize",nargout,nargin-1,0);
|
// checkArguments("string_serialize",nargout,nargin-1,0);
|
||||||
// Shared obj = unwrap_shared_ptr<Point3>(in[0], "ptr_Point3");
|
// Shared obj = unwrap_shared_ptr<Point3>(in[0], "ptr_Point3");
|
||||||
// std::ostringstream out_archive_stream;
|
// ostringstream out_archive_stream;
|
||||||
// boost::archive::text_oarchive out_archive(out_archive_stream);
|
// boost::archive::text_oarchive out_archive(out_archive_stream);
|
||||||
// out_archive << *obj;
|
// out_archive << *obj;
|
||||||
// out[0] = wrap< string >(out_archive_stream.str());
|
// out[0] = wrap< string >(out_archive_stream.str());
|
||||||
|
@ -469,7 +450,7 @@ void Class::serialization_fragments(FileWriter& proxyFile,
|
||||||
<< ">(in[0], \"ptr_" << matlabUniqueName << "\");" << endl;
|
<< ">(in[0], \"ptr_" << matlabUniqueName << "\");" << endl;
|
||||||
|
|
||||||
// Serialization boilerplate
|
// Serialization boilerplate
|
||||||
wrapperFile.oss << " std::ostringstream out_archive_stream;\n";
|
wrapperFile.oss << " ostringstream out_archive_stream;\n";
|
||||||
wrapperFile.oss
|
wrapperFile.oss
|
||||||
<< " boost::archive::text_oarchive out_archive(out_archive_stream);\n";
|
<< " boost::archive::text_oarchive out_archive(out_archive_stream);\n";
|
||||||
wrapperFile.oss << " out_archive << *obj;\n";
|
wrapperFile.oss << " out_archive << *obj;\n";
|
||||||
|
@ -520,14 +501,14 @@ void Class::serialization_fragments(FileWriter& proxyFile,
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
void Class::deserialization_fragments(FileWriter& proxyFile,
|
void Class::deserialization_fragments(FileWriter& proxyFile,
|
||||||
FileWriter& wrapperFile, const std::string& wrapperName,
|
FileWriter& wrapperFile, const string& wrapperName,
|
||||||
std::vector<std::string>& functionNames) const {
|
vector<string>& functionNames) const {
|
||||||
//void Point3_string_deserialize_18(int nargout, mxArray *out[], int nargin, const mxArray *in[])
|
//void Point3_string_deserialize_18(int nargout, mxArray *out[], int nargin, const mxArray *in[])
|
||||||
//{
|
//{
|
||||||
// typedef boost::shared_ptr<Point3> Shared;
|
// typedef boost::shared_ptr<Point3> Shared;
|
||||||
// checkArguments("Point3.string_deserialize",nargout,nargin,1);
|
// checkArguments("Point3.string_deserialize",nargout,nargin,1);
|
||||||
// string serialized = unwrap< string >(in[0]);
|
// string serialized = unwrap< string >(in[0]);
|
||||||
// std::istringstream in_archive_stream(serialized);
|
// istringstream in_archive_stream(serialized);
|
||||||
// boost::archive::text_iarchive in_archive(in_archive_stream);
|
// boost::archive::text_iarchive in_archive(in_archive_stream);
|
||||||
// Shared output(new Point3());
|
// Shared output(new Point3());
|
||||||
// in_archive >> *output;
|
// in_archive >> *output;
|
||||||
|
@ -553,7 +534,7 @@ void Class::deserialization_fragments(FileWriter& proxyFile,
|
||||||
|
|
||||||
// string argument with deserialization boilerplate
|
// string argument with deserialization boilerplate
|
||||||
wrapperFile.oss << " string serialized = unwrap< string >(in[0]);\n";
|
wrapperFile.oss << " string serialized = unwrap< string >(in[0]);\n";
|
||||||
wrapperFile.oss << " std::istringstream in_archive_stream(serialized);\n";
|
wrapperFile.oss << " istringstream in_archive_stream(serialized);\n";
|
||||||
wrapperFile.oss
|
wrapperFile.oss
|
||||||
<< " boost::archive::text_iarchive in_archive(in_archive_stream);\n";
|
<< " boost::archive::text_iarchive in_archive(in_archive_stream);\n";
|
||||||
wrapperFile.oss << " Shared output(new " << cppClassName << "());\n";
|
wrapperFile.oss << " Shared output(new " << cppClassName << "());\n";
|
||||||
|
@ -604,7 +585,7 @@ void Class::deserialization_fragments(FileWriter& proxyFile,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
std::string Class::getSerializationExport() const {
|
string Class::getSerializationExport() const {
|
||||||
//BOOST_CLASS_EXPORT_GUID(gtsam::SharedDiagonal, "gtsamSharedDiagonal");
|
//BOOST_CLASS_EXPORT_GUID(gtsam::SharedDiagonal, "gtsamSharedDiagonal");
|
||||||
return "BOOST_CLASS_EXPORT_GUID(" + qualifiedName("::") + ", \""
|
return "BOOST_CLASS_EXPORT_GUID(" + qualifiedName("::") + ", \""
|
||||||
+ qualifiedName() + "\");";
|
+ qualifiedName() + "\");";
|
||||||
|
|
|
@ -59,9 +59,13 @@ struct Class {
|
||||||
|
|
||||||
std::string qualifiedName(const std::string& delim = "") const; ///< creates a namespace-qualified name, optional delimiter
|
std::string qualifiedName(const std::string& delim = "") const; ///< creates a namespace-qualified name, optional delimiter
|
||||||
|
|
||||||
std::vector<Class> expandTemplate(const std::string& templateArg, const std::vector<std::vector<std::string> >& instantiations) const;
|
Class expandTemplate(const std::string& templateArg,
|
||||||
|
const std::vector<std::string>& instantiation,
|
||||||
|
const std::vector<std::string>& expandedClassNamespace,
|
||||||
|
const std::string& expandedClassName) const;
|
||||||
|
|
||||||
Class expandTemplate(const std::string& templateArg, const std::vector<std::string>& instantiation, const std::vector<std::string>& expandedClassNamespace, const std::string& expandedClassName) const;
|
std::vector<Class> expandTemplate(const std::string& templateArg,
|
||||||
|
const std::vector<std::vector<std::string> >& instantiations) const;
|
||||||
|
|
||||||
// The typedef line for this class, if this class is a typedef, otherwise returns an empty string.
|
// The typedef line for this class, if this class is a typedef, otherwise returns an empty string.
|
||||||
std::string getTypedef() const;
|
std::string getTypedef() const;
|
||||||
|
|
Loading…
Reference in New Issue