[asterisk-scf-commits] asterisk-scf/integration/ice.git branch "slice-plugins" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Thu Mar 10 12:22:38 CST 2011


branch "slice-plugins" has been updated
       via  c88b2f91fb28cc43cae1d49b98159a1aef4f9486 (commit)
      from  2942fcd1c8f1ef81687bbb7b3b629fb1a79695f7 (commit)

Summary of changes:
 cpp/include/Slice/Plugin.h |    2 +-
 cpp/src/Slice/Plugin.cpp   |   48 ++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 47 insertions(+), 3 deletions(-)


- Log -----------------------------------------------------------------
commit c88b2f91fb28cc43cae1d49b98159a1aef4f9486
Author: Kevin P. Fleming <kpfleming at digium.com>
Date:   Thu Mar 10 12:22:22 2011 -0600

    Add support for arguments specified to plugins.

diff --git a/cpp/include/Slice/Plugin.h b/cpp/include/Slice/Plugin.h
index b47ba3a..7d6363a 100644
--- a/cpp/include/Slice/Plugin.h
+++ b/cpp/include/Slice/Plugin.h
@@ -21,7 +21,7 @@ namespace Plugin
 
     typedef std::list<ParserVisitor *> VisitorList;
 
-    typedef VisitorList* (*FACTORY)(Language);
+    typedef VisitorList* (*FACTORY)(Language, const StringList*);
 
     void applyPluginsToUnit(const std::vector<std::string>&, Language, const UnitPtr&);
 
diff --git a/cpp/src/Slice/Plugin.cpp b/cpp/src/Slice/Plugin.cpp
index 8e8cb12..632629e 100644
--- a/cpp/src/Slice/Plugin.cpp
+++ b/cpp/src/Slice/Plugin.cpp
@@ -21,8 +21,51 @@ Plugin::applyPluginsToUnit(const std::vector<std::string>& plugins, Language lan
 {
     for(vector<string>::const_iterator plugin = plugins.begin(); plugin != plugins.end(); plugin++)
     {
+        StringList args;
+
         IceUtil::DynamicLibraryPtr library = new IceUtil::DynamicLibrary();
-        IceUtil::DynamicLibrary::symbol_type sym = library->loadEntryPoint(*plugin, false);
+        IceUtil::DynamicLibrary::symbol_type sym;
+
+        string::size_type firstColon = plugin->find(':');
+        string::size_type argStart = plugin->rfind(':');
+
+        // if there is more than one colon, then there could be arguments for the
+        // plugin
+        if(firstColon != string::npos && firstColon != argStart)
+        {
+            string pluginName = plugin->substr(0, argStart);
+            string::size_type argEnd;
+            string arg;
+
+            sym = library->loadEntryPoint(pluginName, false);
+
+            if(sym != 0)
+            {
+                do
+                {
+                    argStart++;
+                    argEnd = plugin->find(',', argStart);
+                    if(argEnd == string::npos)
+                    {
+                        arg = plugin->substr(argStart);
+                    }
+                    else
+                    {
+                        arg = plugin->substr(argStart, argEnd - argStart);
+                    }
+                    if(arg.size() != 0)
+                    {
+                        args.push_back(arg);
+                    }
+                    argStart = argEnd;
+                } while (argEnd != string::npos);
+            }
+        }
+        else
+        {
+            sym = library->loadEntryPoint(*plugin, false);
+        }
+
         if(sym == 0)
         {
             string msg = library->getErrorMessage();
@@ -32,7 +75,8 @@ Plugin::applyPluginsToUnit(const std::vector<std::string>& plugins, Language lan
         
         Plugin::VisitorList* pluginVisitors;
         Plugin::FACTORY factory = (Plugin::FACTORY) sym;
-        pluginVisitors = factory(lang);
+        pluginVisitors = factory(lang, &args);
+        args.clear();
         
         if(pluginVisitors)
         {

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


-- 
asterisk-scf/integration/ice.git



More information about the asterisk-scf-commits mailing list