diff options
Diffstat (limited to 'cpp/test')
-rw-r--r-- | cpp/test/Slice/Makefile | 3 | ||||
-rw-r--r-- | cpp/test/Slice/Makefile.mak | 3 | ||||
-rw-r--r-- | cpp/test/Slice/macros/.depend | 0 | ||||
-rw-r--r-- | cpp/test/Slice/macros/.depend.mak | 0 | ||||
-rw-r--r-- | cpp/test/Slice/macros/.gitignore | 7 | ||||
-rw-r--r-- | cpp/test/Slice/macros/Client.cpp | 43 | ||||
-rw-r--r-- | cpp/test/Slice/macros/Makefile | 32 | ||||
-rw-r--r-- | cpp/test/Slice/macros/Makefile.mak | 38 | ||||
-rw-r--r-- | cpp/test/Slice/macros/Test.ice | 57 | ||||
-rwxr-xr-x | cpp/test/Slice/macros/run.py | 24 |
10 files changed, 205 insertions, 2 deletions
diff --git a/cpp/test/Slice/Makefile b/cpp/test/Slice/Makefile index 5981153b272..ee003135bd9 100644 --- a/cpp/test/Slice/Makefile +++ b/cpp/test/Slice/Makefile @@ -13,7 +13,8 @@ include $(top_srcdir)/config/Make.rules SUBDIRS = keyword \ parser \ - structure + structure \ + macros .PHONY: $(EVERYTHING) $(SUBDIRS) diff --git a/cpp/test/Slice/Makefile.mak b/cpp/test/Slice/Makefile.mak index 487e968ec03..e2f51a27dd2 100644 --- a/cpp/test/Slice/Makefile.mak +++ b/cpp/test/Slice/Makefile.mak @@ -13,7 +13,8 @@ top_srcdir = ..\.. SUBDIRS = keyword \ parser \ - structure + structure \ + macros $(EVERYTHING):: @for %i in ( $(SUBDIRS) ) do \ diff --git a/cpp/test/Slice/macros/.depend b/cpp/test/Slice/macros/.depend new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/cpp/test/Slice/macros/.depend diff --git a/cpp/test/Slice/macros/.depend.mak b/cpp/test/Slice/macros/.depend.mak new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/cpp/test/Slice/macros/.depend.mak diff --git a/cpp/test/Slice/macros/.gitignore b/cpp/test/Slice/macros/.gitignore new file mode 100644 index 00000000000..182a4020a50 --- /dev/null +++ b/cpp/test/Slice/macros/.gitignore @@ -0,0 +1,7 @@ +// Generated by makegitignore.py + +// IMPORTANT: Do not edit this file -- any edits made here will be lost! +client +Test.cpp +Test.h + diff --git a/cpp/test/Slice/macros/Client.cpp b/cpp/test/Slice/macros/Client.cpp new file mode 100644 index 00000000000..b7955fa1367 --- /dev/null +++ b/cpp/test/Slice/macros/Client.cpp @@ -0,0 +1,43 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2013 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 <TestCommon.h> +#include <Test.h> + +using namespace Test; +using namespace std; + +int +main(int argc, char* argv[]) +{ + int status = EXIT_SUCCESS; + try + { + cout << "Testing Slice predefined macros... " << flush; + DefaultPtr d = new Default(); + test(d->x == 10); + test(d->y == 10); + + NoDefaultPtr nd = new NoDefault(); + test(nd->x != 10); + test(nd->y != 10); + + CppOnlyPtr c = new CppOnly(); + test(c->lang == "cpp"); + test(c->version == ICE_INT_VERSION); + cout << "ok" << endl; + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } + return status; +} diff --git a/cpp/test/Slice/macros/Makefile b/cpp/test/Slice/macros/Makefile new file mode 100644 index 00000000000..125dffe7af1 --- /dev/null +++ b/cpp/test/Slice/macros/Makefile @@ -0,0 +1,32 @@ +# ********************************************************************** +# +# Copyright (c) 2003-2013 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 = $(call mktestname,client) + +TARGETS = $(CLIENT) + +COBJS = Client.o \ + Test.o + +SRCS = $(COBJS:.o=.cpp) + +SLICE_SRCS = Test.ice + +include $(top_srcdir)/config/Make.rules + +CPPFLAGS := -I. -I../../include $(CPPFLAGS) +SLICE2CPPFLAGS := --underscore --stream $(SLICE2CPPFLAGS) + +$(CLIENT): $(COBJS) + rm -f $@ + $(call mktest,$@,$(COBJS),$(LIBS)) + +include .depend diff --git a/cpp/test/Slice/macros/Makefile.mak b/cpp/test/Slice/macros/Makefile.mak new file mode 100644 index 00000000000..f10a61f1da6 --- /dev/null +++ b/cpp/test/Slice/macros/Makefile.mak @@ -0,0 +1,38 @@ +# ********************************************************************** +# +# Copyright (c) 2003-2013 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 = Test.obj \ + Client.obj + +SRCS = $(COBJS:.obj=.cpp) + +!include $(top_srcdir)/config/Make.rules.mak + +CPPFLAGS = -I. -I../../include $(CPPFLAGS) -DWIN32_LEAN_AND_MEAN +SLICE2CPPFLAGS = --underscore --stream $(SLICE2CPPFLAGS) + +!if "$(GENERATE_PDB)" == "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 Test.cpp Test.h + +!include .depend.mak diff --git a/cpp/test/Slice/macros/Test.ice b/cpp/test/Slice/macros/Test.ice new file mode 100644 index 00000000000..e156f51beee --- /dev/null +++ b/cpp/test/Slice/macros/Test.ice @@ -0,0 +1,57 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2013 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. +// +// ********************************************************************** + + +// +// This macro sets the default value only when compile with slice2cpp +// +#if defined(ICE_COMPILER) && (ICE_COMPILER == ICE_SLICE2CPP) +# define DEFAULT(X) = X +#else +# define DEFAULT(X) /**/ +#endif + +// +// This macro sets the default value only when not compile with slice2cpp +// +#if defined(ICE_COMPILER) && (ICE_COMPILER != ICE_SLICE2CPP) +# define NODEFAULT(X) = X +#else +# define NODEFAULT(X) /**/ +#endif + + + +module Test +{ + +class Default +{ + int x DEFAULT(10); + int y DEFAULT(10); +}; + +class NoDefault +{ + int x NODEFAULT(10); + int y NODEFAULT(10); +}; + +// +// This class is only defined when compile with slice2cpp. +// +#if defined(ICE_COMPILER) && (ICE_COMPILER == ICE_SLICE2CPP) +class CppOnly +{ + string lang DEFAULT("cpp"); + int version DEFAULT(ICE_VERSION); +}; +#endif + +}; diff --git a/cpp/test/Slice/macros/run.py b/cpp/test/Slice/macros/run.py new file mode 100755 index 00000000000..de12d2ecf70 --- /dev/null +++ b/cpp/test/Slice/macros/run.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python +# ********************************************************************** +# +# Copyright (c) 2003-2013 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 + +path = [ ".", "..", "../..", "../../..", "../../../.." ] +head = os.path.dirname(sys.argv[0]) +if len(head) > 0: + path = [os.path.join(head, p) for p in path] +path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] +if len(path) == 0: + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil + +client = os.path.join(os.getcwd(), "client") +TestUtil.simpleTest(client) |