summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <daniel.goodliffe@pressassociation.com>2016-10-05 16:41:38 +0100
committerDan Goodliffe <daniel.goodliffe@pressassociation.com>2016-10-05 16:41:38 +0100
commitca31f0e300d49e52c1ab354bd901be0f0c066614 (patch)
treeddeb6c305f6bce630613032c902590632227d52b
parentUse single instantiation point for model part roots (diff)
downloadslicer-ca31f0e300d49e52c1ab354bd901be0f0c066614.tar.bz2
slicer-ca31f0e300d49e52c1ab354bd901be0f0c066614.tar.xz
slicer-ca31f0e300d49e52c1ab354bd901be0f0c066614.zip
Implement class model part creation in a real function, not a machine built lambda
-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",