[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 20:53:18 UTC 2011


branch "visitor-generators" has been updated
       via  80ee5f1875885581ad24e4982a96742b519938cb (commit)
      from  01d7120ddeba5864f618b930ebe392b9122a4ad7 (commit)

Summary of changes:
 cpp/include/Slice/Parser.h |    3 +
 cpp/src/Slice/Parser.cpp   |   21 ++++++++-
 cpp/src/slice2cs/Gen.cpp   |  115 +++++++++++++++++++++++++++++++++++++++++---
 cpp/src/slice2cs/Gen.h     |    3 +
 4 files changed, 134 insertions(+), 8 deletions(-)


- Log -----------------------------------------------------------------
commit 80ee5f1875885581ad24e4982a96742b519938cb
Author: Kevin P. Fleming <kpfleming at digium.com>
Date:   Thu Jan 6 14:52:52 2011 -0600

    ... and now GeneratedOperations work for C# as well.

diff --git a/cpp/include/Slice/Parser.h b/cpp/include/Slice/Parser.h
index 3f39d7b..86ee25b 100644
--- a/cpp/include/Slice/Parser.h
+++ b/cpp/include/Slice/Parser.h
@@ -633,6 +633,8 @@ public:
     virtual bool uses(const ContainedPtr&) const;
     StringList body() const;
     bool isAbstract() const;
+    bool isOverride() const;
+    void setOverride(bool);
     virtual std::string kindOf() const;
     virtual void visit(ParserVisitor*, bool);
 
@@ -644,6 +646,7 @@ protected:
     TypePtr _returnType;
     Mode _mode;
     StringList _body;
+    bool _override;
 };
 
 // ----------------------------------------------------------------------
diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp
index bba65c1..8eac593 100644
--- a/cpp/src/Slice/Parser.cpp
+++ b/cpp/src/Slice/Parser.cpp
@@ -3442,6 +3442,12 @@ Slice::ClassDef::hasOperations() const
 }
 
 bool
+Slice::ClassDef::hasGeneratedOperations() const
+{
+    return _hasGeneratedOperations;
+}
+
+bool
 Slice::ClassDef::hasDefaultValues() const
 {
     DataMemberList dml = dataMembers();
@@ -5056,6 +5062,18 @@ Slice::GeneratedOperation::visit(ParserVisitor* visitor, bool)
     visitor->visitGeneratedOperation(this);
 }
 
+bool
+Slice::GeneratedOperation::isOverride() const
+{
+    return _override;
+}
+
+void
+Slice::GeneratedOperation::setOverride(bool override)
+{
+    _override = override;
+}
+
 Slice::GeneratedOperation::GeneratedOperation(const ContainerPtr& container,
 					      const string& name,
 					      const TypePtr& returnType,
@@ -5066,7 +5084,8 @@ Slice::GeneratedOperation::GeneratedOperation(const ContainerPtr& container,
     Container(container->unit()),
     _returnType(returnType),
     _mode(mode),
-    _body(body)
+    _body(body),
+    _override(false)
 {
 }
 
diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp
index 275c405..de88696 100644
--- a/cpp/src/slice2cs/Gen.cpp
+++ b/cpp/src/slice2cs/Gen.cpp
@@ -984,6 +984,24 @@ Slice::CsVisitor::getParams(const OperationPtr& op)
 }
 
 vector<string>
+Slice::CsVisitor::getParams(const GeneratedOperationPtr& op)
+{
+    vector<string> params;
+    ParamDeclList paramList = op->parameters();
+    for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
+    {
+        string param = getParamAttributes(*q);
+        if((*q)->isOutParam())
+        {
+            param += "out ";
+        }
+        param += typeToString((*q)->type()) + " " + fixId((*q)->name());
+        params.push_back(param);
+    }
+    return params;
+}
+
+vector<string>
 Slice::CsVisitor::getParamsAsync(const OperationPtr& op, bool amd, bool newAMI)
 {
     vector<string> params;
@@ -1065,6 +1083,23 @@ Slice::CsVisitor::getArgs(const OperationPtr& op)
 }
 
 vector<string>
+Slice::CsVisitor::getArgs(const GeneratedOperationPtr& op)
+{
+    vector<string> args;
+    ParamDeclList paramList = op->parameters();
+    for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
+    {
+        string arg = fixId((*q)->name());
+        if((*q)->isOutParam())
+        {
+            arg = "out " + arg;
+        }
+        args.push_back(arg);
+    }
+    return args;
+}
+
+vector<string>
 Slice::CsVisitor::getArgsAsync(const OperationPtr& op, bool newAMI)
 {
     vector<string> args;
@@ -2303,7 +2338,7 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
 
     if(!p->isInterface())
     {
-        if(p->hasDataMembers() && !p->hasOperations())
+        if(p->hasDataMembers() && !(p->hasOperations() || p->hasGeneratedOperations()))
         {
             _out << sp << nl << "#region Slice data members";
         }
@@ -2311,14 +2346,14 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
         {
             _out << sp << nl << "#region Slice data members and operations";
         }
-        else if(p->hasOperations())
+        else if(p->hasOperations() || p->hasGeneratedOperations())
         {
             _out << sp << nl << "#region Slice operations";
         }
     }
     else
     {
-        if(p->isLocal() && p->hasOperations())
+        if(p->isLocal() && (p->hasOperations() || p->hasGeneratedOperations()))
         {
             _out << sp << nl << "#region Slice operations";
         }
@@ -2341,7 +2376,7 @@ Slice::Gen::TypesVisitor::visitClassDefEnd(const ClassDefPtr& p)
 
     if(!p->isInterface())
     {
-        if(p->hasDataMembers() && !p->hasOperations())
+        if(p->hasDataMembers() && !(p->hasOperations() || p->hasGeneratedOperations()))
         {
             _out << sp << nl << "#endregion"; // Slice data members"
         }
@@ -2349,7 +2384,7 @@ Slice::Gen::TypesVisitor::visitClassDefEnd(const ClassDefPtr& p)
         {
             _out << sp << nl << "#endregion"; // Slice data members and operations"
         }
-        else if(p->hasOperations())
+        else if(p->hasOperations() || p->hasGeneratedOperations())
         {
             _out << sp << nl << "#endregion"; // Slice operations"
         }
@@ -2410,7 +2445,7 @@ Slice::Gen::TypesVisitor::visitClassDefEnd(const ClassDefPtr& p)
     }
     else
     {
-        if(p->isLocal() && p->hasOperations())
+        if(p->isLocal() && (p->hasOperations() || p->hasGeneratedOperations()))
         {
             _out << sp << nl << "#endregion"; // Slice operations"
         }
@@ -2432,7 +2467,7 @@ Slice::Gen::TypesVisitor::visitOperation(const OperationPtr& p)
     bool isInterface = classDef->isInterface();
 
     //
-    // Non-local classes and interfaces get the operations from their
+    // Non-local interfaces get the operations from their
     // Operations base interfaces.
     //
     if(isInterface && !isLocal)
@@ -2550,6 +2585,72 @@ Slice::Gen::TypesVisitor::visitOperation(const OperationPtr& p)
 }
 
 void
+Slice::Gen::TypesVisitor::visitGeneratedOperation(const GeneratedOperationPtr& p)
+{
+    ClassDefPtr classDef = ClassDefPtr::dynamicCast(p->container());
+    bool isLocal = classDef->isLocal();
+    bool isInterface = classDef->isInterface();
+
+    //
+    // Non-local interfaces get the operations from their
+    // Operations base interfaces.
+    //
+    if(isInterface && !isLocal)
+    {
+        return;
+    }
+
+    string name = p->name();
+    ParamDeclList paramList = p->parameters();
+    vector<string> params;
+    vector<string> args;
+    string retS;
+
+    params = getParams(p);
+    args = getArgs(p);
+    name = fixId(name, DotNet::ICloneable, true);
+    retS = typeToString(p->returnType());
+
+    _out << sp;
+    if(isInterface && isLocal)
+    {
+        _out << nl;
+    }
+
+    writeDocComment(p, getDeprecateReason(p, classDef, "generatedOperation"));
+    emitAttributes(p);
+    emitGeneratedCodeAttribute();
+    _out << nl << "public ";
+    if(p->isAbstract())
+    {
+        _out << "abstract ";
+    }
+    else if(p->isOverride())
+    {
+        _out << "override ";
+    }
+    else
+    {
+        _out << "virtual ";
+    }
+    _out << retS << " " << name << spar << params << epar;
+    if(p->isAbstract())
+    {
+        _out << ";";
+    }
+    else
+    {
+        _out << sb;
+        StringList body = p->body();
+        for(StringList::const_iterator it = body.begin(); it != body.end(); it++)
+        {
+            _out << nl << *it;
+        }
+        _out << eb;
+    }
+}
+
+void
 Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p)
 {
     //
diff --git a/cpp/src/slice2cs/Gen.h b/cpp/src/slice2cs/Gen.h
index 9702216..d4c98df 100644
--- a/cpp/src/slice2cs/Gen.h
+++ b/cpp/src/slice2cs/Gen.h
@@ -28,9 +28,11 @@ protected:
     virtual void writeInheritedOperations(const ClassDefPtr&);
     virtual void writeDispatchAndMarshalling(const ClassDefPtr&, bool);
     virtual std::vector<std::string> getParams(const OperationPtr&);
+    virtual std::vector<std::string> getParams(const GeneratedOperationPtr&);
     virtual std::vector<std::string> getParamsAsync(const OperationPtr&, bool, bool = false);
     virtual std::vector<std::string> getParamsAsyncCB(const OperationPtr&, bool = false, bool = true);
     virtual std::vector<std::string> getArgs(const OperationPtr&);
+    virtual std::vector<std::string> getArgs(const GeneratedOperationPtr&);
     virtual std::vector<std::string> getArgsAsync(const OperationPtr&, bool = false);
     virtual std::vector<std::string> getArgsAsyncCB(const OperationPtr&, bool = false, bool = false);
 
@@ -117,6 +119,7 @@ private:
         virtual void visitModuleEnd(const ModulePtr&);
         virtual bool visitClassDefStart(const ClassDefPtr&);
         virtual void visitOperation(const OperationPtr&);
+        virtual void visitGeneratedOperation(const GeneratedOperationPtr&);
         virtual void visitClassDefEnd(const ClassDefPtr&);
         virtual bool visitExceptionStart(const ExceptionPtr&);
         virtual void visitExceptionEnd(const ExceptionPtr&);

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


-- 
asterisk-scf/release/ice.git



More information about the asterisk-scf-commits mailing list