summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorMichi Henning <michi@zeroc.com>2004-10-06 01:35:43 +0000
committerMichi Henning <michi@zeroc.com>2004-10-06 01:35:43 +0000
commit48522e29f4932093fc4fdc9c0d8c407b8bb48d55 (patch)
tree9bf8fb31d4e7a99ef4f5e5d581f7f63887118889 /cpp
parentWin32 fixes (diff)
downloadice-48522e29f4932093fc4fdc9c0d8c407b8bb48d55.tar.bz2
ice-48522e29f4932093fc4fdc9c0d8c407b8bb48d55.tar.xz
ice-48522e29f4932093fc4fdc9c0d8c407b8bb48d55.zip
Fixed problems around escaping of inherited method names.
Diffstat (limited to 'cpp')
-rw-r--r--cpp/include/Slice/CsUtil.h2
-rwxr-xr-xcpp/include/Slice/DotNetNames.h34
-rw-r--r--cpp/include/Slice/VbUtil.h2
-rwxr-xr-xcpp/src/Slice/CsUtil.cpp43
-rwxr-xr-xcpp/src/Slice/DotNetNames.cpp155
-rw-r--r--cpp/src/Slice/Makefile3
-rwxr-xr-xcpp/src/Slice/VbUtil.cpp40
-rwxr-xr-xcpp/src/slice2cs/Gen.cpp100
-rwxr-xr-xcpp/src/slice2vb/Gen.cpp103
9 files changed, 365 insertions, 117 deletions
diff --git a/cpp/include/Slice/CsUtil.h b/cpp/include/Slice/CsUtil.h
index 563db12e712..259080b2d20 100644
--- a/cpp/include/Slice/CsUtil.h
+++ b/cpp/include/Slice/CsUtil.h
@@ -28,7 +28,7 @@ public:
static void validateMetaData(const UnitPtr&);
protected:
- static std::string fixId(const std::string&);
+ static std::string fixId(const std::string&, int = 0, bool = false);
static std::string typeToString(const TypePtr&);
static bool isValueType(const TypePtr&);
//
diff --git a/cpp/include/Slice/DotNetNames.h b/cpp/include/Slice/DotNetNames.h
new file mode 100755
index 00000000000..f8a089ecec6
--- /dev/null
+++ b/cpp/include/Slice/DotNetNames.h
@@ -0,0 +1,34 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2004 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+#ifndef DOTNETNAMES_H
+#define DOTNETNAMES_H
+
+#include <string>
+
+namespace Slice
+{
+
+namespace DotNet
+{
+
+enum BaseType
+{
+ Object=1, ICloneable=2, Exception=4, ApplicationException=8, END=16
+};
+
+extern const char * manglePrefix;
+
+std::string mangleName(const std::string&, int baseTypes = 0);
+
+}
+
+}
+
+#endif
diff --git a/cpp/include/Slice/VbUtil.h b/cpp/include/Slice/VbUtil.h
index 3b818d8e41b..7ccc9410853 100644
--- a/cpp/include/Slice/VbUtil.h
+++ b/cpp/include/Slice/VbUtil.h
@@ -28,7 +28,7 @@ public:
static void validateMetaData(const UnitPtr&);
protected:
- static std::string fixId(const std::string&);
+ static std::string fixId(const std::string&, int = 0, bool = false);
static std::string typeToString(const TypePtr&);
static bool isValueType(const TypePtr&);
//
diff --git a/cpp/src/Slice/CsUtil.cpp b/cpp/src/Slice/CsUtil.cpp
index 9e9220c9597..2ca465693df 100755
--- a/cpp/src/Slice/CsUtil.cpp
+++ b/cpp/src/Slice/CsUtil.cpp
@@ -8,6 +8,7 @@
// **********************************************************************
#include <Slice/CsUtil.h>
+#include <Slice/DotNetNames.h>
#include <IceUtil/Functional.h>
#include <sys/types.h>
@@ -26,7 +27,7 @@ using namespace Slice;
using namespace IceUtil;
static string
-lookupKwd(const string& name)
+lookupKwd(const string& name, int baseTypes, bool mangleCasts = false)
{
//
// Keyword list. *Must* be kept in alphabetical order.
@@ -43,26 +44,17 @@ lookupKwd(const string& name)
};
bool found = binary_search(&keywordList[0],
&keywordList[sizeof(keywordList) / sizeof(*keywordList)],
- name);
+ name,
+ Slice::CICompare());
if(found)
{
return "@" + name;
}
-
- static const string memberList[] =
+ if(mangleCasts && (name == "checkedCast" || name == "uncheckedCast"))
{
- "Add", "Clear", "Clone", "Contains", "CopyTo", "Dictionary", "Equals", "Finalize",
- "GetBaseException", "GetEnumerator", "GetHashCode", "GetObjectData", "GetType",
- "IndexOf", "Insert", "IsFixedSize", "IsReadOnly", "IsSynchronized", "MemberWiseClone",
- "Microsoft", "OnClear", "OnClearComplete", "OnGet", "OnInsert", "OnInsertComplete",
- "OnRemove", "OnRemoveComplete", "OnSet", "OnSetComplete", "OnValidate", "ReferenceEquals",
- "Remove", "RemoveAt", "SyncRoot", "System", "ToString", "checkedCast", "uncheckedCast"
- };
- found = binary_search(&memberList[0],
- &memberList[sizeof(memberList) / sizeof(*memberList)],
- name,
- Slice::CICompare());
- return found ? "_Ice_" + name : name;
+ return string(DotNet::manglePrefix) + name;
+ }
+ return Slice::DotNet::mangleName(name, baseTypes);
}
//
@@ -105,10 +97,11 @@ splitScopedName(const string& scoped)
// but with all components that are C# keywords replaced by
// their "@"-prefixed version; otherwise, if the passed name is
// not scoped, but a C# keyword, return the "@"-prefixed name;
-// otherwise, return the name unchanged.
+// otherwise, check if the name is one of the method names of baseTypes;
+// if so, prefix it with _Ice_; otherwise, return the name unchanged.
//
string
-Slice::CsGenerator::fixId(const string& name)
+Slice::CsGenerator::fixId(const string& name, int baseTypes, bool mangleCasts)
{
if(name.empty())
{
@@ -116,18 +109,22 @@ Slice::CsGenerator::fixId(const string& name)
}
if(name[0] != ':')
{
- return lookupKwd(name);
+ return lookupKwd(name, baseTypes, mangleCasts);
}
StringList ids = splitScopedName(name);
- transform(ids.begin(), ids.end(), ids.begin(), ptr_fun(lookupKwd));
- stringstream result;
+ StringList newIds;
for(StringList::const_iterator i = ids.begin(); i != ids.end(); ++i)
{
- if(i != ids.begin())
+ newIds.push_back(lookupKwd(*i, baseTypes));
+ }
+ stringstream result;
+ for(StringList::const_iterator j = newIds.begin(); j != newIds.end(); ++j)
+ {
+ if(j != newIds.begin())
{
result << '.';
}
- result << *i;
+ result << *j;
}
return result.str();
}
diff --git a/cpp/src/Slice/DotNetNames.cpp b/cpp/src/Slice/DotNetNames.cpp
new file mode 100755
index 00000000000..ab5b4d5ec0c
--- /dev/null
+++ b/cpp/src/Slice/DotNetNames.cpp
@@ -0,0 +1,155 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2004 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+#include <Slice/DotNetNames.h>
+
+using namespace std;
+
+namespace Slice
+{
+
+namespace DotNet
+{
+
+struct Node
+{
+ const char** names;
+ const Node** parents;
+};
+
+static const char* ObjectNames[] =
+ {
+ "Equals", "Finalize", "GetHashCode", "GetType",
+ "MemberwiseClone", "ReferenceEquals", "ToString", 0
+ };
+static const Node* ObjectParents[] =
+ {
+ 0
+ };
+static const Node ObjectNode =
+ {
+ ObjectNames, &ObjectParents[0]
+ };
+
+static const char* ICloneableNames[] =
+ {
+ "Clone", 0
+ };
+static const Node* ICloneableParents[] =
+ {
+ &ObjectNode, 0
+ };
+static const Node ICloneableNode =
+ {
+ ICloneableNames, &ICloneableParents[0]
+ };
+
+static const char* ExceptionNames[] =
+ {
+ "GetBaseException", "GetObjectData", 0
+ };
+static const Node* ExceptionParents[] =
+ {
+ &ObjectNode, 0
+ };
+static const Node ExceptionNode =
+ {
+ ExceptionNames, &ExceptionParents[0]
+ };
+
+static const char* ApplicationExceptionNames[] =
+ {
+ 0
+ };
+static const Node* ApplicationExceptionParents[] =
+ {
+ &ExceptionNode, 0
+ };
+static const Node ApplicationExceptionNode =
+ {
+ ApplicationExceptionNames, &ApplicationExceptionParents[0]
+ };
+
+//
+// Must be kept in same order as definition of BaseType in header file!
+//
+static const Node* nodes[] =
+ {
+ &ObjectNode, &ICloneableNode, &ExceptionNode, &ApplicationExceptionNode
+ };
+
+static bool
+ciEquals(const string& s, const char* p)
+{
+ if(s.size() != strlen(p))
+ {
+ return false;
+ }
+ string::const_iterator i = s.begin();
+ while(i != s.end())
+ {
+ if(tolower(*i++) != tolower(*p++))
+ {
+ return false;
+ }
+ }
+ return true;
+}
+
+const char* Slice::DotNet::manglePrefix = "_Ice_";
+
+static bool
+mangle(const string& s, const Node* np, string& newName)
+{
+ const char** namep = np->names;
+ while(*namep)
+ {
+ if(ciEquals(s, *namep))
+ {
+ newName = manglePrefix + s;
+ return true;
+ }
+ ++namep;
+ }
+ const Node** parentp = np->parents;
+ while(*parentp)
+ {
+ if(mangle(s, *parentp, newName))
+ {
+ return true;
+ }
+ ++parentp;
+ }
+ return false;
+}
+
+}
+
+}
+
+string
+Slice::DotNet::mangleName(const string& s, int baseTypes)
+{
+ if(baseTypes == 0)
+ {
+ return s;
+ }
+ string newName;
+ for(unsigned int mask = 1, i=0; mask < END; mask <<= 1, ++i)
+ {
+ if(baseTypes & mask)
+ {
+ if(mangle(s, nodes[i], newName))
+ {
+ return newName;
+ }
+ }
+ }
+ return s;
+}
diff --git a/cpp/src/Slice/Makefile b/cpp/src/Slice/Makefile
index 53007535409..8a18cc450f8 100644
--- a/cpp/src/Slice/Makefile
+++ b/cpp/src/Slice/Makefile
@@ -24,7 +24,8 @@ OBJS = Scanner.o \
JavaUtil.o \
Preprocessor.o \
Checksum.o \
- PythonUtil.o
+ PythonUtil.o \
+ DotNetNames.o
SRCS = $(OBJS:.o=.cpp)
diff --git a/cpp/src/Slice/VbUtil.cpp b/cpp/src/Slice/VbUtil.cpp
index c5f6e3c428d..76497a14d83 100755
--- a/cpp/src/Slice/VbUtil.cpp
+++ b/cpp/src/Slice/VbUtil.cpp
@@ -8,6 +8,7 @@
// **********************************************************************
#include <Slice/VbUtil.h>
+#include <Slice/DotNetNames.h>
#include <IceUtil/Functional.h>
#include <sys/types.h>
@@ -26,7 +27,7 @@ using namespace Slice;
using namespace IceUtil;
static string
-lookupKwd(const string& name)
+lookupKwd(const string& name, int baseTypes, bool mangleCasts = false)
{
//
// Keyword list. *Must* be kept in alphabetical order.
@@ -57,21 +58,11 @@ lookupKwd(const string& name)
{
return "[" + name + "]";
}
-
- static const string memberList[] =
+ if(mangleCasts && (name == "checkedCast" || name == "uncheckedCast"))
{
- "Add", "Clear", "Clone", "Contains", "CopyTo", "Dictionary", "Equals", "Finalize",
- "GetBaseException", "GetEnumerator", "GetHashCode", "GetObjectData", "GetType",
- "IndexOf", "Insert", "IsFixedSize", "IsReadOnly", "IsSynchronized", "MemberWiseClone",
- "Microsoft", "OnClear", "OnClearComplete", "OnGet", "OnInsert", "OnInsertComplete",
- "OnRemove", "OnRemoveComplete", "OnSet", "OnSetComplete", "OnValidate", "ReferenceEquals",
- "Remove", "RemoveAt", "SyncRoot", "System", "ToString", "checkedCast", "uncheckedCast"
- };
- found = binary_search(&memberList[0],
- &memberList[sizeof(memberList) / sizeof(*memberList)],
- name,
- Slice::CICompare());
- return found ? "_Ice_" + name : name;
+ return string(DotNet::manglePrefix) + name;
+ }
+ return Slice::DotNet::mangleName(name, baseTypes);
}
//
@@ -114,10 +105,11 @@ splitScopedName(const string& scoped)
// but with all components that are VB keywords replaced by
// their "[]"-surrounded version; otherwise, if the passed name is
// not scoped, but a VB keyword, return the "[]"-surrounded name;
-// otherwise, return the name unchanged.
+// otherwise, check if the name is one of the method names of baseTypes;
+// if so, prefix it with _Ice_; otherwise, reutrn the name unchanged.
//
string
-Slice::VbGenerator::fixId(const string& name)
+Slice::VbGenerator::fixId(const string& name, int baseTypes, bool mangleCasts)
{
if(name.empty())
{
@@ -125,18 +117,22 @@ Slice::VbGenerator::fixId(const string& name)
}
if(name[0] != ':')
{
- return lookupKwd(name);
+ return lookupKwd(name, baseTypes, mangleCasts);
}
StringList ids = splitScopedName(name);
- transform(ids.begin(), ids.end(), ids.begin(), ptr_fun(lookupKwd));
- stringstream result;
+ StringList newIds;
for(StringList::const_iterator i = ids.begin(); i != ids.end(); ++i)
{
- if(i != ids.begin())
+ newIds.push_back(lookupKwd(*i, baseTypes));
+ }
+ stringstream result;
+ for(StringList::const_iterator j = ids.begin(); j != ids.end(); ++j)
+ {
+ if(j != ids.begin())
{
result << '.';
}
- result << *i;
+ result << *j;
}
return result.str();
}
diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp
index 9cf8ae45aa7..2a90ff6aaad 100755
--- a/cpp/src/slice2cs/Gen.cpp
+++ b/cpp/src/slice2cs/Gen.cpp
@@ -20,6 +20,7 @@
#include <IceUtil/Iterator.h>
#include <IceUtil/UUID.h>
#include <Slice/Checksum.h>
+#include <Slice/DotNetNames.h>
using namespace std;
using namespace Slice;
@@ -99,7 +100,7 @@ Slice::CsVisitor::writeInheritedOperations(const ClassDefPtr& p)
{
ClassDefPtr containingClass = ClassDefPtr::dynamicCast((*op)->container());
bool amd = containingClass->hasMetaData("amd") || (*op)->hasMetaData("amd");
- string name = fixId((*op)->name());
+ string name = fixId((*op)->name(), DotNet::ICloneable, true);
if(!amd)
{
vector<string> params = getParams(*op);
@@ -363,7 +364,7 @@ Slice::CsVisitor::writeDispatch(const ClassDefPtr& p)
string retS = typeToString(ret);
_out << retS << " __ret = ";
}
- _out << "__obj." << fixId(opName) << spar;
+ _out << "__obj." << fixId(opName, DotNet::ICloneable, true) << spar;
for(q = inParams.begin(); q != inParams.end(); ++q)
{
BuiltinPtr builtin = BuiltinPtr::dynamicCast(q->first);
@@ -487,7 +488,7 @@ Slice::CsVisitor::writeDispatch(const ClassDefPtr& p)
}
else
{
- _out << fixId(opName);
+ _out << fixId(opName, DotNet::ICloneable, true);
}
_out << spar;
if(amd)
@@ -1140,7 +1141,9 @@ Slice::Gen::TypesVisitor::visitClassDefEnd(const ClassDefPtr& p)
for(d = members.begin(); d != members.end(); ++d)
{
StringList metaData = (*d)->getMetaData();
- writeMarshalUnmarshalCode(_out, (*d)->type(), fixId((*d)->name()), true, false);
+ writeMarshalUnmarshalCode(_out, (*d)->type(),
+ fixId((*d)->name(), DotNet::ICloneable, true),
+ true, false);
}
_out << nl << "__os.endWriteSlice();";
_out << nl << "base.__write(__os);";
@@ -1187,7 +1190,7 @@ Slice::Gen::TypesVisitor::visitClassDefEnd(const ClassDefPtr& p)
_out << nl << "case " << memberCount << ":";
_out.inc();
}
- string memberName = fixId((*d)->name());
+ string memberName = fixId((*d)->name(), DotNet::ICloneable, true);
string memberType = typeToString((*d)->type());
_out << nl << "_type = typeof(" << memberType << ");";
_out << nl << "_instance." << memberName << " = (" << memberType << ")v;";
@@ -1233,7 +1236,9 @@ Slice::Gen::TypesVisitor::visitClassDefEnd(const ClassDefPtr& p)
patchParams << ", " << classMemberCount++;
}
}
- writeMarshalUnmarshalCode(_out, (*d)->type(), fixId((*d)->name()), false, false, patchParams.str());
+ writeMarshalUnmarshalCode(_out, (*d)->type(),
+ fixId((*d)->name(), DotNet::ICloneable, true),
+ false, false, patchParams.str());
}
_out << nl << "__is.endReadSlice();";
_out << nl << "base.__read(__is, true);";
@@ -1258,7 +1263,7 @@ Slice::Gen::TypesVisitor::visitOperation(const OperationPtr& p)
bool isLocal = classDef->isLocal();
bool amd = !isLocal && (classDef->hasMetaData("amd") || p->hasMetaData("amd"));
- string name = fixId(p->name());
+ string name = p->name();
ParamDeclList paramList = p->parameters();
vector<string> params;
vector<string> args;
@@ -1268,6 +1273,7 @@ Slice::Gen::TypesVisitor::visitOperation(const OperationPtr& p)
{
params = getParams(p);
args = getArgs(p);
+ name = fixId(name, DotNet::ICloneable, true);
retS = typeToString(p->returnType());
}
else
@@ -1624,7 +1630,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
_out << nl << "int __h = 0;";
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
- string memberName = fixId((*q)->name());
+ string memberName = fixId((*q)->name(), DotNet::ApplicationException);
bool isValue = isValueType((*q)->type());
if(!isValue)
{
@@ -1656,7 +1662,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
_out << eb;
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
- string memberName = fixId((*q)->name());
+ string memberName = fixId((*q)->name(), DotNet::ApplicationException);
_out << nl << "if(!" << memberName << ".Equals(((" << name << ")__other)." << memberName << "))";
_out << sb;
_out << nl << "return false;";
@@ -1702,7 +1708,9 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
_out << nl << "__os.startWriteSlice();";
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
- writeMarshalUnmarshalCode(_out, (*q)->type(), fixId((*q)->name()), true, false);
+ writeMarshalUnmarshalCode(_out, (*q)->type(),
+ fixId((*q)->name(), DotNet::ApplicationException),
+ true, false);
}
_out << nl << "__os.endWriteSlice();";
if(base)
@@ -1751,7 +1759,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
_out << nl << "case " << memberCount << ":";
_out.inc();
}
- string memberName = fixId((*q)->name());
+ string memberName = fixId((*q)->name(), DotNet::ApplicationException);
string memberType = typeToString((*q)->type());
_out << nl << "_type = typeof(" << memberType << ");";
_out << nl << "_instance." << memberName << " = (" << memberType << ")v;";
@@ -1795,7 +1803,9 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
patchParams << ", " << classMemberCount++;
}
}
- writeMarshalUnmarshalCode(_out, (*q)->type(), fixId((*q)->name()), false, false, patchParams.str());
+ writeMarshalUnmarshalCode(_out, (*q)->type(),
+ fixId((*q)->name(), DotNet::ApplicationException),
+ false, false, patchParams.str());
}
_out << nl << "__is.endReadSlice();";
if(base)
@@ -1848,7 +1858,8 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
_out << sp << nl << "#endregion"; // Slice data members
- if(p->hasMetaData("cs:class"))
+ bool isClass = p->hasMetaData("cs:class");
+ if(isClass)
{
_out << sp << nl << "#region ICloneable members";
@@ -1867,7 +1878,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
_out << nl << "int __h = 0;";
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
- string memberName = fixId((*q)->name());
+ string memberName = fixId((*q)->name(), isClass ? DotNet::ICloneable : 0);
bool isValue = isValueType((*q)->type());
if(!isValue)
{
@@ -1895,7 +1906,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
_out << eb;
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
- string memberName = fixId((*q)->name());
+ string memberName = fixId((*q)->name(), isClass ? DotNet::ICloneable : 0);
if(!isValueType((*q)->type()))
{
_out << nl << "if(" << memberName << " == null)";
@@ -1955,13 +1966,15 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
_out << sb;
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
- writeMarshalUnmarshalCode(_out, (*q)->type(), fixId((*q)->name()), true, false);
+ writeMarshalUnmarshalCode(_out, (*q)->type(),
+ fixId((*q)->name(), isClass ? DotNet::ICloneable : 0),
+ true, false);
}
_out << eb;
DataMemberList classMembers = p->classDataMembers();
- bool patchStruct = !p->hasMetaData("cs:class") && classMembers.size() != 0;
+ bool patchStruct = !isClass && classMembers.size() != 0;
if(classMembers.size() != 0)
{
@@ -2003,7 +2016,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
_out.inc();
}
string memberType = typeToString((*q)->type());
- string memberName = fixId((*q)->name());
+ string memberName = fixId((*q)->name(), isClass ? DotNet::ICloneable : 0);
_out << nl << "_type = typeof(" << memberType << ");";
_out << nl << "_instance." << memberName << " = (" << memberType << ")v;";
if(classMembers.size() > 1)
@@ -2037,7 +2050,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
for(q = classMembers.begin(); q != classMembers.end(); ++q)
{
string memberType = typeToString((*q)->type());
- string memberName = fixId((*q)->name());
+ string memberName = fixId((*q)->name(), isClass ? DotNet::ICloneable : 0);
_out << nl << "internal " << memberType << ' ' << memberName << ';';
}
_out << eb;
@@ -2048,7 +2061,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
_out << sb;
for(q = classMembers.begin(); q != classMembers.end(); ++q)
{
- string memberName = fixId((*q)->name());
+ string memberName = fixId((*q)->name(), isClass ? DotNet::ICloneable : 0);
_out << nl << memberName << " = _pm." << memberName << ';';
}
_out << eb;
@@ -2077,7 +2090,9 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
patchParams << ", " << classMemberCount++;
}
}
- writeMarshalUnmarshalCode(_out, (*q)->type(), fixId((*q)->name()), false, false, patchParams.str());
+ writeMarshalUnmarshalCode(_out, (*q)->type(),
+ fixId((*q)->name(), isClass ? DotNet::ICloneable : 0 ),
+ false, false, patchParams.str());
}
_out << eb;
@@ -2409,7 +2424,24 @@ Slice::Gen::TypesVisitor::visitConst(const ConstPtr& p)
void
Slice::Gen::TypesVisitor::visitDataMember(const DataMemberPtr& p)
{
- _out << sp << nl << "public " << typeToString(p->type()) << " " << fixId(p->name()) << ";";
+ int baseTypes = 0;
+ bool isClass = false;
+ ContainedPtr cont = ContainedPtr::dynamicCast(p->container());
+ assert(cont);
+ if(StructPtr::dynamicCast(cont) && cont->hasMetaData("cs:class"))
+ {
+ baseTypes = DotNet::ICloneable;
+ }
+ else if(ExceptionPtr::dynamicCast(cont))
+ {
+ baseTypes = DotNet::ApplicationException;
+ }
+ else if(ClassDefPtr::dynamicCast(cont))
+ {
+ baseTypes = DotNet::ICloneable;
+ isClass = true;
+ }
+ _out << sp << nl << "public " << typeToString(p->type()) << " " << fixId(p->name(), baseTypes, isClass) << ";";
}
Slice::Gen::ProxyVisitor::ProxyVisitor(IceUtil::Output& out)
@@ -2479,7 +2511,8 @@ Slice::Gen::ProxyVisitor::visitClassDefEnd(const ClassDefPtr&)
void
Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
{
- string name = fixId(p->name());
+ ClassDefPtr cl = ClassDefPtr::dynamicCast(p->container());
+ string name = fixId(p->name(), DotNet::ICloneable, true);
vector<string> params = getParams(p);
_out << sp << nl << typeToString(p->returnType()) << " " << name << spar << params << epar << ';';
@@ -2487,7 +2520,6 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
_out << nl << typeToString(p->returnType()) << " " << name
<< spar << params << "Ice.Context __context" << epar << ';';
- ClassDefPtr cl = ClassDefPtr::dynamicCast(p->container());
if(cl->hasMetaData("ami") || p->hasMetaData("ami"))
{
vector<string> paramsAMI = getParamsAsync(p, false);
@@ -2590,7 +2622,7 @@ Slice::Gen::OpsVisitor::writeOperations(const ClassDefPtr& p, bool noCurrent)
{
OperationPtr op = *r;
bool amd = !p->isLocal() && (p->hasMetaData("amd") || op->hasMetaData("amd"));
- string name = amd ? (op->name() + "_async") : fixId(op->name());
+ string name = amd ? (op->name() + "_async") : fixId(op->name(), DotNet::ICloneable, true);
TypePtr ret;
vector<string> params;
@@ -2676,7 +2708,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
for(r = ops.begin(); r != ops.end(); ++r)
{
OperationPtr op = *r;
- string opName = fixId(op->name());
+ string opName = fixId(op->name(), DotNet::ICloneable, true);
TypePtr ret = op->returnType();
string retS = typeToString(ret);
@@ -3081,7 +3113,7 @@ Slice::Gen::DelegateVisitor::visitClassDefStart(const ClassDefPtr& p)
for(r = ops.begin(); r != ops.end(); ++r)
{
OperationPtr op = *r;
- string opName = fixId(op->name());
+ string opName = fixId(op->name(), DotNet::ICloneable, true);
TypePtr ret = op->returnType();
string retS = typeToString(ret);
vector<string> params = getParams(op);
@@ -3142,7 +3174,7 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p)
for(r = ops.begin(); r != ops.end(); ++r)
{
OperationPtr op = *r;
- string opName = fixId(op->name());
+ string opName = fixId(op->name(), DotNet::ICloneable, true);
TypePtr ret = op->returnType();
string retS = typeToString(ret);
@@ -3364,7 +3396,7 @@ Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p)
for(r = ops.begin(); r != ops.end(); ++r)
{
OperationPtr op = *r;
- string opName = fixId(op->name());
+ string opName = fixId(op->name(), DotNet::ICloneable, true);
TypePtr ret = op->returnType();
string retS = typeToString(ret);
ClassDefPtr containingClass = ClassDefPtr::dynamicCast(op->container());
@@ -3483,10 +3515,11 @@ Slice::Gen::DispatcherVisitor::visitClassDefStart(const ClassDefPtr& p)
{
bool amd = p->hasMetaData("amd") || (*op)->hasMetaData("amd");
- string name = fixId((*op)->name());
+ string name = (*op)->name();
vector<string> params;
vector<string> args;
TypePtr ret;
+
if(amd)
{
name = name + "_async";
@@ -3495,6 +3528,7 @@ Slice::Gen::DispatcherVisitor::visitClassDefStart(const ClassDefPtr& p)
}
else
{
+ name = fixId(name, DotNet::ICloneable, true);
params = getParams(*op);
ret = (*op)->returnType();
args = getArgs(*op);
@@ -3981,7 +4015,7 @@ Slice::Gen::TieVisitor::visitClassDefStart(const ClassDefPtr& p)
for(r = ops.begin(); r != ops.end(); ++r)
{
bool hasAMD = p->hasMetaData("amd") || (*r)->hasMetaData("amd");
- string opName = hasAMD ? (*r)->name() + "_async" : fixId((*r)->name());
+ string opName = hasAMD ? (*r)->name() + "_async" : fixId((*r)->name(), DotNet::ICloneable, true);
TypePtr ret = (*r)->returnType();
string retS = typeToString(ret);
@@ -4051,7 +4085,7 @@ Slice::Gen::TieVisitor::writeInheritedOperations(const ClassDefPtr& p, NameSet&
for(r = ops.begin(); r != ops.end(); ++r)
{
bool hasAMD = p->hasMetaData("amd") || (*r)->hasMetaData("amd");
- string opName = hasAMD ? (*r)->name() + "_async" : fixId((*r)->name());
+ string opName = hasAMD ? (*r)->name() + "_async" : fixId((*r)->name(), DotNet::ICloneable, true);
if(opNames.find(opName) != opNames.end())
{
continue;
@@ -4186,7 +4220,7 @@ Slice::Gen::BaseImplVisitor::writeOperation(const OperationPtr& op, bool local,
{
_out << "override ";
}
- _out << retS << ' ' << fixId(opName) << spar << pDecls;
+ _out << retS << ' ' << fixId(opName, DotNet::ICloneable, true) << spar << pDecls;
if(!local)
{
_out << "Ice.Current __current";
diff --git a/cpp/src/slice2vb/Gen.cpp b/cpp/src/slice2vb/Gen.cpp
index cd4dae81962..93b3ca6b9b6 100755
--- a/cpp/src/slice2vb/Gen.cpp
+++ b/cpp/src/slice2vb/Gen.cpp
@@ -20,6 +20,7 @@
#include <IceUtil/Iterator.h>
#include <IceUtil/UUID.h>
#include <Slice/Checksum.h>
+#include <Slice/DotNetNames.h>
using namespace std;
using namespace Slice;
@@ -109,31 +110,33 @@ Slice::VbVisitor::writeInheritedOperations(const ClassDefPtr& p)
string retS = typeToString((*op)->returnType());
string vbOp = ret ? "Function" : "Sub";
- _out << sp << nl << "Public " << vbOp << ' ' << fixId(name) << spar << params << epar;
+ _out << sp << nl << "Public " << vbOp << ' ' << fixId(name, DotNet::ICloneable, true)
+ << spar << params << epar;
if(ret)
{
_out << " As " << retS;
}
_out << " Implements " << fixId(containingClass->scope()) << "_" << containingClass->name()
- << "OperationsNC." << fixId(name);
+ << "OperationsNC." << fixId(name, DotNet::ICloneable, true);
_out.inc();
_out << nl;
if((*op)->returnType())
{
_out << "Return ";
}
- _out << fixId(name) << spar << args << "Ice.ObjectImpl.defaultCurrent" << epar;
+ _out << fixId(name, DotNet::ICloneable, true)
+ << spar << args << "Ice.ObjectImpl.defaultCurrent" << epar;
_out.dec();
_out << nl << "End " << vbOp;
- _out << sp << nl << "Public MustOverride " << vbOp << ' ' << fixId(name)
+ _out << sp << nl << "Public MustOverride " << vbOp << ' ' << fixId(name, DotNet::ICloneable, true)
<< spar << params << "ByVal __current As Ice.Current" << epar;
if(ret)
{
_out << " As " << retS;
}
_out << " Implements " << fixId(containingClass->scope()) << "_" << containingClass->name()
- << "Operations." << fixId(name);
+ << "Operations." << fixId(name, DotNet::ICloneable, true);
}
else
{
@@ -394,7 +397,7 @@ Slice::VbVisitor::writeDispatch(const ClassDefPtr& p)
string retS = typeToString(ret);
_out << "Dim __ret As " << retS << " = ";
}
- _out << "__obj." << fixId(opName) << spar;
+ _out << "__obj." << fixId(opName, DotNet::ICloneable, true) << spar;
for(q = inParams.begin(); q != inParams.end(); ++q)
{
BuiltinPtr builtin = BuiltinPtr::dynamicCast(q->first);
@@ -517,7 +520,7 @@ Slice::VbVisitor::writeDispatch(const ClassDefPtr& p)
}
else
{
- _out << fixId(opName);
+ _out << fixId(opName, DotNet::ICloneable, true);
}
_out << spar;
if(amd)
@@ -1183,7 +1186,7 @@ Slice::Gen::TypesVisitor::visitClassDefEnd(const ClassDefPtr& p)
for(d = members.begin(); d != members.end(); ++d)
{
StringList metaData = (*d)->getMetaData();
- writeMarshalUnmarshalCode(_out, (*d)->type(), fixId((*d)->name()), true, false);
+ writeMarshalUnmarshalCode(_out, (*d)->type(), fixId((*d)->name(), DotNet::ICloneable, true), true, false);
}
_out << nl << "__os.endWriteSlice()";
_out << nl << "MyBase.__write(__os)";
@@ -1226,7 +1229,7 @@ Slice::Gen::TypesVisitor::visitClassDefEnd(const ClassDefPtr& p)
_out << nl << "Case " << memberCount;
_out.inc();
}
- string memberName = fixId((*d)->name());
+ string memberName = fixId((*d)->name(), DotNet::ICloneable, true);
string memberType = typeToString((*d)->type());
_out << nl << "_type = GetType(" << memberType << ')';
_out << nl << "_instance." << memberName << " = CType(v, " << memberType << ')';
@@ -1277,7 +1280,9 @@ Slice::Gen::TypesVisitor::visitClassDefEnd(const ClassDefPtr& p)
patchParams << ", " << classMemberCount++;
}
}
- writeMarshalUnmarshalCode(_out, (*d)->type(), fixId((*d)->name()), false, false, patchParams.str());
+ writeMarshalUnmarshalCode(_out, (*d)->type(),
+ fixId((*d)->name(), DotNet::ICloneable, true),
+ false, false, patchParams.str());
}
_out << nl << "__is.endReadSlice()";
_out << nl << "MyBase.__read(__is, true)";
@@ -1317,7 +1322,7 @@ Slice::Gen::TypesVisitor::visitOperation(const OperationPtr& p)
{
params = getParams(p);
args = getArgs(p);
- name = fixId(name);
+ name = fixId(name, DotNet::ICloneable, true);
ret = p->returnType();
retS = typeToString(ret);
}
@@ -1758,7 +1763,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
_out << nl << "Dim __h As Integer = 0";
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
- string memberName = fixId((*q)->name());
+ string memberName = fixId((*q)->name(), DotNet::ApplicationException);
bool isValue = isValueType((*q)->type());
if(!isValue)
{
@@ -1811,7 +1816,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
_out << nl << "End If";
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
- string memberName = fixId((*q)->name());
+ string memberName = fixId((*q)->name(), DotNet::ApplicationException);
ClassDeclPtr cl = ClassDeclPtr::dynamicCast((*q)->type());
if(cl && cl->isInterface()) // Bug in VB 7.1: cast should not be necessary.
@@ -1882,7 +1887,9 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
_out << nl << "__os.startWriteSlice()";
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
- writeMarshalUnmarshalCode(_out, (*q)->type(), fixId((*q)->name()), true, false);
+ writeMarshalUnmarshalCode(_out, (*q)->type(),
+ fixId((*q)->name(), DotNet::ApplicationException),
+ true, false);
}
_out << nl << "__os.endWriteSlice()";
if(base)
@@ -1928,7 +1935,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
_out << nl << "Case " << memberCount;
_out.inc();
}
- string memberName = fixId((*q)->name());
+ string memberName = fixId((*q)->name(), DotNet::ApplicationException);
string memberType = typeToString((*q)->type());
_out << nl << "_type = GetType(" << memberType << ')';
_out << nl << "_instance." << memberName << " = CType(v, " << memberType << ')';
@@ -1977,7 +1984,9 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
patchParams << ", " << classMemberCount++;
}
}
- writeMarshalUnmarshalCode(_out, (*q)->type(), fixId((*q)->name()), false, false, patchParams.str());
+ writeMarshalUnmarshalCode(_out, (*q)->type(),
+ fixId((*q)->name(), DotNet::ApplicationException),
+ false, false, patchParams.str());
}
_out << nl << "__is.endReadSlice()";
if(base)
@@ -2039,7 +2048,8 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
_out << sp << nl << "#End Region"; // Slice data members
_out.restoreIndent();
- if(p->hasMetaData("vb:class"))
+ bool isClass = p->hasMetaData("vb:class");
+ if(isClass)
{
_out.zeroIndent();
_out << sp << nl << "#Region \"ICloneable members\"";
@@ -2065,7 +2075,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
_out << nl << "Dim __h As Integer = 0";
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
- string memberName = fixId((*q)->name());
+ string memberName = fixId((*q)->name(), isClass ? DotNet::ICloneable : 0);
bool isValue = isValueType((*q)->type());
if(!isValue)
{
@@ -2112,7 +2122,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
_out << nl << "End If";
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
- string memberName = fixId((*q)->name());
+ string memberName = fixId((*q)->name(), isClass ? DotNet::ICloneable : 0);
if(!isValueType((*q)->type()))
{
_out << nl << "If " << memberName << " Is Nothing Then";
@@ -2200,7 +2210,9 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
_out.inc();
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
- writeMarshalUnmarshalCode(_out, (*q)->type(), fixId((*q)->name()), true, false);
+ writeMarshalUnmarshalCode(_out, (*q)->type(),
+ fixId((*q)->name(), isClass ? DotNet::ICloneable : 0),
+ true, false);
}
_out.dec();
_out << nl << "End Sub";
@@ -2249,7 +2261,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
_out.inc();
}
string memberType = typeToString((*q)->type());
- string memberName = fixId((*q)->name());
+ string memberName = fixId((*q)->name(), isClass ? DotNet::ICloneable : 0);
_out << nl << "_type = GetType(" << memberType << ')';
_out << nl << "_instance." << memberName << " = CType(v, " << memberType << ')';
if(classMembers.size() > 1)
@@ -2285,7 +2297,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
for(q = classMembers.begin(); q != classMembers.end(); ++q)
{
string memberType = typeToString((*q)->type());
- string memberName = fixId((*q)->name());
+ string memberName = fixId((*q)->name(), isClass ? DotNet::ICloneable : 0);
_out << nl << "Friend " << memberName << " As " << memberType;
}
_out.dec();
@@ -2297,7 +2309,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
_out.inc();
for(q = classMembers.begin(); q != classMembers.end(); ++q)
{
- string memberName = fixId((*q)->name());
+ string memberName = fixId((*q)->name(), isClass ? DotNet::ICloneable : 0);
_out << nl << memberName << " = _pm." << memberName;
}
_out.dec();
@@ -2328,7 +2340,9 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
patchParams << ", " << classMemberCount++;
}
}
- writeMarshalUnmarshalCode(_out, (*q)->type(), fixId((*q)->name()), false, false, patchParams.str());
+ writeMarshalUnmarshalCode(_out, (*q)->type(),
+ fixId((*q)->name(), isClass ? DotNet::ICloneable : 0),
+ false, false, patchParams.str());
}
_out.dec();
_out << nl << "End Sub";
@@ -2769,7 +2783,24 @@ Slice::Gen::TypesVisitor::visitConst(const ConstPtr& p)
void
Slice::Gen::TypesVisitor::visitDataMember(const DataMemberPtr& p)
{
- _out << sp << nl << "Public " << fixId(p->name()) << " As " << typeToString(p->type());
+ int baseTypes = 0;
+ bool isClass = false;
+ ContainedPtr cont = ContainedPtr::dynamicCast(p->container());
+ assert(cont);
+ if(StructPtr::dynamicCast(cont) && cont->hasMetaData("cs:class"))
+ {
+ baseTypes = DotNet::ICloneable;
+ }
+ else if(ExceptionPtr::dynamicCast(cont))
+ {
+ baseTypes = DotNet::ApplicationException;
+ }
+ else if(ClassDefPtr::dynamicCast(cont))
+ {
+ baseTypes = DotNet::ICloneable;
+ isClass = true;
+ }
+ _out << sp << nl << "Public " << fixId(p->name(), baseTypes, isClass) << " As " << typeToString(p->type());
}
Slice::Gen::ProxyVisitor::ProxyVisitor(IceUtil::Output& out)
@@ -2841,7 +2872,7 @@ Slice::Gen::ProxyVisitor::visitClassDefEnd(const ClassDefPtr&)
void
Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
{
- string name = fixId(p->name());
+ string name = fixId(p->name(), DotNet::ICloneable, true);
vector<string> params = getParams(p);
TypePtr ret = p->returnType();
@@ -2964,7 +2995,7 @@ Slice::Gen::OpsVisitor::writeOperations(const ClassDefPtr& p, bool noCurrent)
{
OperationPtr op = *r;
bool amd = !p->isLocal() && (p->hasMetaData("amd") || op->hasMetaData("amd"));
- string name = amd ? (op->name() + "_async") : fixId(op->name());
+ string name = amd ? (op->name() + "_async") : fixId(op->name(), DotNet::ICloneable, true);
TypePtr ret;
vector<string> params;
@@ -3059,7 +3090,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
for(r = ops.begin(); r != ops.end(); ++r)
{
OperationPtr op = *r;
- string opName = fixId(op->name());
+ string opName = fixId(op->name(), DotNet::ICloneable, true);
TypePtr ret = op->returnType();
string retS = typeToString(ret);
@@ -3528,7 +3559,7 @@ Slice::Gen::DelegateVisitor::visitClassDefStart(const ClassDefPtr& p)
for(r = ops.begin(); r != ops.end(); ++r)
{
OperationPtr op = *r;
- string opName = fixId(op->name());
+ string opName = fixId(op->name(), DotNet::ICloneable, true);
TypePtr ret = op->returnType();
string retS = typeToString(ret);
vector<string> params = getParams(op);
@@ -3598,7 +3629,7 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p)
for(r = ops.begin(); r != ops.end(); ++r)
{
OperationPtr op = *r;
- string opName = fixId(op->name());
+ string opName = fixId(op->name(), DotNet::ICloneable, true);
TypePtr ret = op->returnType();
string retS = typeToString(ret);
@@ -3837,7 +3868,7 @@ Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p)
for(r = ops.begin(); r != ops.end(); ++r)
{
OperationPtr op = *r;
- string opName = fixId(op->name());
+ string opName = fixId(op->name(), DotNet::ICloneable, true);
TypePtr ret = op->returnType();
string retS = typeToString(ret);
string vbOp = ret ? "Function" : "Sub";
@@ -3984,7 +4015,7 @@ Slice::Gen::DispatcherVisitor::visitClassDefStart(const ClassDefPtr& p)
}
else
{
- name = fixId(name);
+ name = fixId(name, DotNet::ICloneable, true);
params = getParams(*op);
ret = (*op)->returnType();
args = getArgs(*op);
@@ -4530,7 +4561,7 @@ Slice::Gen::TieVisitor::visitClassDefStart(const ClassDefPtr& p)
for(r = ops.begin(); r != ops.end(); ++r)
{
bool hasAMD = p->hasMetaData("amd") || (*r)->hasMetaData("amd");
- string opName = hasAMD ? (*r)->name() + "_async" : fixId((*r)->name());
+ string opName = hasAMD ? (*r)->name() + "_async" : fixId((*r)->name(), DotNet::ICloneable, true);
TypePtr ret = (*r)->returnType();
string retS = typeToString(ret);
@@ -4607,7 +4638,7 @@ Slice::Gen::TieVisitor::writeInheritedOperations(const ClassDefPtr& p, NameSet&
for(r = ops.begin(); r != ops.end(); ++r)
{
bool hasAMD = p->hasMetaData("amd") || (*r)->hasMetaData("amd");
- string opName = hasAMD ? (*r)->name() + "_async" : fixId((*r)->name());
+ string opName = hasAMD ? (*r)->name() + "_async" : fixId((*r)->name(), DotNet::ICloneable, true);
if(opNames.find(opName) != opNames.end())
{
continue;
@@ -4756,7 +4787,7 @@ Slice::Gen::BaseImplVisitor::writeOperation(const OperationPtr& op, bool local,
{
_out << "Overrides ";
}
- _out << vbOp << ' ' << fixId(opName) << spar << pDecls;
+ _out << vbOp << ' ' << fixId(opName, DotNet::ICloneable, true) << spar << pDecls;
if(!local)
{
_out << "ByVal __current As Ice.Current";
@@ -4774,7 +4805,7 @@ Slice::Gen::BaseImplVisitor::writeOperation(const OperationPtr& op, bool local,
{
if(forTie)
{
- _out << " Implements _" << cl->name() << "Operations." << fixId(opName); // TODO: should be containing class?
+ _out << " Implements _" << cl->name() << "Operations." << fixId(opName, DotNet::ICloneable, true); // TODO: should be containing class?
}
}
_out.inc();