[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
Tue Jan 4 02:09:22 UTC 2011


branch "visitor-generators" has been updated
       via  615a1be18e8fe040c50f844deee6353873643611 (commit)
      from  04f2277cee56e3286fc26e7d691b0ebee94cd762 (commit)

Summary of changes:
 cpp/src/slice2cpp/Gen.cpp  |   40 ++++++++++++++++++++++------------------
 cpp/src/slice2cpp/Gen.h    |    4 +++-
 cpp/src/slice2cpp/Main.cpp |    6 +++++-
 3 files changed, 30 insertions(+), 20 deletions(-)


- Log -----------------------------------------------------------------
commit 615a1be18e8fe040c50f844deee6353873643611
Author: Kevin P. Fleming <kpfleming at digium.com>
Date:   Mon Jan 3 20:07:02 2011 -0600

    Add support for plugins (via --plugin option) to slice2cpp.

diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index 2d893ca..1e2d458 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -130,7 +130,7 @@ writeDataMemberInitializers(IceUtilInternal::Output& C, const DataMemberList& me
 Slice::Gen::Gen(const string& base, const string& headerExtension, const string& sourceExtension,
                 const vector<string>& extraHeaders, const string& include,
                 const vector<string>& includePaths, const string& dllExport, const string& dir,
-                bool imp, bool checksum, bool stream, bool ice) :
+                bool imp, bool checksum, bool stream, bool ice, const vector<string>& plugins) :
     _base(base),
     _headerExtension(headerExtension),
     _implHeaderExtension(headerExtension),
@@ -143,7 +143,8 @@ Slice::Gen::Gen(const string& base, const string& headerExtension, const string&
     _impl(imp),
     _checksum(checksum),
     _stream(stream),
-    _ice(ice)
+    _ice(ice),
+    _plugins(plugins)
 {
     for(vector<string>::iterator p = _includePaths.begin(); p != _includePaths.end(); ++p)
     {
@@ -176,25 +177,28 @@ Slice::Gen::generate(const UnitPtr& p)
 {
     string file = p->topLevelFile();
     
-    IceUtil::DynamicLibraryPtr library = new IceUtil::DynamicLibrary();
-    IceUtil::DynamicLibrary::symbol_type sym = library->loadEntryPoint("SliceVisitorPattern:create", false);
-    if(sym == 0)
+    for(vector<string>::const_iterator plugin = _plugins.begin(); plugin != _plugins.end(); plugin++)
     {
-        string msg = library->getErrorMessage();
-        cerr << "Unable to find SliceVisitorPattern:create = " << msg << endl;
-    }
-    
-    Plugin::PluginVisitorList* pluginVisitors;
-    PLUGIN_FACTORY factory = (PLUGIN_FACTORY)sym;
-    pluginVisitors = factory(Plugin::LanguageCXX);
-
-    if(pluginVisitors)
-    {
-        for(Plugin::PluginVisitorList::const_iterator it = pluginVisitors->begin(); it != pluginVisitors->end(); it++)
+        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::PluginVisitorList* pluginVisitors;
+        PLUGIN_FACTORY factory = (PLUGIN_FACTORY)sym;
+        pluginVisitors = factory(Plugin::LanguageCXX);
+        
+        if(pluginVisitors)
         {
-            p->visit(it->get(), true);
+            for(Plugin::PluginVisitorList::const_iterator it = pluginVisitors->begin(); it != pluginVisitors->end(); it++)
+            {
+                p->visit(it->get(), true);
+            }
+            delete pluginVisitors;
         }
-        delete pluginVisitors;
     }
 
     //
diff --git a/cpp/src/slice2cpp/Gen.h b/cpp/src/slice2cpp/Gen.h
index e4c71e9..8b2cd0b 100644
--- a/cpp/src/slice2cpp/Gen.h
+++ b/cpp/src/slice2cpp/Gen.h
@@ -31,7 +31,8 @@ public:
         bool,
         bool,
         bool,
-        bool);
+        bool,
+        const std::vector<std::string>&);
     ~Gen();
 
     void generate(const UnitPtr&);
@@ -70,6 +71,7 @@ private:
     bool _checksum;
     bool _stream;
     bool _ice;
+    std::vector<std::string> _plugins;
 
     class TypesVisitor : private ::IceUtil::noncopyable, public ParserVisitor
     {
diff --git a/cpp/src/slice2cpp/Main.cpp b/cpp/src/slice2cpp/Main.cpp
index 0ca754b..3381bfa 100644
--- a/cpp/src/slice2cpp/Main.cpp
+++ b/cpp/src/slice2cpp/Main.cpp
@@ -79,6 +79,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"
         ;
 }
 
@@ -105,6 +106,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
@@ -156,6 +158,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 include = opts.optArg("include-dir");
@@ -275,7 +279,7 @@ compile(int argc, char* argv[])
                     try
                     {
                         Gen gen(icecpp->getBaseName(), headerExtension, sourceExtension, extraHeaders, include,
-                                includePaths, dllExport, output, impl, checksum, stream, ice);
+                                includePaths, dllExport, output, impl, checksum, stream, ice, plugins);
                         gen.generate(u);
                     }
                     catch(const Slice::FileException& ex)

-----------------------------------------------------------------------


-- 
asterisk-scf/release/ice.git



More information about the asterisk-scf-commits mailing list