Skip to content
Snippets Groups Projects
Commit 42eb40f6 authored by Chrissi's avatar Chrissi
Browse files

modify the view generation because of interface modification

parent 61aa52b4
Branches
No related tags found
No related merge requests found
Subproject commit 15ff628c095805abcd57609437c7f26bbb8df362 Subproject commit f10627a3d70d860e59c4924e3c0b0ecb93d8d0bc
...@@ -41,7 +41,8 @@ class ViewGeneratingVisitor extends SModelVisitor { ...@@ -41,7 +41,8 @@ class ViewGeneratingVisitor extends SModelVisitor {
} }
//add initialize method if necessary //add initialize method if necessary
if (!inner.isAbstract && !inner.isInterface) { if (!inner.isAbstract && !inner.isInterface) {
inner.addMethod(ViewMethods.getInitializeMethod(inner)) inner.addMethod(ViewMethods.getIsRelationalMethod(false))
inner.addMethod(ViewMethods.getCreationObjectMethod(inner))
} }
//add delete method //add delete method
inner.addMethod(ViewMethods.getDeleteElementNaturalMethod(inner)) inner.addMethod(ViewMethods.getDeleteElementNaturalMethod(inner))
...@@ -86,7 +87,8 @@ class ViewGeneratingVisitor extends SModelVisitor { ...@@ -86,7 +87,8 @@ class ViewGeneratingVisitor extends SModelVisitor {
val internalClass = new SInnerViewRelationalClass(r.getName + "Role", _externalClass = viewCompartment, val internalClass = new SInnerViewRelationalClass(r.getName + "Role", _externalClass = viewCompartment,
sumSource = r.asInstanceOf[SRelationalCompartmentClass], viewSource = sourceRole, viewTarget = targetRole) sumSource = r.asInstanceOf[SRelationalCompartmentClass], viewSource = sourceRole, viewTarget = targetRole)
internalClass.setAttributes(sourceAtt ++ targetAtt) internalClass.setAttributes(sourceAtt ++ targetAtt)
internalClass.addMethod(ViewMethods.getInitializeMethod(internalClass)) internalClass.addMethod(ViewMethods.getIsRelationalMethod(true))
internalClass.addMethod(ViewMethods.getCreationObjectMethod(internalClass))
internalClass.addMethod(ViewMethods.getDeleteElementRelationMethod(internalClass)) internalClass.addMethod(ViewMethods.getDeleteElementRelationMethod(internalClass))
ViewMethods.getSourceAndTargetGetter(internalClass).foreach(internalClass.addMethod(_)) ViewMethods.getSourceAndTargetGetter(internalClass).foreach(internalClass.addMethod(_))
internalClass.addParent(PredefRsumTypes.AVIEW_ROLE_STYPE) internalClass.addParent(PredefRsumTypes.AVIEW_ROLE_STYPE)
......
...@@ -60,22 +60,33 @@ object ViewMethods { ...@@ -60,22 +60,33 @@ object ViewMethods {
methods methods
} }
def getInitializeMethod(nat: SInnerViewNaturalClass): SMethod = { def getIsRelationalMethod(relational: Boolean): SMethod = {
val method = new SMethod( val method = new SMethod(
name = "initialize", name = "isRelational",
result = PredefTypes.Unit, result = PredefTypes.Boolean,
params = Seq.empty, params = Seq.empty,
implementation = Seq(SMethodStatement(content = s"initializeElement(new ${nat.sumSource.getName}(" + implementation = Seq(SMethodStatement(content = s"return ${relational}", usedTypes = Set.empty)),
s"${nat.sumSource.getAllConstructorParameters.map(m => m.getName).mkString(", ")}), false)", usedTypes = Set.empty)),
true) true)
method.setVisibility(MethodVisibility.protectedVis) method.setVisibility(MethodVisibility.protectedVis)
method method
} }
def getInitializeMethod(ref: SInnerViewRelationalClass): SMethod = { def getCreationObjectMethod(nat: SInnerViewNaturalClass): SMethod = {
val method = new SMethod( val method = new SMethod(
name = "initialize", name = "getCreationObject",
result = PredefTypes.Unit, result = PredefTypes.Object,
params = Seq.empty,
implementation = Seq(SMethodStatement(content = s"return new ${nat.sumSource.getName}(" +
s"${nat.sumSource.getAllConstructorParameters.map(m => m.getName).mkString(", ")})", usedTypes = Set.empty)),
true)
method.setVisibility(MethodVisibility.protectedVis)
method
}
def getCreationObjectMethod(ref: SInnerViewRelationalClass): SMethod = {
val method = new SMethod(
name = "getCreationObject",
result = PredefTypes.Object,
params = Seq.empty, params = Seq.empty,
implementation = Seq(SMethodStatement(content = "return", usedTypes = Set.empty)), implementation = Seq(SMethodStatement(content = "return", usedTypes = Set.empty)),
true) true)
...@@ -90,7 +101,7 @@ object ViewMethods { ...@@ -90,7 +101,7 @@ object ViewMethods {
usedTypes = Set(ref.viewTarget.sumSource)), usedTypes = Set(ref.viewTarget.sumSource)),
SMethodStatement(content = s"val v: ${ref.sumSource.getName} = new ${ref.sumSource.getName}(sp, tp)", SMethodStatement(content = s"val v: ${ref.sumSource.getName} = new ${ref.sumSource.getName}(sp, tp)",
usedTypes = Set(ref.sumSource)), usedTypes = Set(ref.sumSource)),
SMethodStatement(content = s"initializeElement(v, true)", SMethodStatement(content = s"return v",
usedTypes = Set.empty)) usedTypes = Set.empty))
method.implementation = statements method.implementation = statements
method.setVisibility(MethodVisibility.protectedVis) method.setVisibility(MethodVisibility.protectedVis)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment