summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp')
-rw-r--r--cpp/CHANGES6
-rw-r--r--cpp/include/IceUtil/Config.h4
-rw-r--r--cpp/src/slice2cppe/Gen.cpp69
-rw-r--r--cpp/src/slice2cppe/Gen.h2
-rw-r--r--cpp/src/slice2freeze/Main.cpp34
5 files changed, 75 insertions, 40 deletions
diff --git a/cpp/CHANGES b/cpp/CHANGES
index 54d2fc585a8..e566da25aee 100644
--- a/cpp/CHANGES
+++ b/cpp/CHANGES
@@ -1,9 +1,9 @@
Changes since version 2.1.2
---------------------------
-- slice2cpp now provides the --add-header option. It adds a #include directive
- for the specified header at the beginning of the generated source file. For
- example:
+- slice2cpp and slice2freeze now provide the --add-header option. It adds a
+ #include directive for the specified header at the beginning of the generated
+ source file. For example:
slice2cpp --add-header=precompiled.h x.ice
diff --git a/cpp/include/IceUtil/Config.h b/cpp/include/IceUtil/Config.h
index 2149da40357..5a41dc098ee 100644
--- a/cpp/include/IceUtil/Config.h
+++ b/cpp/include/IceUtil/Config.h
@@ -198,7 +198,7 @@ typedef long long Int64;
//
// The Ice version.
//
-#define ICE_STRING_VERSION "2.1.0" // "A.B.C", with A=major, B=minor, C=patch
-#define ICE_INT_VERSION 20100 // AABBCC, with AA=major, BB=minor, CC=patch
+#define ICE_STRING_VERSION "3.0.0" // "A.B.C", with A=major, B=minor, C=patch
+#define ICE_INT_VERSION 30000 // AABBCC, with AA=major, BB=minor, CC=patch
#endif
diff --git a/cpp/src/slice2cppe/Gen.cpp b/cpp/src/slice2cppe/Gen.cpp
index 5808126ef91..0e160b0c096 100644
--- a/cpp/src/slice2cppe/Gen.cpp
+++ b/cpp/src/slice2cppe/Gen.cpp
@@ -187,40 +187,8 @@ Slice::Gen::generate(const UnitPtr& p)
{
validateMetaData(p);
- //
- // Output additional header includes first.
- //
- vector<string>::const_iterator i;
- for(i = _extraHeaders.begin(); i != _extraHeaders.end(); ++i)
- {
- string hdr = *i;
- string guard;
- string::size_type pos = hdr.rfind(',');
- if(pos != string::npos)
- {
- hdr = i->substr(0, pos);
- guard = i->substr(pos + 1);
- }
- if(!guard.empty())
- {
- C << "\n#ifndef " << guard;
- C << "\n#define " << guard;
- }
- C << "\n#include <";
- if(!_include.empty())
- {
- C << _include << '/';
- }
- C << hdr << '>';
- if(!guard.empty())
- {
- C << "\n#endif";
- }
- }
+ writeExtraHeaders(C);
- //
- // Output remaining includes.
- //
C << "\n#include <";
if(_include.size())
{
@@ -325,7 +293,9 @@ Slice::Gen::generate(const UnitPtr& p)
}
implH << _base << ".h>";
- implC << "#include <";
+ writeExtraHeaders(implC);
+
+ implC << "\n#include <";
if(_include.size())
{
implC << _include << '/';
@@ -337,6 +307,37 @@ Slice::Gen::generate(const UnitPtr& p)
}
}
+void
+Slice::Gen::writeExtraHeaders(Output& out)
+{
+ for(vector<string>::const_iterator i = _extraHeaders.begin(); i != _extraHeaders.end(); ++i)
+ {
+ string hdr = *i;
+ string guard;
+ string::size_type pos = hdr.rfind(',');
+ if(pos != string::npos)
+ {
+ hdr = i->substr(0, pos);
+ guard = i->substr(pos + 1);
+ }
+ if(!guard.empty())
+ {
+ out << "\n#ifndef " << guard;
+ out << "\n#define " << guard;
+ }
+ out << "\n#include <";
+ if(!_include.empty())
+ {
+ out << _include << '/';
+ }
+ out << hdr << '>';
+ if(!guard.empty())
+ {
+ out << "\n#endif";
+ }
+ }
+}
+
Slice::Gen::TypesVisitor::TypesVisitor(Output& h, Output& c, const string& dllExport) :
H(h), C(c), _dllExport(dllExport), _doneStaticSymbol(false)
{
diff --git a/cpp/src/slice2cppe/Gen.h b/cpp/src/slice2cppe/Gen.h
index 5dd2ef6bced..f1fe0778070 100644
--- a/cpp/src/slice2cppe/Gen.h
+++ b/cpp/src/slice2cppe/Gen.h
@@ -44,6 +44,8 @@ public:
private:
+ void writeExtraHeaders(::IceUtil::Output&);
+
::IceUtil::Output H;
::IceUtil::Output C;
diff --git a/cpp/src/slice2freeze/Main.cpp b/cpp/src/slice2freeze/Main.cpp
index 22bce317e9f..10d308cb595 100644
--- a/cpp/src/slice2freeze/Main.cpp
+++ b/cpp/src/slice2freeze/Main.cpp
@@ -54,6 +54,8 @@ usage(const char* n)
"-v, --version Display the Ice version.\n"
"--header-ext EXT Use EXT instead of the default `h' extension.\n"
"--source-ext EXT Use EXT instead of the default `cpp' extension.\n"
+ "--add-header HDR[,GUARD]\n"
+ " Add #include for HDR (with guard GUARD) to generated source file.\n"
"-DNAME Define NAME as 1.\n"
"-DNAME=DEF Define NAME as DEF.\n"
"-UNAME Remove any definition for NAME.\n"
@@ -979,6 +981,7 @@ main(int argc, char* argv[])
opts.addOpt("v", "version");
opts.addOpt("", "header-ext", IceUtil::Options::NeedArg, "h");
opts.addOpt("", "source-ext", IceUtil::Options::NeedArg, "cpp");
+ opts.addOpt("", "add-header", IceUtil::Options::NeedArg, "", IceUtil::Options::Repeat);
opts.addOpt("D", "", IceUtil::Options::NeedArg, "", IceUtil::Options::Repeat);
opts.addOpt("U", "", IceUtil::Options::NeedArg, "", IceUtil::Options::Repeat);
opts.addOpt("I", "", IceUtil::Options::NeedArg, "", IceUtil::Options::Repeat);
@@ -1019,6 +1022,8 @@ main(int argc, char* argv[])
headerExtension = opts.optArg("header-ext");
sourceExtension = opts.optArg("source-ext");
+ vector<string> extraHeaders = opts.argVec("add-header");
+
if(opts.isSet("D"))
{
vector<string> optargs = opts.argVec("D");
@@ -1367,7 +1372,34 @@ main(int argc, char* argv[])
}
printHeader(C);
printFreezeTypes(C, dicts, indices);
-
+
+ for(vector<string>::const_iterator i = extraHeaders.begin(); i != extraHeaders.end(); ++i)
+ {
+ string hdr = *i;
+ string guard;
+ string::size_type pos = hdr.rfind(',');
+ if(pos != string::npos)
+ {
+ hdr = i->substr(0, pos);
+ guard = i->substr(pos + 1);
+ }
+ if(!guard.empty())
+ {
+ C << "\n#ifndef " << guard;
+ C << "\n#define " << guard;
+ }
+ C << "\n#include <";
+ if(!include.empty())
+ {
+ C << include << '/';
+ }
+ C << hdr << '>';
+ if(!guard.empty())
+ {
+ C << "\n#endif";
+ }
+ }
+
string s = fileH;
transform(s.begin(), s.end(), s.begin(), ToIfdef());
H << "\n#ifndef __" << s << "__";