diff options
-rw-r--r-- | slicer/slicer/modelPartsTypes.h | 8 | ||||
-rw-r--r-- | slicer/slicer/modelPartsTypes.impl.h | 10 | ||||
-rw-r--r-- | slicer/test/conversions.cpp | 4 | ||||
-rw-r--r-- | slicer/test/conversions.h | 2 | ||||
-rw-r--r-- | slicer/tool/parser.cpp | 17 |
5 files changed, 24 insertions, 17 deletions
diff --git a/slicer/slicer/modelPartsTypes.h b/slicer/slicer/modelPartsTypes.h index 363891d..d53be93 100644 --- a/slicer/slicer/modelPartsTypes.h +++ b/slicer/slicer/modelPartsTypes.h @@ -167,15 +167,15 @@ namespace Slicer { }; template<typename T> - class DLL_PUBLIC ModelPartForClass : public ModelPartForComplex<typename T::element_type>, protected ModelPartModel<T> { + class DLL_PUBLIC ModelPartForClass : public ModelPartForComplex<T>, protected ModelPartModel<IceInternal::Handle<T> > { public: - typedef T element_type; + typedef IceInternal::Handle<T> element_type; - ModelPartForClass(T & h); + ModelPartForClass(element_type & h); virtual void Create() override; - typename T::element_type * GetModel() override; + T * GetModel() override; virtual ModelPartPtr GetSubclassModelPart(const std::string & name) override; diff --git a/slicer/slicer/modelPartsTypes.impl.h b/slicer/slicer/modelPartsTypes.impl.h index 443b96b..b3abc2c 100644 --- a/slicer/slicer/modelPartsTypes.impl.h +++ b/slicer/slicer/modelPartsTypes.impl.h @@ -204,19 +204,19 @@ namespace Slicer { // ModelPartForClass template<typename T> - ModelPartForClass<T>::ModelPartForClass(T & h) : - ModelPartModel<T>(h) + ModelPartForClass<T>::ModelPartForClass(element_type & h) : + ModelPartModel<element_type>(h) { } template<typename T> void ModelPartForClass<T>::Create() { - this->Model = new typename T::element_type(); + this->Model = new T(); } template<typename T> - typename T::element_type * ModelPartForClass<T>::GetModel() + T * ModelPartForClass<T>::GetModel() { return this->Model.get(); } @@ -242,7 +242,7 @@ namespace Slicer { template<typename T> ModelPartPtr ModelPartForClass<T>::CreateModelPart(void * p) { - return new ModelPartForClass<T>(*static_cast<T *>(p)); + return new ModelPartForClass<T>(*static_cast<element_type *>(p)); } template<typename T> diff --git a/slicer/test/conversions.cpp b/slicer/test/conversions.cpp index 8510089..63de1de 100644 --- a/slicer/test/conversions.cpp +++ b/slicer/test/conversions.cpp @@ -109,7 +109,7 @@ namespace TestModule { int completions = 0; AbValidator::AbValidator(ClassTypePtr & m) : - Slicer::ModelPartForClass<ClassTypePtr>(m) + Slicer::ModelPartForClass<ClassType>(m) { } @@ -121,7 +121,7 @@ namespace TestModule { throw std::runtime_error("Mock error"); // LCOV_EXCL_STOP } - Slicer::ModelPartForClass<ClassTypePtr>::Complete(); + Slicer::ModelPartForClass<ClassType>::Complete(); completions += 1; } diff --git a/slicer/test/conversions.h b/slicer/test/conversions.h index e33b670..62a9c4b 100644 --- a/slicer/test/conversions.h +++ b/slicer/test/conversions.h @@ -9,7 +9,7 @@ namespace TestModule { DLL_PUBLIC extern int completions; - class DLL_PUBLIC AbValidator : public Slicer::ModelPartForClass<ClassTypePtr> { + class DLL_PUBLIC AbValidator : public Slicer::ModelPartForClass<ClassType> { public: AbValidator(ClassTypePtr &); diff --git a/slicer/tool/parser.cpp b/slicer/tool/parser.cpp index 5aa5f5c..466f4dd 100644 --- a/slicer/tool/parser.cpp +++ b/slicer/tool/parser.cpp @@ -188,7 +188,7 @@ namespace Slicer { fprintbf(cpp, "template<> DLL_PUBLIC\n"); auto typeId = metaDataValue("slicer:typeid:", c->getMetaData()); fprintbf(cpp, "const std::string ModelPartForClass< %s >::typeIdProperty(\"%s\");\n\n", - typeToString(decl), + decl->typeId(), typeId ? *typeId : "slicer-typeid"); auto name = metaDataValue("slicer:root:", c->getMetaData()); @@ -197,10 +197,10 @@ namespace Slicer { auto typeName = metaDataValue("slicer:typename:", c->getMetaData()); fprintbf(cpp, "template<> DLL_PUBLIC\n"); fprintbf(cpp, "__attribute__ ((init_priority(209)))\nconst std::string ModelPartForClass< %s >::className(\"%s\");\n", - typeToString(decl), c->scoped()); + decl->typeId(), c->scoped()); fprintbf(cpp, "template<> DLL_PUBLIC\n"); fprintbf(cpp, "__attribute__ ((init_priority(209)))\nconst IceUtil::Optional<std::string> ModelPartForClass< %s >::typeName", - typeToString(decl)); + decl->typeId()); if (typeName) { fprintbf(cpp, "(\"%s\")", *typeName); @@ -215,7 +215,14 @@ namespace Slicer { copyMetadata(c->getMetaData()); fprintbf(cpp, ";\n\n"); - defineMODELPART(stringbf("::IceInternal::Handle< %s >", c->scoped()), decl, c->getMetaData()); + if (auto cmp = metaDataValue("slicer:custommodelpart:", c->getMetaData())) { + fprintbf(cpp, "CUSTOMMODELPARTFOR(%s, %s< %s >, %s);\n\n", + Slice::typeToString(decl), getBasicModelPart(decl), c->scoped(), boost::algorithm::replace_all_copy(*cmp, ".", "::")); + } + else { + fprintbf(cpp, "CUSTOMMODELPARTFOR(%s, ModelPartForClass<%s>, ModelPartForClass<%s>);\n\n", + Slice::typeToString(decl), c->scoped(), c->scoped()); + } classNo += 1; @@ -471,7 +478,7 @@ namespace Slicer { } else { fprintbf(cpp, "%s< %s >", - getBasicModelPart(type), Slice::typeToString(type)); + getBasicModelPart(type), Slice::ClassDeclPtr::dynamicCast(type) ? type->typeId() : Slice::typeToString(type)); } } |