[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
Wed Jan 5 23:59:04 UTC 2011


branch "master" has been updated
       via  b096fc094a69d8a40a6c59ee6f083835c6ceb8ce (commit)
       via  53ecd412781c6c0149095a4b02679398eeb3931f (commit)
      from  d3f29246702159f4ca0dea9950b5701da027ec6a (commit)

Summary of changes:
 CMakeLists.txt              |   10 +++---
 src/SliceVisitorPattern.cpp |   63 ++++++++++++++++++++++++++++++++++---------
 2 files changed, 55 insertions(+), 18 deletions(-)


- Log -----------------------------------------------------------------
commit b096fc094a69d8a40a6c59ee6f083835c6ceb8ce
Author: Kevin P. Fleming <kpfleming at digium.com>
Date:   Wed Jan 5 17:58:25 2011 -0600

    Use new simplified plugin visitor interface.
    
    Use new LanguageHelper interface to properly represent Slice type
    names in generated function bodies.

diff --git a/src/SliceVisitorPattern.cpp b/src/SliceVisitorPattern.cpp
index 3f45e8a..77d6659 100644
--- a/src/SliceVisitorPattern.cpp
+++ b/src/SliceVisitorPattern.cpp
@@ -27,7 +27,7 @@ using namespace Slice::Plugin;
 // where FOO is the name of the class to be visited. The operation
 // receives the visited class object as a parameter.
 
-class VisitorPatternVisitor : public PluginVisitor
+class VisitorPatternVisitor : public ParserVisitor
 {
 public:
 	virtual bool visitClassDefStart(const ClassDefPtr&);
@@ -44,6 +44,8 @@ protected:
 	// function body in a language-appropriate manner.
 	virtual StringList generateVisitFunctionBody(const string&, const ClassDefPtr&, const ClassDefPtr&, const string&) = 0;
 
+	VisitorPatternVisitor(ParserVisitor::LanguageHelper* helper) : ParserVisitor(helper) { }
+
 private:
 	// This map contains the list of classes known to be visitors;
 	// the key is the fully-scoped named of the class, and the value
@@ -245,26 +247,42 @@ VisitorPatternVisitor::visitClassDefStart(const ClassDefPtr& p)
 
 class ICE_DECLSPEC_EXPORT CPPVisitor : public VisitorPatternVisitor
 {
+public:
+	CPPVisitor(ParserVisitor::LanguageHelper* helper) : VisitorPatternVisitor(helper) { }
 protected:
         StringList generateVisitFunctionBody(const std::string&, const ClassDefPtr&, const ClassDefPtr&, const std::string&);
+private:
+	CPPVisitor();
 };
 
 class ICE_DECLSPEC_EXPORT CSVisitor : public VisitorPatternVisitor
 {
+public:
+	CSVisitor(ParserVisitor::LanguageHelper* helper) : VisitorPatternVisitor(helper) { }
 protected:
         StringList generateVisitFunctionBody(const std::string&, const ClassDefPtr&, const ClassDefPtr&, const std::string&);
+private:
+	CSVisitor();
 };
 
 class ICE_DECLSPEC_EXPORT JavaVisitor : public VisitorPatternVisitor
 {
+public:
+	JavaVisitor(ParserVisitor::LanguageHelper* helper) : VisitorPatternVisitor(helper) { }
 protected:
         StringList generateVisitFunctionBody(const std::string&, const ClassDefPtr&, const ClassDefPtr&, const std::string&);
+private:
+	JavaVisitor();
 };
 
 class ICE_DECLSPEC_EXPORT PythonVisitor : public VisitorPatternVisitor
 {
+public:
+	PythonVisitor(ParserVisitor::LanguageHelper* helper) : VisitorPatternVisitor(helper) { }
 protected:
         StringList generateVisitFunctionBody(const std::string&, const ClassDefPtr&, const ClassDefPtr&, const std::string&);
+private:
+	PythonVisitor();
 };
 
 StringList
@@ -275,6 +293,7 @@ CPPVisitor::generateVisitFunctionBody(const string& paramName,
 {
     ostringstream ostr;
     StringList body;
+    string derivedVisitorString = _languageHelper->typeToString(derivedVisitor->declaration(), derivedVisitor->getMetaData());
 
     if(baseVisitor != derivedVisitor)
     {
@@ -282,7 +301,7 @@ CPPVisitor::generateVisitFunctionBody(const string& paramName,
         // IceUtil::Handle-derived shared pointer. Since that is the case, we can use
         // the dynamicCast() operation defined by IceUtil::Handle to convert the pointer
         // into a derived visitor class pointer.
-        ostr << derivedVisitor->scoped() << "Ptr v = " << derivedVisitor->scoped() << "Ptr::dynamicCast(" << paramName << ");";
+        ostr << derivedVisitorString << " v = " << derivedVisitorString << "::dynamicCast(" << paramName << ");";
         body.push_back(ostr.str());
         ostr.str("");
         ostr << "if (!v) return;";
@@ -306,14 +325,32 @@ JavaVisitor::generateVisitFunctionBody(const string& paramName,
 				       const ClassDefPtr& derivedVisitor,
 				       const string& operationName)
 {
-	return StringList();
+    ostringstream ostr;
+    StringList body;
+    string derivedVisitorString = _languageHelper->typeToString(derivedVisitor->declaration(), derivedVisitor->getMetaData());
+
+    if(baseVisitor != derivedVisitor)
+    {
+	    ostr << "if (" << paramName << " instanceof " << 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
 CSVisitor::generateVisitFunctionBody(const string& paramName,
-					 const ClassDefPtr& baseVisitor,
-					 const ClassDefPtr& derivedVisitor,
-					 const string& operationName)
+				     const ClassDefPtr& baseVisitor,
+				     const ClassDefPtr& derivedVisitor,
+				     const string& operationName)
 {
 	return StringList();
 }
@@ -329,23 +366,23 @@ PythonVisitor::generateVisitFunctionBody(const string& paramName,
 
 extern "C"
 {
-	ICE_DECLSPEC_EXPORT PluginVisitorList*
-	create(Language language)
+	ICE_DECLSPEC_EXPORT VisitorList*
+	create(Language language, ParserVisitor::LanguageHelper* helper)
 	{
-		PluginVisitorList* result = new PluginVisitorList();
+		VisitorList* result = new VisitorList();
 		switch(language)
 		{
 		case LanguageCXX:
-			result->push_back(new CPPVisitor);
+			result->push_back(new CPPVisitor(helper));
 			break;
 		case LanguageCS:
-			result->push_back(new CSVisitor);
+			result->push_back(new CSVisitor(helper));
 			break;
 		case LanguageJava:
-			result->push_back(new JavaVisitor);
+			result->push_back(new JavaVisitor(helper));
 			break;
 		case LanguagePython:
-			result->push_back(new PythonVisitor);
+			result->push_back(new PythonVisitor(helper));
 			break;
 		default:
 			cerr << "SliceVisitorPattern plugin does not support language " << language << "." << endl;

commit 53ecd412781c6c0149095a4b02679398eeb3931f
Author: Kevin P. Fleming <kpfleming at digium.com>
Date:   Wed Jan 5 17:57:58 2011 -0600

    Don't try to check for the CXX compiler type before learning what it is.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index cf65d40..1d3f585 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,11 +11,6 @@ endif()
 # for consistency
 string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE)
 
-if(CMAKE_COMPILER_IS_GNUCXX)
-    set(CMAKE_CXX_FLAGS_DEBUG "-Werror -Wall -g3"
-        CACHE STRING "Flags used by the compiler during debug builds." FORCE)
-endif()
-
 if(WIN32 AND ${CMAKE_BUILD_TYPE} STREQUAL profile)
     message(FATAL_ERROR "Profile builds not supported")
 endif()
@@ -143,6 +138,11 @@ endfunction()
 
 project("Digium Slice Translator Plugins" CXX)
 
+if(CMAKE_COMPILER_IS_GNUCXX)
+    set(CMAKE_CXX_FLAGS_DEBUG "-Werror -Wall -g3"
+        CACHE STRING "Flags used by the compiler during debug builds." FORCE)
+endif()
+
 if(WIN32)
   message(STATUS "Setting SLICE_EXPORT definition for Windows plugins")
   add_definitions(-DSLICE_EXPORT=__declspec\(dllexport\))

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


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



More information about the asterisk-scf-commits mailing list