summaryrefslogtreecommitdiff
path: root/cpp/src/Slice/CPlusPlusUtil.cpp
diff options
context:
space:
mode:
authorZeroC Staff <git@zeroc.com>2014-06-04 23:03:57 +0000
committerZeroC Staff <git@zeroc.com>2014-06-04 23:03:57 +0000
commit7aaf53c7ecb429a8e3b6abab3f7b9dbdc387b171 (patch)
tree78bde514408b4d02488e5efffd325faaa1c9a287 /cpp/src/Slice/CPlusPlusUtil.cpp
parentfix for Java metrics test (diff)
downloadice-7aaf53c7ecb429a8e3b6abab3f7b9dbdc387b171.tar.bz2
ice-7aaf53c7ecb429a8e3b6abab3f7b9dbdc387b171.tar.xz
ice-7aaf53c7ecb429a8e3b6abab3f7b9dbdc387b171.zip
New cpp:view-type metadata for strings, sequences and dictionaries, plus updates
to throughput demo. Fixes ICE-5382.
Diffstat (limited to 'cpp/src/Slice/CPlusPlusUtil.cpp')
-rw-r--r--cpp/src/Slice/CPlusPlusUtil.cpp115
1 files changed, 67 insertions, 48 deletions
diff --git a/cpp/src/Slice/CPlusPlusUtil.cpp b/cpp/src/Slice/CPlusPlusUtil.cpp
index 86a7b138805..3f1104a156c 100644
--- a/cpp/src/Slice/CPlusPlusUtil.cpp
+++ b/cpp/src/Slice/CPlusPlusUtil.cpp
@@ -43,6 +43,31 @@ string toTemplateArg(const string& arg)
}
string
+stringTypeToString(const TypePtr& type, const StringList& metaData, int typeCtx)
+{
+ string strType = findMetaData(metaData, typeCtx);
+ if(strType == "wstring" || (typeCtx & TypeContextUseWstring && strType == ""))
+ {
+ if(featureProfile == IceE)
+ {
+ return "::Ice::Wstring";
+ }
+ else
+ {
+ return "::std::wstring";
+ }
+ }
+ else if(strType != "" && strType != "string")
+ {
+ return strType;
+ }
+ else
+ {
+ return "::std::string";
+ }
+}
+
+string
sequenceTypeToString(const SequencePtr& seq, const StringList& metaData, int typeCtx)
{
string seqType = findMetaData(metaData, typeCtx);
@@ -420,6 +445,7 @@ Slice::printDllExportStuff(Output& out, const string& dllExport)
}
}
+
string
Slice::typeToString(const TypePtr& type, const StringList& metaData, int typeCtx)
{
@@ -443,20 +469,12 @@ Slice::typeToString(const TypePtr& type, const StringList& metaData, int typeCtx
{
if(builtin->kind() == Builtin::KindString)
{
- string strType = findMetaData(metaData);
- if(strType != "string" && (typeCtx & TypeContextUseWstring || strType == "wstring"))
- {
- if(featureProfile == IceE)
- {
- return "::Ice::Wstring";
- }
- else
- {
- return "::std::wstring";
- }
- }
+ return stringTypeToString(type, metaData, typeCtx);
+ }
+ else
+ {
+ return builtinTable[builtin->kind()];
}
- return builtinTable[builtin->kind()];
}
ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type);
@@ -567,20 +585,12 @@ Slice::inputTypeToString(const TypePtr& type, bool optional, const StringList& m
{
if(builtin->kind() == Builtin::KindString)
{
- string strType = findMetaData(metaData);
- if(strType != "string" && (typeCtx & TypeContextUseWstring || strType == "wstring"))
- {
- if(featureProfile == IceE)
- {
- return "const ::Ice::Wstring&";
- }
- else
- {
- return "const ::std::wstring&";
- }
- }
+ return string("const ") + stringTypeToString(type, metaData, typeCtx) + "&";
+ }
+ else
+ {
+ return inputBuiltinTable[builtin->kind()];
}
- return inputBuiltinTable[builtin->kind()];
}
ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type);
@@ -660,20 +670,12 @@ Slice::outputTypeToString(const TypePtr& type, bool optional, const StringList&
{
if(builtin->kind() == Builtin::KindString)
{
- string strType = findMetaData(metaData);
- if(strType != "string" && (typeCtx & TypeContextUseWstring || strType == "wstring"))
- {
- if(featureProfile == IceE)
- {
- return "::Ice::Wstring&";
- }
- else
- {
- return "::std::wstring&";
- }
- }
+ return stringTypeToString(type, metaData, typeCtx) + "&";
+ }
+ else
+ {
+ return outputBuiltinTable[builtin->kind()];
}
- return outputBuiltinTable[builtin->kind()];
}
ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type);
@@ -1015,6 +1017,7 @@ string
Slice::findMetaData(const StringList& metaData, int typeCtx)
{
static const string prefix = "cpp:";
+
for(StringList::const_iterator q = metaData.begin(); q != metaData.end(); ++q)
{
string str = *q;
@@ -1025,34 +1028,50 @@ Slice::findMetaData(const StringList& metaData, int typeCtx)
//
// If the form is cpp:type:<...> the data after cpp:type:
// is returned.
+ // If the form is cpp:view-type:<...> the data after the
+ // cpp:view-type: is returned
// If the form is cpp:range[:<...>], cpp:array or cpp:class,
// the return value is % followed by the string after cpp:.
//
+ // The priority of the metadata is as follows:
+ // 1: protobuf
+ // 2: array, range, range:array, view-type for "view" parameters
+ // 3: class
+
if(pos != string::npos)
{
string ss = str.substr(prefix.size());
- if(ss.find("type:") == 0 || ss.find("protobuf:") == 0)
+
+ if(ss.find("protobuf:") == 0)
{
return str.substr(pos + 1);
- }
- else if((typeCtx & (TypeContextInParam | TypeContextAMIPrivateEnd)) &&
- !(typeCtx & TypeContextAMIEnd) && ss.find("range:") == 0)
+ }
+
+ if(typeCtx & (TypeContextInParam | TypeContextAMIPrivateEnd))
{
- return string("%") + str.substr(prefix.size());
+ if(ss.find("range:") == 0)
+ {
+ return string("%") + str.substr(prefix.size());
+ }
+ else if(ss.find("view-type:") == 0)
+ {
+ return str.substr(pos + 1);
+ }
}
- else if((typeCtx & TypeContextAMIPrivateEnd) && ss == "range:array")
+
+ if(ss.find("type:") == 0)
{
- return "%range:array";
+ return str.substr(pos + 1);
}
}
- else if(typeCtx & (TypeContextInParam | TypeContextAMIPrivateEnd) && !(typeCtx & TypeContextAMIEnd))
+ else if(typeCtx & (TypeContextInParam | TypeContextAMIPrivateEnd))
{
string ss = str.substr(prefix.size());
if(ss == "array")
{
return "%array";
}
- else if((typeCtx & TypeContextInParam) && ss == "range")
+ else if(ss == "range")
{
return "%range";
}