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

Renaming ros2rag.{base,tests} to ragconnect.{base,tests}.

- rename nonterminal (M)Ros2Rag to (M)RagConnect, and attribute ros2rag to ragconnect
- rename starter to safety
- make receiverstub, receiverstub not depend on safety
- make tests not depend on common (copied proto files)
parent 07accb5e
...@@ -3,7 +3,7 @@ apply plugin: 'application' ...@@ -3,7 +3,7 @@ apply plugin: 'application'
sourceCompatibility = 1.8 sourceCompatibility = 1.8
mainClassName = 'org.jastadd.ros2rag.compiler.Compiler' mainClassName = 'org.jastadd.ragconnect.compiler.Compiler'
repositories { repositories {
jcenter() jcenter()
...@@ -37,7 +37,7 @@ test { ...@@ -37,7 +37,7 @@ test {
jar { jar {
manifest { manifest {
attributes "Main-Class": 'org.jastadd.ros2rag.compiler.Compiler' attributes "Main-Class": 'org.jastadd.ragconnect.compiler.Compiler'
} }
from { from {
...@@ -51,47 +51,47 @@ task relast(type: JavaExec) { ...@@ -51,47 +51,47 @@ task relast(type: JavaExec) {
doFirst { doFirst {
delete "src/gen/jastadd/*.ast" delete "src/gen/jastadd/*.ast"
delete "src/gen/jastadd/Ros2Rag.jadd" delete "src/gen/jastadd/RagConnect.jadd"
delete "src/gen/jastadd/Ros2RagRefResolver.jadd" delete "src/gen/jastadd/RagConnectRefResolver.jadd"
delete "src/gen/jastadd/Ros2RagResolverStubs.jrag" delete "src/gen/jastadd/RagConnectResolverStubs.jrag"
mkdir "src/gen/jastadd/" mkdir "src/gen/jastadd/"
} }
args = [ args = [
"../libs/relast.jar", "../libs/relast.jar",
"../relast.preprocessor/src/main/jastadd/RelAst.relast", "../relast.preprocessor/src/main/jastadd/RelAst.relast",
"./src/main/jastadd/Ros2Rag.relast", "./src/main/jastadd/RagConnect.relast",
"./src/main/jastadd/MustacheNodes.relast", "./src/main/jastadd/MustacheNodes.relast",
"--listClass=java.util.ArrayList", "--listClass=java.util.ArrayList",
"--jastAddList=JastAddList", "--jastAddList=JastAddList",
"--useJastAddNames", "--useJastAddNames",
"--file", "--file",
"--resolverHelper", "--resolverHelper",
"--grammarName=./src/gen/jastadd/Ros2Rag" "--grammarName=./src/gen/jastadd/RagConnect"
] ]
inputs.files file("../libs/relast.jar"), inputs.files file("../libs/relast.jar"),
file("../relast.preprocessor/src/main/jastadd/RelAST.relast"), 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") file("./src/main/jastadd/MustacheNodes.relast")
outputs.files file("./src/gen/jastadd/Ros2Rag.ast"), outputs.files file("./src/gen/jastadd/RagConnect.ast"),
file("./src/gen/jastadd/Ros2Rag.jadd"), file("./src/gen/jastadd/RagConnect.jadd"),
file("./src/gen/jastadd/Ros2RagRefResolver.jadd"), file("./src/gen/jastadd/RagConnectRefResolver.jadd"),
file('./src/gen/jastadd/Ros2RagResolverStubs.jrag') file('./src/gen/jastadd/RagConnectResolverStubs.jrag')
} }
jastadd { jastadd {
configureModuleBuild() configureModuleBuild()
modules { modules {
//noinspection GroovyAssignabilityCheck //noinspection GroovyAssignabilityCheck
module("Ros2Rag") { module("RagConnect") {
java { java {
basedir ".." basedir ".."
include "relast.preprocessor/main/**/*.java" include "relast.preprocessor/main/**/*.java"
include "relast.preprocessor/gen/**/*.java" include "relast.preprocessor/gen/**/*.java"
include "ros2rag.base/src/main/**/*.java" include "ragconnect.base/src/main/**/*.java"
include "ros2rag.base/src/gen/**/*.java" include "ragconnect.base/src/gen/**/*.java"
} }
jastadd { jastadd {
...@@ -99,23 +99,23 @@ jastadd { ...@@ -99,23 +99,23 @@ jastadd {
include "relast.preprocessor/src/main/jastadd/**/*.ast" include "relast.preprocessor/src/main/jastadd/**/*.ast"
include "relast.preprocessor/src/main/jastadd/**/*.jadd" include "relast.preprocessor/src/main/jastadd/**/*.jadd"
include "relast.preprocessor/src/main/jastadd/**/*.jrag" include "relast.preprocessor/src/main/jastadd/**/*.jrag"
include "ros2rag.base/src/main/jastadd/**/*.ast" include "ragconnect.base/src/main/jastadd/**/*.ast"
include "ros2rag.base/src/main/jastadd/**/*.jadd" include "ragconnect.base/src/main/jastadd/**/*.jadd"
include "ros2rag.base/src/main/jastadd/**/*.jrag" include "ragconnect.base/src/main/jastadd/**/*.jrag"
include "ros2rag.base/src/gen/jastadd/**/*.ast" include "ragconnect.base/src/gen/jastadd/**/*.ast"
include "ros2rag.base/src/gen/jastadd/**/*.jadd" include "ragconnect.base/src/gen/jastadd/**/*.jadd"
include "ros2rag.base/src/gen/jastadd/**/*.jrag" include "ragconnect.base/src/gen/jastadd/**/*.jrag"
} }
scanner { scanner {
basedir ".." 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/Preamble.flex", [-4]
include "relast.preprocessor/src/main/jastadd/scanner/Macros.flex", [-3] 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 "relast.preprocessor/src/main/jastadd/scanner/RulesPreamble.flex", [-2]
include "ros2rag.base/src/main/jastadd/scanner/MappingContent.flex", [-1] include "ragconnect.base/src/main/jastadd/scanner/MappingContent.flex", [-1]
include "ros2rag.base/src/main/jastadd/scanner/Keywords.flex" 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/Keywords.flex"
include "relast.preprocessor/src/main/jastadd/scanner/Symbols.flex", [1] include "relast.preprocessor/src/main/jastadd/scanner/Symbols.flex", [1]
include "relast.preprocessor/src/main/jastadd/scanner/RulesPostamble.flex", [2] include "relast.preprocessor/src/main/jastadd/scanner/RulesPostamble.flex", [2]
...@@ -123,8 +123,8 @@ jastadd { ...@@ -123,8 +123,8 @@ jastadd {
parser { parser {
basedir ".." basedir ".."
include "ros2rag.base/src/main/jastadd/parser/Preamble.parser" include "ragconnect.base/src/main/jastadd/parser/Preamble.parser"
include "ros2rag.base/src/main/jastadd/parser/Ros2Rag.parser" include "ragconnect.base/src/main/jastadd/parser/RagConnect.parser"
include "relast.preprocessor/src/main/jastadd/parser/RelAst.parser" include "relast.preprocessor/src/main/jastadd/parser/RelAst.parser"
} }
} }
...@@ -141,18 +141,18 @@ jastadd { ...@@ -141,18 +141,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' genDir = 'src/gen/java'
buildInfoDir = 'src/gen-res' buildInfoDir = 'src/gen-res'
scanner.genDir = "src/gen/java/org/jastadd/ros2rag/scanner" scanner.genDir = "src/gen/java/org/jastadd/ragconnect/scanner"
parser.genDir = "src/gen/java/org/jastadd/ros2rag/parser" parser.genDir = "src/gen/java/org/jastadd/ragconnect/parser"
jastaddOptions = ["--lineColumnNumbers", "--List=JastAddList", "--safeLazy", "--visitCheck=true", "--rewrite=cnta", "--cache=all"] jastaddOptions = ["--lineColumnNumbers", "--List=JastAddList", "--safeLazy", "--visitCheck=true", "--rewrite=cnta", "--cache=all"]
} }
......
aspect Analysis { aspect Analysis {
// --- lookupTokenUpdateDefinition --- // --- lookupTokenUpdateDefinition ---
inh TokenUpdateDefinition TokenUpdateDefinition.lookupTokenUpdateDefinition(TokenComponent token); inh TokenUpdateDefinition TokenUpdateDefinition.lookupTokenUpdateDefinition(TokenComponent token);
eq Ros2Rag.getUpdateDefinition().lookupTokenUpdateDefinition(TokenComponent token) { eq RagConnect.getUpdateDefinition().lookupTokenUpdateDefinition(TokenComponent token) {
for (UpdateDefinition def : getUpdateDefinitionList()) { for (UpdateDefinition def : getUpdateDefinitionList()) {
if (def.isTokenUpdateDefinition() && def.asTokenUpdateDefinition().getToken().equals(token)) { if (def.isTokenUpdateDefinition() && def.asTokenUpdateDefinition().getToken().equals(token)) {
return def.asTokenUpdateDefinition(); return def.asTokenUpdateDefinition();
...@@ -12,7 +12,7 @@ aspect Analysis { ...@@ -12,7 +12,7 @@ aspect Analysis {
// --- lookupDependencyDefinition --- // --- lookupDependencyDefinition ---
inh DependencyDefinition DependencyDefinition.lookupDependencyDefinition(TypeDecl source, String id); 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()) { for (DependencyDefinition def : getDependencyDefinitionList()) {
if (def.getID().equals(id) && def.getSource().containingTypeDecl().equals(source)) { if (def.getID().equals(id) && def.getSource().containingTypeDecl().equals(source)) {
return def; return def;
......
...@@ -3,17 +3,17 @@ import java.util.TreeSet; ...@@ -3,17 +3,17 @@ import java.util.TreeSet;
import java.util.LinkedList; import java.util.LinkedList;
aspect Errors { aspect Errors {
coll Set<ErrorMessage> Ros2Rag.errors() coll Set<ErrorMessage> RagConnect.errors()
[new TreeSet<ErrorMessage>()] [new TreeSet<ErrorMessage>()]
root Ros2Rag; root RagConnect;
ReadFromMqttDefinition contributes error("Read definition already defined for " + getToken().getName()) ReadFromMqttDefinition contributes error("Read definition already defined for " + getToken().getName())
when isAlreadyDefined() when isAlreadyDefined()
to Ros2Rag.errors(); to RagConnect.errors();
ReadFromMqttDefinition contributes error("Reading target token must not be an NTA token!") ReadFromMqttDefinition contributes error("Reading target token must not be an NTA token!")
when getToken().getNTA() when getToken().getNTA()
to Ros2Rag.errors(); to RagConnect.errors();
// if first mapping is null, then suitableDefaultMapping() == null // if first mapping is null, then suitableDefaultMapping() == null
ReadFromMqttDefinition contributes error("No suitable default mapping found for type " + ReadFromMqttDefinition contributes error("No suitable default mapping found for type " +
...@@ -21,32 +21,32 @@ aspect Errors { ...@@ -21,32 +21,32 @@ aspect Errors {
? getToken().getJavaTypeUse().prettyPrint() ? getToken().getJavaTypeUse().prettyPrint()
: getMappingList().get(0).getFromType().prettyPrint())) : getMappingList().get(0).getFromType().prettyPrint()))
when effectiveMappings().get(0) == null 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!") ReadFromMqttDefinition contributes error("to-type of last mapping must be type of the Token!")
when getToken().getJavaTypeUse().prettyPrint().equals( when getToken().getJavaTypeUse().prettyPrint().equals(
effectiveMappings().get(effectiveMappings().size() - 1)) effectiveMappings().get(effectiveMappings().size() - 1))
to Ros2Rag.errors(); to RagConnect.errors();
WriteToMqttDefinition contributes error("Writing target token must be an NTA token!") WriteToMqttDefinition contributes error("Writing target token must be an NTA token!")
when !getToken().getNTA() when !getToken().getNTA()
to Ros2Rag.errors(); to RagConnect.errors();
WriteToMqttDefinition contributes error("Write definition already defined for " + getToken().getName()) WriteToMqttDefinition contributes error("Write definition already defined for " + getToken().getName())
when isAlreadyDefined() when isAlreadyDefined()
to Ros2Rag.errors(); to RagConnect.errors();
DependencyDefinition contributes error("Dependency definition already defined for " + getSource().containingTypeDecl().getName() + " with name " + getID()) DependencyDefinition contributes error("Dependency definition already defined for " + getSource().containingTypeDecl().getName() + " with name " + getID())
when isAlreadyDefined() 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") DependencyDefinition contributes error("The name of a dependency definition must not be equal to a list-node on the source")
when isAlreadyDefinedAsList() 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()) DependencyDefinition contributes error("There must be a write update definition targeting " + getSource().parentTypeypeAndName() + " for dependency definition " + getID())
when targetUpdateDefinition() == null when targetUpdateDefinition() == null
to Ros2Rag.errors(); to RagConnect.errors();
} }
aspect ErrorHelpers { aspect ErrorHelpers {
......
//TypeComponentMustache ; //TypeComponentMustache ;
//rel TypeComponentMustache.TypeComponent -> TypeComponent ; //rel TypeComponentMustache.TypeComponent -> TypeComponent ;
MRos2Rag ::= ReadDefinition:MReadDefinition* WriteDefinition:MWriteDefinition* MappingDefinition:MMappingDefinition* DependencyDefinition:MDependencyDefinition* RootTypeComponent:MTypeComponent* TokenComponent:MTokenComponent*; MRagConnect ::= ReadDefinition:MReadDefinition* WriteDefinition:MWriteDefinition* MappingDefinition:MMappingDefinition* DependencyDefinition:MDependencyDefinition* RootTypeComponent:MTypeComponent* TokenComponent:MTokenComponent*;
abstract MUpdateDefinition ::= InnerMappingDefinition:MInnerMappingDefinition*; abstract MUpdateDefinition ::= InnerMappingDefinition:MInnerMappingDefinition*;
MReadDefinition : MUpdateDefinition; MReadDefinition : MUpdateDefinition;
MWriteDefinition : MUpdateDefinition; MWriteDefinition : MUpdateDefinition;
...@@ -11,7 +11,7 @@ MDependencyDefinition; ...@@ -11,7 +11,7 @@ MDependencyDefinition;
MTypeComponent; MTypeComponent;
MTokenComponent; MTokenComponent;
rel MRos2Rag.Ros2Rag -> Ros2Rag; rel MRagConnect.RagConnect -> RagConnect;
rel MInnerMappingDefinition.MappingDefinition -> MappingDefinition; rel MInnerMappingDefinition.MappingDefinition -> MappingDefinition;
rel MReadDefinition.ReadFromMqttDefinition -> ReadFromMqttDefinition; rel MReadDefinition.ReadFromMqttDefinition -> ReadFromMqttDefinition;
rel MWriteDefinition.WriteToMqttDefinition -> WriteToMqttDefinition; rel MWriteDefinition.WriteToMqttDefinition -> WriteToMqttDefinition;
......
...@@ -2,7 +2,7 @@ aspect NameResolution { ...@@ -2,7 +2,7 @@ aspect NameResolution {
refine RefResolverStubs eq UpdateDefinition.resolveMappingByToken(String id, int position) { refine RefResolverStubs eq UpdateDefinition.resolveMappingByToken(String id, int position) {
// return a MappingDefinition // return a MappingDefinition
for (MappingDefinition mappingDefinition : ros2rag().getMappingDefinitionList()) { for (MappingDefinition mappingDefinition : ragconnect().getMappingDefinitionList()) {
if (mappingDefinition.getID().equals(id)) { if (mappingDefinition.getID().equals(id)) {
return mappingDefinition; return mappingDefinition;
} }
......
aspect Navigation { aspect Navigation {
// --- program --- // --- program ---
eq Ros2Rag.getChild().program() = getProgram(); eq RagConnect.getChild().program() = getProgram();
eq MRos2Rag.getChild().program() = getRos2Rag().program(); eq MRagConnect.getChild().program() = getRagConnect().program();
// --- ros2rag --- // --- ragconnect ---
inh Ros2Rag ASTNode.ros2rag(); inh RagConnect ASTNode.ragconnect();
eq Ros2Rag.getChild().ros2rag() = this; eq RagConnect.getChild().ragconnect() = this;
eq MRos2Rag.getChild().ros2rag() = getRos2Rag(); eq MRagConnect.getChild().ragconnect() = getRagConnect();
// --- containedFile (first equation should be in preprocessor) --- // --- containedFile (first equation should be in preprocessor) ---
eq Program.getChild().containedFile() = null; eq Program.getChild().containedFile() = null;
eq Ros2Rag.getChild().containedFile() = null; eq RagConnect.getChild().containedFile() = null;
// --- isTypeComponent (should be in preprocessor) --- // --- isTypeComponent (should be in preprocessor) ---
syn boolean Component.isTypeComponent() = false; syn boolean Component.isTypeComponent() = false;
...@@ -32,9 +32,9 @@ aspect Navigation { ...@@ -32,9 +32,9 @@ aspect Navigation {
// --- containedFileName (should replace containedFile in preprocessor) --- // --- containedFileName (should replace containedFile in preprocessor) ---
inh String ASTNode.containedFileName(); inh String ASTNode.containedFileName();
eq GrammarFile.getChild().containedFileName() = getFileName(); eq GrammarFile.getChild().containedFileName() = getFileName();
eq Ros2Rag.getChild().containedFileName() = getFileName(); eq RagConnect.getChild().containedFileName() = getFileName();
eq Program.getChild().containedFileName() = null; eq Program.getChild().containedFileName() = null;
eq MRos2Rag.getChild().containedFileName() = null; eq MRagConnect.getChild().containedFileName() = null;
// --- isTokenUpdateDefinition --- // --- isTokenUpdateDefinition ---
syn boolean UpdateDefinition.isTokenUpdateDefinition() = false; syn boolean UpdateDefinition.isTokenUpdateDefinition() = false;
...@@ -59,7 +59,7 @@ aspect Navigation { ...@@ -59,7 +59,7 @@ aspect Navigation {
// --- targetUpdateDefinition --- // --- targetUpdateDefinition ---
syn WriteToMqttDefinition DependencyDefinition.targetUpdateDefinition() { syn WriteToMqttDefinition DependencyDefinition.targetUpdateDefinition() {
// resolve definition in here, as we do not need resolveMethod in any other place (yet) // resolve definition in here, as we do not need resolveMethod in any other place (yet)
for (UpdateDefinition updateDefinition : ros2rag().getUpdateDefinitionList()) { for (UpdateDefinition updateDefinition : ragconnect().getUpdateDefinitionList()) {
if (updateDefinition.isWriteToMqttDefinition() && if (updateDefinition.isWriteToMqttDefinition() &&
updateDefinition.asWriteToMqttDefinition().getToken().equals(this.getTarget())) { updateDefinition.asWriteToMqttDefinition().getToken().equals(this.getTarget())) {
return updateDefinition.asWriteToMqttDefinition(); return updateDefinition.asWriteToMqttDefinition();
......
Ros2Rag ::= UpdateDefinition* DependencyDefinition* MappingDefinition* Program <FileName> ; RagConnect ::= UpdateDefinition* DependencyDefinition* MappingDefinition* Program <FileName> ;
abstract UpdateDefinition ::= <AlwaysApply:boolean> ; abstract UpdateDefinition ::= <AlwaysApply:boolean> ;
......
...@@ -26,15 +26,16 @@ aspect GenerationUtils { ...@@ -26,15 +26,16 @@ aspect GenerationUtils {
*/ */
aspect AttributesForMustache { aspect AttributesForMustache {
// --- MRos2Rag --- // --- MRagConnect ---
eq MRos2Rag.getChild().mqttHandlerAttribute() = mqttHandlerAttribute(); eq MRagConnect.getChild().mqttHandlerAttribute() = mqttHandlerAttribute();
eq MRos2Rag.getChild().mqttHandlerField() = mqttHandlerField(); eq MRagConnect.getChild().mqttHandlerField() = mqttHandlerField();
eq MRagConnect.getRootTypeComponent(int i).isFirst() = i == 0;
syn String MRos2Rag.mqttHandlerAttribute() = getRos2Rag().mqttHandlerAttribute(); syn String MRagConnect.mqttHandlerAttribute() = getRagConnect().mqttHandlerAttribute();
syn String MRos2Rag.mqttHandlerField() = getRos2Rag().mqttHandlerField(); syn String MRagConnect.mqttHandlerField() = getRagConnect().mqttHandlerField();
syn String MRos2Rag.mqttSetHostMethod() = getRos2Rag().mqttSetHostMethod(); syn String MRagConnect.mqttSetHostMethod() = getRagConnect().mqttSetHostMethod();
syn String MRos2Rag.mqttWaitUntilReadyMethod() = getRos2Rag().mqttWaitUntilReadyMethod(); syn String MRagConnect.mqttWaitUntilReadyMethod() = getRagConnect().mqttWaitUntilReadyMethod();
syn String MRos2Rag.mqttCloseMethod() = getRos2Rag().mqttCloseMethod(); syn String MRagConnect.mqttCloseMethod() = getRagConnect().mqttCloseMethod();
// --- MUpdateDefinition --- // --- MUpdateDefinition ---
syn String MUpdateDefinition.preemptiveExpectedValue(); syn String MUpdateDefinition.preemptiveExpectedValue();
...@@ -116,6 +117,7 @@ aspect AttributesForMustache { ...@@ -116,6 +117,7 @@ aspect AttributesForMustache {
syn String MTypeComponent.name() = getTypeComponent().getName(); syn String MTypeComponent.name() = getTypeComponent().getName();
inh String MTypeComponent.mqttHandlerAttribute(); inh String MTypeComponent.mqttHandlerAttribute();
inh String MTypeComponent.mqttHandlerField(); inh String MTypeComponent.mqttHandlerField();
inh boolean MTypeComponent.isFirst();
// --- MTokenComponent --- // --- MTokenComponent ---
syn String MTokenComponent.parentTypeName() = getTokenComponent().containingTypeDecl().getName(); syn String MTokenComponent.parentTypeName() = getTokenComponent().containingTypeDecl().getName();
...@@ -124,9 +126,9 @@ aspect AttributesForMustache { ...@@ -124,9 +126,9 @@ aspect AttributesForMustache {
syn String MTokenComponent.internalName() = getTokenComponent().internalName(); syn String MTokenComponent.internalName() = getTokenComponent().internalName();
// --- toMustache --- // --- toMustache ---
syn lazy MRos2Rag Ros2Rag.toMustache() { syn lazy MRagConnect RagConnect.toMustache() {
MRos2Rag result = new MRos2Rag(); MRagConnect result = new MRagConnect();
result.setRos2Rag(this); result.setRagConnect(this);
for (UpdateDefinition def : getUpdateDefinitionList()) { for (UpdateDefinition def : getUpdateDefinitionList()) {
if (def.isWriteToMqttDefinition()) { if (def.isWriteToMqttDefinition()) {
result.addWriteDefinition(def.asWriteToMqttDefinition().toMustache()); result.addWriteDefinition(def.asWriteToMqttDefinition().toMustache());
...@@ -216,29 +218,29 @@ aspect AspectGeneration { ...@@ -216,29 +218,29 @@ aspect AspectGeneration {
syn String DependencyDefinition.internalRelationPrefix() = "_internal_" + getID(); syn String DependencyDefinition.internalRelationPrefix() = "_internal_" + getID();
syn String DependencyDefinition.internalTokenName() = getSource().internalName(); syn String DependencyDefinition.internalTokenName() = getSource().internalName();
syn String Ros2Rag.mqttHandlerAttribute() = "_mqttHandler"; syn String RagConnect.mqttHandlerAttribute() = "_mqttHandler";
syn String Ros2Rag.mqttHandlerField() = "_mqttHandler"; syn String RagConnect.mqttHandlerField() = "_mqttHandler";
syn String Ros2Rag.mqttSetHostMethod() = "MqttSetHost"; syn String RagConnect.mqttSetHostMethod() = "MqttSetHost";
syn String Ros2Rag.mqttWaitUntilReadyMethod() = "MqttWaitUntilReady"; syn String RagConnect.mqttWaitUntilReadyMethod() = "MqttWaitUntilReady";
syn String Ros2Rag.mqttCloseMethod() = "MqttCloseConnections"; syn String RagConnect.mqttCloseMethod() = "MqttCloseConnections";
// naming copy attributes // naming copy attributes
// --- mqttHandlerAttribute --- // --- mqttHandlerAttribute ---
inh String UpdateDefinition.mqttHandlerAttribute(); inh String UpdateDefinition.mqttHandlerAttribute();
inh String MappingDefinition.mqttHandlerAttribute(); inh String MappingDefinition.mqttHandlerAttribute();
inh String DependencyDefinition.mqttHandlerAttribute(); inh String DependencyDefinition.mqttHandlerAttribute();
eq Ros2Rag.getChild().mqttHandlerAttribute() = mqttHandlerAttribute(); eq RagConnect.getChild().mqttHandlerAttribute() = mqttHandlerAttribute();
// --- rootNodeName --- // --- rootNodeName ---
syn String ASTNode.rootNodeName() = rootNode.getName(); syn String ASTNode.rootNodeName() = rootNode.getName();
public String Ros2Rag.generateAspect(String rootNodeName) { public String RagConnect.generateAspect(String rootNodeName) {
rootNode = getProgram().resolveTypeDecl(rootNodeName); rootNode = getProgram().resolveTypeDecl(rootNodeName);
return toMustache().generateAspect(); return toMustache().generateAspect();
} }
public String MRos2Rag.generateAspect() { public String MRagConnect.generateAspect() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
com.github.mustachejava.reflect.ReflectionObjectHandler roh = new com.github.mustachejava.reflect.ReflectionObjectHandler() { com.github.mustachejava.reflect.ReflectionObjectHandler roh = new com.github.mustachejava.reflect.ReflectionObjectHandler() {
@Override @Override
...@@ -257,14 +259,14 @@ aspect AspectGeneration { ...@@ -257,14 +259,14 @@ aspect AspectGeneration {
}; };
com.github.mustachejava.DefaultMustacheFactory mf = new com.github.mustachejava.DefaultMustacheFactory(); com.github.mustachejava.DefaultMustacheFactory mf = new com.github.mustachejava.DefaultMustacheFactory();
mf.setObjectHandler(roh); mf.setObjectHandler(roh);
com.github.mustachejava.Mustache m = mf.compile("ros2rag.mustache"); com.github.mustachejava.Mustache m = mf.compile("ragconnect.mustache");
m.execute(new java.io.PrintWriter(new org.jastadd.ros2rag.compiler.AppendableWriter(sb)), this); m.execute(new java.io.PrintWriter(new org.jastadd.ragconnect.compiler.AppendableWriter(sb)), this);
return sb.toString(); return sb.toString();
} }
} }
aspect RelationGeneration { aspect RelationGeneration {
syn java.util.List<Relation> Ros2Rag.additionalRelations() { syn java.util.List<Relation> RagConnect.additionalRelations() {
java.util.List<Relation> result = new java.util.ArrayList<>(); java.util.List<Relation> result = new java.util.ArrayList<>();
for (DependencyDefinition dd : getDependencyDefinitionList()) { for (DependencyDefinition dd : getDependencyDefinitionList()) {
result.add(dd.getRelationToCreate()); result.add(dd.getRelationToCreate());
......
aspect DefaultMappings { aspect DefaultMappings {
private DefaultMappingDefinition Ros2Rag.baseDefaultMappingDefinitionFromBytes(String typeName) { private DefaultMappingDefinition RagConnect.baseDefaultMappingDefinitionFromBytes(String typeName) {
DefaultMappingDefinition result = new DefaultMappingDefinition(); DefaultMappingDefinition result = new DefaultMappingDefinition();
result.setID("_DefaultBytesTo" + Character.toUpperCase(typeName.charAt(0)) + typeName.substring(1) + "Mapping"); result.setID("_DefaultBytesTo" + Character.toUpperCase(typeName.charAt(0)) + typeName.substring(1) + "Mapping");
result.setFromType(new JavaArrayMappingDefinitionType(new SimpleJavaTypeUse("byte"))); result.setFromType(new JavaArrayMappingDefinitionType(new SimpleJavaTypeUse("byte")));
...@@ -9,7 +9,7 @@ aspect DefaultMappings { ...@@ -9,7 +9,7 @@ aspect DefaultMappings {
return result; return result;
} }
private DefaultMappingDefinition Ros2Rag.baseDefaultMappingDefinitionToBytes(String typeName) { private DefaultMappingDefinition RagConnect.baseDefaultMappingDefinitionToBytes(String typeName) {
DefaultMappingDefinition result = new DefaultMappingDefinition(); DefaultMappingDefinition result = new DefaultMappingDefinition();
result.setID("_Default" + Character.toUpperCase(typeName.charAt(0)) + typeName.substring(1) + "ToBytesMapping"); result.setID("_Default" + Character.toUpperCase(typeName.charAt(0)) + typeName.substring(1) + "ToBytesMapping");
result.setFromType(new JavaMappingDefinitionType(new SimpleJavaTypeUse(typeName))); result.setFromType(new JavaMappingDefinitionType(new SimpleJavaTypeUse(typeName)));
...@@ -18,85 +18,85 @@ aspect DefaultMappings { ...@@ -18,85 +18,85 @@ aspect DefaultMappings {
return result; return result;
} }
syn nta DefaultMappingDefinition Ros2Rag.defaultBytesToIntMapping() { syn nta DefaultMappingDefinition RagConnect.defaultBytesToIntMapping() {
DefaultMappingDefinition result = baseDefaultMappingDefinitionFromBytes("int"); DefaultMappingDefinition result = baseDefaultMappingDefinitionFromBytes("int");
result.setContent("return java.nio.ByteBuffer.wrap(bytes).getInt();"); result.setContent("return java.nio.ByteBuffer.wrap(bytes).getInt();");
return result; return result;
} }
syn nta DefaultMappingDefinition Ros2Rag.defaultBytesToShortMapping() { syn nta DefaultMappingDefinition RagConnect.defaultBytesToShortMapping() {
DefaultMappingDefinition result = baseDefaultMappingDefinitionFromBytes("short"); DefaultMappingDefinition result = baseDefaultMappingDefinitionFromBytes("short");
result.setContent("return java.nio.ByteBuffer.wrap(bytes).getShort();"); result.setContent("return java.nio.ByteBuffer.wrap(bytes).getShort();");
return result; return result;
} }
syn nta DefaultMappingDefinition Ros2Rag.defaultBytesToLongMapping() { syn nta DefaultMappingDefinition RagConnect.defaultBytesToLongMapping() {
DefaultMappingDefinition result = baseDefaultMappingDefinitionFromBytes("long"); DefaultMappingDefinition result = baseDefaultMappingDefinitionFromBytes("long");
result.setContent("return java.nio.ByteBuffer.wrap(bytes).getLong();"); result.setContent("return java.nio.ByteBuffer.wrap(bytes).getLong();");
return result; return result;
} } <