summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--slicer/tool/parser.cpp72
-rw-r--r--slicer/tool/parser.h6
2 files changed, 39 insertions, 39 deletions
diff --git a/slicer/tool/parser.cpp b/slicer/tool/parser.cpp
index 0b7b2a8..205180f 100644
--- a/slicer/tool/parser.cpp
+++ b/slicer/tool/parser.cpp
@@ -32,7 +32,7 @@ namespace Slicer {
auto type = dm->type();
auto c = Slice::ContainedPtr::dynamicCast(dm->container());
- auto conversions = getAllConversions(dm);
+ auto conversions = getConversions(getAllMetadata(dm));
for (const auto & conversion : conversions) {
if (!AdHoc::containerContains(conversion.Options, "nodeclare")) {
if (!AdHoc::containerContains(conversion.Options, "nodeclareto")) {
@@ -274,7 +274,6 @@ namespace Slicer {
t = Slice::ClassDefPtr::dynamicCast(dm->container())->declaration();
}
auto name = metaDataValue("slicer:name:", dm->getMetaData());
- auto conversions = getAllConversions(dm);
fprintbf(cpp, "\t\tnew ");
auto type = dm->type();
createNewModelPartPtrFor(it);
@@ -286,15 +285,7 @@ namespace Slicer {
if (dm->optional()) {
fprintbf(cpp, "ModelPartForOptional< ");
}
- if (!conversions.empty()) {
- fprintbf(cpp, "ModelPartForConverted< %s, %s, &%s >",
- Slice::typeToString(type),
- boost::algorithm::trim_right_copy_if(dm->container()->thisScope(), ispunct),
- dm->scoped());
- }
- else {
- createNewModelPartPtrFor(type);
- }
+ createNewModelPartPtrFor(type, dm, getAllMetadata(dm));
if (dm->optional()) {
fprintbf(cpp, " > ");
}
@@ -490,28 +481,37 @@ namespace Slicer {
}
void
- Slicer::createNewModelPartPtrFor(const Slice::TypePtr & type) const
+ Slicer::createNewModelPartPtrFor(const Slice::TypePtr & type, const Slice::DataMemberPtr & dm, const Slice::StringList & md) const
{
- if (auto builtin = Slice::BuiltinPtr::dynamicCast(type)) {
- fprintbf(cpp, "ModelPartForSimple");
- }
- else if (auto complexClass = Slice::ClassDeclPtr::dynamicCast(type)) {
- fprintbf(cpp, "ModelPartForClass");
- }
- else if (auto complexStruct = Slice::StructPtr::dynamicCast(type)) {
- fprintbf(cpp, "ModelPartForStruct");
- }
- else if (auto sequence = Slice::SequencePtr::dynamicCast(type)) {
- fprintbf(cpp, "ModelPartForSequence");
- }
- else if (auto dictionary = Slice::DictionaryPtr::dynamicCast(type)) {
- fprintbf(cpp, "ModelPartForDictionary");
+ auto conversions = getConversions(md);
+ if (dm && !conversions.empty()) {
+ fprintbf(cpp, "ModelPartForConverted< %s, %s, &%s >",
+ Slice::typeToString(type),
+ boost::algorithm::trim_right_copy_if(dm->container()->thisScope(), ispunct),
+ dm->scoped());
}
- else if (auto enumeration = Slice::EnumPtr::dynamicCast(type)) {
- fprintbf(cpp, "ModelPartForEnum");
+ else {
+ if (auto builtin = Slice::BuiltinPtr::dynamicCast(type)) {
+ fprintbf(cpp, "ModelPartForSimple");
+ }
+ else if (auto complexClass = Slice::ClassDeclPtr::dynamicCast(type)) {
+ fprintbf(cpp, "ModelPartForClass");
+ }
+ else if (auto complexStruct = Slice::StructPtr::dynamicCast(type)) {
+ fprintbf(cpp, "ModelPartForStruct");
+ }
+ else if (auto sequence = Slice::SequencePtr::dynamicCast(type)) {
+ fprintbf(cpp, "ModelPartForSequence");
+ }
+ else if (auto dictionary = Slice::DictionaryPtr::dynamicCast(type)) {
+ fprintbf(cpp, "ModelPartForDictionary");
+ }
+ else if (auto enumeration = Slice::EnumPtr::dynamicCast(type)) {
+ fprintbf(cpp, "ModelPartForEnum");
+ }
+ fprintbf(cpp, "< %s >",
+ Slice::typeToString(type));
}
- fprintbf(cpp, "< %s >",
- Slice::typeToString(type));
}
bool
@@ -537,19 +537,19 @@ namespace Slicer {
fprintbf(cpp, "};\n\n");
}
- Slicer::Conversions
- Slicer::getAllConversions(Slice::DataMemberPtr dm)
+ Slice::StringList
+ Slicer::getAllMetadata(const Slice::DataMemberPtr & dm)
{
- auto conversions = getConversions(dm->getMetaData());
+ auto metadata = dm->getMetaData();
auto typec = Slice::ContainedPtr::dynamicCast(dm->type());
if (typec) {
if (auto cd = Slice::ClassDeclPtr::dynamicCast(typec)) {
typec = cd->definition();
}
- auto typeConversions = getConversions(typec->getMetaData());
- std::copy(typeConversions.begin(), typeConversions.end(), std::back_inserter(conversions));
+ auto typeMetadata = typec->getMetaData();
+ std::copy(typeMetadata.begin(), typeMetadata.end(), std::back_inserter(metadata));
}
- return conversions;
+ return metadata;
}
Slicer::Conversions
diff --git a/slicer/tool/parser.h b/slicer/tool/parser.h
index a58df3a..b8bdf0b 100644
--- a/slicer/tool/parser.h
+++ b/slicer/tool/parser.h
@@ -55,7 +55,7 @@ namespace Slicer {
virtual void visitModuleEnd(const Slice::ModulePtr & m) override;
private:
- void createNewModelPartPtrFor(const Slice::TypePtr & type) const;
+ void createNewModelPartPtrFor(const Slice::TypePtr & type, const Slice::DataMemberPtr & dm = Slice::DataMemberPtr(), const Slice::StringList & md = Slice::StringList()) const;
void visitComplexDataMembers(Slice::ConstructedPtr t, const Slice::DataMemberList &) const;
@@ -64,8 +64,8 @@ namespace Slicer {
bool hasMetadata(const std::list<std::string> & metadata) const;
void copyMetadata(const std::list<std::string> & metadata) const;
- static Conversions getAllConversions(Slice::DataMemberPtr dm);
- static Conversions getConversions(const std::list<std::string> & metadata);
+ static Slice::StringList getAllMetadata(const Slice::DataMemberPtr & dm);
+ static Conversions getConversions(const Slice::StringList & metadata);
#pragma GCC visibility pop
unsigned int components;