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

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Thu Jan 6 20:54:09 UTC 2011


branch "master" has been updated
       via  6db266d8b484f5bc4562f8d091065b56fb71a900 (commit)
      from  d09388b8943776275a25767811d702370b34d033 (commit)

Summary of changes:
 src/SliceVisitorPattern.cpp |   26 +++++++++++++++++++++++++-
 1 files changed, 25 insertions(+), 1 deletions(-)


- Log -----------------------------------------------------------------
commit 6db266d8b484f5bc4562f8d091065b56fb71a900
Author: Kevin P. Fleming <kpfleming at digium.com>
Date:   Thu Jan 6 14:53:30 2011 -0600

    Generate appropriate function body for C# translation, and mark
    some GeneratedOperations as 'override', since C# requires that.

diff --git a/src/SliceVisitorPattern.cpp b/src/SliceVisitorPattern.cpp
index 9e9550e..0114368 100644
--- a/src/SliceVisitorPattern.cpp
+++ b/src/SliceVisitorPattern.cpp
@@ -3,6 +3,7 @@
 #include <Slice/Plugin.h>
 #include <Slice/CPlusPlusUtil.h>
 #include <Slice/JavaUtil.h>
+#include <Slice/CsUtil.h>
 
 using namespace std;
 using namespace Slice;
@@ -176,6 +177,10 @@ VisitorPatternVisitor::visitClassDefStart(const ClassDefPtr& p)
 					{
 						GeneratedOperationPtr gop = p->createGeneratedOperation("visit", 0,
 													generateVisitFunctionBody("visitor", baseVisitor, derivedVisitor, "visit" + p->name()));
+						if(baseVisitor != derivedVisitor)
+						{
+							gop->setOverride(true);
+						}
 						gop->createParamDecl("visitor", baseVisitor->declaration(), false);
 					}
 					return false;
@@ -219,6 +224,7 @@ VisitorPatternVisitor::visitClassDefStart(const ClassDefPtr& p)
 			{
 				GeneratedOperationPtr gop = p->createGeneratedOperation("visit", 0,
 											generateVisitFunctionBody("visitor", baseVisitor, derivedVisitor, "visit" + p->name()));
+				gop->setOverride(true);
 				gop->createParamDecl("visitor", baseVisitor->declaration(), false);
 			}
 		}
@@ -414,7 +420,25 @@ CSVisitor::generateVisitFunctionBody(const string& paramName,
 				     const ClassDefPtr& derivedVisitor,
 				     const string& operationName)
 {
-	return StringList();
+    ostringstream ostr;
+    StringList body;
+    string derivedVisitorString = CsGenerator::typeToString(derivedVisitor->declaration());
+
+    if(baseVisitor != derivedVisitor)
+    {
+	    ostr << "if (" << paramName << " is " << derivedVisitorString << ")";
+	    body.push_back(ostr.str());
+	    ostr.str("");
+	    ostr << "((" << derivedVisitorString << ") " << paramName << ")";
+    }
+    else
+    {
+        ostr << paramName;
+    }
+    ostr << "." << operationName << "(this);";
+    body.push_back(ostr.str());
+
+    return body;
 }
 
 StringList

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


-- 
asterisk-scf/integration/slice-plugins.git



More information about the asterisk-scf-commits mailing list