summaryrefslogtreecommitdiff
path: root/cpp/src/slice2cppe
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2005-07-15 17:36:11 +0000
committerMark Spruiell <mes@zeroc.com>2005-07-15 17:36:11 +0000
commit08d0be306e431b3296f4e33b49beef96aafd6f84 (patch)
tree92f10ec363a6692c4224d960255038fa2ba4cc33 /cpp/src/slice2cppe
parentremoving Ice-E code (diff)
downloadice-08d0be306e431b3296f4e33b49beef96aafd6f84.tar.bz2
ice-08d0be306e431b3296f4e33b49beef96aafd6f84.tar.xz
ice-08d0be306e431b3296f4e33b49beef96aafd6f84.zip
moving code from CPlusPlusUtil; show Ice-E version for -v
Diffstat (limited to 'cpp/src/slice2cppe')
-rw-r--r--cpp/src/slice2cppe/Gen.cpp72
-rw-r--r--cpp/src/slice2cppe/Gen.h11
-rw-r--r--cpp/src/slice2cppe/Main.cpp2
3 files changed, 70 insertions, 15 deletions
diff --git a/cpp/src/slice2cppe/Gen.cpp b/cpp/src/slice2cppe/Gen.cpp
index 06527596a48..02323403aba 100644
--- a/cpp/src/slice2cppe/Gen.cpp
+++ b/cpp/src/slice2cppe/Gen.cpp
@@ -139,8 +139,8 @@ Slice::Gen::Gen(const string& name, const string& base, const string& headerExte
return;
}
- printHeader(H, true);
- printHeader(C, true);
+ printHeader(H);
+ printHeader(C);
H << "\n// Generated from file `" << changeInclude(_base, _includePaths) << ".ice'\n";
C << "\n// Generated from file `" << changeInclude(_base, _includePaths) << ".ice'\n";
@@ -248,10 +248,10 @@ Slice::Gen::generate(const UnitPtr& p)
H << "\n#include <IceE/UndefSysMacros.h>";
- printVersionCheck(H, true);
- printVersionCheck(C, true);
+ printVersionCheck(H);
+ printVersionCheck(C);
- printDllExportStuff(H, _dllExport, true);
+ printDllExportStuff(H, _dllExport);
if(_dllExport.size())
{
_dllExport += " ";
@@ -2778,13 +2778,6 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p)
return true;
}
-void
-Slice::Gen::validateMetaData(const UnitPtr& unit)
-{
- MetaDataVisitor visitor;
- unit->visit(&visitor, false);
-}
-
bool
Slice::Gen::MetaDataVisitor::visitModuleStart(const ModulePtr& p)
{
@@ -2934,3 +2927,58 @@ Slice::Gen::MetaDataVisitor::validate(const ContainedPtr& cont)
}
}
}
+
+void
+Slice::Gen::validateMetaData(const UnitPtr& unit)
+{
+ MetaDataVisitor visitor;
+ unit->visit(&visitor, false);
+}
+
+void
+Slice::Gen::printHeader(Output& out)
+{
+ static const char* header =
+"// **********************************************************************\n"
+"//\n"
+"// Copyright (c) 2005 ZeroC, Inc. All rights reserved.\n"
+"//\n"
+"// This copy of Ice-E is licensed to you under the terms described in the\n"
+"// ICEE_LICENSE file included in this distribution.\n"
+"//\n"
+"// **********************************************************************\n"
+ ;
+
+ out << header;
+ out << "\n// Ice-E version " << ICEE_STRING_VERSION;
+}
+
+void
+Slice::Gen::printVersionCheck(Output& out)
+{
+ out << "\n";
+ out << "\n#ifndef ICEE_IGNORE_VERSION";
+ out << "\n# if ICEE_INT_VERSION / 100 != " << ICEE_INT_VERSION / 100;
+ out << "\n# error IceE version mismatch!";
+ out << "\n# endif";
+ out << "\n# if ICEE_INT_VERSION % 100 < " << ICEE_INT_VERSION % 100;
+ out << "\n# error IceE patch level mismatch!";
+ out << "\n# endif";
+ out << "\n#endif";
+}
+
+void
+Slice::Gen::printDllExportStuff(Output& out, const string& dllExport)
+{
+ if(dllExport.size())
+ {
+ out << sp;
+ out << "\n#ifndef " << dllExport;
+ out << "\n# ifdef " << dllExport << "_EXPORTS";
+ out << "\n# define " << dllExport << " ICEE_DECLSPEC_EXPORT";
+ out << "\n# else";
+ out << "\n# define " << dllExport << " ICEE_DECLSPEC_IMPORT";
+ out << "\n# endif";
+ out << "\n#endif";
+ }
+}
diff --git a/cpp/src/slice2cppe/Gen.h b/cpp/src/slice2cppe/Gen.h
index e3ecaeb5ddf..d8b6ab74aab 100644
--- a/cpp/src/slice2cppe/Gen.h
+++ b/cpp/src/slice2cppe/Gen.h
@@ -13,6 +13,12 @@
#include <Slice/Parser.h>
#include <IceUtil/OutputUtil.h>
+//
+// The Ice-E version.
+//
+#define ICEE_STRING_VERSION "1.0.0" // "A.B.C", with A=major, B=minor, C=patch
+#define ICEE_INT_VERSION 10000 // AABBCC, with AA=major, BB=minor, CC=patch
+
namespace Slice
{
@@ -254,8 +260,6 @@ private:
void writeReturn(::IceUtil::Output&, const TypePtr&);
};
-private:
-
class MetaDataVisitor : public ParserVisitor
{
public:
@@ -285,6 +289,9 @@ private:
};
static void validateMetaData(const UnitPtr&);
+ static void printHeader(IceUtil::Output&);
+ static void printVersionCheck(IceUtil::Output&);
+ static void printDllExportStuff(IceUtil::Output&, const std::string&);
};
}
diff --git a/cpp/src/slice2cppe/Main.cpp b/cpp/src/slice2cppe/Main.cpp
index cb8288dcda9..39900a5f5a4 100644
--- a/cpp/src/slice2cppe/Main.cpp
+++ b/cpp/src/slice2cppe/Main.cpp
@@ -92,7 +92,7 @@ main(int argc, char* argv[])
}
if(opts.isSet("v") || opts.isSet("version"))
{
- cout << ICE_STRING_VERSION << endl;
+ cout << ICEE_STRING_VERSION << endl;
return EXIT_SUCCESS;
}