diff options
author | Bernard Normier <bernard@zeroc.com> | 2017-02-08 09:41:55 -0500 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2017-02-08 09:41:55 -0500 |
commit | af38cbf2ebf9c009fcea81cc316be64176da620e (patch) | |
tree | 28d6975bf5f1c4b7b89a5c24d2e1d9f1a2ba633c /cpp/src/slice2js | |
parent | Added wide char overloads of Ice::createProperties & Ice::initialize (diff) | |
download | ice-af38cbf2ebf9c009fcea81cc316be64176da620e.tar.bz2 ice-af38cbf2ebf9c009fcea81cc316be64176da620e.tar.xz ice-af38cbf2ebf9c009fcea81cc316be64176da620e.zip |
Make Slice enums scoped
Add new cpp:scoped and objc:scoped metadata directives
Diffstat (limited to 'cpp/src/slice2js')
-rw-r--r-- | cpp/src/slice2js/Gen.cpp | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/cpp/src/slice2js/Gen.cpp b/cpp/src/slice2js/Gen.cpp index 29c1c9f47dc..5f80870769c 100644 --- a/cpp/src/slice2js/Gen.cpp +++ b/cpp/src/slice2js/Gen.cpp @@ -185,7 +185,7 @@ Slice::JsVisitor::getValue(const string& scope, const TypePtr& type) EnumPtr en = EnumPtr::dynamicCast(type); if(en) { - return getReference(scope, en->scoped()) + '.' + fixId((*en->getEnumerators().begin())->name()); + return getReference(scope, en->scoped()) + '.' + fixId((*en->enumerators().begin())->name()); } StructPtr st = StructPtr::dynamicCast(type); @@ -238,17 +238,9 @@ Slice::JsVisitor::writeConstantValue(const string& scope, const TypePtr& type, c } else if((ep = EnumPtr::dynamicCast(type))) { - string::size_type colon = value.rfind(':'); - string enumerator; - if(colon != string::npos) - { - enumerator = fixId(value.substr(colon + 1)); - } - else - { - enumerator = fixId(value); - } - os << getReference(scope, ep->scoped()) << '.' << enumerator; + EnumeratorPtr lte = EnumeratorPtr::dynamicCast(valueType); + assert(lte); + os << getReference(scope, ep->scoped()) << '.' << fixId(lte->name()); } else { @@ -1723,7 +1715,7 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) _out.inc(); _out << nl; - const EnumeratorList enumerators = p->getEnumerators(); + const EnumeratorList enumerators = p->enumerators(); int i = 0; for(EnumeratorList::const_iterator en = enumerators.begin(); en != enumerators.end(); ++en) { |