[Mobies-commit] [commit] r4347 - GReAT/trunk/Tools/CodeGenerator/CodeGenerator
ksmyth at redhat3.isis.vanderbilt.edu
ksmyth at redhat3.isis.vanderbilt.edu
Thu Oct 23 09:47:02 CDT 2014
Author: ksmyth
Date: Thu Oct 23 09:47:02 2014
New Revision: 4347
Log:
Fix namespace issue in Code Generator with simple associations in Rules
Modified:
GReAT/trunk/Tools/CodeGenerator/CodeGenerator/PE.CPP
GReAT/trunk/Tools/CodeGenerator/CodeGenerator/PE.H
GReAT/trunk/Tools/CodeGenerator/CodeGenerator/PatternMatcher.cpp
GReAT/trunk/Tools/CodeGenerator/CodeGenerator/PatternMatcher.h
Modified: GReAT/trunk/Tools/CodeGenerator/CodeGenerator/PE.CPP
==============================================================================
--- GReAT/trunk/Tools/CodeGenerator/CodeGenerator/PE.CPP Wed Oct 22 08:37:50 2014 (r4346)
+++ GReAT/trunk/Tools/CodeGenerator/CodeGenerator/PE.CPP Thu Oct 23 09:47:02 2014 (r4347)
@@ -41,12 +41,17 @@
std::string PE::getFullType(const GR::ObjectWrapper &grObj)
{
std::string ns = grObj.nameSpace();
+ return getFullType(ns, grObj.paradigmName(), grObj.classType());
+}
+
+std::string PE::getFullType(const std::string& ns, const std::string& paradigmName, const std::string& classType)
+{
if(ns.empty())
{
- return (std::string)(grObj.paradigmName())+RES+(std::string)(grObj.classType());
+ return (std::string)(paradigmName)+RES+(std::string)(classType);
}
else
- return (std::string)(grObj.paradigmName()) + RES + ns + RES + (std::string)(grObj.classType());
+ return (std::string)(paradigmName) + RES + ns + RES + (std::string)(classType);
}
std::ostream& PE::printTab( std::ostream& os)
Modified: GReAT/trunk/Tools/CodeGenerator/CodeGenerator/PE.H
==============================================================================
--- GReAT/trunk/Tools/CodeGenerator/CodeGenerator/PE.H Wed Oct 22 08:37:50 2014 (r4346)
+++ GReAT/trunk/Tools/CodeGenerator/CodeGenerator/PE.H Thu Oct 23 09:47:02 2014 (r4347)
@@ -51,6 +51,7 @@
static std::string getPE_UID();
static std::string createUniqueName( const std::string& name, bool decorateName= true);
static std::string getFullType(const GR::ObjectWrapper &grObj);
+ static std::string getFullType(const std::string& ns, const std::string& paradigmName, const std::string& classType);
protected:
// Current tabulation position.
Modified: GReAT/trunk/Tools/CodeGenerator/CodeGenerator/PatternMatcher.cpp
==============================================================================
--- GReAT/trunk/Tools/CodeGenerator/CodeGenerator/PatternMatcher.cpp Wed Oct 22 08:37:50 2014 (r4346)
+++ GReAT/trunk/Tools/CodeGenerator/CodeGenerator/PatternMatcher.cpp Thu Oct 23 09:47:02 2014 (r4347)
@@ -694,10 +694,11 @@
}
// is source association association class?
bool is_sa_ac= assoc && ( Uml::IsAssocClass( assoc)) && !unbound.isAssociationClass(); // association class specified as simple association
- if ( is_sa_ac)
+ if (is_sa_ac)
{
printLogMsg("INFO: Association class specified in the meta <-> simple association specified in the pattern.");
- unboundType+= targetName= targetClass= assocClass;
+ targetName = targetClass = assocClass;
+ unboundType = PE::getFullType(targetClass_namespace, unbound.paradigmName(), assocClass);
}
else
{
@@ -722,7 +723,7 @@
bool isMultipleAssoc= 1< (unsigned int) maxMultiplicityAssoc; // * multiplicity is represented as -1.
if ( isMultipleAssoc)
{
- Definition* unboundsDef= new Definition;
+ Definition* unboundsDef = new Definition;
unboundsDef->createRoles( ( std::string)unbound.paradigmName(), targetClass_namespace, targetClass, lowerBegin(PE::createUniqueName( targetName+ "s")), lowerBegin( getBoundObjectName( bound)), dstRoleName);
_currCode->add( *unboundsDef);
// negative application condition for associations with multiple cardinality
@@ -741,7 +742,7 @@
if ( is_sa_ac)
{
GR::ObjectWrapper owNewAssocClass;
- createPseudoAssocClass( simpleAssocLink, ( std::string) unbound.paradigmName(), assocClass, owNewAssocClass);
+ createPseudoAssocClass(simpleAssocLink, ( std::string) unbound.paradigmName(), targetClass_namespace, assocClass, owNewAssocClass);
unbound= owNewAssocClass;
}
unboundDef->_variable= PE::createUniqueName( "curr"+ ( std::string)unbound.name());
@@ -765,7 +766,7 @@
if ( is_sa_ac)
{
GR::ObjectWrapper owNewAssocClass;
- createPseudoAssocClass( simpleAssocLink, ( std::string) unbound.paradigmName(), assocClass, owNewAssocClass);
+ createPseudoAssocClass(simpleAssocLink, ( std::string) unbound.paradigmName(), targetClass_namespace, assocClass, owNewAssocClass);
unbound= owNewAssocClass;
}
// negative application condition for associations with single cardinality
@@ -1154,6 +1155,7 @@
void PatternMatcher::createPseudoAssocClass(
const GR::ObjectLink& simpleLink,
const std::string& paradigmName,
+ const std::string& targetClass_namespace,
const string& classType,
GR::ObjectWrapper& assocClass
) const
@@ -1166,6 +1168,7 @@
assocClass.classType()= classType;
assocClass.isAssociationClass()= true;
assocClass.dataNetworkID() = -1;
+ assocClass.nameSpace() = targetClass_namespace;
// Create a simple association type link...
GR::ObjectLink assocClassLink= GR::ObjectLink::Create( simpleLink.parent());
assocClassLink.relationshipType()= "SimpleAssociation";
Modified: GReAT/trunk/Tools/CodeGenerator/CodeGenerator/PatternMatcher.h
==============================================================================
--- GReAT/trunk/Tools/CodeGenerator/CodeGenerator/PatternMatcher.h Wed Oct 22 08:37:50 2014 (r4346)
+++ GReAT/trunk/Tools/CodeGenerator/CodeGenerator/PatternMatcher.h Thu Oct 23 09:47:02 2014 (r4347)
@@ -148,7 +148,7 @@
// This function creates an object wrapper under 'simpleLink.parent()', which refers to an association class
// with paradigm 'paradigmName', type 'classType'. Also creates a simple association connecting the association class and
// the object wrapper on the proper end of 'simpleLink'. This association class is then returned in 'assocClass'.
- void createPseudoAssocClass( const GR::ObjectLink& simpleLink, const std::string& paradigmName, const std::string& classType, GR::ObjectWrapper& assocClass) const;
+ void createPseudoAssocClass( const GR::ObjectLink& simpleLink, const std::string& paradigmName, const std::string& targetClass_namespace, const std::string& classType, GR::ObjectWrapper& assocClass) const;
// Used for the case when association class type links in the meta are specified as simple associations in the pattern.
// In these cases, code must be generated which incorporates the use of association classes.
// This function creates an object link under 'simpleLink.parent()', connecting the association class 'assocClass' and
More information about the Mobies-commit
mailing list