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

More cleanup

parent 5757b0c0
......@@ -5,9 +5,6 @@ Design considerations
aspect AttributesForMustache {
// --- MRagConnect ---
eq MRagConnect.getChild().mqttHandlerAttribute() = mqttHandlerAttribute();
eq MRagConnect.getChild().restHandlerAttribute() = restHandlerAttribute();
eq MRagConnect.getChild().mqttHandlerField() = mqttHandlerField();
eq MRagConnect.getRootTypeComponent(int i).isFirst() = i == 0;
syn String MRagConnect.closeMethod() = "ragconnectCloseConnections";
......@@ -25,20 +22,17 @@ aspect AttributesForMustache {
syn String MEndpointDefinition.firstInputVarName();
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).methodName();
eq MEndpointDefinition.getInnerMappingDefinition(int i).inputVarName() = i == 0 ? firstInputVarName() : getInnerMappingDefinition(i - 1).outputVarName();
syn String MEndpointDefinition.connectParameterName() = "uriString";
syn String MEndpointDefinition.connectMethod() = "connect" + tokenName();
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.lastResult() = lastDefinition().outputVarName();
syn String MEndpointDefinition.condition() {
if (lastDefinition().mappingDef().getToType().isArray()) {
return "java.util.Arrays.equals(" + preemptiveExpectedValue() + ", " + lastResult() + ")";
......@@ -54,11 +48,11 @@ aspect AttributesForMustache {
// --- MInnerMappingDefinition ---
inh boolean MInnerMappingDefinition.isLast();
inh String MInnerMappingDefinition.resultVarPrefix();
inh String MInnerMappingDefinition.inputVarName();
syn String MInnerMappingDefinition.toType() = mappingDef().getToType().prettyPrint();
syn String MInnerMappingDefinition.methodName() = getMMappingDefinition().methodName();
syn MappingDefinition MInnerMappingDefinition.mappingDef() = getMMappingDefinition().getMappingDefinition();
syn String MInnerMappingDefinition.outputVarName() = "result" + methodName(); // we do not need "_" in between here, because methodName begins with one
// --- MReceiveDefinition ---
eq MReceiveDefinition.preemptiveExpectedValue() = "get" + tokenName() + "()";
......@@ -96,8 +90,6 @@ aspect AttributesForMustache {
// --- MTypeComponent ---
syn String MTypeComponent.name() = getTypeComponent().getName();
inh String MTypeComponent.mqttHandlerAttribute();
inh String MTypeComponent.mqttHandlerField();
inh boolean MTypeComponent.isFirst();
// --- MTokenComponent ---
......@@ -138,7 +130,6 @@ aspect AttributesForMustache {
return result;
}
//MInnerMappingDefinition.MappingDefinition -> MappingDefinition;
protected void MEndpointDefinition.addInnerMappings() {
for (MappingDefinition def : endpointDef().effectiveMappings()) {
MInnerMappingDefinition inner = new MInnerMappingDefinition();
......@@ -146,33 +137,39 @@ aspect AttributesForMustache {
addInnerMappingDefinition(inner);
}
}
syn lazy MReceiveDefinition ReceiveTokenEndpointDefinition.toMustache() {
MReceiveDefinition result = new MReceiveDefinition();
result.setReceiveTokenEndpointDefinition(this);
result.addInnerMappings();
return result;
}
syn lazy MSendDefinition SendTokenEndpointDefinition.toMustache() {
MSendDefinition result = new MSendDefinition();
result.setSendTokenEndpointDefinition(this);
result.addInnerMappings();
return result;
}
syn lazy MMappingDefinition MappingDefinition.toMustache() {
MMappingDefinition result = new MMappingDefinition();
result.setMappingDefinition(this);
return result;
}
syn lazy MDependencyDefinition DependencyDefinition.toMustache() {
MDependencyDefinition result = new MDependencyDefinition();
result.setDependencyDefinition(this);
return result;
}
syn lazy MTypeComponent TypeComponent.toMustache() {
MTypeComponent result = new MTypeComponent();
result.setTypeComponent(this);
return result;
}
syn lazy MTokenComponent TokenComponent.toMustache() {
MTokenComponent result = new MTokenComponent();
result.setTokenComponent(this);
......@@ -184,7 +181,6 @@ aspect AttributesForMustache {
}
aspect AspectGeneration {
// --- rootNodeName ---
syn String ASTNode.rootNodeName() = rootNode.getName();
......
......@@ -70,15 +70,13 @@ aspect MustacheNodesToYAML {
result.addKeyValuePair("connectMethod", StringElement.of(connectMethod()));
result.addKeyValuePair("connectParameterName", StringElement.of(connectParameterName()));
result.addKeyValuePair("lastDefinitionToType", StringElement.of(lastDefinitionToType()));
result.addKeyValuePair("resultVarPrefix", StringElement.of(resultVarPrefix()));
result.addKeyValuePair("lastDefinitionName", StringElement.of(lastDefinitionName()));
result.addKeyValuePair("preemptiveReturn", StringElement.of(preemptiveReturn()));
result.addKeyValuePair("alwaysApply", ValueElement.of(alwaysApply()));
result.addKeyValuePair("condition", StringElement.of(
condition().replace("\"", "\\\"").replace("\n", "\\n")));
result.addKeyValuePair("lastResult", StringElement.of(lastResult()));
result.addKeyValuePair("InnerMappingDefinitions", innerMappingDefinitionsAsListElement());
result.addKeyValuePair("tokenName", StringElement.of(tokenName()));
result.addKeyValuePair("InnerMappingDefinitions", innerMappingDefinitionsAsListElement());
return result;
}
......@@ -147,6 +145,7 @@ aspect MustacheNodesToYAML {
inner.addKeyValuePair("toType", StringElement.of(def.toType()));
inner.addKeyValuePair("methodName", StringElement.of(def.methodName()));
inner.addKeyValuePair("inputVarName", StringElement.of(def.inputVarName()));
inner.addKeyValuePair("outputVarName", StringElement.of(def.outputVarName()));
inner.addKeyValuePair("last", ValueElement.of(def.isLast()));
innerMappingDefinitions.addElement(inner);
}
......
{{lastDefinitionToType}} {{resultVarPrefix}}{{lastDefinitionName}};
{{lastDefinitionToType}} {{lastResult}};
try {
{{#InnerMappingDefinitions}}
{{^last}}{{toType}} {{/last}}{{resultVarPrefix}}{{methodName}} = {{methodName}}({{inputVarName}});
{{^last}}{{toType}} {{/last}}{{outputVarName}} = {{methodName}}({{inputVarName}});
{{/InnerMappingDefinitions}}
} catch (Exception e) {
e.printStackTrace();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment