diff options
author | Jose <jose@zeroc.com> | 2015-12-07 21:08:51 +0100 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2015-12-07 21:08:51 +0100 |
commit | acb6c5333de462e29d21166057fc074a815f2e3d (patch) | |
tree | 9acad37c34ef7b503f3aac13ea1858f1c965946c /cpp/src/slice2cpp/Gen.cpp | |
parent | ICE-6897 - Add delegate metadata (diff) | |
download | ice-acb6c5333de462e29d21166057fc074a815f2e3d.tar.bz2 ice-acb6c5333de462e29d21166057fc074a815f2e3d.tar.xz ice-acb6c5333de462e29d21166057fc074a815f2e3d.zip |
C++11 mapping updates:
- Added missing __hash method
- Added missing virtual method Value::ice_clone
- Fixed issue with unmarshalling the idirection table
- Fixed default value initialization for scoped enums
- Fixed scoped enums mapping to use correct size types
- Added missing ice_id method to generated Value classes
- Fixed defaultValue, hash, networkProxy, plug-in,
stringConverter, threadPoolPriority and slicing/objects
tests to work with C++11 mapping
Diffstat (limited to 'cpp/src/slice2cpp/Gen.cpp')
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 51 |
1 files changed, 36 insertions, 15 deletions
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index b81b5a887dd..4ee563d740a 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -181,7 +181,24 @@ writeConstantValue(IceUtilInternal::Output& out, const TypePtr& type, const Synt EnumPtr ep = EnumPtr::dynamicCast(type); if(ep) { - out << fixKwd(value); + bool unscoped = findMetaData(ep->getMetaData()) == "%unscoped"; + if(!cpp11 || unscoped) + { + out << fixKwd(value); + } + else + { + string v = value; + string scope; + size_t pos = value.rfind("::"); + if(pos != string::npos) + { + v = value.substr(pos + 2); + scope = value.substr(0, value.size() - v.size()); + } + + out << fixKwd(scope + ep->name() + "::" + v); + } } else { @@ -223,7 +240,7 @@ writeMarshalUnmarshalDataMembers(IceUtilInternal::Output& C, } void -writeDataMemberInitializers(IceUtilInternal::Output& C, const DataMemberList& members, int useWstring) +writeDataMemberInitializers(IceUtilInternal::Output& C, const DataMemberList& members, int useWstring, bool cpp11 = false) { bool first = true; for(DataMemberList::const_iterator p = members.begin(); p != members.end(); ++p) @@ -242,7 +259,7 @@ writeDataMemberInitializers(IceUtilInternal::Output& C, const DataMemberList& me } C << nl << memberName << '('; writeConstantValue(C, (*p)->type(), (*p)->defaultValueType(), (*p)->defaultValue(), useWstring, - (*p)->getMetaData()); + (*p)->getMetaData(), cpp11); C << ')'; } } @@ -5794,7 +5811,6 @@ Slice::Gen::Cpp11ObjectDeclVisitor::visitClassDecl(const ClassDeclPtr& p) { H << sp << nl << "class " << name << ';'; H << nl << "typedef ::std::shared_ptr< " << name << "> " << p->name() << "Ptr;"; - H << nl << _dllExport << "void __patch(" << p->name() << "Ptr&, const ::Ice::ValuePtr&);"; } } @@ -5953,7 +5969,7 @@ Slice::Gen::Cpp11TypesVisitor::visitExceptionStart(const ExceptionPtr& p) if(p->hasDefaultValues()) { C << ", "; - writeDataMemberInitializers(C, dataMembers, _useWstring); + writeDataMemberInitializers(C, dataMembers, _useWstring, true); } C.dec(); C << sb; @@ -5963,7 +5979,7 @@ Slice::Gen::Cpp11TypesVisitor::visitExceptionStart(const ExceptionPtr& p) { C << sp << nl << scoped.substr(2) << "::" << name << "() :"; C.inc(); - writeDataMemberInitializers(C, dataMembers, _useWstring); + writeDataMemberInitializers(C, dataMembers, _useWstring, true); C.dec(); C << sb; C << eb; @@ -7298,19 +7314,15 @@ enumSizeType(IceUtil::Int64 size) { if(size <= 0xFF) { - return "char"; + return "unsigned char"; } else if(size <= 0xFFFF) { - return "short"; - } - else if(size <= 0xFFFFFFFF) - { - return "int"; + return "unsigned short"; } else { - return "long long int"; + return "unsigned int"; } } @@ -7523,7 +7535,7 @@ Slice::Gen::Cpp11LocalObjectVisitor::visitClassDefStart(const ClassDefPtr& p) { H << sp << nl << name << "() :"; H.inc(); - writeDataMemberInitializers(H, dataMembers, _useWstring); + writeDataMemberInitializers(H, dataMembers, _useWstring, true); H.dec(); H << sb; H << eb; @@ -8449,7 +8461,7 @@ Slice::Gen::Cpp11ValueVisitor::visitClassDefStart(const ClassDefPtr& p) { H << sp << nl << name << "() :"; H.inc(); - writeDataMemberInitializers(H, dataMembers, _useWstring); + writeDataMemberInitializers(H, dataMembers, _useWstring, true); H.dec(); H << sb; H << eb; @@ -8464,6 +8476,8 @@ Slice::Gen::Cpp11ValueVisitor::visitClassDefStart(const ClassDefPtr& p) H << sp; H << nl << "virtual ::Ice::ValuePtr ice_clone() const;"; H << sp; + H << nl << "const ::std::string& ice_id() const;"; + H << sp; H << nl << "static const ::std::string& ice_staticId();"; return true; } @@ -8554,6 +8568,13 @@ Slice::Gen::Cpp11ValueVisitor::visitClassDefEnd(const ClassDefPtr& p) C << nl << "static const ::std::string typeId = \"" << p->scoped() << "\";"; C << nl << "return typeId;"; C << eb; + + C << sp; + C << nl << "const ::std::string&" << nl << scoped.substr(2) << "::ice_id() const"; + C << sb; + C << nl << "static const ::std::string typeId = \"" << p->scoped() << "\";"; + C << nl << "return typeId;"; + C << eb; C << sp << nl << "namespace"; C << nl << "{"; |