summaryrefslogtreecommitdiff
path: root/cpp/src/slice2cpp
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2016-07-18 20:55:31 +0000
committerBernard Normier <bernard@zeroc.com>2016-07-18 20:56:23 +0000
commita05470bdfc2c43e49eae41bbf045cd8856d9433d (patch)
tree4dc1d42cd865dfa3663a7083d08e1ad5df9b5e60 /cpp/src/slice2cpp
parentCustomizable PHP config (diff)
downloadice-a05470bdfc2c43e49eae41bbf045cd8856d9433d.tar.bz2
ice-a05470bdfc2c43e49eae41bbf045cd8856d9433d.tar.xz
ice-a05470bdfc2c43e49eae41bbf045cd8856d9433d.zip
New C++11 optional mapping
Diffstat (limited to 'cpp/src/slice2cpp')
-rw-r--r--cpp/src/slice2cpp/Gen.cpp37
1 files changed, 31 insertions, 6 deletions
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index 4ee6807b16b..6b64c5832b1 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -811,7 +811,7 @@ Slice::Gen::generate(const UnitPtr& p)
}
H << "\n#include <IceUtil/ScopedArray.h>";
- H << "\n#include <IceUtil/Optional.h>";
+ H << "\n#include <Ice/Optional.h>";
if(p->hasExceptions())
{
@@ -5937,8 +5937,21 @@ Slice::Gen::Cpp11TypesVisitor::visitDataMember(const DataMemberPtr& p)
string defaultValue = p->defaultValue();
if(!defaultValue.empty())
{
- H << " = ";
- writeConstantValue(H, p->type(), p->defaultValueType(), defaultValue, _useWstring, p->getMetaData(), true);
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(p->type());
+ if(p->optional() && builtin->kind() == Builtin::KindString)
+ {
+ //
+ // = "<string literal>" doesn't work for optional<std::string>
+ //
+ H << '{';
+ writeConstantValue(H, p->type(), p->defaultValueType(), defaultValue, _useWstring, p->getMetaData(), true);
+ H << '}';
+ }
+ else
+ {
+ H << " = ";
+ writeConstantValue(H, p->type(), p->defaultValueType(), defaultValue, _useWstring, p->getMetaData(), true);
+ }
}
H << ';';
@@ -6603,8 +6616,21 @@ Slice::Gen::Cpp11ObjectVisitor::emitDataMember(const DataMemberPtr& p)
string defaultValue = p->defaultValue();
if(!defaultValue.empty())
{
- H << " = ";
- writeConstantValue(H, p->type(), p->defaultValueType(), defaultValue, _useWstring, p->getMetaData(), true);
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(p->type());
+ if(p->optional() && builtin->kind() == Builtin::KindString)
+ {
+ //
+ // = "<string literal>" doesn't work for optional<std::string>
+ //
+ H << '{';
+ writeConstantValue(H, p->type(), p->defaultValueType(), defaultValue, _useWstring, p->getMetaData(), true);
+ H << '}';
+ }
+ else
+ {
+ H << " = ";
+ writeConstantValue(H, p->type(), p->defaultValueType(), defaultValue, _useWstring, p->getMetaData(), true);
+ }
}
H << ";";
}
@@ -7593,7 +7619,6 @@ Slice::Gen::Cpp11ValueVisitor::visitClassDefStart(const ClassDefPtr& p)
H.inc();
// Out of line dtor to avoid weak vtable
- H << sp;
H << nl << _dllMemberExport << "virtual ~" << name << "();";
C << sp;
C << nl << scoped.substr(2) << "::~" << name << "()";