summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp')
-rwxr-xr-xcpp/allTests.py1
-rw-r--r--cpp/include/Slice/Preprocessor.h4
-rw-r--r--cpp/src/FreezeScript/DumpDB.cpp2
-rw-r--r--cpp/src/FreezeScript/Util.cpp4
-rw-r--r--cpp/src/FreezeScript/Util.h2
-rw-r--r--cpp/src/FreezeScript/transformdb.cpp6
-rw-r--r--cpp/src/Slice/Preprocessor.cpp59
-rw-r--r--cpp/src/slice2confluence/Gen.cpp4
-rw-r--r--cpp/src/slice2cpp/Main.cpp7
-rw-r--r--cpp/src/slice2cs/Main.cpp7
-rw-r--r--cpp/src/slice2freeze/Main.cpp2
-rw-r--r--cpp/src/slice2freezej/Main.cpp7
-rw-r--r--cpp/src/slice2html/Main.cpp2
-rw-r--r--cpp/src/slice2java/Main.cpp8
-rw-r--r--cpp/src/slice2php/Main.cpp6
-rw-r--r--cpp/src/slice2py/Main.cpp7
-rw-r--r--cpp/src/slice2rb/Main.cpp7
-rw-r--r--cpp/test/Slice/Makefile3
-rw-r--r--cpp/test/Slice/Makefile.mak3
-rw-r--r--cpp/test/Slice/macros/.depend0
-rw-r--r--cpp/test/Slice/macros/.depend.mak0
-rw-r--r--cpp/test/Slice/macros/.gitignore7
-rw-r--r--cpp/test/Slice/macros/Client.cpp43
-rw-r--r--cpp/test/Slice/macros/Makefile32
-rw-r--r--cpp/test/Slice/macros/Makefile.mak38
-rw-r--r--cpp/test/Slice/macros/Test.ice57
-rwxr-xr-xcpp/test/Slice/macros/run.py24
27 files changed, 290 insertions, 52 deletions
diff --git a/cpp/allTests.py b/cpp/allTests.py
index edcb7533a8f..bf69d3496b2 100755
--- a/cpp/allTests.py
+++ b/cpp/allTests.py
@@ -35,6 +35,7 @@ tests = [
("Slice/errorDetection", ["once"]),
("Slice/keyword", ["once"]),
("Slice/structure", ["once"]),
+ ("Slice/macros", ["once"]),
("Ice/properties", ["once", "nomingw"]),
("Ice/proxy", ["core"]),
("Ice/operations", ["core"]),
diff --git a/cpp/include/Slice/Preprocessor.h b/cpp/include/Slice/Preprocessor.h
index 44f7becb344..16e3aa7c1da 100644
--- a/cpp/include/Slice/Preprocessor.h
+++ b/cpp/include/Slice/Preprocessor.h
@@ -36,12 +36,12 @@ public:
~Preprocessor();
- FILE* preprocess(bool);
+ FILE* preprocess(bool, const std::string& = "");
bool close();
enum Language { CPlusPlus, Java, JavaXML, CSharp, Python, Ruby, PHP };
- bool printMakefileDependencies(Language, const std::vector<std::string>&, const std::string& = "cpp",
+ bool printMakefileDependencies(Language, const std::vector<std::string>&, const std::string& = "", const std::string& = "cpp",
const std::string& = "");
std::string getBaseName();
diff --git a/cpp/src/FreezeScript/DumpDB.cpp b/cpp/src/FreezeScript/DumpDB.cpp
index a31148abda5..ca011caedb0 100644
--- a/cpp/src/FreezeScript/DumpDB.cpp
+++ b/cpp/src/FreezeScript/DumpDB.cpp
@@ -343,7 +343,7 @@ run(const Ice::StringSeq& originalArgs, const Ice::CommunicatorPtr& communicator
Slice::UnitPtr unit = Slice::Unit::createUnit(true, true, ice, underscore);
FreezeScript::Destroyer<Slice::UnitPtr> unitD(unit);
- if(!FreezeScript::parseSlice(appName, unit, slice, cppArgs, debug))
+ if(!FreezeScript::parseSlice(appName, unit, slice, cppArgs, debug, "-DICE_COMPILER=ICE_DUMPDB"))
{
return EXIT_FAILURE;
}
diff --git a/cpp/src/FreezeScript/Util.cpp b/cpp/src/FreezeScript/Util.cpp
index 52e72b956a0..6ba2715713a 100644
--- a/cpp/src/FreezeScript/Util.cpp
+++ b/cpp/src/FreezeScript/Util.cpp
@@ -170,7 +170,7 @@ FreezeScript::createEvictorSliceTypes(const Slice::UnitPtr& u)
bool
FreezeScript::parseSlice(const string& n, const Slice::UnitPtr& u, const vector<string>& files,
- const vector<string>& cppArgs, bool debug)
+ const vector<string>& cppArgs, bool debug, const std::string& extraArgs)
{
//
// Parse the Slice files.
@@ -179,7 +179,7 @@ FreezeScript::parseSlice(const string& n, const Slice::UnitPtr& u, const vector<
{
PreprocessorPtr icecpp = Preprocessor::create(n, *p, cppArgs);
- FILE* cppHandle = icecpp->preprocess(false);
+ FILE* cppHandle = icecpp->preprocess(false, extraArgs);
if(cppHandle == 0)
{
diff --git a/cpp/src/FreezeScript/Util.h b/cpp/src/FreezeScript/Util.h
index 67986f18515..47d4dc751ba 100644
--- a/cpp/src/FreezeScript/Util.h
+++ b/cpp/src/FreezeScript/Util.h
@@ -56,7 +56,7 @@ std::string typeToString(const Slice::TypePtr&);
bool ignoreType(const std::string&);
void createEvictorSliceTypes(const Slice::UnitPtr&);
bool parseSlice(const std::string&, const Slice::UnitPtr&, const std::vector<std::string>&,
- const std::vector<std::string>&, bool);
+ const std::vector<std::string>&, bool, const std::string&);
typedef std::map<std::string, Freeze::CatalogData> CatalogDataMap;
diff --git a/cpp/src/FreezeScript/transformdb.cpp b/cpp/src/FreezeScript/transformdb.cpp
index 09c870b2c78..c4c3f1fe002 100644
--- a/cpp/src/FreezeScript/transformdb.cpp
+++ b/cpp/src/FreezeScript/transformdb.cpp
@@ -436,14 +436,16 @@ run(const Ice::StringSeq& originalArgs, const Ice::CommunicatorPtr& communicator
Slice::UnitPtr oldUnit = Slice::Unit::createUnit(true, true, ice, underscore);
FreezeScript::Destroyer<Slice::UnitPtr> oldD(oldUnit);
- if(!FreezeScript::parseSlice(appName, oldUnit, oldSlice, oldCppArgs, debug))
+ if(!FreezeScript::parseSlice(appName, oldUnit, oldSlice, oldCppArgs, debug,
+ "-DICE_COMPILER=ICE_TRANSFORMDB"))
{
return EXIT_FAILURE;
}
Slice::UnitPtr newUnit = Slice::Unit::createUnit(true, true, ice, underscore);
FreezeScript::Destroyer<Slice::UnitPtr> newD(newUnit);
- if(!FreezeScript::parseSlice(appName, newUnit, newSlice, newCppArgs, debug))
+ if(!FreezeScript::parseSlice(appName, newUnit, newSlice, newCppArgs, debug,
+ "-DICE_COMPILER=ICE_TRANSFORMDB"))
{
return EXIT_FAILURE;
}
diff --git a/cpp/src/Slice/Preprocessor.cpp b/cpp/src/Slice/Preprocessor.cpp
index 68072500ece..352cdf4147a 100644
--- a/cpp/src/Slice/Preprocessor.cpp
+++ b/cpp/src/Slice/Preprocessor.cpp
@@ -136,18 +136,12 @@ Slice::Preprocessor::normalizeIncludePath(const string& path)
return result;
}
-FILE*
-Slice::Preprocessor::preprocess(bool keepComments)
+namespace
{
- if(!checkInputFile())
- {
- return 0;
- }
- //
- // Build arguments list.
- //
- vector<string> args = _args;
+vector<string>
+baseArgs(vector<string> args, bool keepComments, const string& extraArgs, const string& fileName)
+{
if(keepComments)
{
args.push_back("-C");
@@ -157,7 +151,41 @@ Slice::Preprocessor::preprocess(bool keepComments)
ostringstream version;
version << "-DICE_VERSION=" << ICE_INT_VERSION;
args.push_back(version.str());
- args.push_back(_fileName);
+
+ args.push_back("-DICE_SLICE2CPP=1");
+ args.push_back("-DICE_SLICE2CS=2");
+ args.push_back("-DICE_SLICE2FREEZE=3");
+ args.push_back("-DICE_SLICE2FREEZEJ=4");
+ args.push_back("-DICE_SLICE2HTML=5");
+ args.push_back("-DICE_SLICE2JAVA=6");
+ args.push_back("-DICE_SLICE2PHP=7");
+ args.push_back("-DICE_SLICE2PY=8");
+ args.push_back("-DICE_SLICE2RB=9");
+ args.push_back("-DICE_TRANSFORMDB=10");
+ args.push_back("-DICE_DUMPDB=11");
+
+ if(!extraArgs.empty())
+ {
+ args.push_back(extraArgs);
+ }
+ args.push_back(fileName);
+ return args;
+}
+
+}
+
+FILE*
+Slice::Preprocessor::preprocess(bool keepComments, const string& extraArgs)
+{
+ if(!checkInputFile())
+ {
+ return 0;
+ }
+
+ //
+ // Build arguments list.
+ //
+ vector<string> args = baseArgs(_args, keepComments, extraArgs, _fileName);
const char** argv = new const char*[args.size() + 1];
argv[0] = "mcpp";
for(unsigned int i = 0; i < args.size(); ++i)
@@ -251,7 +279,8 @@ Slice::Preprocessor::preprocess(bool keepComments)
bool
Slice::Preprocessor::printMakefileDependencies(Language lang, const vector<string>& includePaths,
- const string& cppSourceExt, const string& optValue)
+ const std::string& extraArgs, const string& cppSourceExt,
+ const string& optValue)
{
if(!checkInputFile())
{
@@ -272,11 +301,7 @@ Slice::Preprocessor::printMakefileDependencies(Language lang, const vector<strin
//
// Build arguments list.
//
- vector<string> args = _args;
- args.push_back("-M");
- args.push_back("-e");
- args.push_back("en_us.utf8");
- args.push_back(_fileName);
+ vector<string> args = baseArgs(_args, false, extraArgs, _fileName);
const char** argv = new const char*[args.size() + 1];
for(unsigned int i = 0; i < args.size(); ++i)
diff --git a/cpp/src/slice2confluence/Gen.cpp b/cpp/src/slice2confluence/Gen.cpp
index 4b059667033..91ae7a4e99a 100644
--- a/cpp/src/slice2confluence/Gen.cpp
+++ b/cpp/src/slice2confluence/Gen.cpp
@@ -888,7 +888,7 @@ Slice::GeneratorBase::printHeaderFooter(const ContainedPtr& c)
bool isFirst = prev == _symbols.end();
bool isLast = next == _symbols.end();
- bool hasParent = false;
+ /*bool hasParent = false;
if(EnumPtr::dynamicCast(c))
{
hasParent = true;
@@ -904,7 +904,7 @@ Slice::GeneratorBase::printHeaderFooter(const ContainedPtr& c)
else if(ContainedPtr::dynamicCast(c))
{
hasParent = true;
- }
+ }*/
bool onEnumPage = EnumPtr::dynamicCast(c);
diff --git a/cpp/src/slice2cpp/Main.cpp b/cpp/src/slice2cpp/Main.cpp
index e90edc5d4fd..eb31d0414db 100644
--- a/cpp/src/slice2cpp/Main.cpp
+++ b/cpp/src/slice2cpp/Main.cpp
@@ -204,7 +204,7 @@ compile(int argc, char* argv[])
if(depend)
{
PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs);
- FILE* cppHandle = icecpp->preprocess(false);
+ FILE* cppHandle = icecpp->preprocess(false, "-DICE_COMPILER=ICE_SLICE2CPP");
if(cppHandle == 0)
{
@@ -220,7 +220,8 @@ compile(int argc, char* argv[])
return EXIT_FAILURE;
}
- if(!icecpp->printMakefileDependencies(Preprocessor::CPlusPlus, includePaths, sourceExtension, headerExtension))
+ if(!icecpp->printMakefileDependencies(Preprocessor::CPlusPlus, includePaths,
+ "-DICE_COMPILER=ICE_SLICE2CPP", sourceExtension, headerExtension))
{
return EXIT_FAILURE;
}
@@ -233,7 +234,7 @@ compile(int argc, char* argv[])
else
{
PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs);
- FILE* cppHandle = icecpp->preprocess(false);
+ FILE* cppHandle = icecpp->preprocess(false, "-DICE_COMPILER=ICE_SLICE2CPP");
if(cppHandle == 0)
{
diff --git a/cpp/src/slice2cs/Main.cpp b/cpp/src/slice2cs/Main.cpp
index 0129ecfbeba..0f91002bbf3 100644
--- a/cpp/src/slice2cs/Main.cpp
+++ b/cpp/src/slice2cs/Main.cpp
@@ -198,7 +198,7 @@ compile(int argc, char* argv[])
if(depend)
{
PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs);
- FILE* cppHandle = icecpp->preprocess(false);
+ FILE* cppHandle = icecpp->preprocess(false, "-DICE_COMPILER=ICE_SLICE2CS");
if(cppHandle == 0)
{
@@ -214,7 +214,8 @@ compile(int argc, char* argv[])
return EXIT_FAILURE;
}
- if(!icecpp->printMakefileDependencies(Preprocessor::CSharp, includePaths))
+ if(!icecpp->printMakefileDependencies(Preprocessor::CSharp, includePaths,
+ "-DICE_COMPILER=ICE_SLICE2CS"))
{
return EXIT_FAILURE;
}
@@ -227,7 +228,7 @@ compile(int argc, char* argv[])
else
{
PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs);
- FILE* cppHandle = icecpp->preprocess(true);
+ FILE* cppHandle = icecpp->preprocess(true, "-DICE_COMPILER=ICE_SLICE2CS");
if(cppHandle == 0)
{
diff --git a/cpp/src/slice2freeze/Main.cpp b/cpp/src/slice2freeze/Main.cpp
index ee807a38989..958e3438fab 100644
--- a/cpp/src/slice2freeze/Main.cpp
+++ b/cpp/src/slice2freeze/Main.cpp
@@ -1952,7 +1952,7 @@ compile(int argc, char* argv[])
//
includes.push_back(icecpp->getBaseName() + ".h");
- FILE* cppHandle = icecpp->preprocess(false);
+ FILE* cppHandle = icecpp->preprocess(false, "-DICE_COMPILER=ICE_SLICE2FREEZE");
if(cppHandle == 0)
{
diff --git a/cpp/src/slice2freezej/Main.cpp b/cpp/src/slice2freezej/Main.cpp
index 3b38ec8e667..6a80a241904 100644
--- a/cpp/src/slice2freezej/Main.cpp
+++ b/cpp/src/slice2freezej/Main.cpp
@@ -1771,7 +1771,7 @@ compile(int argc, char* argv[])
if(depend || dependxml)
{
PreprocessorPtr icecpp = Preprocessor::create(argv[0], args[idx], cppArgs);
- FILE* cppHandle = icecpp->preprocess(false);
+ FILE* cppHandle = icecpp->preprocess(false, "-DICE_COMPILER=ICE_SLICE2FREEZEJ");
if(cppHandle == 0)
{
@@ -1787,7 +1787,8 @@ compile(int argc, char* argv[])
return EXIT_FAILURE;
}
- if(!icecpp->printMakefileDependencies(depend ? Preprocessor::Java : Preprocessor::JavaXML, includePaths))
+ if(!icecpp->printMakefileDependencies(depend ? Preprocessor::Java : Preprocessor::JavaXML, includePaths,
+ "-DICE_COMPILER=ICE_SLICE2FREEZEJ"))
{
u->destroy();
return EXIT_FAILURE;
@@ -1802,7 +1803,7 @@ compile(int argc, char* argv[])
else
{
PreprocessorPtr icecpp = Preprocessor::create(argv[0], args[idx], cppArgs);
- FILE* cppHandle = icecpp->preprocess(false);
+ FILE* cppHandle = icecpp->preprocess(false, "-DICE_COMPILER=ICE_SLICE2FREEZEJ");
if(cppHandle == 0)
{
diff --git a/cpp/src/slice2html/Main.cpp b/cpp/src/slice2html/Main.cpp
index 43646495f9e..b58360de8ed 100644
--- a/cpp/src/slice2html/Main.cpp
+++ b/cpp/src/slice2html/Main.cpp
@@ -222,7 +222,7 @@ compile(int argc, char* argv[])
for(vector<string>::size_type idx = 0; idx < args.size(); ++idx)
{
PreprocessorPtr icecpp = Preprocessor::create(argv[0], args[idx], cppArgs);
- FILE* cppHandle = icecpp->preprocess(true);
+ FILE* cppHandle = icecpp->preprocess(true, "-DICE_COMPILER=ICE_SLICE2HTML");
if(cppHandle == 0)
{
diff --git a/cpp/src/slice2java/Main.cpp b/cpp/src/slice2java/Main.cpp
index 2d0f6cb06f1..d06b1477a66 100644
--- a/cpp/src/slice2java/Main.cpp
+++ b/cpp/src/slice2java/Main.cpp
@@ -219,7 +219,7 @@ compile(int argc, char* argv[])
if(depend || dependxml)
{
PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs);
- FILE* cppHandle = icecpp->preprocess(false);
+ FILE* cppHandle = icecpp->preprocess(false, "-DICE_COMPILER=ICE_SLICE2JAVA");
if(cppHandle == 0)
{
@@ -235,7 +235,9 @@ compile(int argc, char* argv[])
return EXIT_FAILURE;
}
- if(!icecpp->printMakefileDependencies(depend ? Preprocessor::Java : Preprocessor::JavaXML, includePaths))
+ if(!icecpp->printMakefileDependencies(depend ? Preprocessor::Java : Preprocessor::JavaXML, includePaths,
+ "-DICE_COMPILER=ICE_SLICE2JAVA"
+ ))
{
return EXIT_FAILURE;
}
@@ -256,7 +258,7 @@ compile(int argc, char* argv[])
FileTracker::instance()->setSource(*i);
PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs);
- FILE* cppHandle = icecpp->preprocess(true);
+ FILE* cppHandle = icecpp->preprocess(true, "-DICE_COMPILER=ICE_SLICE2JAVA");
if(cppHandle == 0)
{
diff --git a/cpp/src/slice2php/Main.cpp b/cpp/src/slice2php/Main.cpp
index 42eac38e19f..1be68d99238 100644
--- a/cpp/src/slice2php/Main.cpp
+++ b/cpp/src/slice2php/Main.cpp
@@ -1670,7 +1670,7 @@ compile(int argc, char* argv[])
if(depend)
{
PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs);
- FILE* cppHandle = icecpp->preprocess(false);
+ FILE* cppHandle = icecpp->preprocess(false, "-DICE_COMPILER=ICE_SLICE2PHP");
if(cppHandle == 0)
{
@@ -1686,7 +1686,7 @@ compile(int argc, char* argv[])
return EXIT_FAILURE;
}
- if(!icecpp->printMakefileDependencies(Preprocessor::PHP, includePaths))
+ if(!icecpp->printMakefileDependencies(Preprocessor::PHP, includePaths, "-DICE_COMPILER=ICE_SLICE2PHP"))
{
return EXIT_FAILURE;
}
@@ -1699,7 +1699,7 @@ compile(int argc, char* argv[])
else
{
PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs);
- FILE* cppHandle = icecpp->preprocess(false);
+ FILE* cppHandle = icecpp->preprocess(false, "-DICE_COMPILER=ICE_SLICE2PHP");
if(cppHandle == 0)
{
diff --git a/cpp/src/slice2py/Main.cpp b/cpp/src/slice2py/Main.cpp
index 15aec1b42b4..317f0d7c68f 100644
--- a/cpp/src/slice2py/Main.cpp
+++ b/cpp/src/slice2py/Main.cpp
@@ -490,7 +490,7 @@ compile(int argc, char* argv[])
if(depend)
{
PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs);
- FILE* cppHandle = icecpp->preprocess(false);
+ FILE* cppHandle = icecpp->preprocess(false, "-DICE_COMPILER=ICE_SLICE2PY");
if(cppHandle == 0)
{
@@ -506,7 +506,8 @@ compile(int argc, char* argv[])
return EXIT_FAILURE;
}
- if(!icecpp->printMakefileDependencies(Preprocessor::Python, includePaths, "", prefix))
+ if(!icecpp->printMakefileDependencies(Preprocessor::Python, includePaths,
+ "-DICE_COMPILER=ICE_SLICE2PY", "", prefix))
{
return EXIT_FAILURE;
}
@@ -519,7 +520,7 @@ compile(int argc, char* argv[])
else
{
PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs);
- FILE* cppHandle = icecpp->preprocess(keepComments);
+ FILE* cppHandle = icecpp->preprocess(keepComments, "-DICE_COMPILER=ICE_SLICE2PY");
if(cppHandle == 0)
{
diff --git a/cpp/src/slice2rb/Main.cpp b/cpp/src/slice2rb/Main.cpp
index c793f2b5b3b..a8d2764a2f5 100644
--- a/cpp/src/slice2rb/Main.cpp
+++ b/cpp/src/slice2rb/Main.cpp
@@ -194,7 +194,7 @@ compile(int argc, char* argv[])
if(depend)
{
PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs);
- FILE* cppHandle = icecpp->preprocess(false);
+ FILE* cppHandle = icecpp->preprocess(false, "-DICE_COMPILER=ICE_SLICE2RB");
if(cppHandle == 0)
{
@@ -210,7 +210,8 @@ compile(int argc, char* argv[])
return EXIT_FAILURE;
}
- if(!icecpp->printMakefileDependencies(Preprocessor::Ruby, includePaths))
+ if(!icecpp->printMakefileDependencies(Preprocessor::Ruby, includePaths,
+ "-DICE_COMPILER=ICE_SLICE2RB"))
{
return EXIT_FAILURE;
}
@@ -223,7 +224,7 @@ compile(int argc, char* argv[])
else
{
PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs);
- FILE* cppHandle = icecpp->preprocess(false);
+ FILE* cppHandle = icecpp->preprocess(false, "-DICE_COMPILER=ICE_SLICE2RB");
if(cppHandle == 0)
{
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)