summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/IcePack/.depend4
-rw-r--r--cpp/src/IcePack/Grammar.y (renamed from cpp/src/IcePack/Grammer.y)0
-rw-r--r--cpp/src/IcePack/Makefile14
-rw-r--r--cpp/src/IcePack/Scanner.l2
-rw-r--r--cpp/src/IcePack/icepackC.dsp30
-rw-r--r--cpp/src/Slice/.depend5
-rw-r--r--cpp/src/Slice/CPlusPlusUtil.cpp (renamed from cpp/src/slice2cpp/GenUtil.cpp)149
-rw-r--r--cpp/src/Slice/Grammar.y (renamed from cpp/src/Slice/Grammer.y)2
-rw-r--r--cpp/src/Slice/GrammarUtil.h (renamed from cpp/src/Slice/GrammerUtil.h)0
-rw-r--r--cpp/src/Slice/Makefile17
-rw-r--r--cpp/src/Slice/Scanner.l4
-rw-r--r--cpp/src/Slice/slice.dsp40
-rw-r--r--cpp/src/slice2cpp/.depend3
-rw-r--r--cpp/src/slice2cpp/Gen.cpp99
-rw-r--r--cpp/src/slice2cpp/Gen.h3
-rw-r--r--cpp/src/slice2cpp/GenUtil.h33
-rw-r--r--cpp/src/slice2cpp/Makefile1
-rw-r--r--cpp/src/slice2cpp/slice2cpp.dsp8
-rw-r--r--cpp/src/slice2freeze/.depend3
-rw-r--r--cpp/src/slice2freeze/GenUtil.cpp216
-rw-r--r--cpp/src/slice2freeze/GenUtil.h32
-rw-r--r--cpp/src/slice2freeze/Main.cpp111
-rw-r--r--cpp/src/slice2freeze/Makefile3
23 files changed, 230 insertions, 549 deletions
diff --git a/cpp/src/IcePack/.depend b/cpp/src/IcePack/.depend
index 53782e50bf2..2f01336bbaf 100644
--- a/cpp/src/IcePack/.depend
+++ b/cpp/src/IcePack/.depend
@@ -1,6 +1,6 @@
Admin.o: Admin.cpp ../../include/IcePack/Admin.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/IceUtil/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/Proxy.h ../../include/IceUtil/Shared.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/EmitterF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/LocalObject.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/Ice/Stream.h ../../include/Ice/InstanceF.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../../include/Ice/Direct.h ../../include/Ice/LocalException.h
-Grammer.o: Grammer.cpp ../../include/Ice/Ice.h ../../include/Ice/Communicator.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/IceUtil/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/PicklerF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ServantFactoryF.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/ServantFactory.h ../../include/Ice/Pickler.h ../../include/Ice/Initialize.h ../../include/Ice/InstanceF.h ../IcePack/Parser.h ../../include/IcePack/Admin.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/EmitterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/Ice/Stream.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../../include/Ice/Direct.h
-Scanner.o: Scanner.cpp ../../include/Ice/Ice.h ../../include/Ice/Communicator.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/IceUtil/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/PicklerF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ServantFactoryF.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/ServantFactory.h ../../include/Ice/Pickler.h ../../include/Ice/Initialize.h ../../include/Ice/InstanceF.h ../IcePack/Parser.h ../../include/IcePack/Admin.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/EmitterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/Ice/Stream.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../../include/Ice/Direct.h ../IcePack/Grammer.h
+Grammar.o: Grammar.cpp ../../include/Ice/Ice.h ../../include/Ice/Communicator.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/IceUtil/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/PicklerF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ServantFactoryF.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/ServantFactory.h ../../include/Ice/Pickler.h ../../include/Ice/Initialize.h ../../include/Ice/InstanceF.h ../IcePack/Parser.h ../../include/IcePack/Admin.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/EmitterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/Ice/Stream.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../../include/Ice/Direct.h
+Scanner.o: Scanner.cpp ../../include/Ice/Ice.h ../../include/Ice/Communicator.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/IceUtil/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/PicklerF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ServantFactoryF.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/ServantFactory.h ../../include/Ice/Pickler.h ../../include/Ice/Initialize.h ../../include/Ice/InstanceF.h ../IcePack/Parser.h ../../include/IcePack/Admin.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/EmitterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/Ice/Stream.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../../include/Ice/Direct.h ../IcePack/Grammar.h
Parser.o: Parser.cpp ../../include/Ice/Ice.h ../../include/Ice/Communicator.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/IceUtil/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/PicklerF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ServantFactoryF.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/ServantFactory.h ../../include/Ice/Pickler.h ../../include/Ice/Initialize.h ../../include/Ice/InstanceF.h ../IcePack/Parser.h ../../include/IcePack/Admin.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/EmitterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/Ice/Stream.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../../include/Ice/Direct.h
Client.o: Client.cpp ../../include/Ice/Ice.h ../../include/Ice/Communicator.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/IceUtil/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/PicklerF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ServantFactoryF.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/ServantFactory.h ../../include/Ice/Pickler.h ../../include/Ice/Initialize.h ../../include/Ice/InstanceF.h ../IcePack/Parser.h ../../include/IcePack/Admin.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/EmitterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/Ice/Stream.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../../include/Ice/Direct.h
Server.o: Server.cpp ../../include/Ice/Ice.h ../../include/Ice/Communicator.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/IceUtil/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/PicklerF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ServantFactoryF.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/ServantFactory.h ../../include/Ice/Pickler.h ../../include/Ice/Initialize.h ../../include/Ice/InstanceF.h ../IcePack/AdminI.h ../../include/IcePack/Admin.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/EmitterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/Ice/Stream.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../../include/Ice/Direct.h ../IcePack/Forward.h ../../include/IcePack/AdminF.h ../IcePack/Activator.h
diff --git a/cpp/src/IcePack/Grammer.y b/cpp/src/IcePack/Grammar.y
index 680fa48884c..680fa48884c 100644
--- a/cpp/src/IcePack/Grammer.y
+++ b/cpp/src/IcePack/Grammar.y
diff --git a/cpp/src/IcePack/Makefile b/cpp/src/IcePack/Makefile
index 5a3e4f0aad4..ea8f94b9924 100644
--- a/cpp/src/IcePack/Makefile
+++ b/cpp/src/IcePack/Makefile
@@ -23,7 +23,7 @@ TARGETS = $(NAME) $(VERSIONED_NAME) $(CLIENT) $(SERVER)
OBJS = Admin.o
-COBJS = Grammer.o \
+COBJS = Grammar.o \
Scanner.o \
Parser.o \
Client.o
@@ -61,17 +61,17 @@ $(SERVER): $(SOBJS)
rm -f $@
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $(SOBJS) -lIcePack $(LIBS)
-Grammer.cpp Grammer.h: Grammer.y
- bison -dvt Grammer.y
- rm -f Grammer.cpp ; mv Grammer.tab.c Grammer.cpp
- rm -f Grammer.h ; mv Grammer.tab.h Grammer.h
+Grammar.cpp Grammar.h: Grammar.y
+ bison -dvt Grammar.y
+ rm -f Grammar.cpp ; mv Grammar.tab.c Grammar.cpp
+ rm -f Grammar.h ; mv Grammar.tab.h Grammar.h
-Scanner.cpp: Scanner.l Grammer.h
+Scanner.cpp: Scanner.l Grammar.h
flex Scanner.l
rm -f Scanner.cpp ; mv lex.yy.c Scanner.cpp
clean::
- -rm -f Grammer.cpp Grammer.h Grammer.output
+ -rm -f Grammar.cpp Grammar.h Grammar.output
-rm -f Scanner.cpp lex.yy.c
$(HDIR)/Admin.h Admin.cpp: $(SDIR)/Admin.ice $(SLICE2CPP)
diff --git a/cpp/src/IcePack/Scanner.l b/cpp/src/IcePack/Scanner.l
index 163cd2bbeb0..d0d91199e44 100644
--- a/cpp/src/IcePack/Scanner.l
+++ b/cpp/src/IcePack/Scanner.l
@@ -12,7 +12,7 @@
#include <Ice/Ice.h>
#include <IcePack/Parser.h>
-#include <IcePack/Grammer.h>
+#include <IcePack/Grammar.h>
using namespace std;
using namespace Ice;
diff --git a/cpp/src/IcePack/icepackC.dsp b/cpp/src/IcePack/icepackC.dsp
index 4f6ce1c10ff..698f89df295 100644
--- a/cpp/src/IcePack/icepackC.dsp
+++ b/cpp/src/IcePack/icepackC.dsp
@@ -93,7 +93,7 @@ SOURCE=.\Client.cpp
# End Source File
# Begin Source File
-SOURCE=.\Grammer.cpp
+SOURCE=.\Grammar.cpp
# End Source File
# Begin Source File
@@ -109,7 +109,7 @@ SOURCE=.\Scanner.cpp
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
-SOURCE=.\Grammer.h
+SOURCE=.\Grammar.h
# End Source File
# Begin Source File
@@ -121,41 +121,41 @@ SOURCE=.\Parser.h
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# Begin Source File
-SOURCE=.\Grammer.y
+SOURCE=.\Grammar.y
!IF "$(CFG)" == "IcePackC - Win32 Release"
# Begin Custom Build
-InputPath=.\Grammer.y
+InputPath=.\Grammar.y
BuildCmds= \
- bison -dvt Grammer.y \
- move Grammer.tab.c Grammer.cpp \
- move Grammer.tab.h Grammer.h \
+ bison -dvt Grammar.y \
+ move Grammar.tab.c Grammar.cpp \
+ move Grammar.tab.h Grammar.h \
-"Grammer.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+"Grammar.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
-"Grammer.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+"Grammar.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
# End Custom Build
!ELSEIF "$(CFG)" == "IcePackC - Win32 Debug"
# Begin Custom Build
-InputPath=.\Grammer.y
+InputPath=.\Grammar.y
BuildCmds= \
- bison -dvt Grammer.y \
- move Grammer.tab.c Grammer.cpp \
- move Grammer.tab.h Grammer.h \
+ bison -dvt Grammar.y \
+ move Grammar.tab.c Grammar.cpp \
+ move Grammar.tab.h Grammar.h \
-"Grammer.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+"Grammar.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
-"Grammer.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+"Grammar.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
# End Custom Build
diff --git a/cpp/src/Slice/.depend b/cpp/src/Slice/.depend
index 44e691f9a2d..7760edd1cc3 100644
--- a/cpp/src/Slice/.depend
+++ b/cpp/src/Slice/.depend
@@ -1,4 +1,5 @@
-Scanner.o: Scanner.cpp ../Slice/GrammerUtil.h ../../include/Slice/Parser.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../Slice/Grammer.h
-Grammer.o: Grammer.cpp ../Slice/GrammerUtil.h ../../include/Slice/Parser.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h
+Scanner.o: Scanner.cpp ../Slice/GrammarUtil.h ../../include/Slice/Parser.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../Slice/Grammar.h
+Grammar.o: Grammar.cpp ../Slice/GrammarUtil.h ../../include/Slice/Parser.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h
Parser.o: Parser.cpp ../../include/IceUtil/Functional.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Slice/Parser.h ../../include/IceUtil/Shared.h
OutputUtil.o: OutputUtil.cpp ../../include/Slice/OutputUtil.h ../../include/IceUtil/Config.h
+CPlusPlusUtil.o: CPlusPlusUtil.cpp ../../include/Slice/CPlusPlusUtil.h ../../include/Slice/Parser.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/Slice/OutputUtil.h
diff --git a/cpp/src/slice2cpp/GenUtil.cpp b/cpp/src/Slice/CPlusPlusUtil.cpp
index bac1dcc146c..6a1b4176062 100644
--- a/cpp/src/slice2cpp/GenUtil.cpp
+++ b/cpp/src/Slice/CPlusPlusUtil.cpp
@@ -8,11 +8,98 @@
//
// **********************************************************************
-#include <GenUtil.h>
+#include <Slice/CPlusPlusUtil.h>
using namespace std;
using namespace Slice;
+char
+Slice::ToIfdef::operator()(char c)
+{
+ if (!isalnum(c))
+ {
+ return '_';
+ }
+ else
+ {
+ return c;
+ }
+}
+
+string
+Slice::changeInclude(const string& orig, const vector<string>& includePaths)
+{
+ string file = orig;
+
+ for (vector<string>::const_iterator p = includePaths.begin(); p != includePaths.end(); ++p)
+ {
+ if (orig.compare(0, p->length(), *p) == 0)
+ {
+ string s = orig.substr(p->length());
+ if (s.size() < file.size())
+ {
+ file = s;
+ }
+ }
+ }
+
+ string::size_type pos = file.rfind('.');
+ if (pos != string::npos)
+ {
+ file.erase(pos);
+ }
+
+ return file;
+}
+
+void
+Slice::printHeader(Output& out)
+{
+ static const char* header =
+"// **********************************************************************\n"
+"//\n"
+"// Copyright (c) 2001\n"
+"// MutableRealms, Inc.\n"
+"// Huntsville, AL, USA\n"
+"//\n"
+"// All Rights Reserved\n"
+"//\n"
+"// **********************************************************************\n"
+ ;
+
+ out << header;
+ out << "\n// Ice version " << ICE_STRING_VERSION;
+}
+
+void
+Slice::printVersionCheck(Output& out)
+{
+ out << "\n";
+ out << "\n#ifndef ICE_IGNORE_VERSION";
+ out << "\n# if ICE_INT_VERSION != 0x" << hex << ICE_INT_VERSION;
+ out << "\n# error Ice version mismatch!";
+ out << "\n# endif";
+ out << "\n#endif";
+}
+
+void
+Slice::printDllExportStuff(Output& out, const string& dllExport)
+{
+ if (dllExport.size())
+ {
+ out << sp;
+ out << "\n#ifdef WIN32";
+ out << "\n# ifdef " << dllExport.substr(0, dllExport.size() - 1) << "_EXPORTS";
+ out << "\n# define " << dllExport << "__declspec(dllexport)";
+ out << "\n# else";
+ out << "\n# define " << dllExport << "__declspec(dllimport)";
+ out << "\n# endif";
+ out << "\n#else";
+ out << "\n# define " << dllExport << "/**/";
+ out << "\n#endif";
+ }
+}
+
string
Slice::typeToString(const TypePtr& type)
{
@@ -239,14 +326,48 @@ Slice::exceptionTypeToString(const TypePtr& type)
}
void
-Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string& param, bool marshal)
+Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string& param, bool marshal,
+ const string& str, bool pointer)
{
- const char* func = marshal ? "write(" : "read(";
- const char* stream = marshal ? "__os" : "__is";
+ string stream;
+ if (str.empty())
+ {
+ stream = marshal ? "__os" : "__is";
+ }
+ else
+ {
+ stream = str;
+ }
+
+ string deref;
+ if (pointer)
+ {
+ deref = "->";
+ }
+ else
+ {
+ deref = '.';
+ }
+
+ string obj;
+ if (stream.find("__") == 0)
+ {
+ obj = "__obj";
+ }
+ else
+ {
+ obj = "obj;";
+ }
+
+ string func = marshal ? "write(" : "read(";
+ if (!pointer)
+ {
+ func += '&';
+ }
if (BuiltinPtr::dynamicCast(type))
{
- out << nl << stream << "->" << func << param << ");";
+ out << nl << stream << deref << func << param << ");";
return;
}
@@ -256,27 +377,27 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string&
out << sb;
if (marshal)
{
- out << nl << "::Ice::ObjectPtr __obj = " << param << ';';
- out << nl << stream << "->write(__obj);";
+ out << nl << "::Ice::ObjectPtr " << obj << ' ' << param << ';';
+ out << nl << stream << deref << "write(" << obj << ");";
}
else
{
- out << nl << "::Ice::ObjectPtr __obj;";
- out << nl << stream << "->read(__obj, " << cl->scoped() << "::__classIds[0]);";
- out << nl << "if (!__obj)";
+ out << nl << "::Ice::ObjectPtr " << obj << ';';
+ out << nl << stream << deref << func << obj << ", " << cl->scoped() << "::__classIds[0]);";
+ out << nl << "if (!" << obj << ')';
out << sb;
ClassDefPtr def = cl->definition();
if (def && !def->isAbstract())
{
- out << nl << "__obj = new " << cl->scoped() << ";";
- out << nl << "__obj->__read(__is);";
+ out << nl << obj << " = new " << cl->scoped() << ";";
+ out << nl << obj << "->" << func << stream << ");";
}
else
{
out << nl << "throw ::Ice::NoServantFactoryException(__FILE__, __LINE__);";
}
out << eb;
- out << nl << param << " = " << cl->scoped() << "Ptr::dynamicCast(__obj);";
+ out << nl << param << " = " << cl->scoped() << "Ptr::dynamicCast(" << obj << ");";
out << nl << "if (!" << param << ')';
out << sb;
out << nl << "throw ::Ice::ServantUnmarshalException(__FILE__, __LINE__);";
@@ -299,7 +420,7 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string&
{
if (BuiltinPtr::dynamicCast(seq->type()))
{
- out << nl << stream << "->" << func << param << ");";
+ out << nl << stream << deref << func << param << ");";
}
else
{
diff --git a/cpp/src/Slice/Grammer.y b/cpp/src/Slice/Grammar.y
index f1cd290ee00..6a49a783def 100644
--- a/cpp/src/Slice/Grammer.y
+++ b/cpp/src/Slice/Grammar.y
@@ -10,7 +10,7 @@
//
// **********************************************************************
-#include <Slice/GrammerUtil.h>
+#include <Slice/GrammarUtil.h>
using namespace std;
using namespace Slice;
diff --git a/cpp/src/Slice/GrammerUtil.h b/cpp/src/Slice/GrammarUtil.h
index 4641c6d49fc..4641c6d49fc 100644
--- a/cpp/src/Slice/GrammerUtil.h
+++ b/cpp/src/Slice/GrammarUtil.h
diff --git a/cpp/src/Slice/Makefile b/cpp/src/Slice/Makefile
index 950b45e91a4..32902297b61 100644
--- a/cpp/src/Slice/Makefile
+++ b/cpp/src/Slice/Makefile
@@ -19,9 +19,10 @@ VERSIONED_NAME = $(top_srcdir)/lib/$(VERSIONED_BASE)
TARGETS = $(NAME) $(VERSIONED_NAME)
OBJS = Scanner.o \
- Grammer.o \
+ Grammar.o \
Parser.o \
- OutputUtil.o
+ OutputUtil.o \
+ CPlusPlusUtil.o
SRCS = $(OBJS:.o=.cpp)
@@ -37,17 +38,17 @@ $(NAME): $(VERSIONED_NAME)
rm -f $@
ln -s $(VERSIONED_BASE) $@
-Grammer.cpp Grammer.h: Grammer.y
- bison -dvt Grammer.y
- rm -f Grammer.cpp ; mv Grammer.tab.c Grammer.cpp
- rm -f Grammer.h ; mv Grammer.tab.h Grammer.h
+Grammar.cpp Grammar.h: Grammar.y
+ bison -dvt Grammar.y
+ rm -f Grammar.cpp ; mv Grammar.tab.c Grammar.cpp
+ rm -f Grammar.h ; mv Grammar.tab.h Grammar.h
-Scanner.cpp: Scanner.l Grammer.h
+Scanner.cpp: Scanner.l Grammar.h
flex Scanner.l
rm -f Scanner.cpp ; mv lex.yy.c Scanner.cpp
clean::
- -rm -f Grammer.cpp Grammer.h Grammer.output
+ -rm -f Grammar.cpp Grammar.h Grammar.output
-rm -f Scanner.cpp lex.yy.c
include .depend
diff --git a/cpp/src/Slice/Scanner.l b/cpp/src/Slice/Scanner.l
index 916b7b6935d..733439d9e1c 100644
--- a/cpp/src/Slice/Scanner.l
+++ b/cpp/src/Slice/Scanner.l
@@ -10,8 +10,8 @@
//
// **********************************************************************
-#include <Slice/GrammerUtil.h> // Before Grammer.h, so that YYSTYPE is defined
-#include <Slice/Grammer.h>
+#include <Slice/GrammarUtil.h> // Before Grammer.h, so that YYSTYPE is defined
+#include <Slice/Grammar.h>
using namespace std;
using namespace Slice;
diff --git a/cpp/src/Slice/slice.dsp b/cpp/src/Slice/slice.dsp
index c69bee84e03..886df264e30 100644
--- a/cpp/src/Slice/slice.dsp
+++ b/cpp/src/Slice/slice.dsp
@@ -104,7 +104,7 @@ PostBuild_Cmds=copy Debug\slice001d.* ..\..\lib
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
-SOURCE=.\Grammer.cpp
+SOURCE=.\Grammar.cpp
# End Source File
# Begin Source File
@@ -112,6 +112,10 @@ SOURCE=.\OutputUtil.cpp
# End Source File
# Begin Source File
+SOURCE=.\CPlusPlusUtil.cpp
+# End Source File
+# Begin Source File
+
SOURCE=.\Parser.cpp
# End Source File
# Begin Source File
@@ -124,11 +128,11 @@ SOURCE=.\Scanner.cpp
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
-SOURCE=.\Grammer.h
+SOURCE=.\Grammar.h
# End Source File
# Begin Source File
-SOURCE=.\GrammerUtil.h
+SOURCE=.\GrammarUtil.h
# End Source File
# Begin Source File
@@ -136,6 +140,10 @@ SOURCE=..\..\incluce\Slice\OutputUtil.h
# End Source File
# Begin Source File
+SOURCE=..\..\incluce\Slice\CPlusPlusUtil.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\include\Slice\Parser.h
# End Source File
# End Group
@@ -144,41 +152,41 @@ SOURCE=..\..\include\Slice\Parser.h
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# Begin Source File
-SOURCE=.\Grammer.y
+SOURCE=.\Grammar.y
!IF "$(CFG)" == "Slice - Win32 Release"
# Begin Custom Build
-InputPath=.\Grammer.y
+InputPath=.\Grammar.y
BuildCmds= \
- bison -dvt Grammer.y \
- move Grammer.tab.c Grammer.cpp \
- move Grammer.tab.h Grammer.h \
+ bison -dvt Grammar.y \
+ move Grammar.tab.c Grammar.cpp \
+ move Grammar.tab.h Grammar.h \
-"Grammer.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+"Grammar.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
-"Grammer.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+"Grammar.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
# End Custom Build
!ELSEIF "$(CFG)" == "Slice - Win32 Debug"
# Begin Custom Build
-InputPath=.\Grammer.y
+InputPath=.\Grammar.y
BuildCmds= \
- bison -dvt Grammer.y \
- move Grammer.tab.c Grammer.cpp \
- move Grammer.tab.h Grammer.h \
+ bison -dvt Grammar.y \
+ move Grammar.tab.c Grammar.cpp \
+ move Grammar.tab.h Grammar.h \
-"Grammer.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+"Grammar.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
-"Grammer.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+"Grammar.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(BuildCmds)
# End Custom Build
diff --git a/cpp/src/slice2cpp/.depend b/cpp/src/slice2cpp/.depend
index e0fdaed0133..4b2269bc434 100644
--- a/cpp/src/slice2cpp/.depend
+++ b/cpp/src/slice2cpp/.depend
@@ -1,3 +1,2 @@
-Gen.o: Gen.cpp ../../include/IceUtil/Functional.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h Gen.h ../../include/Slice/Parser.h ../../include/IceUtil/Shared.h ../../include/Slice/OutputUtil.h GenUtil.h
-GenUtil.o: GenUtil.cpp GenUtil.h ../../include/Slice/Parser.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/Slice/OutputUtil.h
+Gen.o: Gen.cpp ../../include/IceUtil/Functional.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Slice/CPlusPlusUtil.h ../../include/Slice/Parser.h ../../include/IceUtil/Shared.h ../../include/Slice/OutputUtil.h Gen.h
Main.o: Main.cpp Gen.h ../../include/Slice/Parser.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/Slice/OutputUtil.h
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index 28f0f1dbc2f..ef56592422f 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -9,28 +9,13 @@
// **********************************************************************
#include <IceUtil/Functional.h>
+#include <Slice/CPlusPlusUtil.h>
#include <Gen.h>
-#include <GenUtil.h>
#include <limits>
using namespace std;
using namespace Slice;
-struct ToIfdef
-{
- char operator()(char c)
- {
- if (!isalnum(c))
- {
- return '_';
- }
- else
- {
- return c;
- }
- }
-};
-
Slice::Gen::Gen(const string& name, const string& base, const string& include, const vector<string>& includePaths,
const string& dllExport, const string& dir) :
_base(base),
@@ -38,11 +23,6 @@ Slice::Gen::Gen(const string& name, const string& base, const string& include, c
_includePaths(includePaths),
_dllExport(dllExport)
{
- if (_dllExport.size())
- {
- _dllExport += " ";
- }
-
for (vector<string>::iterator p = _includePaths.begin(); p != _includePaths.end(); ++p)
{
if (p->length() && (*p)[p->length() - 1] != '/')
@@ -81,6 +61,8 @@ Slice::Gen::Gen(const string& name, const string& base, const string& include, c
printHeader(H);
printHeader(C);
+ H << "\n// Generated from file `" << changeInclude(_base, _includePaths) << ".ice'\n";
+ C << "\n// Generated from file `" << changeInclude(_base, _includePaths) << ".ice'\n";
string s = fileH;
if (_include.size())
@@ -137,35 +119,16 @@ Slice::Gen::generate(const UnitPtr& unit)
StringList includes = unit->includeFiles();
for (StringList::const_iterator q = includes.begin(); q != includes.end(); ++q)
{
- H << "\n#include <" << changeInclude(*q) << ".h>";
+ H << "\n#include <" << changeInclude(*q, _includePaths) << ".h>";
}
- H << sp;
- H << "\n#ifndef ICE_IGNORE_VERSION";
- H << "\n# if ICE_INT_VERSION != 0x" << hex << ICE_INT_VERSION;
- H << "\n# error Ice version mismatch!";
- H << "\n# endif";
- H << "\n#endif";
-
- C << sp;
- C << "\n#ifndef ICE_IGNORE_VERSION";
- C << "\n# if ICE_INT_VERSION != 0x" << hex << ICE_INT_VERSION;
- C << "\n# error Ice version mismatch!";
- C << "\n# endif";
- C << "\n#endif";
+ printVersionCheck(H);
+ printVersionCheck(C);
+ printDllExportStuff(H, _dllExport);
if (_dllExport.size())
{
- H << sp;
- H << "\n#ifdef WIN32";
- H << "\n# ifdef " << _dllExport.substr(0, _dllExport.size() - 1) << "_EXPORTS";
- H << "\n# define " << _dllExport << "__declspec(dllexport)";
- H << "\n# else";
- H << "\n# define " << _dllExport << "__declspec(dllimport)";
- H << "\n# endif";
- H << "\n#else";
- H << "\n# define " << _dllExport << "/**/";
- H << "\n#endif";
+ _dllExport += " ";
}
ProxyDeclVisitor proxyDeclVisitor(H, C, _dllExport);
@@ -199,52 +162,6 @@ Slice::Gen::generate(const UnitPtr& unit)
unit->visit(&objectVisitor);
}
-string
-Slice::Gen::changeInclude(const string& orig)
-{
- string file = orig;
- for (vector<string>::const_iterator p = _includePaths.begin(); p != _includePaths.end(); ++p)
- {
- if (orig.compare(0, p->length(), *p) == 0)
- {
- string s = orig.substr(p->length());
- if (s.size() < file.size())
- {
- file = s;
- }
- }
- }
-
- string::size_type pos = file.rfind('.');
- if (pos != string::npos)
- {
- file.erase(pos);
- }
-
- return file;
-}
-
-void
-Slice::Gen::printHeader(Output& out)
-{
- static const char* header =
-"// **********************************************************************\n"
-"//\n"
-"// Copyright (c) 2001\n"
-"// MutableRealms, Inc.\n"
-"// Huntsville, AL, USA\n"
-"//\n"
-"// All Rights Reserved\n"
-"//\n"
-"// **********************************************************************\n"
- ;
-
- out << header;
- out << "\n// Generated from file `" << changeInclude(_base) << ".ice'";
- out << "\n// Ice version " << ICE_STRING_VERSION;
- out << '\n';
-}
-
Slice::Gen::TypesVisitor::TypesVisitor(Output& h, Output& c, const string& dllExport) :
H(h), C(c), _dllExport(dllExport)
{
diff --git a/cpp/src/slice2cpp/Gen.h b/cpp/src/slice2cpp/Gen.h
index 8972d2f60f9..024f202a12e 100644
--- a/cpp/src/slice2cpp/Gen.h
+++ b/cpp/src/slice2cpp/Gen.h
@@ -35,9 +35,6 @@ public:
private:
- std::string changeInclude(const std::string&);
- void printHeader(Output&);
-
Output H;
Output C;
diff --git a/cpp/src/slice2cpp/GenUtil.h b/cpp/src/slice2cpp/GenUtil.h
deleted file mode 100644
index 0959c4eef80..00000000000
--- a/cpp/src/slice2cpp/GenUtil.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2001
-// MutableRealms, Inc.
-// Huntsville, AL, USA
-//
-// All Rights Reserved
-//
-// **********************************************************************
-
-#ifndef GEN_UTIL_H
-#define GEN_UTIL_H
-
-#include <Slice/Parser.h>
-#include <Slice/OutputUtil.h>
-
-namespace Slice
-{
-
-std::string typeToString(const TypePtr&);
-std::string returnTypeToString(const TypePtr&);
-std::string inputTypeToString(const TypePtr&);
-std::string outputTypeToString(const TypePtr&);
-std::string exceptionTypeToString(const TypePtr&);
-
-void writeMarshalUnmarshalCode(Output&, const TypePtr&, const std::string&, bool);
-void writeMarshalCode(Output&, const std::list<std::pair<TypePtr, std::string> >&, const TypePtr&);
-void writeUnmarshalCode(Output&, const std::list<std::pair<TypePtr, std::string> >&, const TypePtr&);
-void writeAllocateCode(Output&, const std::list<std::pair<TypePtr, std::string> >&, const TypePtr&);
-
-}
-
-#endif
diff --git a/cpp/src/slice2cpp/Makefile b/cpp/src/slice2cpp/Makefile
index b74e28f90b6..423aa9fed07 100644
--- a/cpp/src/slice2cpp/Makefile
+++ b/cpp/src/slice2cpp/Makefile
@@ -15,7 +15,6 @@ NAME = $(top_srcdir)/bin/slice2cpp
TARGETS = $(NAME)
OBJS = Gen.o \
- GenUtil.o \
Main.o
SRCS = $(OBJS:.o=.cpp)
diff --git a/cpp/src/slice2cpp/slice2cpp.dsp b/cpp/src/slice2cpp/slice2cpp.dsp
index 93dd144ebcb..23790b1ea0f 100644
--- a/cpp/src/slice2cpp/slice2cpp.dsp
+++ b/cpp/src/slice2cpp/slice2cpp.dsp
@@ -93,10 +93,6 @@ SOURCE=.\Gen.cpp
# End Source File
# Begin Source File
-SOURCE=.\GenUtil.cpp
-# End Source File
-# Begin Source File
-
SOURCE=.\Main.cpp
# End Source File
# End Group
@@ -107,10 +103,6 @@ SOURCE=.\Main.cpp
SOURCE=.\Gen.h
# End Source File
-# Begin Source File
-
-SOURCE=.\GenUtil.h
-# End Source File
# End Group
# Begin Group "Resource Files"
diff --git a/cpp/src/slice2freeze/.depend b/cpp/src/slice2freeze/.depend
index dc5654bed5e..d6821eb50ec 100644
--- a/cpp/src/slice2freeze/.depend
+++ b/cpp/src/slice2freeze/.depend
@@ -1,2 +1 @@
-Main.o: Main.cpp ../../include/Slice/Parser.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/Slice/OutputUtil.h GenUtil.h
-GenUtil.o: GenUtil.cpp GenUtil.h ../../include/Slice/Parser.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/Slice/OutputUtil.h
+Main.o: Main.cpp ../../include/Slice/CPlusPlusUtil.h ../../include/Slice/Parser.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/Slice/OutputUtil.h
diff --git a/cpp/src/slice2freeze/GenUtil.cpp b/cpp/src/slice2freeze/GenUtil.cpp
deleted file mode 100644
index 17a58e9a1e3..00000000000
--- a/cpp/src/slice2freeze/GenUtil.cpp
+++ /dev/null
@@ -1,216 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2001
-// MutableRealms, Inc.
-// Huntsville, AL, USA
-//
-// All Rights Reserved
-//
-// **********************************************************************
-
-//
-// TODO: This is the same stuff as in ../slice2cpp/GenUtil.cpp. This
-// needs to be put into a library!
-//
-
-#include <GenUtil.h>
-
-using namespace std;
-using namespace Slice;
-
-string
-Slice::typeToString(const TypePtr& type)
-{
- static const char* builtinTable[] =
- {
- "::Ice::Byte",
- "bool",
- "::Ice::Short",
- "::Ice::Int",
- "::Ice::Long",
- "::Ice::Float",
- "::Ice::Double",
- "::std::string",
- "::std::wstring",
- "::Ice::ObjectPtr",
- "::Ice::ObjectPrx",
- "::Ice::LocalObjectPtr"
- };
-
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
- if (builtin)
- {
- return builtinTable[builtin->kind()];
- }
-
- ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type);
- if (cl)
- {
- return cl->scoped() + "Ptr";
- }
-
- ProxyPtr proxy = ProxyPtr::dynamicCast(type);
- if (proxy)
- {
- return proxy->_class()->scoped() + "Prx";
- }
-
- ContainedPtr contained = ContainedPtr::dynamicCast(type);
- if (contained)
- {
- return contained->scoped();
- }
-
- return "???";
-}
-
-string
-Slice::inputTypeToString(const TypePtr& type)
-{
- static const char* inputBuiltinTable[] =
- {
- "::Ice::Byte",
- "bool",
- "::Ice::Short",
- "::Ice::Int",
- "::Ice::Long",
- "::Ice::Float",
- "::Ice::Double",
- "const ::std::string&",
- "const ::std::wstring&",
- "const ::Ice::ObjectPtr&",
- "const ::Ice::ObjectPrx&",
- "const ::Ice::LocalObjectPtr&"
- };
-
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
- if (builtin)
- {
- return inputBuiltinTable[builtin->kind()];
- }
-
- ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type);
- if (cl)
- {
- return "const " + cl->scoped() + "Ptr&";
- }
-
- ProxyPtr proxy = ProxyPtr::dynamicCast(type);
- if (proxy)
- {
- return "const " + proxy->_class()->scoped() + "Prx&";
- }
-
- EnumPtr en = EnumPtr::dynamicCast(type);
- if (en)
- {
- return en->scoped();
- }
-
- NativePtr native = NativePtr::dynamicCast(type);
- if (native)
- {
- return native->scoped();
- }
-
- ContainedPtr contained = ContainedPtr::dynamicCast(type);
- if (contained)
- {
- return "const " + contained->scoped() + "&";
- }
-
- return "???";
-}
-
-void
-Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string& param, const string& stream,
- bool marshal)
-{
- const char* func = marshal ? "write(" : "read(";
-
- if (BuiltinPtr::dynamicCast(type))
- {
- out << nl << stream << '.' << func << param << ");";
- return;
- }
-
- ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type);
- if (cl)
- {
- out << sb;
- if (marshal)
- {
- out << nl << "::Ice::ObjectPtr obj = " << param << ';';
- out << nl << stream << ".write(obj);";
- }
- else
- {
- out << nl << "::Ice::ObjectPtr obj;";
- out << nl << stream << ".read(obj, " << cl->scoped() << "::__classIds[0]);";
- out << nl << "if (!obj)";
- out << sb;
- ClassDefPtr def = cl->definition();
- if (def && !def->isAbstract())
- {
- out << nl << "obj = new " << cl->scoped() << ";";
- out << nl << "obj->__read(&" << stream << ");";
- }
- else
- {
- out << nl << "throw ::Ice::NoServantFactoryException(__FILE__, __LINE__);";
- }
- out << eb;
- out << nl << param << " = " << cl->scoped() << "Ptr::dynamicCast(obj);";
- out << nl << "if (!" << param << ')';
- out << sb;
- out << nl << "throw ::Ice::ServantUnmarshalException(__FILE__, __LINE__);";
- out << eb;
- }
- out << eb;
-
- return;
- }
-
- StructPtr st = StructPtr::dynamicCast(type);
- if (st)
- {
- out << nl << param << ".__" << func << '&' << stream << ");";
- return;
- }
-
- SequencePtr seq = SequencePtr::dynamicCast(type);
- if (seq)
- {
- if (BuiltinPtr::dynamicCast(seq->type()))
- {
- out << nl << stream << '.' << func << param << ");";
- }
- else
- {
- out << nl << seq->scope() << "__" << func << '&' << stream << ", " << param << ", " << seq->scope()
- << "__U__" << seq->name() << "());";
- }
- return;
- }
-
- DictionaryPtr dict = DictionaryPtr::dynamicCast(type);
- if (dict)
- {
- out << nl << dict->scope() << "__" << func << '&' << stream << ", " << param << ", " << dict->scope()
- << "__U__" << dict->name() << "());";
- return;
- }
-
- NativePtr native = NativePtr::dynamicCast(type);
- assert(!native); // TODO
-
- ConstructedPtr constructed = ConstructedPtr::dynamicCast(type);
- if (!constructed)
- {
- ProxyPtr proxy = ProxyPtr::dynamicCast(type);
- assert(proxy);
- constructed = proxy->_class();
- }
-
- out << nl << constructed->scope() << "__" << func << '&' << stream << ", " << param << ");";
-}
diff --git a/cpp/src/slice2freeze/GenUtil.h b/cpp/src/slice2freeze/GenUtil.h
deleted file mode 100644
index 4944d569355..00000000000
--- a/cpp/src/slice2freeze/GenUtil.h
+++ /dev/null
@@ -1,32 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2001
-// MutableRealms, Inc.
-// Huntsville, AL, USA
-//
-// All Rights Reserved
-//
-// **********************************************************************
-
-//
-// TODO: This is the same stuff as in ../slice2cpp/GenUtil.cpp. This
-// needs to be put into a library!
-//
-
-#ifndef GEN_UTIL_H
-#define GEN_UTIL_H
-
-#include <Slice/Parser.h>
-#include <Slice/OutputUtil.h>
-
-namespace Slice
-{
-
-std::string typeToString(const TypePtr&);
-std::string inputTypeToString(const TypePtr&);
-
-void writeMarshalUnmarshalCode(Output&, const TypePtr&, const std::string&, const std::string&, bool);
-
-}
-
-#endif
diff --git a/cpp/src/slice2freeze/Main.cpp b/cpp/src/slice2freeze/Main.cpp
index ebec43c02cc..d71a171ac8a 100644
--- a/cpp/src/slice2freeze/Main.cpp
+++ b/cpp/src/slice2freeze/Main.cpp
@@ -8,9 +8,7 @@
//
// **********************************************************************
-#include <Slice/Parser.h>
-#include <Slice/OutputUtil.h>
-#include <GenUtil.h>
+#include <Slice/CPlusPlusUtil.h>
#include <fstream>
using namespace std;
@@ -23,21 +21,6 @@ struct Dict
string value;
};
-struct ToIfdef
-{
- char operator()(char c)
- {
- if (!isalnum(c))
- {
- return '_';
- }
- else
- {
- return c;
- }
- }
-};
-
void
usage(const char* n)
{
@@ -81,41 +64,9 @@ checkIdentifier(string n, string t, string s)
return true;
}
-string
-changeInclude(const string& orig, const vector<string>& includePaths)
-{
- string file = orig;
- for (vector<string>::const_iterator p = includePaths.begin(); p != includePaths.end(); ++p)
- {
- if (orig.compare(0, p->length(), *p) == 0)
- {
- string s = orig.substr(p->length());
- if (s.size() < file.size())
- {
- file = s;
- }
- }
- }
- return file;
-}
-
void
-printHeader(Output& out, const vector<Dict>& dicts)
+printFreezeTypes(Output& out, const vector<Dict>& dicts)
{
- static const char* header =
-"// **********************************************************************\n"
-"//\n"
-"// Copyright (c) 2001\n"
-"// MutableRealms, Inc.\n"
-"// Huntsville, AL, USA\n"
-"//\n"
-"// All Rights Reserved\n"
-"//\n"
-"// **********************************************************************\n"
- ;
-
- out << header;
- out << "\n// Ice version " << ICE_STRING_VERSION;
out << '\n';
out << "\n// Freeze types in this file:";
for (vector<Dict>::const_iterator p = dicts.begin(); p != dicts.end(); ++p)
@@ -212,9 +163,9 @@ writeDict(const string& n, UnitPtr& unit, const Dict& dict, Output& H, Output& C
C << sb;
C << nl << "IceInternal::InstancePtr instance = IceInternal::getInstance(_db->getCommunicator());";
C << nl << "IceInternal::Stream keyStream(instance);";
- writeMarshalUnmarshalCode(C, keyType, "key", "keyStream", true);
+ writeMarshalUnmarshalCode(C, keyType, "key", true, "keyStream", false);
C << nl << "IceInternal::Stream valueStream(instance);";
- writeMarshalUnmarshalCode(C, keyType, "value", "valueStream", true);
+ writeMarshalUnmarshalCode(C, keyType, "value", true, "valueStream", false);
C << nl << "_db->put(keyStream.b, valueStream.b);";
C << eb;
C << sp << nl << typeToString(valueType) << nl << absolute << "::get(" << inputTypeToString(keyType)
@@ -222,19 +173,19 @@ writeDict(const string& n, UnitPtr& unit, const Dict& dict, Output& H, Output& C
C << sb;
C << nl << "IceInternal::InstancePtr instance = IceInternal::getInstance(_db->getCommunicator());";
C << nl << "IceInternal::Stream keyStream(instance);";
- writeMarshalUnmarshalCode(C, keyType, "key", "keyStream", true);
+ writeMarshalUnmarshalCode(C, keyType, "key", true, "keyStream", false);
C << nl << "IceInternal::Stream valueStream(instance);";
C << nl << "valueStream.b = _db->get(keyStream.b);";
C << nl << "valueStream.i = valueStream.b.begin();";
C << nl << typeToString(valueType) << " value;";
- writeMarshalUnmarshalCode(C, keyType, "value", "valueStream", false);
+ writeMarshalUnmarshalCode(C, keyType, "value", false, "valueStream", false);
C << nl << "return value;";
C << eb;
C << sp << nl << "void" << nl << absolute << "::del(" << inputTypeToString(keyType) << " key)";
C << sb;
C << nl << "IceInternal::InstancePtr instance = IceInternal::getInstance(_db->getCommunicator());";
C << nl << "IceInternal::Stream keyStream(instance);";
- writeMarshalUnmarshalCode(C, keyType, "key", "keyStream", true);
+ writeMarshalUnmarshalCode(C, keyType, "key", true, "keyStream", false);
C << nl << "_db->del(keyStream.b);";
C << eb;
@@ -501,7 +452,8 @@ main(int argc, char* argv[])
unit->destroy();
return EXIT_FAILURE;
}
- printHeader(H, dicts);
+ printHeader(H);
+ printFreezeTypes(H, dicts);
Output C;
C.open(fileC.c_str());
@@ -511,7 +463,8 @@ main(int argc, char* argv[])
unit->destroy();
return EXIT_FAILURE;
}
- printHeader(C, dicts);
+ printHeader(C);
+ printFreezeTypes(C, dicts);
string s = fileH;
transform(s.begin(), s.end(), s.begin(), ToIfdef());
@@ -529,32 +482,6 @@ main(int argc, char* argv[])
}
}
- H << sp;
- H << "\n#ifndef ICE_IGNORE_VERSION";
- H << "\n# if ICE_INT_VERSION != 0x" << hex << ICE_INT_VERSION;
- H << "\n# error Ice version mismatch!";
- H << "\n# endif";
- H << "\n#endif";
-
- if (dllExport.size())
- {
- dllExport += " ";
- }
-
- if (dllExport.size())
- {
- H << sp;
- H << "\n#ifdef WIN32";
- H << "\n# ifdef " << dllExport.substr(0, dllExport.size() - 1) << "_EXPORTS";
- H << "\n# define " << dllExport << "__declspec(dllexport)";
- H << "\n# else";
- H << "\n# define " << dllExport << "__declspec(dllimport)";
- H << "\n# endif";
- H << "\n#else";
- H << "\n# define " << dllExport << "/**/";
- H << "\n#endif";
- }
-
C << "\n#include <";
if (include.size())
{
@@ -562,13 +489,15 @@ main(int argc, char* argv[])
}
C << fileH << '>';
- C << sp;
- C << "\n#ifndef ICE_IGNORE_VERSION";
- C << "\n# if ICE_INT_VERSION != 0x" << hex << ICE_INT_VERSION;
- C << "\n# error Ice version mismatch!";
- C << "\n# endif";
- C << "\n#endif";
-
+ printVersionCheck(H);
+ printVersionCheck(C);
+
+ printDllExportStuff(H, dllExport);
+ if (dllExport.size())
+ {
+ dllExport += " ";
+ }
+
{
for (vector<Dict>::const_iterator p = dicts.begin(); p != dicts.end(); ++p)
{
diff --git a/cpp/src/slice2freeze/Makefile b/cpp/src/slice2freeze/Makefile
index 0fc04ca6505..6b1a438ebcc 100644
--- a/cpp/src/slice2freeze/Makefile
+++ b/cpp/src/slice2freeze/Makefile
@@ -14,8 +14,7 @@ NAME = $(top_srcdir)/bin/slice2freeze
TARGETS = $(NAME)
-OBJS = Main.o \
- GenUtil.o
+OBJS = Main.o
SRCS = $(OBJS:.o=.cpp)