[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 17:38:56 UTC 2011
branch "master" has been updated
via d09388b8943776275a25767811d702370b34d033 (commit)
from b096fc094a69d8a40a6c59ee6f083835c6ceb8ce (commit)
Summary of changes:
src/SliceVisitorPattern.cpp | 112 +++++++++++++++++++++++++++++++++----------
1 files changed, 87 insertions(+), 25 deletions(-)
- Log -----------------------------------------------------------------
commit d09388b8943776275a25767811d702370b34d033
Author: Kevin P. Fleming <kpfleming at digium.com>
Date: Thu Jan 6 11:38:17 2011 -0600
Use direct access to CPlusPlusUtil and JavaUtil identifier conversion
functions instead of LanguageHelper mechanism.
diff --git a/src/SliceVisitorPattern.cpp b/src/SliceVisitorPattern.cpp
index 77d6659..9e9550e 100644
--- a/src/SliceVisitorPattern.cpp
+++ b/src/SliceVisitorPattern.cpp
@@ -1,6 +1,8 @@
#include <Slice/Parser.h>
#include <Slice/Util.h>
#include <Slice/Plugin.h>
+#include <Slice/CPlusPlusUtil.h>
+#include <Slice/JavaUtil.h>
using namespace std;
using namespace Slice;
@@ -44,8 +46,6 @@ 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
@@ -248,41 +248,101 @@ VisitorPatternVisitor::visitClassDefStart(const ClassDefPtr& p)
class ICE_DECLSPEC_EXPORT CPPVisitor : public VisitorPatternVisitor
{
public:
- CPPVisitor(ParserVisitor::LanguageHelper* helper) : VisitorPatternVisitor(helper) { }
+ CPPVisitor()
+ {
+ _useWstring.push(0);
+ }
+
+ virtual bool visitModuleStart(const ModulePtr& in)
+ {
+ setUseWstring(in);
+ return true;
+ }
+
+ virtual void visitModuleEnd(const ModulePtr& in)
+ {
+ resetUseWstring();
+ }
+
+ virtual bool visitClassDefStart(const ClassDefPtr& in)
+ {
+ setUseWstring(in);
+ VisitorPatternVisitor::visitClassDefStart(in);
+ return true;
+ }
+
+ virtual void visitClassDefEnd(const ClassDefPtr& in)
+ {
+ resetUseWstring();
+ }
+
+ virtual bool visitExceptionStart(const ExceptionPtr& in)
+ {
+ setUseWstring(in);
+ return true;
+ }
+
+ virtual void visitExceptionEnd(const ExceptionPtr& in)
+ {
+ resetUseWstring();
+ }
+
+ virtual bool visitStructStart(const StructPtr& in)
+ {
+ setUseWstring(in);
+ return true;
+ }
+
+ virtual void visitStructEnd(const StructPtr& in)
+ {
+ resetUseWstring();
+ }
+
protected:
StringList generateVisitFunctionBody(const std::string&, const ClassDefPtr&, const ClassDefPtr&, const std::string&);
+
private:
- CPPVisitor();
+ stack<int> _useWstring;
+
+ void setUseWstring(ContainedPtr p)
+ {
+ StringList metaData = p->getMetaData();
+ if(find(metaData.begin(), metaData.end(), "cpp:type:wstring") != metaData.end())
+ {
+ _useWstring.push(TypeContextUseWstring);
+ }
+ else if(find(metaData.begin(), metaData.end(), "cpp:type:string") != metaData.end())
+ {
+ _useWstring.push(0);
+ }
+ else
+ {
+ _useWstring.push(_useWstring.top());
+ }
+ }
+
+ void resetUseWstring()
+ {
+ _useWstring.pop();
+ }
};
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
@@ -293,7 +353,8 @@ CPPVisitor::generateVisitFunctionBody(const string& paramName,
{
ostringstream ostr;
StringList body;
- string derivedVisitorString = _languageHelper->typeToString(derivedVisitor->declaration(), derivedVisitor->getMetaData());
+ string derivedVisitorString = typeToString(derivedVisitor->declaration(), derivedVisitor->getMetaData(),
+ _useWstring.top());
if(baseVisitor != derivedVisitor)
{
@@ -327,7 +388,8 @@ JavaVisitor::generateVisitFunctionBody(const string& paramName,
{
ostringstream ostr;
StringList body;
- string derivedVisitorString = _languageHelper->typeToString(derivedVisitor->declaration(), derivedVisitor->getMetaData());
+ string derivedVisitorString = JavaGenerator::typeToString(derivedVisitor->declaration(), JavaGenerator::TypeModeMember,
+ "", derivedVisitor->getMetaData(), false);
if(baseVisitor != derivedVisitor)
{
@@ -367,22 +429,22 @@ PythonVisitor::generateVisitFunctionBody(const string& paramName,
extern "C"
{
ICE_DECLSPEC_EXPORT VisitorList*
- create(Language language, ParserVisitor::LanguageHelper* helper)
+ create(Language language)
{
VisitorList* result = new VisitorList();
switch(language)
{
- case LanguageCXX:
- result->push_back(new CPPVisitor(helper));
+ case LanguageCPlusPlus:
+ result->push_back(new CPPVisitor());
break;
- case LanguageCS:
- result->push_back(new CSVisitor(helper));
+ case LanguageCs:
+ result->push_back(new CSVisitor());
break;
case LanguageJava:
- result->push_back(new JavaVisitor(helper));
+ result->push_back(new JavaVisitor());
break;
case LanguagePython:
- result->push_back(new PythonVisitor(helper));
+ result->push_back(new PythonVisitor());
break;
default:
cerr << "SliceVisitorPattern plugin does not support language " << language << "." << endl;
-----------------------------------------------------------------------
--
asterisk-scf/integration/slice-plugins.git
More information about the asterisk-scf-commits
mailing list