From f92d61814158825e7cbf71eefaac6d79373167fb Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 26 Jan 2015 01:16:21 +0000 Subject: Explicitly implement the auto modelpart deduction templates --- slicer/slicer/modelParts.h | 13 ------------- slicer/slicer/parser.cpp | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/slicer/slicer/modelParts.h b/slicer/slicer/modelParts.h index a28de0c..5b1e634 100644 --- a/slicer/slicer/modelParts.h +++ b/slicer/slicer/modelParts.h @@ -664,19 +664,6 @@ namespace Slicer { static std::string pairName; static Metadata metadata; }; - - // Templates for automatically determining a model part implementation -#define templateMODELPARTFOR(Type, ModelPart) \ - template ModelPartPtr ModelPartFor(Type & t) { return new ModelPart< Type >(t); } \ - template ModelPartPtr ModelPartFor(Type * t) { return new ModelPart< Type >(t); } - templateMODELPARTFOR(IceInternal::Handle, ModelPartForClass); - templateMODELPARTFOR(std::vector, ModelPartForSequence); - templateMODELPARTFOR(std::list, ModelPartForSequence); - template ModelPartPtr ModelPartFor(std::map & t) { return new ModelPartForDictionary< std::map >(t); } \ - template ModelPartPtr ModelPartFor(std::map * t) { return new ModelPartForDictionary< std::map >(t); } \ - // Everything else is a struct? - templateMODELPARTFOR(T, ModelPartForStruct); -#undef templateMODELPARTFOR } #endif diff --git a/slicer/slicer/parser.cpp b/slicer/slicer/parser.cpp index d2d05a2..a4ee2dd 100644 --- a/slicer/slicer/parser.cpp +++ b/slicer/slicer/parser.cpp @@ -89,6 +89,9 @@ namespace Slicer { fprintf(cpp, "// Begin Slicer code\n\n"); fprintf(cpp, "#include <%s>\n\n", fs::change_extension(topLevelFile.filename(), ".h").string().c_str()); fprintf(cpp, "#include \n\n"); + fprintf(cpp, "#define templateMODELPARTFOR(Type, ModelPart) \\\n"); + fprintf(cpp, "template <> ModelPartPtr ModelPartFor(Type & t) { return new ModelPart< Type >(t); } \\\n"); + fprintf(cpp, "template <> ModelPartPtr ModelPartFor(Type * t) { return new ModelPart< Type >(t); }\n\n"); fprintf(cpp, "namespace Slicer {\n"); return true; } @@ -188,6 +191,9 @@ namespace Slicer { c->scoped().c_str()); copyMetadata(c->getMetaData()); + fprintf(cpp, "templateMODELPARTFOR(::IceInternal::Handle< %s >, ModelPartForClass);\n\n", + c->scoped().c_str()); + classNo += 1; return true; @@ -212,6 +218,9 @@ namespace Slicer { c->scoped().c_str()); copyMetadata(c->getMetaData()); + fprintf(cpp, "templateMODELPARTFOR(%s, ModelPartForStruct);\n\n", + c->scoped().c_str()); + return true; } @@ -325,6 +334,9 @@ namespace Slicer { fprintf(cpp, "template<>\nMetadata ModelPartForSequence< %s >::metadata ", s->scoped().c_str()); copyMetadata(s->getMetaData()); + + fprintf(cpp, "templateMODELPARTFOR(%s, ModelPartForSequence);\n\n", + s->scoped().c_str()); } void @@ -392,6 +404,9 @@ namespace Slicer { Slice::typeToString(vtype).c_str(), d->scoped().c_str(), d->scoped().c_str()); + + fprintf(cpp, "templateMODELPARTFOR(%s, ModelPartForDictionary);\n\n", + d->scoped().c_str()); } void -- cgit v1.2.3