summaryrefslogtreecommitdiff
path: root/cpp/test
diff options
context:
space:
mode:
authorMatthew Newhook <matthew@zeroc.com>2007-09-04 11:14:53 +0800
committerMatthew Newhook <matthew@zeroc.com>2007-09-04 11:14:53 +0800
commita55b88dc20dacaf23c5fce8415daf28c63388ccf (patch)
tree713968abb7de9959600eb59461bd97384b0c4d74 /cpp/test
parentbug 2442 - slice2java generating bad impl code (diff)
downloadice-a55b88dc20dacaf23c5fce8415daf28c63388ccf.tar.bz2
ice-a55b88dc20dacaf23c5fce8415daf28c63388ccf.tar.xz
ice-a55b88dc20dacaf23c5fce8415daf28c63388ccf.zip
http://bugzilla.zeroc.com/bugzilla/show_bug.cgi?id=2369
Diffstat (limited to 'cpp/test')
-rw-r--r--cpp/test/Makefile1
-rw-r--r--cpp/test/Makefile.mak1
-rw-r--r--cpp/test/Slice/Makefile21
-rw-r--r--cpp/test/Slice/Makefile.mak19
-rw-r--r--cpp/test/Slice/keyword/.depend4
-rw-r--r--cpp/test/Slice/keyword/Client.cpp175
-rw-r--r--cpp/test/Slice/keyword/Key.ice81
-rw-r--r--cpp/test/Slice/keyword/Makefile32
-rw-r--r--cpp/test/Slice/keyword/Makefile.mak38
-rwxr-xr-xcpp/test/Slice/keyword/run.py42
10 files changed, 414 insertions, 0 deletions
diff --git a/cpp/test/Makefile b/cpp/test/Makefile
index d7820b95c61..59dbc105836 100644
--- a/cpp/test/Makefile
+++ b/cpp/test/Makefile
@@ -12,6 +12,7 @@ top_srcdir = ..
include $(top_srcdir)/config/Make.rules
SUBDIRS = IceUtil \
+ Slice \
Ice \
IceSSL \
IceStorm \
diff --git a/cpp/test/Makefile.mak b/cpp/test/Makefile.mak
index e31c48fec56..1a9d6a70d3b 100644
--- a/cpp/test/Makefile.mak
+++ b/cpp/test/Makefile.mak
@@ -12,6 +12,7 @@ top_srcdir = ..
!include $(top_srcdir)/config/Make.rules.mak
SUBDIRS = IceUtil \
+ Slice \
Ice \
IceSSL \
Glacier2 \
diff --git a/cpp/test/Slice/Makefile b/cpp/test/Slice/Makefile
new file mode 100644
index 00000000000..864904542da
--- /dev/null
+++ b/cpp/test/Slice/Makefile
@@ -0,0 +1,21 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2007 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.
+#
+# **********************************************************************
+
+top_srcdir = ../..
+
+include $(top_srcdir)/config/Make.rules
+
+SUBDIRS = keyword
+
+$(EVERYTHING)::
+ @for subdir in $(SUBDIRS); \
+ do \
+ echo "making $@ in $$subdir"; \
+ ( cd $$subdir && $(MAKE) $@ ) || exit 1; \
+ done
diff --git a/cpp/test/Slice/Makefile.mak b/cpp/test/Slice/Makefile.mak
new file mode 100644
index 00000000000..6b822657c05
--- /dev/null
+++ b/cpp/test/Slice/Makefile.mak
@@ -0,0 +1,19 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2007 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.
+#
+# **********************************************************************
+
+top_srcdir = ..\..
+
+!include $(top_srcdir)\config\Make.rules.mak
+
+SUBDIRS = keyword
+
+$(EVERYTHING)::
+ @for %i in ( $(SUBDIRS) ) do \
+ @echo "making $@ in %i" && \
+ cmd /c "cd %i && $(MAKE) -nologo -f Makefile.mak $@" || exit 1
diff --git a/cpp/test/Slice/keyword/.depend b/cpp/test/Slice/keyword/.depend
new file mode 100644
index 00000000000..52576334989
--- /dev/null
+++ b/cpp/test/Slice/keyword/.depend
@@ -0,0 +1,4 @@
+Client$(OBJEXT): Client.cpp ../../../include/Ice/Ice.h ../../../include/Ice/Initialize.h ../../../include/Ice/CommunicatorF.h ../../../include/Ice/LocalObjectF.h ../../../include/IceUtil/Shared.h ../../../include/IceUtil/Config.h ../../../include/IceUtil/Mutex.h ../../../include/IceUtil/Lock.h ../../../include/IceUtil/ThreadException.h ../../../include/IceUtil/Exception.h ../../../include/Ice/Handle.h ../../../include/IceUtil/Handle.h ../../../include/Ice/Config.h ../../../include/Ice/ProxyHandle.h ../../../include/Ice/ProxyF.h ../../../include/Ice/ObjectF.h ../../../include/Ice/GCCountMap.h ../../../include/Ice/GCShared.h ../../../include/Ice/Exception.h ../../../include/Ice/LocalObject.h ../../../include/Ice/UndefSysMacros.h ../../../include/Ice/PropertiesF.h ../../../include/Ice/InstanceF.h ../../../include/Ice/LoggerF.h ../../../include/Ice/StreamF.h ../../../include/Ice/StatsF.h ../../../include/Ice/StringConverter.h ../../../include/Ice/BuiltinSequences.h ../../../include/Ice/Proxy.h ../../../include/Ice/ProxyFactoryF.h ../../../include/Ice/ConnectionIF.h ../../../include/Ice/EndpointIF.h ../../../include/Ice/Endpoint.h ../../../include/Ice/ObjectAdapterF.h ../../../include/Ice/ReferenceF.h ../../../include/Ice/OutgoingAsyncF.h ../../../include/Ice/Current.h ../../../include/Ice/ConnectionF.h ../../../include/Ice/Identity.h ../../../include/Ice/LocalException.h ../../../include/Ice/Properties.h ../../../include/Ice/Logger.h ../../../include/Ice/LoggerUtil.h ../../../include/Ice/Stats.h ../../../include/Ice/Communicator.h ../../../include/Ice/Object.h ../../../include/Ice/IncomingAsyncF.h ../../../include/Ice/ObjectFactoryF.h ../../../include/Ice/RouterF.h ../../../include/Ice/LocatorF.h ../../../include/Ice/PluginF.h ../../../include/Ice/ImplicitContextF.h ../../../include/Ice/ObjectFactory.h ../../../include/Ice/ObjectAdapter.h ../../../include/Ice/ServantLocatorF.h ../../../include/Ice/FacetMap.h ../../../include/Ice/ServantLocator.h ../../../include/Ice/OutgoingAsync.h ../../../include/IceUtil/Monitor.h ../../../include/IceUtil/Cond.h ../../../include/IceUtil/Time.h ../../../include/IceUtil/RecMutex.h ../../../include/Ice/IncomingAsync.h ../../../include/Ice/Incoming.h ../../../include/Ice/ServantManagerF.h ../../../include/Ice/BasicStream.h ../../../include/Ice/Buffer.h ../../../include/Ice/Protocol.h ../../../include/IceUtil/Unicode.h ../../../include/Ice/Process.h ../../../include/Ice/Outgoing.h ../../../include/Ice/Direct.h ../../../include/Ice/Application.h ../../../include/Ice/Connection.h ../../../include/Ice/Functional.h ../../../include/IceUtil/Functional.h ../../../include/Ice/Stream.h ../../../include/Ice/ImplicitContext.h ../../../include/Ice/Locator.h ../../../include/Ice/UserExceptionFactory.h ../../../include/Ice/FactoryTable.h ../../../include/Ice/FactoryTableDef.h ../../../include/IceUtil/StaticMutex.h ../../../include/Ice/UserExceptionFactoryF.h ../../../include/Ice/ProcessF.h ../../../include/Ice/Router.h ../../../include/Ice/DispatchInterceptor.h ../../../include/Ice/IconvStringConverter.h Key.h
+Key$(OBJEXT): Key.cpp Key.h ../../../include/Ice/LocalObjectF.h ../../../include/IceUtil/Shared.h ../../../include/IceUtil/Config.h ../../../include/IceUtil/Mutex.h ../../../include/IceUtil/Lock.h ../../../include/IceUtil/ThreadException.h ../../../include/IceUtil/Exception.h ../../../include/Ice/Handle.h ../../../include/IceUtil/Handle.h ../../../include/Ice/Config.h ../../../include/Ice/ProxyHandle.h ../../../include/Ice/ProxyF.h ../../../include/Ice/ObjectF.h ../../../include/Ice/GCCountMap.h ../../../include/Ice/GCShared.h ../../../include/Ice/Exception.h ../../../include/Ice/LocalObject.h ../../../include/Ice/Proxy.h ../../../include/Ice/ProxyFactoryF.h ../../../include/Ice/ConnectionIF.h ../../../include/Ice/EndpointIF.h ../../../include/Ice/Endpoint.h ../../../include/Ice/UndefSysMacros.h ../../../include/Ice/ObjectAdapterF.h ../../../include/Ice/ReferenceF.h ../../../include/Ice/OutgoingAsyncF.h ../../../include/Ice/Current.h ../../../include/Ice/ConnectionF.h ../../../include/Ice/Identity.h ../../../include/Ice/StreamF.h ../../../include/Ice/CommunicatorF.h ../../../include/Ice/Object.h ../../../include/Ice/IncomingAsyncF.h ../../../include/Ice/Outgoing.h ../../../include/IceUtil/Monitor.h ../../../include/IceUtil/Cond.h ../../../include/IceUtil/Time.h ../../../include/Ice/BasicStream.h ../../../include/Ice/InstanceF.h ../../../include/Ice/ObjectFactoryF.h ../../../include/Ice/Buffer.h ../../../include/Ice/Protocol.h ../../../include/Ice/StringConverter.h ../../../include/IceUtil/Unicode.h ../../../include/Ice/OutgoingAsync.h ../../../include/IceUtil/RecMutex.h ../../../include/Ice/Incoming.h ../../../include/Ice/ServantLocatorF.h ../../../include/Ice/ServantManagerF.h ../../../include/Ice/IncomingAsync.h ../../../include/Ice/Direct.h ../../../include/Ice/UserExceptionFactory.h ../../../include/Ice/FactoryTable.h ../../../include/Ice/FactoryTableDef.h ../../../include/IceUtil/StaticMutex.h ../../../include/Ice/UserExceptionFactoryF.h ../../../include/Ice/LocalException.h ../../../include/Ice/BuiltinSequences.h ../../../include/Ice/ObjectFactory.h ../../../include/Ice/Stream.h ../../../include/IceUtil/Iterator.h ../../../include/IceUtil/ScopedArray.h
+Key.cpp: Key.ice
+Key.ice: $(SLICE2CPP) $(SLICEPARSERLIB)
diff --git a/cpp/test/Slice/keyword/Client.cpp b/cpp/test/Slice/keyword/Client.cpp
new file mode 100644
index 00000000000..8d9bb8dd931
--- /dev/null
+++ b/cpp/test/Slice/keyword/Client.cpp
@@ -0,0 +1,175 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2007 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 <Ice/Ice.h>
+#include <Key.h>
+
+using namespace std;
+
+class breakI : public _cpp_and::_cpp_break
+{
+public:
+ virtual void case_async(const ::_cpp_and::AMD_break_casePtr& cb, ::Ice::Int, const ::Ice::Current&)
+ {
+ cb->ice_response(0);
+ }
+};
+
+class charI: public _cpp_and::_cpp_char
+{
+public:
+ virtual void _cpp_explicit(const ::Ice::Current& current)
+ {
+ assert(current.operation == "explicit");
+ }
+};
+
+class complI: public _cpp_and::_cpp_compl
+{
+public:
+ virtual void foo(const _cpp_and::charPrx&, Ice::Int&, const ::Ice::Current&)
+ {
+ }
+};
+
+class doI : public _cpp_and::_cpp_do
+{
+public:
+ virtual void case_async(const ::_cpp_and::AMD_break_casePtr&, ::Ice::Int, const ::Ice::Current&)
+ {
+ }
+ virtual void _cpp_explicit(const ::Ice::Current&)
+ {
+ }
+ virtual void foo(const _cpp_and::charPrx&, Ice::Int&, const ::Ice::Current&)
+ {
+ }
+};
+
+class friendI : public _cpp_and::_cpp_friend
+{
+public:
+ virtual _cpp_and::_cpp_auto
+ _cpp_goto(_cpp_and::_cpp_continue, const _cpp_and::_cpp_auto&, const _cpp_and::deletePtr&,
+ const _cpp_and::complPtr&, const _cpp_and::doPtr&, const _cpp_and::breakPrx&,
+ const _cpp_and::charPrx&, const _cpp_and::complPrx&, const _cpp_and::doPrx&,
+ ::Ice::Int, ::Ice::Int, ::Ice::Int, ::Ice::Int)
+ {
+ return _cpp_and::_cpp_auto();
+ }
+};
+
+class fooI : public _cpp_and::AMI_compl_foo
+{
+public:
+
+ virtual void ice_response(Ice::Int) {}
+ virtual void ice_exception(const ::Ice::Exception&) {}
+};
+
+//
+// This section of the test is present to ensure that the C++ types
+// are named correctly. It is not expected to run.
+//
+void
+testtypes()
+{
+ _cpp_and::_cpp_continue a = _cpp_and::_cpp_asm;
+ assert(a);
+
+ _cpp_and::_cpp_auto b;
+ b._cpp_default = 0;
+
+ _cpp_and::deletePtr c = new _cpp_and::_cpp_delete();
+ c->_cpp_else = "";
+
+ _cpp_and::breakPrx d;
+ int d2;
+ d->_cpp_case(0, d2);
+ _cpp_and::breakPtr d1 = new breakI();
+
+ _cpp_and::charPrx e;
+ e->_cpp_explicit();
+ _cpp_and::charPtr e1 = new charI();
+
+ _cpp_and::complPrx f;
+ f->foo_async(new fooI(), e);
+ _cpp_and::complPtr f1 = new complI();
+
+ _cpp_and::doPrx g;
+ g->_cpp_case(0, d2);
+ g->_cpp_explicit();
+ _cpp_and::doPtr g1 = new doI();
+
+ _cpp_and::_cpp_extern h;
+ _cpp_and::_cpp_for i;
+ _cpp_and::_cpp_return j;
+ j._cpp_signed = 0;
+ _cpp_and::_cpp_sizeof k;
+ k._cpp_static = 0;
+ k._cpp_switch = 1;
+ k._cpp_signed = 2;
+
+ _cpp_and::friendPtr l = new friendI();
+
+ const int m = _cpp_and::_cpp_template;
+ assert(m == _cpp_and::_cpp_template);
+}
+
+int
+run(const Ice::CommunicatorPtr& communicator)
+{
+ communicator->getProperties()->setProperty("TestAdapter.Endpoints", "default -p 12010 -t 10000:udp");
+ Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
+ adapter->add(new charI, communicator->stringToIdentity("test"));
+ adapter->activate();
+
+ cout << "Testing operation name... " << flush;
+ _cpp_and::charPrx p = _cpp_and::charPrx::uncheckedCast(
+ adapter->createProxy(communicator->stringToIdentity("test")));
+ p->_cpp_explicit();
+ cout << "ok!" << endl;
+
+ return EXIT_SUCCESS;
+}
+
+int
+main(int argc, char* argv[])
+{
+ int status;
+ Ice::CommunicatorPtr communicator;
+
+ try
+ {
+ Ice::InitializationData initData;
+ initData.properties = Ice::createProperties(argc, argv);
+ communicator = Ice::initialize(argc, argv, initData);
+ status = run(communicator);
+ }
+ catch(const Ice::Exception& ex)
+ {
+ cerr << ex << endl;
+ status = EXIT_FAILURE;
+ }
+
+ if(communicator)
+ {
+ try
+ {
+ communicator->destroy();
+ }
+ catch(const Ice::Exception& ex)
+ {
+ cerr << ex << endl;
+ status = EXIT_FAILURE;
+ }
+ }
+
+ return status;
+}
diff --git a/cpp/test/Slice/keyword/Key.ice b/cpp/test/Slice/keyword/Key.ice
new file mode 100644
index 00000000000..790f5277746
--- /dev/null
+++ b/cpp/test/Slice/keyword/Key.ice
@@ -0,0 +1,81 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2007 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.
+//
+// **********************************************************************
+
+module and
+{
+
+enum continue
+{
+ asm
+};
+
+struct auto
+{
+ int default;
+};
+
+["cpp:class"] struct delete
+{
+ string else;
+};
+
+interface break
+{
+ ["amd"] void case(int catch, out int try);
+};
+
+interface char
+{
+ void explicit();
+};
+
+class compl
+{
+ ["ami"] void foo(char* export, out int volatile);
+};
+
+class do extends compl implements char, break
+{
+};
+
+sequence<auto> extern;
+
+dictionary<string,auto> for;
+
+exception return
+{
+ int signed;
+};
+
+exception sizeof extends return
+{
+ int static; int switch;
+};
+
+local interface friend
+{
+ auto goto(continue if, auto d, delete inline, compl private, do mutable, break* namespace,
+ char* new, compl* not, do* operator, int or, int protected, int public, int register)
+ throws return, sizeof;
+};
+
+const int template = 0;
+const int this = 0;
+const int throw = 0;
+const int typedef = 0;
+const int typeid = 0;
+const int typename = 0;
+const int union = 0;
+const int unsigned = 0;
+const int using = 0;
+const int virtual = 0;
+const int while = 0;
+const int xor = 0;
+
+};
diff --git a/cpp/test/Slice/keyword/Makefile b/cpp/test/Slice/keyword/Makefile
new file mode 100644
index 00000000000..c5f5f5e2813
--- /dev/null
+++ b/cpp/test/Slice/keyword/Makefile
@@ -0,0 +1,32 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2007 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.
+#
+# **********************************************************************
+
+top_srcdir = ../../..
+
+CLIENT = client
+
+TARGETS = $(CLIENT)
+
+COBJS = Client.o \
+ Key.o
+
+SRCS = $(COBJS:.o=.cpp)
+
+SLICE_SRCS = Key.ice
+
+include $(top_srcdir)/config/Make.rules
+
+CPPFLAGS := -I. -I../../include $(CPPFLAGS)
+SLICE2CPPFLAGS := --stream $(SLICE2CPPFLAGS)
+
+$(CLIENT): $(COBJS)
+ rm -f $@
+ $(CXX) $(LDFLAGS) -o $@ $(COBJS) $(LIBS)
+
+include .depend
diff --git a/cpp/test/Slice/keyword/Makefile.mak b/cpp/test/Slice/keyword/Makefile.mak
new file mode 100644
index 00000000000..b859b99f893
--- /dev/null
+++ b/cpp/test/Slice/keyword/Makefile.mak
@@ -0,0 +1,38 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2007 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.
+#
+# **********************************************************************
+
+top_srcdir = ..\..\..
+
+CLIENT = client.exe
+
+TARGETS = $(CLIENT)
+
+COBJS = Key.obj \
+ Client.obj
+
+SRCS = $(COBJS:.obj=.cpp)
+
+!include $(top_srcdir)/config/Make.rules.mak
+
+CPPFLAGS = -I. -I../../include $(CPPFLAGS) -DWIN32_LEAN_AND_MEAN
+SLICE2CPPFLAGS = --stream $(SLICE2CPPFLAGS)
+
+!if "$(CPP_COMPILER)" != "BCC2006" && "$(OPTIMIZE)" != "yes"
+CPDBFLAGS = /pdb:$(CLIENT:.exe=.pdb)
+!endif
+
+$(CLIENT): $(COBJS)
+ $(LINK) $(LD_EXEFLAGS) $(CPDBFLAGS) $(SETARGV) $(COBJS) $(PREOUT)$@ $(PRELIBS)$(LIBS)
+ @if exist $@.manifest echo ^ ^ ^ Embedding manifest using $(MT) && \
+ $(MT) -nologo -manifest $@.manifest -outputresource:$@;#1 && del /q $@.manifest
+
+clean::
+ del /q Key.cpp Key.h
+
+!include .depend
diff --git a/cpp/test/Slice/keyword/run.py b/cpp/test/Slice/keyword/run.py
new file mode 100755
index 00000000000..e033a8e4d1a
--- /dev/null
+++ b/cpp/test/Slice/keyword/run.py
@@ -0,0 +1,42 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2007 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.
+#
+# **********************************************************************
+
+import os, sys
+
+for toplevel in [".", "..", "../..", "../../..", "../../../.."]:
+ toplevel = os.path.normpath(toplevel)
+ if os.path.exists(os.path.join(toplevel, "config", "TestUtil.py")):
+ break
+else:
+ raise "can't find toplevel directory!"
+
+sys.path.append(os.path.join(toplevel, "config"))
+import TestUtil
+
+name = os.path.join("Slice", "keyword")
+testdir = os.path.join(toplevel, "test", name)
+
+cwd = os.getcwd()
+os.chdir(testdir)
+
+client = os.path.join(testdir, "client")
+
+print "starting client...",
+clientPipe = os.popen(client + " 2>&1")
+print "ok"
+
+TestUtil.printOutputFromPipe(clientPipe);
+
+clientStatus = TestUtil.closePipe(clientPipe)
+
+if clientStatus:
+ sys.exit(1)
+
+sys.exit(0)