[asterisk-scf-commits] asterisk-scf/integration/slice-plugins.git branch "ice-3.4.2" created.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Wed Jun 22 07:37:20 CDT 2011


branch "ice-3.4.2" has been created
        at  dc6ca809ded80806cd63d8daf44b826aae426dc0 (commit)

- Log -----------------------------------------------------------------
commit dc6ca809ded80806cd63d8daf44b826aae426dc0
Author: Kevin P. Fleming <kpfleming at digium.com>
Date:   Wed Jun 22 07:36:51 2011 -0500

    Update for Ice 3.4.2 default value handling.

diff --git a/src/SliceClassMemberDefault.cpp b/src/SliceClassMemberDefault.cpp
index 69c0785..2e2c73e 100644
--- a/src/SliceClassMemberDefault.cpp
+++ b/src/SliceClassMemberDefault.cpp
@@ -29,7 +29,7 @@ public:
 void
 ClassMemberDefaultVisitor::visitDataMember(const DataMemberPtr& p)
 {
-	if(p->hasDefaultValue())
+	if(!p->defaultValueType())
 	{
 		return;
 	}
@@ -45,10 +45,10 @@ ClassMemberDefaultVisitor::visitDataMember(const DataMemberPtr& p)
 		case Builtin::KindLong:
 		case Builtin::KindFloat:
 		case Builtin::KindDouble:
-			p->setDefaultValue("0");
+			p->setDefaultValue(builtin, "0");
 			break;
 		case Builtin::KindBool:
-			p->setDefaultValue("false");
+			p->setDefaultValue(builtin, "false");
 			break;
 		default:
 			break;
@@ -61,7 +61,7 @@ ClassMemberDefaultVisitor::visitDataMember(const DataMemberPtr& p)
 	if(enumtype)
 	{
 		EnumeratorPtr enumerator = enumtype->getEnumerators().front();
-		p->setDefaultValue(enumerator->name());
+		p->setDefaultValue(enumtype, enumerator->name());
 		return;
 	}
 }

commit 74f375f081b25c02e8df68dbb319f83439c2c0a8
Author: Kevin P. Fleming <kpfleming at digium.com>
Date:   Fri Jun 17 11:44:05 2011 -0500

    Provide constructor to ensure parametersRequireName is initialized.

diff --git a/src/SliceVisitorPattern.cpp b/src/SliceVisitorPattern.cpp
index be9d3a3..9a20d39 100644
--- a/src/SliceVisitorPattern.cpp
+++ b/src/SliceVisitorPattern.cpp
@@ -44,6 +44,7 @@ using namespace Slice::Plugin;
 class VisitorPatternVisitor : public ParserVisitor
 {
 public:
+	VisitorPatternVisitor() : parametersRequireName(false) { }
 	virtual bool visitClassDefStart(const ClassDefPtr&);
 
 protected:

commit c0f29cd8adb23ad3309e10b2fcf52a572f9f3631
Author: Kevin P. Fleming <kpfleming at digium.com>
Date:   Fri Jun 17 11:20:12 2011 -0500

    Generate parameter names for languages that require them.
    
    For some languages, unnamed parameters are not allowed, so the VisitorPatternVisitor
    base class can now be told when it must generate parameter names for functions
    that have empty bodies.

diff --git a/src/SliceVisitorPattern.cpp b/src/SliceVisitorPattern.cpp
index ff6c838..be9d3a3 100644
--- a/src/SliceVisitorPattern.cpp
+++ b/src/SliceVisitorPattern.cpp
@@ -58,6 +58,7 @@ protected:
 	// function body in a language-appropriate manner.
 	virtual StringList generateVisitFunctionBody(const string&, const ClassDefPtr&, const ClassDefPtr&, const string&) = 0;
 	virtual StringList generateEmptyFunctionBody() = 0;
+	bool parametersRequireName;
 
 private:
 	// This map contains the list of classes known to be visitors;
@@ -194,7 +195,14 @@ VisitorPatternVisitor::visitClassDefStart(const ClassDefPtr& p)
 				if(derivedVisitor->includeLevel() == 0)
 				{
 					GeneratedOperationPtr gop = derivedVisitor->createGeneratedOperation("visit" + p->name(), 0, generateEmptyFunctionBody());
-					gop->createParamDecl("", p->declaration(), false);
+					if(parametersRequireName)
+					{
+						gop->createParamDecl("in", p->declaration(), false);
+					}
+					else
+					{
+						gop->createParamDecl("", p->declaration(), false);
+					}
 				}
 				// There is no need to actually generate operations into the visited
 				// class if it was defined in an include file, since the translator
@@ -237,7 +245,14 @@ VisitorPatternVisitor::visitClassDefStart(const ClassDefPtr& p)
 		if(derivedVisitor->includeLevel() == 0)
 		{
 			GeneratedOperationPtr gop = derivedVisitor->createGeneratedOperation("visit" + p->name(), 0, generateEmptyFunctionBody());
-			gop->createParamDecl("", p->declaration(), false);
+			if(parametersRequireName)
+			{
+				gop->createParamDecl("in", p->declaration(), false);
+			}
+			else
+			{
+				gop->createParamDecl("", p->declaration(), false);
+			}
 		}
 		if(p->includeLevel() == 0)
 		{
@@ -351,6 +366,11 @@ private:
 
 class ICE_DECLSPEC_EXPORT CsVisitor : public VisitorPatternVisitor
 {
+public:
+	CsVisitor()
+	{
+		parametersRequireName = true;
+	}
 protected:
         StringList generateVisitFunctionBody(const std::string&, const ClassDefPtr&, const ClassDefPtr&, const std::string&);
 	StringList generateEmptyFunctionBody();

commit 3bab1e4316559aae55381cd6804c5dc78cdcae12
Author: Kevin P. Fleming <kpfleming at digium.com>
Date:   Fri Apr 15 16:42:16 2011 -0500

    When adding parameters to the base class visit<foo> operations, don't give
    them names, as the operations won't have any body and this will result in
    'unused parameter' warnings.

diff --git a/src/SliceVisitorPattern.cpp b/src/SliceVisitorPattern.cpp
index 36e9b7b..ff6c838 100644
--- a/src/SliceVisitorPattern.cpp
+++ b/src/SliceVisitorPattern.cpp
@@ -194,7 +194,7 @@ VisitorPatternVisitor::visitClassDefStart(const ClassDefPtr& p)
 				if(derivedVisitor->includeLevel() == 0)
 				{
 					GeneratedOperationPtr gop = derivedVisitor->createGeneratedOperation("visit" + p->name(), 0, generateEmptyFunctionBody());
-					gop->createParamDecl("item", p->declaration(), false);
+					gop->createParamDecl("", p->declaration(), false);
 				}
 				// There is no need to actually generate operations into the visited
 				// class if it was defined in an include file, since the translator
@@ -237,7 +237,7 @@ VisitorPatternVisitor::visitClassDefStart(const ClassDefPtr& p)
 		if(derivedVisitor->includeLevel() == 0)
 		{
 			GeneratedOperationPtr gop = derivedVisitor->createGeneratedOperation("visit" + p->name(), 0, generateEmptyFunctionBody());
-			gop->createParamDecl("item", p->declaration(), false);
+			gop->createParamDecl("", p->declaration(), false);
 		}
 		if(p->includeLevel() == 0)
 		{

commit 19de6a7af6358362a4a56d76a6d966048cf5bd88
Author: Kevin P. Fleming <kpfleming at digium.com>
Date:   Tue Apr 12 11:11:52 2011 -0500

    Add a simple Slice file that can be used to test the SliceVisitorPattern
    plugin to ensure it is operating properly. Maybe someday there will be a unit
    test that actually automates this... but for now at least having the Slice
    file available is a good start.

diff --git a/test/visitor-test.ice b/test/visitor-test.ice
new file mode 100644
index 0000000..adad11a
--- /dev/null
+++ b/test/visitor-test.ice
@@ -0,0 +1,25 @@
+module test {
+    ["visitor"] local class VisitorA {
+    };
+
+    ["visitor:VisitorA"] class ItemABase {
+    };
+
+    class ItemA1 extends ItemABase {
+    };
+
+    class ItemA2 extends ItemABase {
+    };
+
+    local class VisitorB extends VisitorA {
+    };
+
+    ["visitor:VisitorB"] class ItemBBase extends ItemABase {
+    };
+
+    class ItemB1 extends ItemBBase {
+    };
+
+    class ItemB2 extends ItemBBase {
+    };
+};

commit 7d5aafa84a46257cd2358d84d17df52de2c0a51f
Author: Kevin P. Fleming <kpfleming at digium.com>
Date:   Fri Mar 11 17:52:07 2011 -0600

    Do not rely on the abstract-ness of classes when deciding whether to search
    for visitable bases or visiting bases; just search for a visitable base, if
    one is found then the process is complete. If one is not found, search
    for a visiting base and handle it if found. A class will never be both a
    visitor and visitable, so there is no need to distinguish between them.

diff --git a/src/SliceVisitorPattern.cpp b/src/SliceVisitorPattern.cpp
index 3a43c01..36e9b7b 100644
--- a/src/SliceVisitorPattern.cpp
+++ b/src/SliceVisitorPattern.cpp
@@ -228,44 +228,38 @@ VisitorPatternVisitor::visitClassDefStart(const ClassDefPtr& p)
 		return false;
 	}
 
-	// For concrete classes that aren't marked with the 'visitor' metadata,
+	// For classes that aren't marked with the 'visitor' metadata,
 	// try to locate a visitable base class that they extend; if one is found,
 	// generate the appropriate operations to support the visitable class.
-	if(!p->isAbstract())
+	ClassDefPtr baseVisitor, derivedVisitor;
+	if (findVisitableBase(_visitableBases, p, baseVisitor, derivedVisitor))
 	{
-		ClassDefPtr baseVisitor, derivedVisitor;
-		if (findVisitableBase(_visitableBases, p, baseVisitor, derivedVisitor))
+		if(derivedVisitor->includeLevel() == 0)
 		{
-			if(derivedVisitor->includeLevel() == 0)
-			{
-				GeneratedOperationPtr gop = derivedVisitor->createGeneratedOperation("visit" + p->name(), 0, generateEmptyFunctionBody());
-				gop->createParamDecl("item", p->declaration(), false);
-			}
-			if(p->includeLevel() == 0)
-			{
-				GeneratedOperationPtr gop = p->createGeneratedOperation("visit", 0,
-											generateVisitFunctionBody("visitor", baseVisitor, derivedVisitor, "visit" + p->name()));
-				gop->setOverride(true);
-				gop->createParamDecl("visitor", baseVisitor->declaration(), false);
-			}
+			GeneratedOperationPtr gop = derivedVisitor->createGeneratedOperation("visit" + p->name(), 0, generateEmptyFunctionBody());
+			gop->createParamDecl("item", p->declaration(), false);
+		}
+		if(p->includeLevel() == 0)
+		{
+			GeneratedOperationPtr gop = p->createGeneratedOperation("visit", 0,
+										generateVisitFunctionBody("visitor", baseVisitor, derivedVisitor, "visit" + p->name()));
+			gop->setOverride(true);
+			gop->createParamDecl("visitor", baseVisitor->declaration(), false);
 		}
 		return false;
 	}
 
-	// For abstract classes that aren't marked with 'visitor' metadata,
+	// For classes that aren't marked with 'visitor' metadata,
 	// try to locate a visiting base class that they extend; if one is found,
 	// remember the derived class as a visiting class.
-	if(p->isAbstract())
+	ClassList bases = p->allBases();
+	for(ClassList::const_iterator q = bases.begin(); q != bases.end(); q++)
 	{
-		ClassList bases = p->allBases();
-		for(ClassList::const_iterator q = bases.begin(); q != bases.end(); q++)
+		map<string, ClassDefPtr>::const_iterator it = _visitorClasses.find((*q)->scoped());
+		if(it != _visitorClasses.end())
 		{
-			map<string, ClassDefPtr>::const_iterator it = _visitorClasses.find((*q)->scoped());
-			if(it != _visitorClasses.end())
-			{
-				_visitorClasses[p->scoped()] = p;
-				return false;
-			}
+			_visitorClasses[p->scoped()] = p;
+			return false;
 		}
 	}
 

commit f6da9883fe4b93b17a609ff7fc92336b601f186b
Author: Kevin P. Fleming <kpfleming at digium.com>
Date:   Fri Mar 11 17:51:48 2011 -0600

    Eliminate an unnecessary level of indentation.

diff --git a/src/SliceVisitorPattern.cpp b/src/SliceVisitorPattern.cpp
index f3960d4..3a43c01 100644
--- a/src/SliceVisitorPattern.cpp
+++ b/src/SliceVisitorPattern.cpp
@@ -162,64 +162,62 @@ VisitorPatternVisitor::visitClassDefStart(const ClassDefPtr& p)
 				emitWarning(p->file(), p->line(), ostr.str());
 				return false;
 			}
-			else
+
+			// Attempt to find the specified visiting class in the list of known
+			// visiting classes.
+			const string visitor = (*q).substr(8);
+			map<string, ClassDefPtr>::const_iterator it = _visitorClasses.find(visitor);
+			// If it wasn't found, try prefixing it with the container that this class
+			// is located in
+			if(it == _visitorClasses.end())
+			{
+				it = _visitorClasses.find(p->container()->thisScope() + visitor);
+			}
+			if(it != _visitorClasses.end())
 			{
-				// Attempt to find the specified visiting class in the list of known
-				// visiting classes.
-				const string visitor = (*q).substr(8);
-				map<string, ClassDefPtr>::const_iterator it = _visitorClasses.find(visitor);
-				// If it wasn't found, try prefixing it with the container that this class
-				// is located in
-				if(it == _visitorClasses.end())
+				// Initially, assume the base visitor class will be the specified class.
+				ClassDefPtr baseVisitor = it->second, derivedVisitor;
+				// Note that the return value of this function is ignored; because this
+				// class has been directly marked with the 'visitor' metadata, we already
+				// know it must support a visitor; the function is being called
+				// to determine if there is a different base visitor class that must be
+				// supported.
+				findVisitableBase(_visitableBases, p, baseVisitor, derivedVisitor);
+				// We know our derived visitor class is the one specified in the directive.
+				derivedVisitor = it->second;
+				// Remember this class as a visitable base, so that any classes that extend
+				// it will automatically be visitable as well.
+				_visitableBases[p->scoped()] = make_pair(baseVisitor, derivedVisitor);
+				// There is no need to actually generate operations into the visitor
+				// class if it was defined in an include file, since the translator
+				// won't actually produce output for the include file.
+				if(derivedVisitor->includeLevel() == 0)
 				{
-					it = _visitorClasses.find(p->container()->thisScope() + visitor);
+					GeneratedOperationPtr gop = derivedVisitor->createGeneratedOperation("visit" + p->name(), 0, generateEmptyFunctionBody());
+					gop->createParamDecl("item", p->declaration(), false);
 				}
-				if(it != _visitorClasses.end())
+				// There is no need to actually generate operations into the visited
+				// class if it was defined in an include file, since the translator
+				// won't actually produce output for the include file.
+				if(p->includeLevel() == 0)
 				{
-					// Initially, assume the base visitor class will be the specified class.
-					ClassDefPtr baseVisitor = it->second, derivedVisitor;
-					// Note that the return value of this function is ignored; because this
-					// class has been directly marked with the 'visitor' metadata, we already
-					// know it must support a visitor; the function is being called
-					// to determine if there is a different base visitor class that must be
-					// supported.
-					findVisitableBase(_visitableBases, p, baseVisitor, derivedVisitor);
-					// We know our derived visitor class is the one specified in the directive.
-					derivedVisitor = it->second;
-					// Remember this class as a visitable base, so that any classes that extend
-					// it will automatically be visitable as well.
-					_visitableBases[p->scoped()] = make_pair(baseVisitor, derivedVisitor);
-					// There is no need to actually generate operations into the visitor
-					// class if it was defined in an include file, since the translator
-					// won't actually produce output for the include file.
-					if(derivedVisitor->includeLevel() == 0)
-					{
-						GeneratedOperationPtr gop = derivedVisitor->createGeneratedOperation("visit" + p->name(), 0, generateEmptyFunctionBody());
-						gop->createParamDecl("item", p->declaration(), false);
-					}
-					// There is no need to actually generate operations into the visited
-					// class if it was defined in an include file, since the translator
-					// won't actually produce output for the include file.
-					if(p->includeLevel() == 0)
+					GeneratedOperationPtr gop = p->createGeneratedOperation("visit", 0,
+												generateVisitFunctionBody("visitor", baseVisitor, derivedVisitor, "visit" + p->name()));
+					if(baseVisitor != derivedVisitor)
 					{
-						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);
+						gop->setOverride(true);
 					}
-					return false;
-				}
-				else
-				{
-					ostr << "ignoring invalid `" << *q << "` metadata: directive specified on "
-					     << "class `" << p->name() << "` but specified interface '" << visitor << "` was "
-					     << "not marked with `visitor` metadata directive";
-					emitWarning(p->file(), p->line(), ostr.str());
-					return false;
+					gop->createParamDecl("visitor", baseVisitor->declaration(), false);
 				}
+				return false;
+			}
+			else
+			{
+				ostr << "ignoring invalid `" << *q << "` metadata: directive specified on "
+				     << "class `" << p->name() << "` but specified interface '" << visitor << "` was "
+				     << "not marked with `visitor` metadata directive";
+				emitWarning(p->file(), p->line(), ostr.str());
+				return false;
 			}
 		}
 	}

commit 107a1a964b3ba8a6780e2ee9b8fb48792de6c980
Author: Kevin P. Fleming <kpfleming at digium.com>
Date:   Fri Mar 11 17:50:35 2011 -0600

    Emit a warning when 'visitor' metadata is applied to a class which extends
    a class that is already known to be a visitor; this is not necessary and
    could potentially cause the plugin to generate incorrect code in the
    future.

diff --git a/src/SliceVisitorPattern.cpp b/src/SliceVisitorPattern.cpp
index 36af4a3..f3960d4 100644
--- a/src/SliceVisitorPattern.cpp
+++ b/src/SliceVisitorPattern.cpp
@@ -126,12 +126,25 @@ VisitorPatternVisitor::visitClassDefStart(const ClassDefPtr& p)
 				emitWarning(p->file(), p->line(), ostr.str());
 				return false;
 			}
-			else
+			else if(!p->bases().empty())
 			{
-				// Remember this class as a visiting class.
-				_visitorClasses[p->scoped()] = p;
-				return false;
+				ClassList bases = p->bases();
+				for(ClassList::const_iterator q = bases.begin(); q != bases.end(); q++)
+				{
+					if(_visitorClasses.find((*q)->scoped()) != _visitorClasses.end())
+					{
+						ostr << "ignoring invalid metadata `visitor`: directive applied"
+						     << "to " << p->name() << " but it inherits from " << (*q)->name()
+						     << " which is already a visitor";
+						emitWarning(p->file(), p->line(), ostr.str());
+						break;
+					}
+				}
 			}
+
+			// Remember this class as a visiting class.
+			_visitorClasses[p->scoped()] = p;
+			return false;
 		}
 		else if(q->find("visitor:", 0) == 0)
 		{

commit 64a412631cc7eb8f62a434885374290e7328f347
Author: Kevin P. Fleming <kpfleming at digium.com>
Date:   Fri Mar 11 17:38:46 2011 -0600

    When searching for a visitable base class of a class, only look at its
    immediate bases, not all of its bases. If any of its bases are visitable,
    at least one of its immediate bases will be too, and by searching this way
    we'll be sure to find the *most* derived visitable base of the class in
    question, not one farther up the tree.

diff --git a/src/SliceVisitorPattern.cpp b/src/SliceVisitorPattern.cpp
index 2998f04..36af4a3 100644
--- a/src/SliceVisitorPattern.cpp
+++ b/src/SliceVisitorPattern.cpp
@@ -85,7 +85,7 @@ findVisitableBase(const map<string, pair<ClassDefPtr, ClassDefPtr> >& visitableB
 		  const ClassDefPtr& p, ClassDefPtr& baseVisitor,
 		  ClassDefPtr& derivedVisitor)
 {
-	ClassList bases = p->allBases();
+	ClassList bases = p->bases();
 	for(ClassList::const_iterator q = bases.begin(); q != bases.end(); q++)
 	{
 		map<string, pair<ClassDefPtr, ClassDefPtr> >::const_iterator it = visitableBases.find((*q)->scoped());

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


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



More information about the asterisk-scf-commits mailing list