From 14c5f205dd20db12164f5588b356ac407b15e33d Mon Sep 17 00:00:00 2001 From: Alex Cunningham Date: Wed, 19 Jun 2013 17:50:00 +0000 Subject: [PATCH] basic serialization works --- wrap/Class.cpp | 23 +++++++++++++---------- wrap/Class.h | 6 ++++-- wrap/tests/expected/Point3.m | 2 +- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/wrap/Class.cpp b/wrap/Class.cpp index 38aef00a1..8bc6ac38d 100644 --- a/wrap/Class.cpp +++ b/wrap/Class.cpp @@ -112,7 +112,7 @@ void Class::matlab_proxy(const string& toolboxPath, const string& wrapperName, wrapperFile.oss << "\n"; } if (isSerializable) - serialization_fragments(proxyFile, wrapperFile, functionNames); + serialization_fragments(proxyFile, wrapperFile, wrapperName, functionNames); proxyFile.oss << " end\n"; proxyFile.oss << "\n"; @@ -126,7 +126,7 @@ void Class::matlab_proxy(const string& toolboxPath, const string& wrapperName, wrapperFile.oss << "\n"; } if (isSerializable) - deserialization_fragments(proxyFile, wrapperFile, functionNames); + deserialization_fragments(proxyFile, wrapperFile, wrapperName, functionNames); proxyFile.oss << " end\n"; proxyFile.oss << "end\n"; @@ -401,10 +401,10 @@ void Class::comment_fragment(FileWriter& proxyFile) const { proxyFile.oss << "%\n"; } -/* ************************************************************************* */ -void Class::serialization_fragments(FileWriter& proxyFile, - FileWriter& wrapperFile, std::vector& functionNames) const { +/* ************************************************************************* */ +void Class::serialization_fragments(FileWriter& proxyFile, FileWriter& wrapperFile, + const std::string& wrapperName, std::vector& functionNames) const { //void Point3_string_serialize_17(int nargout, mxArray *out[], int nargin, const mxArray *in[]) //{ @@ -463,14 +463,16 @@ void Class::serialization_fragments(FileWriter& proxyFile, proxyFile.oss << " % STRING_SERIALIZE usage: string_serialize() : returns string\n"; proxyFile.oss << " % Doxygen can be found at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html\n"; proxyFile.oss << " if length(varargin) == 0\n"; - proxyFile.oss << " varargout{1} = geometry_wrapper(" << boost::lexical_cast(serialize_id) << ", this, varargin{:});\n"; + proxyFile.oss << " varargout{1} = " << wrapperName << "(" << boost::lexical_cast(serialize_id) << ", this, varargin{:});\n"; proxyFile.oss << " else\n"; proxyFile.oss << " error('Arguments do not match any overload of function " << matlabQualName << ".string_serialize');\n"; proxyFile.oss << " end\n"; proxyFile.oss << " end\n"; } -void Class::deserialization_fragments(FileWriter& proxyFile, FileWriter& wrapperFile, std::vector& functionNames) const { +/* ************************************************************************* */ +void Class::deserialization_fragments(FileWriter& proxyFile, FileWriter& wrapperFile, + const std::string& wrapperName, std::vector& functionNames) const { //void Point3_string_deserialize_18(int nargout, mxArray *out[], int nargin, const mxArray *in[]) //{ // typedef boost::shared_ptr Shared; @@ -511,7 +513,7 @@ void Class::deserialization_fragments(FileWriter& proxyFile, FileWriter& wrapper // function varargout = string_deserialize(varargin) // % STRING_DESERIALIZE usage: string_deserialize() : returns Point3 // % Doxygen can be found at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html -// if length(varargin) == 0 +// if length(varargin) == 1 // varargout{1} = geometry_wrapper(18, varargin{:}); // else // error('Arguments do not match any overload of function Point3.string_deserialize'); @@ -521,10 +523,11 @@ void Class::deserialization_fragments(FileWriter& proxyFile, FileWriter& wrapper proxyFile.oss << " function varargout = string_deserialize(varargin)\n"; proxyFile.oss << " % STRING_DESERIALIZE usage: string_deserialize() : returns " << matlabQualName << "\n"; proxyFile.oss << " % Doxygen can be found at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html\n"; - proxyFile.oss << " if length(varargin) == 0\n"; - proxyFile.oss << " varargout{1} = geometry_wrapper(" << boost::lexical_cast(deserialize_id) << ", varargin{:});\n"; + proxyFile.oss << " if length(varargin) == 1\n"; + proxyFile.oss << " varargout{1} = " << wrapperName << "(" << boost::lexical_cast(deserialize_id) << ", varargin{:});\n"; proxyFile.oss << " else\n"; proxyFile.oss << " error('Arguments do not match any overload of function " << matlabQualName << ".string_deserialize');\n"; proxyFile.oss << " end\n"; proxyFile.oss << " end\n\n"; } +/* ************************************************************************* */ diff --git a/wrap/Class.h b/wrap/Class.h index 7e3dfd221..d33124e50 100644 --- a/wrap/Class.h +++ b/wrap/Class.h @@ -67,10 +67,12 @@ struct Class { std::string getTypedef() const; // Creates a member function that performs serialization - void serialization_fragments(FileWriter& proxyFile, FileWriter& wrapperFile, std::vector& functionNames) const; + void serialization_fragments(FileWriter& proxyFile, FileWriter& wrapperFile, + const std::string& wrapperName, std::vector& functionNames) const; // Creates a static member function that performs deserialization - void deserialization_fragments(FileWriter& proxyFile, FileWriter& wrapperFile, std::vector& functionNames) const; + void deserialization_fragments(FileWriter& proxyFile, FileWriter& wrapperFile, + const std::string& wrapperName, std::vector& functionNames) const; private: void pointer_constructor_fragments(FileWriter& proxyFile, FileWriter& wrapperFile, const std::string& wrapperName, std::vector& functionNames) const; diff --git a/wrap/tests/expected/Point3.m b/wrap/tests/expected/Point3.m index 385bfeabb..e0681ab41 100644 --- a/wrap/tests/expected/Point3.m +++ b/wrap/tests/expected/Point3.m @@ -93,7 +93,7 @@ classdef Point3 < handle function varargout = string_deserialize(varargin) % STRING_DESERIALIZE usage: string_deserialize() : returns Point3 % Doxygen can be found at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html - if length(varargin) == 0 + if length(varargin) == 1 varargout{1} = geometry_wrapper(18, varargin{:}); else error('Arguments do not match any overload of function Point3.string_deserialize');