summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--slicer/slicer/modelPartsTypes.h2
-rw-r--r--slicer/slicer/modelPartsTypes.impl.h6
-rw-r--r--slicer/tool/parser.cpp3
3 files changed, 9 insertions, 2 deletions
diff --git a/slicer/slicer/modelPartsTypes.h b/slicer/slicer/modelPartsTypes.h
index 5dae7bf..886dcb0 100644
--- a/slicer/slicer/modelPartsTypes.h
+++ b/slicer/slicer/modelPartsTypes.h
@@ -168,6 +168,8 @@ namespace Slicer {
virtual IceUtil::Optional<std::string> GetTypeIdProperty() const override;
static const std::string typeIdProperty;
+
+ static ModelPartPtr CreateModelPart(void *);
};
template<typename T>
diff --git a/slicer/slicer/modelPartsTypes.impl.h b/slicer/slicer/modelPartsTypes.impl.h
index c34b482..2ed8996 100644
--- a/slicer/slicer/modelPartsTypes.impl.h
+++ b/slicer/slicer/modelPartsTypes.impl.h
@@ -298,6 +298,12 @@ namespace Slicer {
return typeIdProperty;
}
+ template<typename T>
+ ModelPartPtr ModelPartForClass<T>::CreateModelPart(void * p)
+ {
+ return new ModelPartForClass<T>(*static_cast<T *>(p));
+ }
+
// ModelPartForStruct
template<typename T>
ModelPartForStruct<T>::ModelPartForStruct(T & o) :
diff --git a/slicer/tool/parser.cpp b/slicer/tool/parser.cpp
index 7613ab6..50f7408 100644
--- a/slicer/tool/parser.cpp
+++ b/slicer/tool/parser.cpp
@@ -197,9 +197,8 @@ namespace Slicer {
auto typeName = metaDataValue("slicer:typename:", c->getMetaData());
fprintbf(cpp, "static void registerClass_%u() __attribute__ ((constructor(210)));\n", classNo);
fprintbf(cpp, "static void registerClass_%u()\n{\n", classNo);
- fprintbf(cpp, "\tSlicer::classRefMap()->insert({ \"%s\", [](void * p){ return new ModelPartForClass< %s >(*static_cast< %s *>(p)); } });\n",
+ fprintbf(cpp, "\tSlicer::classRefMap()->insert({ \"%s\", &ModelPartForClass< %s >::CreateModelPart });\n",
c->scoped(),
- typeToString(decl),
typeToString(decl));
if (typeName) {
fprintbf(cpp, "\tSlicer::classNameMap()->insert({ \"%s\", \"%s\" });\n",