[asterisk-scf-commits] asterisk-scf/release/ice.git branch "visitor-generators" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Thu Jan 6 14:10:47 UTC 2011
branch "visitor-generators" has been updated
via acb595531400e601176d5bcd1b0b4478beade2c7 (commit)
from 025784b070e939bf80d21f2a06dda5d97d2ddae8 (commit)
Summary of changes:
cpp/src/slice2cs/Gen.cpp | 32 ++++++++++++++++++++++++++++++--
cpp/src/slice2cs/Gen.h | 5 ++++-
cpp/src/slice2cs/Main.cpp | 6 +++++-
3 files changed, 39 insertions(+), 4 deletions(-)
- Log -----------------------------------------------------------------
commit acb595531400e601176d5bcd1b0b4478beade2c7
Author: Kevin P. Fleming <kpfleming at digium.com>
Date: Thu Jan 6 08:10:43 2011 -0600
Add plugin (but not LanguageHelper) support to slice2cs.
diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp
index 7a089e9..7e3a229 100644
--- a/cpp/src/slice2cs/Gen.cpp
+++ b/cpp/src/slice2cs/Gen.cpp
@@ -10,6 +10,7 @@
#include <IceUtil/DisableWarnings.h>
#include <IceUtil/Functional.h>
#include <IceUtil/StringUtil.h>
+#include <IceUtil/DynamicLibrary.h>
#include <Gen.h>
#include <limits>
#include <sys/stat.h>
@@ -24,6 +25,7 @@
#include <Slice/DotNetNames.h>
#include <Slice/FileTracker.h>
#include <Slice/Util.h>
+#include <Slice/Plugin.h>
#include <string.h>
using namespace std;
@@ -1849,9 +1851,10 @@ Slice::CsVisitor::writeDocCommentParam(const OperationPtr& p, ParamDir paramType
}
Slice::Gen::Gen(const string& base, const vector<string>& includePaths, const string& dir,
- bool impl, bool implTie, bool stream)
+ bool impl, bool implTie, bool stream, const vector<string>& plugins)
: _includePaths(includePaths),
- _stream(stream)
+ _stream(stream),
+ _plugins(plugins)
{
string fileBase = base;
string::size_type pos = base.find_last_of("/\\");
@@ -1924,6 +1927,31 @@ Slice::Gen::generate(const UnitPtr& p)
{
CsGenerator::validateMetaData(p);
+ for(vector<string>::const_iterator plugin = _plugins.begin(); plugin != _plugins.end(); plugin++)
+ {
+ IceUtil::DynamicLibraryPtr library = new IceUtil::DynamicLibrary();
+ IceUtil::DynamicLibrary::symbol_type sym = library->loadEntryPoint(*plugin, false);
+ if(sym == 0)
+ {
+ string msg = library->getErrorMessage();
+ cerr << "Unable to find " << *plugin << " = " << msg << endl;
+ }
+
+ Plugin::VisitorList* pluginVisitors;
+ Plugin::FACTORY factory = (Plugin::FACTORY) sym;
+ pluginVisitors = factory(Plugin::LanguageCS, 0);
+
+ if(pluginVisitors)
+ {
+ for(Plugin::VisitorList::const_iterator it = pluginVisitors->begin(); it != pluginVisitors->end(); it++)
+ {
+ p->visit(*it, true);
+ delete *it;
+ }
+ delete pluginVisitors;
+ }
+ }
+
UnitVisitor unitVisitor(_out);
p->visit(&unitVisitor, false);
diff --git a/cpp/src/slice2cs/Gen.h b/cpp/src/slice2cs/Gen.h
index 7e30421..9702216 100644
--- a/cpp/src/slice2cs/Gen.h
+++ b/cpp/src/slice2cs/Gen.h
@@ -74,7 +74,8 @@ public:
const std::string&,
bool,
bool,
- bool);
+ bool,
+ const std::vector<std::string>&);
~Gen();
void generate(const UnitPtr&);
@@ -93,6 +94,8 @@ private:
bool _stream;
+ std::vector<std::string> _plugins;
+
void printHeader();
class UnitVisitor : public CsVisitor
diff --git a/cpp/src/slice2cs/Main.cpp b/cpp/src/slice2cs/Main.cpp
index 87ed3c6..b8be8ab 100644
--- a/cpp/src/slice2cs/Main.cpp
+++ b/cpp/src/slice2cs/Main.cpp
@@ -76,6 +76,7 @@ usage(const char* n)
"--underscore Permit underscores in Slice identifiers.\n"
"--checksum Generate checksums for Slice definitions.\n"
"--stream Generate marshaling support for public stream API.\n"
+ "--plugin PATH Load and apply plugin before generating output.\n"
;
}
@@ -99,6 +100,7 @@ compile(int argc, char* argv[])
opts.addOpt("", "underscore");
opts.addOpt("", "checksum");
opts.addOpt("", "stream");
+ opts.addOpt("", "plugin", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat);
vector<string> args;
try
@@ -144,6 +146,8 @@ compile(int argc, char* argv[])
cppArgs.push_back("-I" + Preprocessor::normalizeIncludePath(*i));
}
+ vector<string> plugins = opts.argVec("plugin");
+
bool preprocess = opts.isSet("E");
string output = opts.optArg("output-dir");
@@ -268,7 +272,7 @@ compile(int argc, char* argv[])
{
try
{
- Gen gen(icecpp->getBaseName(), includePaths, output, impl, implTie, stream);
+ Gen gen(icecpp->getBaseName(), includePaths, output, impl, implTie, stream, plugins);
gen.generate(p);
if(tie)
{
-----------------------------------------------------------------------
--
asterisk-scf/release/ice.git
More information about the asterisk-scf-commits
mailing list