[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
Wed Jan 5 16:30:15 UTC 2011


branch "visitor-generators" has been updated
       via  b06b126594eb9cb371e7e5e3813561fdb678c1f3 (commit)
      from  1fda4bed82b4de606f2b114758f875131234712c (commit)

Summary of changes:
 cpp/src/slice2java/Gen.cpp |   54 +++++++++++++++++++++++++++++++++++++++++++-
 cpp/src/slice2java/Gen.h   |    1 +
 2 files changed, 54 insertions(+), 1 deletions(-)


- Log -----------------------------------------------------------------
commit b06b126594eb9cb371e7e5e3813561fdb678c1f3
Author: Kevin P. Fleming <kpfleming at digium.com>
Date:   Wed Jan 5 10:29:49 2011 -0600

    Teach slice2java how to emit GeneratedOperations.

diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp
index 51fdade..e59c185 100644
--- a/cpp/src/slice2java/Gen.cpp
+++ b/cpp/src/slice2java/Gen.cpp
@@ -113,6 +113,27 @@ Slice::JavaVisitor::getParams(const OperationPtr& op, const string& package, boo
 }
 
 vector<string>
+Slice::JavaVisitor::getParams(const GeneratedOperationPtr& gop, const string& package, bool final)
+{
+    vector<string> params;
+
+    ParamDeclList paramList = gop->parameters();
+    for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
+    {
+        StringList metaData = (*q)->getMetaData();
+        string typeString = typeToString((*q)->type(), (*q)->isOutParam() ? TypeModeOut : TypeModeIn, package,
+                                         metaData);
+        if(final)
+        {
+            typeString = "final " + typeString;
+        }
+        params.push_back(typeString + ' ' + fixKwd((*q)->name()));
+    }
+
+    return params;
+}
+
+vector<string>
 Slice::JavaVisitor::getInOutParams(const OperationPtr& op, const string& package, ParamDir paramType)
 {
     vector<string> params;
@@ -1752,7 +1773,7 @@ Slice::Gen::generate(const UnitPtr& p, bool stream)
         
         Plugin::PluginVisitorList* pluginVisitors;
         PLUGIN_FACTORY factory = (PLUGIN_FACTORY)sym;
-        pluginVisitors = factory(Plugin::LanguageCXX);
+        pluginVisitors = factory(Plugin::LanguageJava);
         
         if(pluginVisitors)
         {
@@ -2476,6 +2497,37 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
         }
     }
 
+    // Emit GeneratedOperations, which are always generated as local members
+    // even for abstract classes.
+    if(!p->isInterface())
+    {
+        GeneratedOperationList gops = p->generatedOperations();
+        for(GeneratedOperationList::const_iterator it = gops.begin(); it != gops.end(); it++)
+        {
+            GeneratedOperationPtr gop = *it;
+            string opname = gop->name();
+            TypePtr ret = gop->returnType();
+            string retS = typeToString(ret, TypeModeReturn, package, gop->getMetaData());
+            out << nl;
+            out << "public ";
+            if(gop->isAbstract())
+            {
+                out << "abstract ";
+            }
+            out << retS << ' ' << fixKwd(opname) << spar << getParams(gop, package) << epar;
+            if(!gop->isAbstract())
+            {
+                StringList body = gop->body();
+                out << sb;
+                for(StringList::const_iterator it = body.begin(); it != body.end(); it++)
+                {
+                    out << nl << *it;
+                }
+                out << eb;
+            }
+        }
+    }
+
     if(!p->isInterface() && !allDataMembers.empty())
     {
         //
diff --git a/cpp/src/slice2java/Gen.h b/cpp/src/slice2java/Gen.h
index 59732d3..fab7fda 100644
--- a/cpp/src/slice2java/Gen.h
+++ b/cpp/src/slice2java/Gen.h
@@ -33,6 +33,7 @@ protected:
     // Compose the parameter lists for an operation.
     //
     std::vector<std::string> getParams(const OperationPtr&, const std::string&, bool = false);
+    std::vector<std::string> getParams(const GeneratedOperationPtr&, const std::string&, bool = false);
     std::vector<std::string> getInOutParams(const OperationPtr&, const std::string&, ParamDir);
     std::vector<std::string> getParamsAsync(const OperationPtr&, const std::string&, bool);
     std::vector<std::string> getParamsAsyncCB(const OperationPtr&, const std::string&);

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


-- 
asterisk-scf/release/ice.git



More information about the asterisk-scf-commits mailing list