Skip to content
Snippets Groups Projects
Commit 9935a093 authored by René Schöne's avatar René Schöne
Browse files

begin with removing tree and list

- renamed useList to isIndexBasedList (flipped semantics)
- fixed readme of test singeList
parent 5188b017
No related branches found
No related tags found
3 merge requests!39Version 1.1.0,!35Version 1.0.0,!19Resolve "Make specification langauge more concise"
Pipeline #11784 failed
...@@ -13,7 +13,7 @@ rel TokenEndpointDefinition.Token <-> TokenComponent.TokenEndpointDefinition*; ...@@ -13,7 +13,7 @@ rel TokenEndpointDefinition.Token <-> TokenComponent.TokenEndpointDefinition*;
ReceiveTokenEndpointDefinition : TokenEndpointDefinition; ReceiveTokenEndpointDefinition : TokenEndpointDefinition;
SendTokenEndpointDefinition : TokenEndpointDefinition; SendTokenEndpointDefinition : TokenEndpointDefinition;
abstract TypeEndpointDefinition : EndpointDefinition ::= <UseList:boolean> ; abstract TypeEndpointDefinition : EndpointDefinition ::= <IndexBasedListAccess:boolean> ;
rel TypeEndpointDefinition.Type <-> TypeComponent.TypeEndpointDefinition*; rel TypeEndpointDefinition.Type <-> TypeComponent.TypeEndpointDefinition*;
ReceiveTypeEndpointDefinition : TypeEndpointDefinition ::= <WithAdd:boolean>; ReceiveTypeEndpointDefinition : TypeEndpointDefinition ::= <WithAdd:boolean>;
......
...@@ -124,10 +124,10 @@ aspect AttributesForMustache { ...@@ -124,10 +124,10 @@ aspect AttributesForMustache {
// --- MTypeEndpointDefinition --- // --- MTypeEndpointDefinition ---
syn boolean MTypeEndpointDefinition.isWithAdd() = endpointDef().isReceiveTypeEndpointDefinition() ? endpointDef().asReceiveTypeEndpointDefinition().getWithAdd() : false; syn boolean MTypeEndpointDefinition.isWithAdd() = endpointDef().isReceiveTypeEndpointDefinition() ? endpointDef().asReceiveTypeEndpointDefinition().getWithAdd() : false;
syn boolean MTypeEndpointDefinition.isUseList() = endpointDef().asTypeEndpointDefinition().getUseList(); syn boolean MTypeEndpointDefinition.isIndexBasedListAccess() = endpointDef().asTypeEndpointDefinition().getIndexBasedListAccess();
eq MTypeEndpointDefinition.getterMethod() = "get" + typeName() + (typeIsList() ? "List" : ""); eq MTypeEndpointDefinition.getterMethod() = "get" + typeName() + (typeIsList() ? "List" : "");
eq MTypeEndpointDefinition.parentTypeName() = type().containingTypeDecl().getName(); eq MTypeEndpointDefinition.parentTypeName() = type().containingTypeDecl().getName();
eq MTypeEndpointDefinition.entityName() = typeName() + (isUseList() ? "List" : ""); eq MTypeEndpointDefinition.entityName() = typeName() + (typeIsList() && !isIndexBasedListAccess() ? "List" : "");
// --- MInnerMappingDefinition --- // --- MInnerMappingDefinition ---
inh boolean MInnerMappingDefinition.isLast(); inh boolean MInnerMappingDefinition.isLast();
...@@ -398,7 +398,7 @@ aspect GrammarGeneration { ...@@ -398,7 +398,7 @@ aspect GrammarGeneration {
syn TokenComponent EndpointDefinition.getTokenToCreate() = null; syn TokenComponent EndpointDefinition.getTokenToCreate() = null;
eq TypeEndpointDefinition.getTokenToCreate() { eq TypeEndpointDefinition.getTokenToCreate() {
if (typeIsList() && !getUseList()) { if (typeIsList() && getIndexBasedListAccess()) {
TokenComponent result = new TokenComponent(); TokenComponent result = new TokenComponent();
result.setName(idTokenName()); result.setName(idTokenName());
result.setNTA(false); result.setNTA(false);
......
...@@ -220,7 +220,7 @@ aspect Mappings { ...@@ -220,7 +220,7 @@ aspect Mappings {
eq TypeEndpointDefinition.suitableReceiveDefaultMapping() { eq TypeEndpointDefinition.suitableReceiveDefaultMapping() {
try { try {
TypeDecl typeDecl = program().resolveTypeDecl(targetTypeName()); TypeDecl typeDecl = program().resolveTypeDecl(targetTypeName());
return typeIsList() && getUseList() ? ragconnect().defaultBytesToListTreeMapping(typeDecl.getName()) : ragconnect().defaultBytesToTreeMapping(typeDecl.getName()); return typeIsList() && !getIndexBasedListAccess() ? ragconnect().defaultBytesToListTreeMapping(typeDecl.getName()) : ragconnect().defaultBytesToTreeMapping(typeDecl.getName());
} catch (Exception ignore) {} } catch (Exception ignore) {}
return super.suitableReceiveDefaultMapping(); return super.suitableReceiveDefaultMapping();
} }
...@@ -256,7 +256,7 @@ aspect Mappings { ...@@ -256,7 +256,7 @@ aspect Mappings {
eq TypeEndpointDefinition.suitableSendDefaultMapping() { eq TypeEndpointDefinition.suitableSendDefaultMapping() {
try { try {
TypeDecl typeDecl = program().resolveTypeDecl(targetTypeName()); TypeDecl typeDecl = program().resolveTypeDecl(targetTypeName());
return typeIsList() && getUseList() ? ragconnect().defaultListTreeToBytesMapping() : ragconnect().defaultTreeToBytesMapping(typeDecl.getName()); return typeIsList() && !getIndexBasedListAccess() ? ragconnect().defaultListTreeToBytesMapping() : ragconnect().defaultTreeToBytesMapping(typeDecl.getName());
} catch (Exception ignore) {} } catch (Exception ignore) {}
return super.suitableSendDefaultMapping(); return super.suitableSendDefaultMapping();
} }
......
...@@ -4,9 +4,7 @@ aspect ParserRewrites { ...@@ -4,9 +4,7 @@ aspect ParserRewrites {
to SendTypeEndpointDefinition { to SendTypeEndpointDefinition {
SendTypeEndpointDefinition result = new SendTypeEndpointDefinition(); SendTypeEndpointDefinition result = new SendTypeEndpointDefinition();
result.applyFrom(this); result.applyFrom(this);
if (this.getIndexed()) { result.setIndexBasedListAccess(this.getIndexed());
result.setUseList(true);
}
return result; return result;
} }
} }
...@@ -16,12 +14,8 @@ aspect ParserRewrites { ...@@ -16,12 +14,8 @@ aspect ParserRewrites {
to ReceiveTypeEndpointDefinition { to ReceiveTypeEndpointDefinition {
ReceiveTypeEndpointDefinition result = new ReceiveTypeEndpointDefinition(); ReceiveTypeEndpointDefinition result = new ReceiveTypeEndpointDefinition();
result.applyFrom(this); result.applyFrom(this);
if (this.getWithAdd()) { result.setWithAdd(this.getWithAdd());
result.setWithAdd(true); result.setIndexBasedListAccess(this.getIndexed());
}
if (this.getIndexed()) {
result.setUseList(true);
}
return result; return result;
} }
} }
......
{{#typeIsList}} {{#typeIsList}}
{{^UseList}} {{#IndexBasedListAccess}}
private int {{parentTypeName}}.{{resolveInListMethodName}}(String topic) { private int {{parentTypeName}}.{{resolveInListMethodName}}(String topic) {
for (int index = 0; index < getNum{{entityName}}(); index++) { for (int index = 0; index < getNum{{entityName}}(); index++) {
if (get{{entityName}}(index).get{{idTokenName}}().equals(topic)) { if (get{{entityName}}(index).get{{idTokenName}}().equals(topic)) {
...@@ -8,7 +8,7 @@ private int {{parentTypeName}}.{{resolveInListMethodName}}(String topic) { ...@@ -8,7 +8,7 @@ private int {{parentTypeName}}.{{resolveInListMethodName}}(String topic) {
} }
return -1; return -1;
} }
{{/UseList}} {{/IndexBasedListAccess}}
{{/typeIsList}} {{/typeIsList}}
/** /**
...@@ -17,13 +17,13 @@ private int {{parentTypeName}}.{{resolveInListMethodName}}(String topic) { ...@@ -17,13 +17,13 @@ private int {{parentTypeName}}.{{resolveInListMethodName}}(String topic) {
* New values are appended to the end of the list. * New values are appended to the end of the list.
{{/isWithAdd}}{{/typeIsList}} {{/isWithAdd}}{{/typeIsList}}
* @param {{connectParameterName}} string describing protocol and path as an URI * @param {{connectParameterName}} string describing protocol and path as an URI
{{#typeIsList}}{{^UseList}}{{^isWithAdd}} {{#typeIsList}}{{#IndexBasedListAccess}}{{^isWithAdd}}
* @param index index of node in list to connect (the list is expected to have enough elements) * @param index index of node in list to connect (the list is expected to have enough elements)
{{/isWithAdd}}{{/UseList}}{{/typeIsList}} {{/isWithAdd}}{{/IndexBasedListAccess}}{{/typeIsList}}
* @return true if connect was successful, false otherwise * @return true if connect was successful, false otherwise
* @throws java.io.IOException if connect failed * @throws java.io.IOException if connect failed
*/ */
public boolean {{parentTypeName}}.{{connectMethod}}(String {{connectParameterName}}{{#typeIsList}}{{^UseList}}{{^isWithAdd}}, int index{{/isWithAdd}}{{/UseList}}{{/typeIsList}}) throws java.io.IOException { public boolean {{parentTypeName}}.{{connectMethod}}(String {{connectParameterName}}{{#typeIsList}}{{#IndexBasedListAccess}}{{^isWithAdd}}, int index{{/isWithAdd}}{{/IndexBasedListAccess}}{{/typeIsList}}) throws java.io.IOException {
java.util.function.BiConsumer<String, byte[]> consumer = (topic, message) -> { java.util.function.BiConsumer<String, byte[]> consumer = (topic, message) -> {
{{> mappingApplication}} {{> mappingApplication}}
{{#loggingEnabledForReads}} {{#loggingEnabledForReads}}
...@@ -32,15 +32,15 @@ public boolean {{parentTypeName}}.{{connectMethod}}(String {{connectParameterNam ...@@ -32,15 +32,15 @@ public boolean {{parentTypeName}}.{{connectMethod}}(String {{connectParameterNam
{{#isTypeEndpointDefinition}} {{#isTypeEndpointDefinition}}
{{lastResult}}.treeResolveAll(); {{lastResult}}.treeResolveAll();
{{#typeIsList}} {{#typeIsList}}
{{#UseList}} {{^IndexBasedListAccess}}
{{#isWithAdd}} {{#isWithAdd}}
{{getterMethod}}().addAll({{lastResult}}); {{getterMethod}}().addAll({{lastResult}});
{{/isWithAdd}} {{/isWithAdd}}
{{^isWithAdd}} {{^isWithAdd}}
set{{entityName}}({{lastResult}}); set{{entityName}}({{lastResult}});
{{/isWithAdd}} {{/isWithAdd}}
{{/UseList}} {{/IndexBasedListAccess}}
{{^UseList}} {{#IndexBasedListAccess}}
{{lastResult}}.set{{idTokenName}}(topic); {{lastResult}}.set{{idTokenName}}(topic);
{{#isWithAdd}} {{#isWithAdd}}
{{getterMethod}}().add({{lastResult}}); {{getterMethod}}().add({{lastResult}});
...@@ -48,7 +48,7 @@ public boolean {{parentTypeName}}.{{connectMethod}}(String {{connectParameterNam ...@@ -48,7 +48,7 @@ public boolean {{parentTypeName}}.{{connectMethod}}(String {{connectParameterNam
{{^isWithAdd}} {{^isWithAdd}}
set{{entityName}}({{lastResult}}, index); set{{entityName}}({{lastResult}}, index);
{{/isWithAdd}} {{/isWithAdd}}
{{/UseList}} {{/IndexBasedListAccess}}
{{/typeIsList}} {{/typeIsList}}
{{^typeIsList}} {{^typeIsList}}
set{{entityName}}({{lastResult}}); set{{entityName}}({{lastResult}});
...@@ -61,7 +61,7 @@ public boolean {{parentTypeName}}.{{connectMethod}}(String {{connectParameterNam ...@@ -61,7 +61,7 @@ public boolean {{parentTypeName}}.{{connectMethod}}(String {{connectParameterNam
return {{internalConnectMethod}}({{connectParameterName}}, consumer); return {{internalConnectMethod}}({{connectParameterName}}, consumer);
} }
{{#typeIsList}}{{^UseList}}{{^isWithAdd}} {{#typeIsList}}{{#IndexBasedListAccess}}{{^isWithAdd}}
/** /**
* Connects the receive endpoint {{entityName}} using a "wildcard" URI (if supported by the chosen protocol). * Connects the receive endpoint {{entityName}} using a "wildcard" URI (if supported by the chosen protocol).
* @param {{connectParameterName}} string describing protocol and path as an URI * @param {{connectParameterName}} string describing protocol and path as an URI
...@@ -84,7 +84,7 @@ public boolean {{parentTypeName}}.{{connectMethod}}(String {{connectParameterNam ...@@ -84,7 +84,7 @@ public boolean {{parentTypeName}}.{{connectMethod}}(String {{connectParameterNam
}; };
return {{internalConnectMethod}}({{connectParameterName}}, consumer); return {{internalConnectMethod}}({{connectParameterName}}, consumer);
} }
{{/isWithAdd}}{{/UseList}}{{/typeIsList}} {{/isWithAdd}}{{/IndexBasedListAccess}}{{/typeIsList}}
private boolean {{parentTypeName}}.{{internalConnectMethod}}(String {{connectParameterName}}, private boolean {{parentTypeName}}.{{internalConnectMethod}}(String {{connectParameterName}},
java.util.function.BiConsumer<String, byte[]> consumer) throws java.io.IOException { java.util.function.BiConsumer<String, byte[]> consumer) throws java.io.IOException {
......
send indexed SenderRoot.A ; send SenderRoot.A ;
send indexed SenderRoot.SingleA ; send SenderRoot.SingleA ;
receive indexed ReceiverRoot.A ; receive ReceiverRoot.A ;
receive indexed ReceiverRoot.FromSingleA ; receive ReceiverRoot.FromSingleA ;
receive indexed with add ReceiverRoot.WithAddFromA ; receive with add ReceiverRoot.WithAddFromA ;
receive indexed with add ReceiverRoot.WithAddFromSingleA ; receive with add ReceiverRoot.WithAddFromSingleA ;
...@@ -18,7 +18,7 @@ SenderRoot ReceiverRoot ...@@ -18,7 +18,7 @@ SenderRoot ReceiverRoot
## Computation ## Computation
A _n_ = Input _n_ + 1, e.g., A1 = Input1 + 1 A _n_ = Input _n_ + _n_, e.g., A1 = Input1 + 1 and A3 = Input3 + 3
## Execution-Trace (SendInitialValue) ## Execution-Trace (SendInitialValue)
......
...@@ -4,10 +4,10 @@ send SenderRoot.A3 ; ...@@ -4,10 +4,10 @@ send SenderRoot.A3 ;
send SenderRoot.A4 ; send SenderRoot.A4 ;
send SenderRoot.InOutput using IntToA ; send SenderRoot.InOutput using IntToA ;
receive ReceiverRoot.A ; receive indexed ReceiverRoot.A ;
receive ReceiverRoot.UsingWildcardA ; receive indexed ReceiverRoot.UsingWildcardA ;
receive with add ReceiverRoot.WithAddA ; receive indexed with add ReceiverRoot.WithAddA ;
receive with add ReceiverRoot.UsingWildcardWithAddA ; receive indexed with add ReceiverRoot.UsingWildcardWithAddA ;
IntToA maps int i to A {: IntToA maps int i to A {:
return new A().setID(i); return new A().setID(i);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment