summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2017-01-06 16:42:35 -0500
committerBernard Normier <bernard@zeroc.com>2017-01-06 16:42:35 -0500
commitd7778df86336f3becb561463ae24243ccfe02164 (patch)
tree4e437427a9d333b44665fbdecea239350c800522 /cpp/src
parentTest script fix, don't terminate the process twice (diff)
downloadice-d7778df86336f3becb561463ae24243ccfe02164.tar.bz2
ice-d7778df86336f3becb561463ae24243ccfe02164.tar.xz
ice-d7778df86336f3becb561463ae24243ccfe02164.zip
Renamed Slice/keyword test to clash, and added identifier-clash test
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Slice/PythonUtil.cpp31
-rw-r--r--cpp/src/slice2cs/CsUtil.cpp2
-rw-r--r--cpp/src/slice2cs/Gen.cpp20
-rw-r--r--cpp/src/slice2java/Gen.cpp47
-rw-r--r--cpp/src/slice2java/GenCompat.cpp8
-rw-r--r--cpp/src/slice2objc/Gen.cpp12
6 files changed, 84 insertions, 36 deletions
diff --git a/cpp/src/Slice/PythonUtil.cpp b/cpp/src/Slice/PythonUtil.cpp
index 6b6493666bb..0553a520791 100644
--- a/cpp/src/Slice/PythonUtil.cpp
+++ b/cpp/src/Slice/PythonUtil.cpp
@@ -20,6 +20,27 @@ using namespace Slice;
using namespace IceUtil;
using namespace IceUtilInternal;
+namespace
+{
+
+string
+getEscapedParamName(const OperationPtr& p, const string& name)
+{
+ ParamDeclList params = p->parameters();
+
+ for(ParamDeclList::const_iterator i = params.begin(); i != params.end(); ++i)
+ {
+ if((*i)->name() == name)
+ {
+ return name + "_";
+ }
+ }
+ return name;
+}
+
+}
+
+
namespace Slice
{
namespace Python
@@ -576,9 +597,11 @@ Slice::Python::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
_out << ", " << fixIdent((*pli)->name());
}
}
+
if(!p->isLocal())
{
- _out << ", current=None";
+ const string currentParamName = getEscapedParamName(*oli, "current");
+ _out << ", " << currentParamName << "=None";
}
_out << "):";
_out.inc();
@@ -603,7 +626,8 @@ Slice::Python::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
}
if(!p->isLocal())
{
- _out << ", current=None";
+ const string currentParamName = getEscapedParamName(*oli, "current");
+ _out << ", " << currentParamName << "=None";
}
_out << "):";
_out.inc();
@@ -2576,7 +2600,8 @@ Slice::Python::CodeVisitor::writeDocstring(const OperationPtr& op, DocstringMode
}
if(!local && (mode == DocDispatch || mode == DocAsyncDispatch))
{
- _out << nl << "current -- The Current object for the invocation.";
+ const string currentParamName = getEscapedParamName(op, "current");
+ _out << nl << currentParamName << " -- The Current object for the invocation.";
}
}
else if(mode == DocAsyncEnd)
diff --git a/cpp/src/slice2cs/CsUtil.cpp b/cpp/src/slice2cs/CsUtil.cpp
index af0e5305b70..6cafdd55690 100644
--- a/cpp/src/slice2cs/CsUtil.cpp
+++ b/cpp/src/slice2cs/CsUtil.cpp
@@ -106,7 +106,7 @@ splitScopedName(const string& scoped)
// their "@"-prefixed version; otherwise, if the passed name is
// not scoped, but a C# keyword, return the "@"-prefixed name;
// otherwise, check if the name is one of the method names of baseTypes;
-// if so, prefix it with _Ice_; otherwise, return the name unchanged.
+// if so, prefix it with ice_; otherwise, return the name unchanged.
//
string
Slice::CsGenerator::fixId(const string& name, int baseTypes, bool mangleCasts)
diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp
index 71c12deedcd..2aca017f2b0 100644
--- a/cpp/src/slice2cs/Gen.cpp
+++ b/cpp/src/slice2cs/Gen.cpp
@@ -337,13 +337,13 @@ Slice::CsVisitor::writeMarshalDataMember(const DataMemberPtr& member, const stri
else
{
string stream = forStruct ? "" : "ostr_";
- string memberName = fixId(member->name());
+ string memberName = name;
if(forStruct)
{
memberName = "this." + memberName;
}
- writeMarshalUnmarshalCode(_out, member->type(), name, true, stream);
+ writeMarshalUnmarshalCode(_out, member->type(), memberName, true, stream);
}
}
@@ -376,13 +376,13 @@ Slice::CsVisitor::writeUnmarshalDataMember(const DataMemberPtr& member, const st
else
{
string stream = forStruct ? "" : "istr_";
- string memberName = fixId(member->name());
+ string memberName = name;
if(forStruct)
{
memberName = "this." + memberName;
}
- writeMarshalUnmarshalCode(_out, member->type(), classType ? patcher : name, false, stream);
+ writeMarshalUnmarshalCode(_out, member->type(), classType ? patcher : memberName, false, stream);
}
}
@@ -1391,13 +1391,13 @@ Slice::CsVisitor::writeDataMemberInitializers(const DataMemberList& members, int
BuiltinPtr builtin = BuiltinPtr::dynamicCast((*p)->type());
if(builtin && builtin->kind() == Builtin::KindString)
{
- _out << nl << fixId((*p)->name(), baseTypes) << " = \"\";";
+ _out << nl << "this." << fixId((*p)->name(), baseTypes) << " = \"\";";
}
StructPtr st = StructPtr::dynamicCast((*p)->type());
if(st)
{
- _out << nl << fixId((*p)->name(), baseTypes) << " = new " << typeToString(st, false) << "();";
+ _out << nl << "this." << fixId((*p)->name(), baseTypes) << " = new " << typeToString(st, false) << "();";
}
}
}
@@ -2479,7 +2479,7 @@ Slice::Gen::TypesVisitor::visitClassDefEnd(const ClassDefPtr& p)
_out << " : base()";
}
_out << sb;
- writeDataMemberInitializers(dataMembers, 0, propertyMapping);
+ writeDataMemberInitializers(dataMembers, DotNet::ICloneable, propertyMapping);
_out << eb;
_out << sp;
@@ -2488,7 +2488,7 @@ Slice::Gen::TypesVisitor::visitClassDefEnd(const ClassDefPtr& p)
vector<string> paramDecl;
for(DataMemberList::const_iterator d = allDataMembers.begin(); d != allDataMembers.end(); ++d)
{
- string memberName = fixId((*d)->name());
+ string memberName = fixId((*d)->name(), DotNet::ICloneable);
string memberType = typeToString((*d)->type(), (*d)->optional());
paramDecl.push_back(memberType + " " + memberName);
}
@@ -2500,7 +2500,7 @@ Slice::Gen::TypesVisitor::visitClassDefEnd(const ClassDefPtr& p)
DataMemberList baseDataMembers = bases.front()->allDataMembers();
for(DataMemberList::const_iterator d = baseDataMembers.begin(); d != baseDataMembers.end(); ++d)
{
- baseParamNames.push_back(fixId((*d)->name()));
+ baseParamNames.push_back(fixId((*d)->name(), DotNet::ICloneable));
}
_out << baseParamNames << epar;
}
@@ -2508,7 +2508,7 @@ Slice::Gen::TypesVisitor::visitClassDefEnd(const ClassDefPtr& p)
for(DataMemberList::const_iterator d = dataMembers.begin(); d != dataMembers.end(); ++d)
{
_out << nl << "this.";
- const string paramName = fixId((*d)->name());
+ const string paramName = fixId((*d)->name(), DotNet::ICloneable);
if(propertyMapping)
{
_out << "_" + (*d)->name();
diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp
index d91af385c73..390d44491ed 100644
--- a/cpp/src/slice2java/Gen.cpp
+++ b/cpp/src/slice2java/Gen.cpp
@@ -85,6 +85,19 @@ getEscapedParamName(const OperationPtr& p, const string& name)
return name;
}
+string
+getEscapedParamName(const DataMemberList& params, const string& name)
+{
+ for(DataMemberList::const_iterator i = params.begin(); i != params.end(); ++i)
+ {
+ if((*i)->name() == name)
+ {
+ return name + "_";
+ }
+ }
+ return name;
+}
+
bool
isDeprecated(const ContainedPtr& p1, const ContainedPtr& p2)
{
@@ -314,7 +327,7 @@ Slice::JavaVisitor::writeResultType(Output& out, const OperationPtr& op, const s
for(ParamDeclList::const_iterator pli = required.begin(); pli != required.end(); ++pli)
{
const string paramName = fixKwd((*pli)->name());
- writeMarshalUnmarshalCode(out, package, (*pli)->type(), OptionalNone, false, 0, paramName, true, iter, "",
+ writeMarshalUnmarshalCode(out, package, (*pli)->type(), OptionalNone, false, 0, "this." + paramName, true, iter, "",
(*pli)->getMetaData());
}
@@ -338,7 +351,7 @@ Slice::JavaVisitor::writeResultType(Output& out, const OperationPtr& op, const s
}
const string paramName = fixKwd((*pli)->name());
- writeMarshalUnmarshalCode(out, package, (*pli)->type(), OptionalOutParam, true, (*pli)->tag(), paramName,
+ writeMarshalUnmarshalCode(out, package, (*pli)->type(), OptionalOutParam, true, (*pli)->tag(), "this." + paramName,
true, iter, "", (*pli)->getMetaData());
}
@@ -358,7 +371,7 @@ Slice::JavaVisitor::writeResultType(Output& out, const OperationPtr& op, const s
{
const string paramName = fixKwd((*pli)->name());
const string patchParams = getPatcher((*pli)->type(), package, paramName, false);
- writeMarshalUnmarshalCode(out, package, (*pli)->type(), OptionalNone, false, 0, paramName, false, iter,
+ writeMarshalUnmarshalCode(out, package, (*pli)->type(), OptionalNone, false, 0, "this." + paramName, false, iter,
"", (*pli)->getMetaData(), patchParams);
}
@@ -386,7 +399,7 @@ Slice::JavaVisitor::writeResultType(Output& out, const OperationPtr& op, const s
const string paramName = fixKwd((*pli)->name());
const string patchParams = getPatcher((*pli)->type(), package, paramName, true);
- writeMarshalUnmarshalCode(out, package, (*pli)->type(), OptionalOutParam, true, (*pli)->tag(), paramName,
+ writeMarshalUnmarshalCode(out, package, (*pli)->type(), OptionalOutParam, true, (*pli)->tag(), "this." + paramName,
false, iter, "", (*pli)->getMetaData(), patchParams);
}
@@ -1585,7 +1598,7 @@ Slice::JavaVisitor::writeDataMemberInitializers(Output& out, const DataMemberLis
}
else
{
- out << nl << fixKwd((*p)->name()) << " = ";
+ out << nl << "this." << fixKwd((*p)->name()) << " = ";
writeConstantValue(out, t, (*p)->defaultValueType(), (*p)->defaultValue(), package);
out << ';';
}
@@ -1595,21 +1608,21 @@ Slice::JavaVisitor::writeDataMemberInitializers(Output& out, const DataMemberLis
BuiltinPtr builtin = BuiltinPtr::dynamicCast(t);
if(builtin && builtin->kind() == Builtin::KindString)
{
- out << nl << fixKwd((*p)->name()) << " = \"\";";
+ out << nl << "this." << fixKwd((*p)->name()) << " = \"\";";
}
EnumPtr en = EnumPtr::dynamicCast(t);
if(en)
{
string firstEnum = fixKwd(en->getEnumerators().front()->name());
- out << nl << fixKwd((*p)->name()) << " = " << getAbsolute(en, package) << '.' << firstEnum << ';';
+ out << nl << "this." << fixKwd((*p)->name()) << " = " << getAbsolute(en, package) << '.' << firstEnum << ';';
}
StructPtr st = StructPtr::dynamicCast(t);
if(st)
{
string memberType = typeToString(st, TypeModeMember, package, (*p)->getMetaData());
- out << nl << fixKwd((*p)->name()) << " = new " << memberType << "();";
+ out << nl << "this." << fixKwd((*p)->name()) << " = new " << memberType << "();";
}
}
}
@@ -2837,7 +2850,9 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
//
if(allDataMembers.size() < 254)
{
- paramDecl.push_back("Throwable cause");
+ const string causeParamName = getEscapedParamName(allDataMembers, "cause");
+
+ paramDecl.push_back("Throwable " + causeParamName);
out << sp << nl << "public " << name << spar;
out << paramDecl << epar;
out << sb;
@@ -2852,12 +2867,12 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
baseParamNames.push_back(fixKwd((*d)->name()));
}
}
- baseParamNames.push_back("cause");
+ baseParamNames.push_back(causeParamName);
out << baseParamNames << epar << ';';
}
else
{
- out << nl << "super(cause);";
+ out << nl << "super(" << causeParamName << ");";
}
for(DataMemberList::const_iterator d = members.begin(); d != members.end(); ++d)
{
@@ -2916,13 +2931,15 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
//
if(allDataMembers.size() < 254)
{
- paramDecl.push_back("Throwable cause");
+ const string causeParamName = getEscapedParamName(allDataMembers, "cause");
+
+ paramDecl.push_back("Throwable " + causeParamName);
out << sp << nl << "public " << name << spar;
out << paramDecl << epar;
out << sb;
if(!base)
{
- out << nl << "super(cause);";
+ out << nl << "super(" << causeParamName << ");";
}
else
{
@@ -2933,7 +2950,7 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
{
baseParamNames.push_back(fixKwd((*d)->name()));
}
- baseParamNames.push_back("cause");
+ baseParamNames.push_back(causeParamName);
out << baseParamNames << epar << ';';
}
for(DataMemberList::const_iterator d = members.begin(); d != members.end(); ++d)
@@ -4727,7 +4744,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
}
out << nl << "default " << future << ' ' << p->name() << "Async" << spar << params << contextParam << epar;
out << sb;
- out << nl << "return _iceI_" << p->name() << "Async" << spar << args << "context" << "false" << epar << ';';
+ out << nl << "return _iceI_" << p->name() << "Async" << spar << args << contextParamName << "false" << epar << ';';
out << eb;
const string futureImpl = getFutureImplType(p, package);
diff --git a/cpp/src/slice2java/GenCompat.cpp b/cpp/src/slice2java/GenCompat.cpp
index 2075af5be57..9890c3c68f0 100644
--- a/cpp/src/slice2java/GenCompat.cpp
+++ b/cpp/src/slice2java/GenCompat.cpp
@@ -1845,7 +1845,7 @@ Slice::JavaCompatVisitor::writeDataMemberInitializers(Output& out, const DataMem
}
else
{
- out << nl << fixKwd((*p)->name()) << " = ";
+ out << nl << "this." << fixKwd((*p)->name()) << " = ";
writeConstantValue(out, t, (*p)->defaultValueType(), (*p)->defaultValue(), package);
out << ';';
}
@@ -1855,21 +1855,21 @@ Slice::JavaCompatVisitor::writeDataMemberInitializers(Output& out, const DataMem
BuiltinPtr builtin = BuiltinPtr::dynamicCast(t);
if(builtin && builtin->kind() == Builtin::KindString)
{
- out << nl << fixKwd((*p)->name()) << " = \"\";";
+ out << nl << "this." << fixKwd((*p)->name()) << " = \"\";";
}
EnumPtr en = EnumPtr::dynamicCast(t);
if(en)
{
string firstEnum = fixKwd(en->getEnumerators().front()->name());
- out << nl << fixKwd((*p)->name()) << " = " << getAbsolute(en, package) << '.' << firstEnum << ';';
+ out << nl << "this." << fixKwd((*p)->name()) << " = " << getAbsolute(en, package) << '.' << firstEnum << ';';
}
StructPtr st = StructPtr::dynamicCast(t);
if(st)
{
string memberType = typeToString(st, TypeModeMember, package, (*p)->getMetaData());
- out << nl << fixKwd((*p)->name()) << " = new " << memberType << "();";
+ out << nl << "this." << fixKwd((*p)->name()) << " = new " << memberType << "();";
}
}
}
diff --git a/cpp/src/slice2objc/Gen.cpp b/cpp/src/slice2objc/Gen.cpp
index 4dcd484ba63..866f0e5d2db 100644
--- a/cpp/src/slice2objc/Gen.cpp
+++ b/cpp/src/slice2objc/Gen.cpp
@@ -759,8 +759,6 @@ Slice::Gen::generate(const UnitPtr& p)
// Necessary for objc_getClass use when marshalling/unmarshalling proxies.
_M << nl << "#import <objc/runtime.h>";
- _M << nl;
-
StringList includes = p->includeFiles();
for(StringList::const_iterator q = includes.begin(); q != includes.end(); ++q)
{
@@ -787,7 +785,6 @@ Slice::Gen::generate(const UnitPtr& p)
_M << nl << "#ifndef " << _dllExport << "_EXPORTS";
_M << nl << "# define " << _dllExport << "_EXPORTS";
_M << nl << "#endif";
- _M << nl;
_H << nl;
_H << nl << "#ifndef " << _dllExport;
@@ -806,6 +803,15 @@ Slice::Gen::generate(const UnitPtr& p)
_dllExport += " ";
}
+ //
+ // Disable shadow warnings in .cppm file
+ //
+ _M << sp;
+ _M.zeroIndent();
+ _M << nl << "#ifdef __clang__";
+ _M << nl << "# pragma clang diagnostic ignored \"-Wshadow-ivar\"";
+ _M << nl << "#endif";
+
UnitVisitor unitVisitor(_H, _M, _dllExport);
p->visit(&unitVisitor, false);