summaryrefslogtreecommitdiff
path: root/cpp/src/slice2cpp
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2016-10-31 15:54:21 -0400
committerBernard Normier <bernard@zeroc.com>2016-10-31 15:54:21 -0400
commit107e03ea13e0eba9c33f120f0d95ac9fefc7dcad (patch)
tree00191b7ccb83fe436ad61bdbb43b523f431c6698 /cpp/src/slice2cpp
parentUpdate 3.7 changelog (diff)
downloadice-107e03ea13e0eba9c33f120f0d95ac9fefc7dcad.tar.bz2
ice-107e03ea13e0eba9c33f120f0d95ac9fefc7dcad.tar.xz
ice-107e03ea13e0eba9c33f120f0d95ac9fefc7dcad.zip
Replaced slice compiler options --ice, --underscore and --dll-export by
global metadata directives (ice-prefix, underscore, cpp:dll-export:SYMBOL and objc:dll-export:SYMBOL) Added new cs:tie and java:tie metadata
Diffstat (limited to 'cpp/src/slice2cpp')
-rw-r--r--cpp/src/slice2cpp/Gen.cpp32
-rw-r--r--cpp/src/slice2cpp/Main.cpp15
2 files changed, 41 insertions, 6 deletions
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index 978ab8114f2..ad125388647 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -463,6 +463,21 @@ Slice::Gen::generate(const UnitPtr& p)
_headerExtension = headerExtension;
}
+ //
+ // Give precedence to --dll-export command-line option
+ //
+ if(_dllExport.empty())
+ {
+ DefinitionContextPtr dc = p->findDefinitionContext(file);
+ assert(dc);
+ static const string dllExportPrefix = "cpp:dll-export:";
+ string meta = dc->findMetaData(dllExportPrefix);
+ if(meta.size() > dllExportPrefix.size())
+ {
+ _dllExport = meta.substr(dllExportPrefix.size());
+ }
+ }
+
if(_implCpp98 || _implCpp11)
{
string fileImplH = _base + "I." + _implHeaderExtension;
@@ -4459,6 +4474,7 @@ Slice::Gen::MetaDataVisitor::visitUnitStart(const UnitPtr& p)
assert(dc);
StringList globalMetaData = dc->getMetaData();
int headerExtension = 0;
+ int dllExport = 0;
for(StringList::const_iterator r = globalMetaData.begin(); r != globalMetaData.end(); ++r)
{
string s = *r;
@@ -4468,6 +4484,8 @@ Slice::Gen::MetaDataVisitor::visitUnitStart(const UnitPtr& p)
{
static const string cppIncludePrefix = "cpp:include:";
static const string cppHeaderExtPrefix = "cpp:header-ext:";
+ static const string cppDllExportPrefix = "cpp:dll-export:";
+
if(s.find(cppIncludePrefix) == 0 && s.size() > cppIncludePrefix.size())
{
continue;
@@ -4485,6 +4503,20 @@ Slice::Gen::MetaDataVisitor::visitUnitStart(const UnitPtr& p)
}
continue;
}
+ else if(s.find(cppDllExportPrefix) == 0 && s.size() > cppDllExportPrefix.size())
+ {
+ dllExport++;
+ if(dllExport > 1)
+ {
+ ostringstream ostr;
+ ostr << "ignoring invalid global metadata `" << s
+ << "': directive can appear only once per file";
+ emitWarning(file, -1, ostr.str());
+ _history.insert(s);
+ }
+ continue;
+ }
+
ostringstream ostr;
ostr << "ignoring invalid global metadata `" << s << "'";
emitWarning(file, -1, ostr.str());
diff --git a/cpp/src/slice2cpp/Main.cpp b/cpp/src/slice2cpp/Main.cpp
index 27376433b57..72a549b454e 100644
--- a/cpp/src/slice2cpp/Main.cpp
+++ b/cpp/src/slice2cpp/Main.cpp
@@ -72,16 +72,19 @@ usage(const string& n)
"-E Print preprocessor output on stdout.\n"
"--include-dir DIR Use DIR as the header include directory in source files.\n"
"--output-dir DIR Create files in the directory DIR.\n"
- "--dll-export SYMBOL Use SYMBOL for DLL exports.\n"
"--impl-c++98 Generate sample implementations for C++98 mapping.\n"
"--impl-c++11 Generate sample implementations for C++11 mapping.\n"
+ "--checksum Generate checksums for Slice definitions.\n"
"--depend Generate Makefile dependencies.\n"
"--depend-xml Generate dependencies in XML format.\n"
"--depend-file FILE Write dependencies to FILE instead of standard output.\n"
"-d, --debug Print debug messages.\n"
- "--ice Allow reserved Ice prefix in Slice identifiers.\n"
- "--underscore Allow underscores in Slice identifiers.\n"
- "--checksum Generate checksums for Slice definitions.\n"
+ "--dll-export SYMBOL Use SYMBOL for DLL exports\n"
+ " deprecated: use instead [[\"cpp:dll-export:SYMBOL\"]] metadata.\n"
+ "--ice Allow reserved Ice prefix in Slice identifiers\n"
+ " deprecated: use instead [[\"ice-prefix\"]] metadata.\n"
+ "--underscore Allow underscores in Slice identifiers\n"
+ " deprecated: use instead [[\"underscore\"]] metadata.\n"
;
}
@@ -174,7 +177,7 @@ compile(const vector<string>& argv)
string dllExport = opts.optArg("dll-export");
bool implCpp98 = opts.isSet("impl-c++98");
-
+
bool implCpp11 = opts.isSet("impl-c++11");
bool depend = opts.isSet("depend");
@@ -210,7 +213,7 @@ compile(const vector<string>& argv)
}
return EXIT_FAILURE;
}
-
+
if(implCpp98 && implCpp11)
{
getErrorStream() << argv[0] << ": error: cannot specify both --impl-c++98 and --impl-c++11" << endl;