summaryrefslogtreecommitdiff
path: root/cpp/src/Slice/DotNetNames.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/src/Slice/DotNetNames.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/src/Slice/DotNetNames.cpp')
-rwxr-xr-xcpp/src/Slice/DotNetNames.cpp155
1 files changed, 155 insertions, 0 deletions
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;
+}