diff options
| author | Dan Goodliffe <randomdan@riogrande.random.lan> | 2014-11-23 00:58:45 +0000 |
|---|---|---|
| committer | Dan Goodliffe <randomdan@riogrande.random.lan> | 2014-11-23 00:58:45 +0000 |
| commit | ca76d111a640c4818d702f69632b059b0fc1f276 (patch) | |
| tree | 13fd0f388d5dbaaf2670a0bd8b788381918667a8 /project2/ice/slice2Type.cpp | |
| parent | Renamed things to avoid conflicts of names (diff) | |
| download | project2-ca76d111a640c4818d702f69632b059b0fc1f276.tar.bz2 project2-ca76d111a640c4818d702f69632b059b0fc1f276.tar.xz project2-ca76d111a640c4818d702f69632b059b0fc1f276.zip | |
Switched to slicer internals, added more tests
Diffstat (limited to 'project2/ice/slice2Type.cpp')
| -rw-r--r-- | project2/ice/slice2Type.cpp | 110 |
1 files changed, 0 insertions, 110 deletions
diff --git a/project2/ice/slice2Type.cpp b/project2/ice/slice2Type.cpp deleted file mode 100644 index 9c3404e..0000000 --- a/project2/ice/slice2Type.cpp +++ /dev/null @@ -1,110 +0,0 @@ -#include <pch.hpp> -#include "slice2Type.h" -#include <Slice/CPlusPlusUtil.h> -#include <boost/foreach.hpp> - -Slice2Type::Slice2Type(FILE * c) : - code(c) -{ -} - -bool -Slice2Type::visitModuleStart(const Slice::ModulePtr & m) -{ - module = m->name(); - return true; -} - -void -Slice2Type::visitModuleEnd(const Slice::ModulePtr &) -{ - module.clear(); -} - -void -Slice2Type::visitClassDecl(const Slice::ClassDeclPtr&) -{ -} - -bool -Slice2Type::visitExceptionStart(const Slice::ExceptionPtr & e) -{ - if (e->hasMetaData("project2:type")) { - fprintf(code, "template <>\nvoid IceType< %s::%s >::ForEachDataMember(const %s::%s & obj, const IceEachDataMemberValue & func)\n{\n", - module.c_str(), e->name().c_str(), - module.c_str(), e->name().c_str()); - membersToVariables(e->dataMembers(), "obj."); - fprintf(code, "}\n\n"); - - fprintf(code, "template <>\nvoid IceType< %s::%s >::CreateColumns(const IceEachDataMemberName & func)\n{\n", - module.c_str(), e->name().c_str()); - membersToColumns(e->dataMembers()); - fprintf(code, "}\n\n"); - } - return false; -} - -bool -Slice2Type::visitClassDefStart(const Slice::ClassDefPtr & c) -{ - if (c->hasMetaData("project2:type")) { - fprintf(code, "template <>\nvoid IceType< IceInternal::Handle< %s::%s > >::ForEachDataMember(const IceInternal::Handle< %s::%s > & ptr, const IceEachDataMemberValue & func)\n{\n", - module.c_str(), c->name().c_str(), - module.c_str(), c->name().c_str()); - membersToVariables(c->dataMembers(), "ptr->"); - fprintf(code, "}\n\n"); - - fprintf(code, "template <>\nvoid IceType< IceInternal::Handle< %s::%s > >::CreateColumns(const IceEachDataMemberName & func)\n{\n", - module.c_str(), c->name().c_str()); - membersToColumns(c->dataMembers()); - fprintf(code, "}\n\n"); - } - return false; -} - -bool -Slice2Type::visitStructStart(const Slice::StructPtr & s) -{ - if (s->hasMetaData("project2:type")) { - fprintf(code, "template <>\nvoid IceType< %s::%s >::ForEachDataMember(const %s::%s & obj, const IceEachDataMemberValue & func)\n{\n", - module.c_str(), s->name().c_str(), - module.c_str(), s->name().c_str()); - membersToVariables(s->dataMembers(), "obj."); - fprintf(code, "}\n\n"); - - fprintf(code, "template <>\nvoid IceType< %s::%s >::CreateColumns(const IceEachDataMemberName & func)\n{\n", - module.c_str(), s->name().c_str()); - membersToColumns(s->dataMembers()); - fprintf(code, "}\n\n"); - } - return false; -} - -void -Slice2Type::membersToVariables(const Slice::DataMemberList & members, const std::string & access) const -{ - BOOST_FOREACH(const auto & m, members) { - if (m->optional()) { - fprintf(code, "\tfunc(IceConvert< IceUtil::Optional< %s> >::ToVariable(%s%s));\n", - Slice::typeToString(m->type()).c_str(), - access.c_str(), - m->name().c_str()); - } - else { - fprintf(code, "\tfunc(IceConvert< %s >::ToVariable(%s%s));\n", - Slice::typeToString(m->type()).c_str(), - access.c_str(), - m->name().c_str()); - } - } -} - -void -Slice2Type::membersToColumns(const Slice::DataMemberList & members) const -{ - BOOST_FOREACH(const auto & m, members) { - fprintf(code, "\tfunc(\"%s\");\n", - m->name().c_str()); - } -} - |
