summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp')
-rw-r--r--cpp/src/slice2cpp/Gen.cpp8
-rw-r--r--cpp/test/Ice/objects/AllTests.cpp34
-rw-r--r--cpp/test/Ice/objects/Client.cpp2
-rw-r--r--cpp/test/Ice/objects/Collocated.cpp1
-rw-r--r--cpp/test/Ice/objects/Derived.ice22
-rw-r--r--cpp/test/Ice/objects/DerivedEx.ice21
-rw-r--r--cpp/test/Ice/objects/Makefile20
-rw-r--r--cpp/test/Ice/objects/Makefile.mak22
-rw-r--r--cpp/test/Ice/objects/Server.cpp1
-rw-r--r--cpp/test/Ice/objects/Test.ice11
-rw-r--r--cpp/test/Ice/objects/TestI.h8
-rw-r--r--cpp/test/Ice/objects/TestIntfI.cpp33
12 files changed, 171 insertions, 12 deletions
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index dff1f3c31aa..cffcff2bafe 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -3326,7 +3326,7 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p)
H << eb << ';';
- if(!p->isAbstract() && !_doneStaticSymbol)
+ if(!p->isAbstract() && !p->isLocal() && !_doneStaticSymbol)
{
//
// We need an instance here to trigger initialization if the implementation is in a shared library.
@@ -3355,6 +3355,12 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p)
H << sp << nl << "static " << p->name() << "__staticInit _" << p->name() << "_init;";
H.zeroIndent();
+ H << nl << "#else";
+ H.restoreIndent();
+
+ H << nl << "static auto _" << p->name() << "_init = " << p->scoped() << "::ice_factory;";
+
+ H.zeroIndent();
H << nl << "#endif";
H.restoreIndent();
}
diff --git a/cpp/test/Ice/objects/AllTests.cpp b/cpp/test/Ice/objects/AllTests.cpp
index 04643d44427..829a0c35602 100644
--- a/cpp/test/Ice/objects/AllTests.cpp
+++ b/cpp/test/Ice/objects/AllTests.cpp
@@ -237,5 +237,39 @@ allTests(const Ice::CommunicatorPtr& communicator)
testUOE(communicator);
cout << "ok" << endl;
+ try
+ {
+ string ref = "test:default -p 12010";
+ TestIntfPrx p = TestIntfPrx::checkedCast(communicator->stringToProxy(ref));
+
+ cout << "testing UnexpectedObjectException... " << flush;
+ testUOE(communicator);
+ cout << "ok" << endl;
+
+ cout << "testing Object factory registration... " << flush;
+ {
+ BasePtr base = p->opDerived();
+ test(base);
+ test(base->ice_id() == "::Test::Derived");
+ }
+ cout << "ok" << endl;
+
+ cout << "testing Exception factory registration... " << flush;
+ {
+ try
+ {
+ p->throwDerived();
+ }
+ catch(const BaseEx& ex)
+ {
+ test(ex.ice_name() == "Test::DerivedEx");
+ }
+ }
+ cout << "ok" << endl;
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ }
+
return initial;
}
diff --git a/cpp/test/Ice/objects/Client.cpp b/cpp/test/Ice/objects/Client.cpp
index 303d79031af..966ee88edd6 100644
--- a/cpp/test/Ice/objects/Client.cpp
+++ b/cpp/test/Ice/objects/Client.cpp
@@ -10,6 +10,8 @@
#include <Ice/Ice.h>
#include <TestCommon.h>
#include <TestI.h>
+#include <Derived.h>
+#include <DerivedEx.h>
DEFINE_TEST("client")
diff --git a/cpp/test/Ice/objects/Collocated.cpp b/cpp/test/Ice/objects/Collocated.cpp
index 781c216a855..4017e717150 100644
--- a/cpp/test/Ice/objects/Collocated.cpp
+++ b/cpp/test/Ice/objects/Collocated.cpp
@@ -82,6 +82,7 @@ run(int, char**, const Ice::CommunicatorPtr& communicator)
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
InitialPtr initial = new InitialI(adapter);
adapter->add(initial, communicator->stringToIdentity("initial"));
+ adapter->add(new TestIntfI(), communicator->stringToIdentity("test"));
UnexpectedObjectExceptionTestIPtr uoet = new UnexpectedObjectExceptionTestI;
adapter->add(uoet, communicator->stringToIdentity("uoet"));
InitialPrx allTests(const Ice::CommunicatorPtr&);
diff --git a/cpp/test/Ice/objects/Derived.ice b/cpp/test/Ice/objects/Derived.ice
new file mode 100644
index 00000000000..e54a7dcbc59
--- /dev/null
+++ b/cpp/test/Ice/objects/Derived.ice
@@ -0,0 +1,22 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+#include <Test.ice>
+
+module Test
+{
+
+class Derived extends Base
+{
+ string b;
+};
+
+};
diff --git a/cpp/test/Ice/objects/DerivedEx.ice b/cpp/test/Ice/objects/DerivedEx.ice
new file mode 100644
index 00000000000..0f8b6ea0a16
--- /dev/null
+++ b/cpp/test/Ice/objects/DerivedEx.ice
@@ -0,0 +1,21 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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.
+//
+// **********************************************************************
+
+#pragma once
+
+#include <Test.ice>
+
+module Test
+{
+
+exception DerivedEx extends BaseEx
+{
+};
+
+};
diff --git a/cpp/test/Ice/objects/Makefile b/cpp/test/Ice/objects/Makefile
index 0031a2e7ccd..8733c116fa0 100644
--- a/cpp/test/Ice/objects/Makefile
+++ b/cpp/test/Ice/objects/Makefile
@@ -12,22 +12,26 @@ top_srcdir = ../../..
CLIENT = $(call mktestname,client)
SERVER = $(call mktestname,server)
COLLOCATED = $(call mktestname,collocated)
+TESTLIBNAME = libTestDerived.a
TARGETS = $(CLIENT) $(SERVER) $(COLLOCATED)
-SLICE_OBJS = Test.o
+SLICE_OBJS = Test.o \
+ Derived.o \
+ DerivedEx.o
-COBJS = $(SLICE_OBJS) \
- TestI.o \
+COBJS = TestI.o \
Client.o \
AllTests.o
SOBJS = $(SLICE_OBJS) \
TestI.o \
+ TestIntfI.o \
Server.o
COLOBJS = $(SLICE_OBJS) \
TestI.o \
+ TestIntfI.o \
Collocated.o \
AllTests.o
@@ -37,11 +41,17 @@ OBJS = $(COBJS) \
include $(top_srcdir)/config/Make.rules
+SLICE2CPPFLAGS := -I. $(SLICE2CPPFLAGS)
CPPFLAGS := -I. -I../../include $(CPPFLAGS)
+LDFLAGS := -L. $(LDFLAGS)
+
+$(TESTLIBNAME): $(SLICE_OBJS)
+ rm -f $@
+ $(call mklib,$@,$(SLICE_OBJS))
-$(CLIENT): $(COBJS)
+$(CLIENT): $(COBJS) $(TESTLIBNAME)
rm -f $@
- $(call mktest,$@,$(COBJS) $(LIBS))
+ $(call mktest,$@,$(COBJS) -lTestDerived $(LIBS))
$(SERVER): $(SOBJS)
rm -f $@
diff --git a/cpp/test/Ice/objects/Makefile.mak b/cpp/test/Ice/objects/Makefile.mak
index ac5d261ddb5..67770dbbc12 100644
--- a/cpp/test/Ice/objects/Makefile.mak
+++ b/cpp/test/Ice/objects/Makefile.mak
@@ -22,22 +22,26 @@ OBJDIR = winrt
CLIENT = $(NAME_PREFIX)client
SERVER = $(NAME_PREFIX)server
COLLOCATED = $(NAME_PREFIX)collocated
+TESTLIBNAME = libTestDerived.lib
-TARGETS = $(CLIENT)$(EXT) $(SERVER)$(EXT) $(COLLOCATED)$(EXT)
+TARGETS = $(CLIENT)$(EXT) $(SERVER)$(EXT) $(COLLOCATED)$(EXT) $(TESTLIBNAME)
-SLICE_OBJS = $(OBJDIR)\Test.obj
+SLICE_OBJS = $(OBJDIR)\Test.obj \
+ $(OBJDIR)\Derived.obj \
+ $(OBJDIR)\DerivedEx.obj
-COBJS = $(SLICE_OBJS) \
- $(OBJDIR)\TestI.obj \
+COBJS = $(OBJDIR)\TestI.obj \
$(OBJDIR)\Client.obj \
$(OBJDIR)\AllTests.obj
SOBJS = $(SLICE_OBJS) \
$(OBJDIR)\TestI.obj \
+ $(OBJDIR)\TestIntfI.obj \
$(OBJDIR)\Server.obj
COLOBJS = $(SLICE_OBJS) \
$(OBJDIR)\TestI.obj \
+ $(OBJDIR)\TestIntfI.obj \
$(OBJDIR)\Collocated.obj \
$(OBJDIR)\AllTests.obj
@@ -48,6 +52,7 @@ OBJS = $(COBJS) \
!include $(top_srcdir)/config/Make.rules.mak
CPPFLAGS = -I. -I../../include $(CPPFLAGS) -DWIN32_LEAN_AND_MEAN
+SLICE2CPPFLAGS = -I. $(SLICE2CPPFLAGS)
!if "$(GENERATE_PDB)" == "yes"
CPDBFLAGS = /pdb:$(CLIENT).pdb
@@ -55,8 +60,11 @@ SPDBFLAGS = /pdb:$(SERVER).pdb
COPDBFLAGS = /pdb:$(COLLOCATED).pdb
!endif
-$(CLIENT)$(EXT): $(COBJS)
- $(LINK) $(LD_TESTFLAGS) $(CPDBFLAGS) $(COBJS) $(PREOUT)$@ $(PRELIBS)$(LIBS)
+$(TESTLIBNAME): $(SLICE_OBJS)
+ $(AR) $(ARFLAGS) $(SLICE_OBJS) /out:$(TESTLIBNAME)
+
+$(CLIENT)$(EXT): $(COBJS) $(TESTLIBNAME)
+ $(LINK) $(LD_TESTFLAGS) $(CPDBFLAGS) $(COBJS) $(PREOUT)$@ $(PRELIBS)$(LIBS) libTestDerived.lib
@if exist $@.manifest echo ^ ^ ^ Embedding manifest using $(MT) && \
$(MT) -nologo -manifest $@.manifest -outputresource:$@;#1 && del /q $@.manifest
@@ -72,3 +80,5 @@ $(COLLOCATED)$(EXT): $(COLOBJS)
clean::
del /q Test.cpp Test.h
+ del /q Derived.cpp Derived.h
+ del /q DerivedEx.cpp DerivedEx.h
diff --git a/cpp/test/Ice/objects/Server.cpp b/cpp/test/Ice/objects/Server.cpp
index f1a1a197d39..8cafb99e040 100644
--- a/cpp/test/Ice/objects/Server.cpp
+++ b/cpp/test/Ice/objects/Server.cpp
@@ -57,6 +57,7 @@ run(int, char**, const Ice::CommunicatorPtr& communicator)
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
InitialPtr initial = new InitialI(adapter);
adapter->add(initial, communicator->stringToIdentity("initial"));
+ adapter->add(new TestIntfI(), communicator->stringToIdentity("test"));
UnexpectedObjectExceptionTestIPtr uoet = new UnexpectedObjectExceptionTestI;
adapter->add(uoet, communicator->stringToIdentity("uoet"));
adapter->activate();
diff --git a/cpp/test/Ice/objects/Test.ice b/cpp/test/Ice/objects/Test.ice
index abbc1b87dc2..638d36dd22f 100644
--- a/cpp/test/Ice/objects/Test.ice
+++ b/cpp/test/Ice/objects/Test.ice
@@ -23,6 +23,11 @@ class Base
string str;
};
+exception BaseEx
+{
+ string reason;
+};
+
class AbstractBase extends Base
{
void op();
@@ -164,6 +169,12 @@ class Initial
void throwInnerSubEx() throws Inner::Sub::Ex;
};
+interface TestIntf
+{
+ Base opDerived();
+ void throwDerived() throws BaseEx;
+};
+
class Empty
{
};
diff --git a/cpp/test/Ice/objects/TestI.h b/cpp/test/Ice/objects/TestI.h
index 46d6835948e..38c427bd9f4 100644
--- a/cpp/test/Ice/objects/TestI.h
+++ b/cpp/test/Ice/objects/TestI.h
@@ -140,4 +140,12 @@ public:
};
typedef IceUtil::Handle<UnexpectedObjectExceptionTestI> UnexpectedObjectExceptionTestIPtr;
+class TestIntfI : public Test::TestIntf
+{
+public:
+
+ virtual Test::BasePtr opDerived(const Ice::Current&);
+ virtual void throwDerived(const Ice::Current&);
+};
+
#endif
diff --git a/cpp/test/Ice/objects/TestIntfI.cpp b/cpp/test/Ice/objects/TestIntfI.cpp
new file mode 100644
index 00000000000..e4e393b1b3e
--- /dev/null
+++ b/cpp/test/Ice/objects/TestIntfI.cpp
@@ -0,0 +1,33 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2015 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 <TestI.h>
+#include <Derived.h>
+#include <DerivedEx.h>
+
+using namespace Test;
+
+BasePtr
+TestIntfI::opDerived(const Ice::Current&)
+{
+ DerivedPtr d = new Derived();
+ d->theS.str = "S.str";
+ d->str = "str";
+ d->b = "b";
+ return d;
+}
+
+void
+TestIntfI::throwDerived(const Ice::Current&)
+{
+ DerivedEx ex;
+ ex.reason = "reason";
+ throw ex;
+}