Commit 2b5156d5 authored by René Schöne's avatar René Schöne
Browse files

Merge branch '35-cleanup' into 'master'

Resolve "Cleanup"

Closes #35

See merge request jastadd/ros2rag!4
parents 68a4ee8e 199d5bcb
Pipeline #7590 passed with stages
in 6 minutes and 15 seconds
......@@ -3,7 +3,7 @@ apply plugin: 'application'
sourceCompatibility = 1.8
mainClassName = 'org.jastadd.ros2rag.compiler.Compiler'
mainClassName = 'org.jastadd.ragconnect.compiler.Compiler'
repositories {
jcenter()
......@@ -17,12 +17,32 @@ buildscript {
}
dependencies {
implementation project(':relast.preprocessor')
implementation group: 'com.github.spullara.mustache.java', name: 'compiler', version: '0.9.6'
implementation group: 'org.apache.logging.log4j', name: 'log4j-jul', version: '2.11.2'
runtime group: 'org.jastadd', name: 'jastadd', version: '2.3.4'
api group: 'net.sf.beaver', name: 'beaver-rt', version: '0.9.11'
}
def versionFile = 'src/main/resources/ragConnectVersion.properties'
def oldProps = new Properties()
try {
file(versionFile).withInputStream { stream -> oldProps.load(stream) }
version = oldProps['version']
} catch (e) {
// this happens, if either the properties file is not present, or cannot be read from
throw new GradleException("File ${versionFile} not found or unreadable. Aborting.", e)
}
task newVersion() {
doFirst {
def props = new Properties()
props['version'] = value
props.store(file(versionFile).newWriter(), null)
}
}
sourceSets {
main {
java.srcDir "src/gen/java"
......@@ -37,7 +57,7 @@ test {
jar {
manifest {
attributes "Main-Class": 'org.jastadd.ros2rag.compiler.Compiler'
attributes "Main-Class": 'org.jastadd.ragconnect.compiler.Compiler'
}
from {
......@@ -51,47 +71,47 @@ task relast(type: JavaExec) {
doFirst {
delete "src/gen/jastadd/*.ast"
delete "src/gen/jastadd/Ros2Rag.jadd"
delete "src/gen/jastadd/Ros2RagRefResolver.jadd"
delete "src/gen/jastadd/Ros2RagResolverStubs.jrag"
delete "src/gen/jastadd/RagConnect.jadd"
delete "src/gen/jastadd/RagConnectRefResolver.jadd"
delete "src/gen/jastadd/RagConnectResolverStubs.jrag"
mkdir "src/gen/jastadd/"
}
args = [
"../libs/relast.jar",
"../relast.preprocessor/src/main/jastadd/RelAst.relast",
"./src/main/jastadd/Ros2Rag.relast",
"./src/main/jastadd/RagConnect.relast",
"./src/main/jastadd/MustacheNodes.relast",
"--listClass=java.util.ArrayList",
"--jastAddList=JastAddList",
"--useJastAddNames",
"--file",
"--resolverHelper",
"--grammarName=./src/gen/jastadd/Ros2Rag"
"--grammarName=./src/gen/jastadd/RagConnect"
]
inputs.files file("../libs/relast.jar"),
file("../relast.preprocessor/src/main/jastadd/RelAST.relast"),
file("./src/main/jastadd/Ros2Rag.relast")
file("./src/main/jastadd/RagConnect.relast")
file("./src/main/jastadd/MustacheNodes.relast")
outputs.files file("./src/gen/jastadd/Ros2Rag.ast"),
file("./src/gen/jastadd/Ros2Rag.jadd"),
file("./src/gen/jastadd/Ros2RagRefResolver.jadd"),
file('./src/gen/jastadd/Ros2RagResolverStubs.jrag')
outputs.files file("./src/gen/jastadd/RagConnect.ast"),
file("./src/gen/jastadd/RagConnect.jadd"),
file("./src/gen/jastadd/RagConnectRefResolver.jadd"),
file('./src/gen/jastadd/RagConnectResolverStubs.jrag')
}
jastadd {
configureModuleBuild()
modules {
//noinspection GroovyAssignabilityCheck
module("Ros2Rag") {
module("RagConnect") {
java {
basedir ".."
include "relast.preprocessor/main/**/*.java"
include "relast.preprocessor/gen/**/*.java"
include "ros2rag.base/src/main/**/*.java"
include "ros2rag.base/src/gen/**/*.java"
include "ragconnect.base/src/main/**/*.java"
include "ragconnect.base/src/gen/**/*.java"
}
jastadd {
......@@ -99,23 +119,23 @@ jastadd {
include "relast.preprocessor/src/main/jastadd/**/*.ast"
include "relast.preprocessor/src/main/jastadd/**/*.jadd"
include "relast.preprocessor/src/main/jastadd/**/*.jrag"
include "ros2rag.base/src/main/jastadd/**/*.ast"
include "ros2rag.base/src/main/jastadd/**/*.jadd"
include "ros2rag.base/src/main/jastadd/**/*.jrag"
include "ros2rag.base/src/gen/jastadd/**/*.ast"
include "ros2rag.base/src/gen/jastadd/**/*.jadd"
include "ros2rag.base/src/gen/jastadd/**/*.jrag"
include "ragconnect.base/src/main/jastadd/**/*.ast"
include "ragconnect.base/src/main/jastadd/**/*.jadd"
include "ragconnect.base/src/main/jastadd/**/*.jrag"
include "ragconnect.base/src/gen/jastadd/**/*.ast"
include "ragconnect.base/src/gen/jastadd/**/*.jadd"
include "ragconnect.base/src/gen/jastadd/**/*.jrag"
}
scanner {
basedir ".."
include "ros2rag.base/src/main/jastadd/scanner/Header.flex", [-5]
include "ragconnect.base/src/main/jastadd/scanner/Header.flex", [-5]
include "relast.preprocessor/src/main/jastadd/scanner/Preamble.flex", [-4]
include "relast.preprocessor/src/main/jastadd/scanner/Macros.flex", [-3]
include "ros2rag.base/src/main/jastadd/scanner/Macros.flex", [-3]
include "ragconnect.base/src/main/jastadd/scanner/Macros.flex", [-3]
include "relast.preprocessor/src/main/jastadd/scanner/RulesPreamble.flex", [-2]
include "ros2rag.base/src/main/jastadd/scanner/MappingContent.flex", [-1]
include "ros2rag.base/src/main/jastadd/scanner/Keywords.flex"
include "ragconnect.base/src/main/jastadd/scanner/MappingContent.flex", [-1]
include "ragconnect.base/src/main/jastadd/scanner/Keywords.flex"
include "relast.preprocessor/src/main/jastadd/scanner/Keywords.flex"
include "relast.preprocessor/src/main/jastadd/scanner/Symbols.flex", [1]
include "relast.preprocessor/src/main/jastadd/scanner/RulesPostamble.flex", [2]
......@@ -123,8 +143,8 @@ jastadd {
parser {
basedir ".."
include "ros2rag.base/src/main/jastadd/parser/Preamble.parser"
include "ros2rag.base/src/main/jastadd/parser/Ros2Rag.parser"
include "ragconnect.base/src/main/jastadd/parser/Preamble.parser"
include "ragconnect.base/src/main/jastadd/parser/RagConnect.parser"
include "relast.preprocessor/src/main/jastadd/parser/RelAst.parser"
}
}
......@@ -141,18 +161,18 @@ jastadd {
}
module = "Ros2Rag"
module = "RagConnect"
astPackage = 'org.jastadd.ros2rag.ast'
astPackage = 'org.jastadd.ragconnect.ast'
parser.name = 'Ros2RagParser'
parser.name = 'RagConnectParser'
genDir = 'src/gen/java'
buildInfoDir = 'src/gen-res'
scanner.genDir = "src/gen/java/org/jastadd/ros2rag/scanner"
parser.genDir = "src/gen/java/org/jastadd/ros2rag/parser"
scanner.genDir = "src/gen/java/org/jastadd/ragconnect/scanner"
parser.genDir = "src/gen/java/org/jastadd/ragconnect/parser"
jastaddOptions = ["--lineColumnNumbers", "--List=JastAddList", "--safeLazy", "--visitCheck=true", "--rewrite=cnta", "--cache=all"]
}
......
aspect Analysis {
// --- lookupTokenUpdateDefinition ---
inh TokenUpdateDefinition TokenUpdateDefinition.lookupTokenUpdateDefinition(TokenComponent token);
eq Ros2Rag.getUpdateDefinition().lookupTokenUpdateDefinition(TokenComponent token) {
for (UpdateDefinition def : getUpdateDefinitionList()) {
if (def.isTokenUpdateDefinition() && def.asTokenUpdateDefinition().getToken().equals(token)) {
return def.asTokenUpdateDefinition();
// --- lookupTokenEndpointDefinition ---
inh TokenEndpointDefinition TokenEndpointDefinition.lookupTokenEndpointDefinition(TokenComponent token);
eq RagConnect.getEndpointDefinition().lookupTokenEndpointDefinition(TokenComponent token) {
for (EndpointDefinition def : getEndpointDefinitionList()) {
if (def.isTokenEndpointDefinition() && def.asTokenEndpointDefinition().getToken().equals(token)) {
return def.asTokenEndpointDefinition();
}
}
return null;
......@@ -12,7 +12,7 @@ aspect Analysis {
// --- lookupDependencyDefinition ---
inh DependencyDefinition DependencyDefinition.lookupDependencyDefinition(TypeDecl source, String id);
eq Ros2Rag.getDependencyDefinition().lookupDependencyDefinition(TypeDecl source, String id) {
eq RagConnect.getDependencyDefinition().lookupDependencyDefinition(TypeDecl source, String id) {
for (DependencyDefinition def : getDependencyDefinitionList()) {
if (def.getID().equals(id) && def.getSource().containingTypeDecl().equals(source)) {
return def;
......@@ -22,6 +22,6 @@ aspect Analysis {
}
// --- isAlreadyDefined ---
syn boolean TokenUpdateDefinition.isAlreadyDefined() = lookupTokenUpdateDefinition(getToken()) != this;
syn boolean TokenEndpointDefinition.isAlreadyDefined() = lookupTokenEndpointDefinition(getToken()) != this;
syn boolean DependencyDefinition.isAlreadyDefined() = lookupDependencyDefinition(getSource().containingTypeDecl(), getID()) != this;
}
......@@ -3,50 +3,50 @@ import java.util.TreeSet;
import java.util.LinkedList;
aspect Errors {
coll Set<ErrorMessage> Ros2Rag.errors()
coll Set<ErrorMessage> RagConnect.errors()
[new TreeSet<ErrorMessage>()]
root Ros2Rag;
root RagConnect;
ReadFromMqttDefinition contributes error("Read definition already defined for " + getToken().getName())
ReceiveFromMqttDefinition contributes error("Receive definition already defined for " + getToken().getName())
when isAlreadyDefined()
to Ros2Rag.errors();
to RagConnect.errors();
ReadFromMqttDefinition contributes error("Reading target token must not be an NTA token!")
ReceiveFromMqttDefinition contributes error("Receiving target token must not be an NTA token!")
when getToken().getNTA()
to Ros2Rag.errors();
to RagConnect.errors();
// if first mapping is null, then suitableDefaultMapping() == null
ReadFromMqttDefinition contributes error("No suitable default mapping found for type " +
ReceiveFromMqttDefinition contributes error("No suitable default mapping found for type " +
((getMappingList().isEmpty())
? getToken().getJavaTypeUse().prettyPrint()
: getMappingList().get(0).getFromType().prettyPrint()))
when effectiveMappings().get(0) == null
to Ros2Rag.errors();
to RagConnect.errors();
ReadFromMqttDefinition contributes error("to-type of last mapping must be type of the Token!")
ReceiveFromMqttDefinition contributes error("to-type of last mapping must be type of the Token!")
when getToken().getJavaTypeUse().prettyPrint().equals(
effectiveMappings().get(effectiveMappings().size() - 1))
to Ros2Rag.errors();
to RagConnect.errors();
WriteToMqttDefinition contributes error("Writing target token must be an NTA token!")
SendToMqttDefinition contributes error("Sending target token must be an NTA token!")
when !getToken().getNTA()
to Ros2Rag.errors();
to RagConnect.errors();
WriteToMqttDefinition contributes error("Write definition already defined for " + getToken().getName())
SendToMqttDefinition contributes error("Send definition already defined for " + getToken().getName())
when isAlreadyDefined()
to Ros2Rag.errors();
to RagConnect.errors();
DependencyDefinition contributes error("Dependency definition already defined for " + getSource().containingTypeDecl().getName() + " with name " + getID())
when isAlreadyDefined()
to Ros2Rag.errors();
to RagConnect.errors();
DependencyDefinition contributes error("The name of a dependency definition must not be equal to a list-node on the source")
when isAlreadyDefinedAsList()
to Ros2Rag.errors();
to RagConnect.errors();
DependencyDefinition contributes error("There must be a write update definition targeting " + getSource().parentTypeypeAndName() + " for dependency definition " + getID())
when targetUpdateDefinition() == null
to Ros2Rag.errors();
DependencyDefinition contributes error("There must be a send update definition targeting " + getSource().parentTypeypeAndName() + " for dependency definition " + getID())
when targetEndpointDefinition() == null
to RagConnect.errors();
}
aspect ErrorHelpers {
......
//TypeComponentMustache ;
//rel TypeComponentMustache.TypeComponent -> TypeComponent ;
MRos2Rag ::= ReadDefinition:MReadDefinition* WriteDefinition:MWriteDefinition* MappingDefinition:MMappingDefinition* DependencyDefinition:MDependencyDefinition* RootTypeComponent:MTypeComponent* TokenComponent:MTokenComponent*;
abstract MUpdateDefinition ::= InnerMappingDefinition:MInnerMappingDefinition*;
MReadDefinition : MUpdateDefinition;
MWriteDefinition : MUpdateDefinition;
MRagConnect ::= ReceiveDefinition:MReceiveDefinition* SendDefinition:MSendDefinition* MappingDefinition:MMappingDefinition* DependencyDefinition:MDependencyDefinition* RootTypeComponent:MTypeComponent* TokenComponent:MTokenComponent*;
abstract MEndpointDefinition ::= InnerMappingDefinition:MInnerMappingDefinition*;
MReceiveDefinition : MEndpointDefinition;
MSendDefinition : MEndpointDefinition;
MMappingDefinition;
MInnerMappingDefinition;
MDependencyDefinition;
MTypeComponent;
MTokenComponent;
rel MRos2Rag.Ros2Rag -> Ros2Rag;
rel MRagConnect.RagConnect -> RagConnect;
rel MInnerMappingDefinition.MappingDefinition -> MappingDefinition;
rel MReadDefinition.ReadFromMqttDefinition -> ReadFromMqttDefinition;
rel MWriteDefinition.WriteToMqttDefinition -> WriteToMqttDefinition;
rel MReceiveDefinition.ReceiveFromMqttDefinition -> ReceiveFromMqttDefinition;
rel MSendDefinition.SendToMqttDefinition -> SendToMqttDefinition;
rel MMappingDefinition.MappingDefinition -> MappingDefinition;
rel MDependencyDefinition.DependencyDefinition -> DependencyDefinition;
rel MTypeComponent.TypeComponent -> TypeComponent;
......
aspect NameResolution {
refine RefResolverStubs eq UpdateDefinition.resolveMappingByToken(String id, int position) {
refine RefResolverStubs eq EndpointDefinition.resolveMappingByToken(String id, int position) {
// return a MappingDefinition
for (MappingDefinition mappingDefinition : ros2rag().getMappingDefinitionList()) {
for (MappingDefinition mappingDefinition : ragconnect().getMappingDefinitionList()) {
if (mappingDefinition.getID().equals(id)) {
return mappingDefinition;
}
......
aspect Navigation {
// --- program ---
eq RagConnect.getChild().program() = getProgram();
eq MRagConnect.getChild().program() = getRagConnect().program();
// --- ragconnect ---
inh RagConnect ASTNode.ragconnect();
eq RagConnect.getChild().ragconnect() = this;
eq MRagConnect.getChild().ragconnect() = getRagConnect();
// --- containedFile
eq RagConnect.getChild().containedFile() = null;
// --- containedFileName ---
eq RagConnect.getChild().containedFileName() = getFileName();
eq MRagConnect.getChild().containedFileName() = null;
// --- isTokenEndpointDefinition ---
syn boolean EndpointDefinition.isTokenEndpointDefinition() = false;
eq TokenEndpointDefinition.isTokenEndpointDefinition() = true;
// --- asTokenEndpointDefinition ---
syn TokenEndpointDefinition EndpointDefinition.asTokenEndpointDefinition() = null;
eq TokenEndpointDefinition.asTokenEndpointDefinition() = this;
// --- isSendToMqttDefinition ---
syn boolean EndpointDefinition.isSendToMqttDefinition() = false;
eq SendToMqttDefinition.isSendToMqttDefinition() = true;
// --- asSendToMqttDefinition ---
syn SendToMqttDefinition EndpointDefinition.asSendToMqttDefinition() = null;
eq SendToMqttDefinition.asSendToMqttDefinition() = this;
// --- asReceiveFromMqttDefinition ---
syn ReceiveFromMqttDefinition EndpointDefinition.asReceiveFromMqttDefinition() = null;
eq ReceiveFromMqttDefinition.asReceiveFromMqttDefinition() = this;
// --- targetEndpointDefinition ---
syn SendToMqttDefinition DependencyDefinition.targetEndpointDefinition() {
// resolve definition in here, as we do not need resolveMethod in any other place (yet)
for (EndpointDefinition endpointDefinition : ragconnect().getEndpointDefinitionList()) {
if (endpointDefinition.isSendToMqttDefinition() &&
endpointDefinition.asSendToMqttDefinition().getToken().equals(this.getTarget())) {
return endpointDefinition.asSendToMqttDefinition();
}
}
return null;
}
// --- isDefaultMappingDefinition ---
syn boolean MappingDefinition.isDefaultMappingDefinition() = false;
eq DefaultMappingDefinition.isDefaultMappingDefinition() = true;
}
Ros2Rag ::= UpdateDefinition* DependencyDefinition* MappingDefinition* Program <FileName> ;
RagConnect ::= EndpointDefinition* DependencyDefinition* MappingDefinition* Program <FileName> ;
abstract UpdateDefinition ::= <AlwaysApply:boolean> ;
abstract EndpointDefinition ::= <AlwaysApply:boolean> ;
rel UpdateDefinition.Mapping* -> MappingDefinition;
rel EndpointDefinition.Mapping* -> MappingDefinition;
abstract TokenUpdateDefinition : UpdateDefinition;
rel TokenUpdateDefinition.Token -> TokenComponent;
abstract TokenEndpointDefinition : EndpointDefinition;
rel TokenEndpointDefinition.Token -> TokenComponent;
ReadFromMqttDefinition : TokenUpdateDefinition;
WriteToMqttDefinition : TokenUpdateDefinition;
ReceiveFromMqttDefinition : TokenEndpointDefinition;
SendToMqttDefinition : TokenEndpointDefinition;
DependencyDefinition ::= <ID>;
rel DependencyDefinition.Source <-> TokenComponent.DependencySourceDefinition*;
......
......@@ -26,39 +26,40 @@ aspect GenerationUtils {
*/
aspect AttributesForMustache {
// --- MRos2Rag ---
eq MRos2Rag.getChild().mqttHandlerAttribute() = mqttHandlerAttribute();
eq MRos2Rag.getChild().mqttHandlerField() = mqttHandlerField();
// --- MRagConnect ---
eq MRagConnect.getChild().mqttHandlerAttribute() = mqttHandlerAttribute();
eq MRagConnect.getChild().mqttHandlerField() = mqttHandlerField();
eq MRagConnect.getRootTypeComponent(int i).isFirst() = i == 0;
syn String MRos2Rag.mqttHandlerAttribute() = getRos2Rag().mqttHandlerAttribute();
syn String MRos2Rag.mqttHandlerField() = getRos2Rag().mqttHandlerField();
syn String MRos2Rag.mqttSetHostMethod() = getRos2Rag().mqttSetHostMethod();
syn String MRos2Rag.mqttWaitUntilReadyMethod() = getRos2Rag().mqttWaitUntilReadyMethod();
syn String MRos2Rag.mqttCloseMethod() = getRos2Rag().mqttCloseMethod();
syn String MRagConnect.mqttHandlerAttribute() = getRagConnect().mqttHandlerAttribute();
syn String MRagConnect.mqttHandlerField() = getRagConnect().mqttHandlerField();
syn String MRagConnect.mqttSetHostMethod() = getRagConnect().mqttSetHostMethod();
syn String MRagConnect.mqttWaitUntilReadyMethod() = getRagConnect().mqttWaitUntilReadyMethod();
syn String MRagConnect.mqttCloseMethod() = getRagConnect().mqttCloseMethod();
// --- MUpdateDefinition ---
syn String MUpdateDefinition.preemptiveExpectedValue();
syn String MUpdateDefinition.preemptiveReturn();
syn TokenUpdateDefinition MUpdateDefinition.updateDef();
syn String MUpdateDefinition.firstInputVarName();
// --- MEndpointDefinition ---
syn String MEndpointDefinition.preemptiveExpectedValue();
syn String MEndpointDefinition.preemptiveReturn();
syn TokenEndpointDefinition MEndpointDefinition.endpointDef();
syn String MEndpointDefinition.firstInputVarName();
eq MUpdateDefinition.getInnerMappingDefinition(int i).isLast() = i == getNumInnerMappingDefinition() - 1;
eq MUpdateDefinition.getInnerMappingDefinition().resultVarPrefix() = resultVarPrefix();
eq MUpdateDefinition.getInnerMappingDefinition(int i).inputVarName() = i == 0 ? firstInputVarName() : resultVarPrefix() + getInnerMappingDefinition(i - 1).getMappingDefinition().methodName();
eq MEndpointDefinition.getInnerMappingDefinition(int i).isLast() = i == getNumInnerMappingDefinition() - 1;
eq MEndpointDefinition.getInnerMappingDefinition().resultVarPrefix() = resultVarPrefix();
eq MEndpointDefinition.getInnerMappingDefinition(int i).inputVarName() = i == 0 ? firstInputVarName() : resultVarPrefix() + getInnerMappingDefinition(i - 1).getMappingDefinition().methodName();
inh String MUpdateDefinition.mqttHandlerAttribute();
inh String MEndpointDefinition.mqttHandlerAttribute();
syn String MUpdateDefinition.connectMethod() = updateDef().connectMethod();
syn TokenComponent MUpdateDefinition.token() = updateDef().getToken();
syn boolean MUpdateDefinition.alwaysApply() = updateDef().getAlwaysApply();
syn String MUpdateDefinition.resultVarPrefix() = "result"; // we do not need "_" here, because methodName begins with one
syn String MUpdateDefinition.parentTypeName() = token().containingTypeDecl().getName();
syn String MUpdateDefinition.tokenName() = token().getName();
syn MInnerMappingDefinition MUpdateDefinition.lastDefinition() = getInnerMappingDefinition(getNumInnerMappingDefinition() - 1);
syn String MUpdateDefinition.lastDefinitionToType() = lastDefinition().ToType();
syn String MUpdateDefinition.lastDefinitionName() = lastDefinition().methodName();
syn String MUpdateDefinition.lastResult() = resultVarPrefix() + lastDefinitionName();
syn String MUpdateDefinition.condition() {
syn String MEndpointDefinition.connectMethod() = endpointDef().connectMethod();
syn TokenComponent MEndpointDefinition.token() = endpointDef().getToken();
syn boolean MEndpointDefinition.alwaysApply() = endpointDef().getAlwaysApply();
syn String MEndpointDefinition.resultVarPrefix() = "result"; // we do not need "_" here, because methodName begins with one
syn String MEndpointDefinition.parentTypeName() = token().containingTypeDecl().getName();
syn String MEndpointDefinition.tokenName() = token().getName();
syn MInnerMappingDefinition MEndpointDefinition.lastDefinition() = getInnerMappingDefinition(getNumInnerMappingDefinition() - 1);
syn String MEndpointDefinition.lastDefinitionToType() = lastDefinition().ToType();
syn String MEndpointDefinition.lastDefinitionName() = lastDefinition().methodName();
syn String MEndpointDefinition.lastResult() = resultVarPrefix() + lastDefinitionName();
syn String MEndpointDefinition.condition() {
if (lastDefinition().getMappingDefinition().getToType().isArray()) {
return "java.util.Arrays.equals(" + preemptiveExpectedValue() + ", " + lastResult() + ")";
}
......@@ -78,23 +79,23 @@ aspect AttributesForMustache {
syn String MInnerMappingDefinition.methodName() = getMappingDefinition().methodName();
inh String MInnerMappingDefinition.inputVarName();
// --- MReadDefinition ---
eq MReadDefinition.preemptiveExpectedValue() = "get" + tokenName() + "()";
eq MReadDefinition.preemptiveReturn() = "return;";
eq MReadDefinition.updateDef() = getReadFromMqttDefinition();
eq MReadDefinition.firstInputVarName() = "message";
// --- MReceiveDefinition ---
eq MReceiveDefinition.preemptiveExpectedValue() = "get" + tokenName() + "()";
eq MReceiveDefinition.preemptiveReturn() = "return;";
eq MReceiveDefinition.endpointDef() = getReceiveFromMqttDefinition();
eq MReceiveDefinition.firstInputVarName() = "message";
// --- MWriteDefinition ---
eq MWriteDefinition.preemptiveExpectedValue() = lastValue();
eq MWriteDefinition.preemptiveReturn() = "return false;";
eq MWriteDefinition.updateDef() = getWriteToMqttDefinition();
eq MWriteDefinition.firstInputVarName() = "get" + tokenName() + "()";
// --- MSendDefinition ---
eq MSendDefinition.preemptiveExpectedValue() = lastValue();
eq MSendDefinition.preemptiveReturn() = "return false;";
eq MSendDefinition.endpointDef() = getSendToMqttDefinition();
eq MSendDefinition.firstInputVarName() = "get" + tokenName() + "()";
syn String MWriteDefinition.writeTopic() = getWriteToMqttDefinition().writeTopic();
syn String MWriteDefinition.lastValue() = getWriteToMqttDefinition().lastValue();
syn String MWriteDefinition.updateMethod() = getWriteToMqttDefinition().updateMethod();
syn String MWriteDefinition.writeMethod() = getWriteToMqttDefinition().writeMethod();
syn String MWriteDefinition.tokenResetMethod() = getWriteToMqttDefinition().tokenResetMethod();
syn String MSendDefinition.sendTopic() = getSendToMqttDefinition().sendTopic();
syn String MSendDefinition.lastValue() = getSendToMqttDefinition().lastValue();
syn String MSendDefinition.updateMethod() = getSendToMqttDefinition().updateMethod();
syn String MSendDefinition.writeMethod() = getSendToMqttDefinition().writeMethod();
syn String MSendDefinition.tokenResetMethod() = getSendToMqttDefinition().tokenResetMethod();
// --- MMappingDefinition ---
syn String MMappingDefinition.toType() = getMappingDefinition().getToType().prettyPrint();
......@@ -108,14 +109,15 @@ aspect AttributesForMustache {
syn String MDependencyDefinition.dependencyMethod() = getDependencyDefinition().dependencyMethod();
syn String MDependencyDefinition.sourceParentTypeName() = getDependencyDefinition().getSource().containingTypeDecl().getName();
syn String MDependencyDefinition.internalRelationPrefix() = getDependencyDefinition().internalRelationPrefix();
syn nta MUpdateDefinition MDependencyDefinition.targetUpdateDefinition() {
return getDependencyDefinition().targetUpdateDefinition().toMustache();
syn nta MEndpointDefinition MDependencyDefinition.targetEndpointDefinition() {
return getDependencyDefinition().targetEndpointDefinition().toMustache();
}
// --- MTypeComponent ---
syn String MTypeComponent.name() = getTypeComponent().getName();
inh String MTypeComponent.mqttHandlerAttribute();
inh String MTypeComponent.mqttHandlerField();
inh boolean MTypeComponent.isFirst();
// --- MTokenComponent ---
syn String MTokenComponent.parentTypeName() = getTokenComponent().containingTypeDecl().getName();
......@@ -124,14 +126,14 @@ aspect AttributesForMustache {
syn String MTokenComponent.internalName() = getTokenComponent().internalName();
// --- toMustache ---
syn lazy MRos2Rag Ros2Rag.toMustache() {
MRos2Rag result = new MRos2Rag();
result.setRos2Rag(this);
for (UpdateDefinition def : getUpdateDefinitionList()) {
if (def.isWriteToMqttDefinition()) {
result.addWriteDefinition(def.asWriteToMqttDefinition().toMustache());
syn lazy MRagConnect RagConnect.toMustache() {
MRagConnect result = new MRagConnect();
result.setRagConnect(this);
for (EndpointDefinition def : getEndpointDefinitionList()) {
if (def.isSendToMqttDefinition()) {
result.addSendDefinition(def.asSendToMqttDefinition().toMustache());
} else {
result.addReadDefinition(def.asReadFromMqttDefinition().toMustache());
result.addReceiveDefinition(def.asReceiveFromMqttDefinition().toMustache());
}
}
for (MappingDefinition def : allMappingDefinitions()) {
......@@ -154,22 +156,22 @@ aspect AttributesForMustache {
}
//MInnerMappingDefinition.MappingDefinition -> MappingDefinition;
protected void MUpdateDefinition.addInnerMappings() {
for (MappingDefinition def : updateDef().effectiveMappings()) {
protected void MEndpointDefinition.addInnerMappings() {
for (MappingDefinition def : endpointDef().effectiveMappings()) {
MInnerMappingDefinition inner = new MInnerMappingDefinition();
inner.setMappingDefinition(def);
addInnerMappingDefinition(inner);
}
}
syn lazy MReadDefinition ReadFromMqttDefinition.toMustache() {
MReadDefinition result = new MReadDefinition();
result.setReadFromMqttDefinition(this);
syn lazy MReceiveDefinition ReceiveFromMqttDefinition.toMustache() {
MReceiveDefinition result = new MReceiveDefinition();
result.setReceiveFromMqttDefinition(this);
result.addInnerMappings();
return result;
}
syn lazy MWriteDefinition WriteToMqttDefinition.toMustache() {
MWriteDefinition result = new MWriteDefinition();
result.setWriteToMqttDefinition(this);
syn lazy MSendDefinition SendToMqttDefinition.toMustache() {
MSendDefinition result = new MSendDefinition();
result.setSendToMqttDefinition(this);
result.addInnerMappings();
return result;
}
......@@ -203,12 +205,12 @@ aspect AspectGeneration {
syn String TokenComponent.internalName() = getDependencySourceDefinitionList().isEmpty() ? externalName() : "_internal_" + getName();
syn String TokenComponent.externalName() = getName();
syn String TokenUpdateDefinition.connectMethod() = "connect" + getToken().getName();
syn String WriteToMqttDefinition.writeTopic() = "_topic_" + getToken().getName();
syn String WriteToMqttDefinition.lastValue() = "_lastValue" + getToken().getName();
syn String WriteToMqttDefinition.updateMethod() = "_update_" + getToken().getName();
syn String WriteToMqttDefinition.writeMethod() = "_writeLastValue_" + getToken().getName();
syn String WriteToMqttDefinition.tokenResetMethod() = "get" + getToken().getName() + "_reset";
syn String TokenEndpointDefinition.connectMethod() = "connect" + getToken().getName();
syn String SendToMqttDefinition.sendTopic() = "_topic_" + getToken().getName();
syn String SendToMqttDefinition.lastValue() = "_lastValue" + getToken().getName();
syn String SendToMqttDefinition.updateMethod() = "_update_" + getToken().getName();
syn String SendToMqttDefinition.writeMethod() = "_writeLastValue_" + getToken().getName();
syn String SendToMqttDefinition.tokenResetMethod() = "get" + getToken().getName() + "_reset";
syn String MappingDefinition.methodName() = "_apply_" + getID();
syn String DependencyDefinition.dependencyMethod() = "add" +
Character.toUpperCase(getID().charAt(0)) +
......@@ -216,29 +218,29 @@ aspect AspectGeneration {
syn String DependencyDefinition.internalRelationPrefix() = "_internal_" + getID();
syn String DependencyDefinition.internalTokenName() = getSource().internalName();
syn String Ros2Rag.mqttHandlerAttribute() = "_mqttHandler";
syn String Ros2Rag.mqttHandlerField() = "_mqttHandler";
syn String RagConnect.mqttHandlerAttribute() = "_mqttHandler";
syn String RagConnect.mqttHandlerField() = "_mqttHandler";