You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by cd...@apache.org on 2019/06/03 11:34:32 UTC

[plc4x] branch feature/code-gen updated (b4f3ecf -> 213929e)

This is an automated email from the ASF dual-hosted git repository.

cdutz pushed a change to branch feature/code-gen
in repository https://gitbox.apache.org/repos/asf/plc4x.git.


    from b4f3ecf  - Implemented the serialization
     new f9d7832  - Fixed an error in the spec
     new 9e13c3e  - Fine-tuned the code generation of optionals
     new 213929e  - Fixed an obvious bug in the code generation for the pojos addressing the discriminator-values.

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../src/main/resources/templates/java/io-template.ftlh            | 6 ++++--
 .../src/main/resources/templates/java/pojo-template.ftlh          | 2 +-
 .../protocol-s7/src/main/resources/protocols/s7/protocol.spec     | 8 ++++----
 3 files changed, 9 insertions(+), 7 deletions(-)


[plc4x] 01/03: - Fixed an error in the spec

Posted by cd...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

cdutz pushed a commit to branch feature/code-gen
in repository https://gitbox.apache.org/repos/asf/plc4x.git

commit f9d7832bfdafdb166e336e380af4e6fd5eb40c60
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Mon Jun 3 13:33:09 2019 +0200

    - Fixed an error in the spec
---
 .../protocol-s7/src/main/resources/protocols/s7/protocol.spec     | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sandbox/code-generation/protocol-s7/src/main/resources/protocols/s7/protocol.spec b/sandbox/code-generation/protocol-s7/src/main/resources/protocols/s7/protocol.spec
index c364d54..8e91b41 100644
--- a/sandbox/code-generation/protocol-s7/src/main/resources/protocols/s7/protocol.spec
+++ b/sandbox/code-generation/protocol-s7/src/main/resources/protocols/s7/protocol.spec
@@ -174,16 +174,16 @@
 
 [discriminatedType 'S7Payload' [uint 8 'messageType', S7Parameter 'parameter']
     [typeSwitch 'parameter.parameterType', 'messageType'
-        ['0x04','response' S7PayloadReadVarResponse
+        ['0x04','0x03' S7PayloadReadVarResponse
             [arrayField S7VarPayloadDataItem 'items' count 'parameter.numItems']
         ]
-        ['0x05','request' S7PayloadWriteVarRequest
+        ['0x05','0x01' S7PayloadWriteVarRequest
             [arrayField S7VarPayloadDataItem 'items' count 'parameter.numItems']
         ]
-        ['0x05','response' S7PayloadWriteVarResponse
+        ['0x05','0x03' S7PayloadWriteVarResponse
             [arrayField S7VarPayloadStatusItem 'items' count 'parameter.numItems']
         ]
-        ['0x00','userData' S7PayloadUserData
+        ['0x00','0x07' S7PayloadUserData
         ]
     ]
 ]


[plc4x] 02/03: - Fine-tuned the code generation of optionals

Posted by cd...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

cdutz pushed a commit to branch feature/code-gen
in repository https://gitbox.apache.org/repos/asf/plc4x.git

commit 9e13c3ebf3b42408a796f1656038d9bd39cb72d3
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Mon Jun 3 13:33:46 2019 +0200

    - Fine-tuned the code generation of optionals
---
 .../src/main/resources/templates/java/io-template.ftlh              | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/sandbox/code-generation/language-template-java/src/main/resources/templates/java/io-template.ftlh b/sandbox/code-generation/language-template-java/src/main/resources/templates/java/io-template.ftlh
index 019eb20..08f0364 100644
--- a/sandbox/code-generation/language-template-java/src/main/resources/templates/java/io-template.ftlh
+++ b/sandbox/code-generation/language-template-java/src/main/resources/templates/java/io-template.ftlh
@@ -115,7 +115,8 @@ public class ${typeName}IO  {
 
         // Optional Field (Can be skipped, if a given expression evaluates to false)
         ${helper.getLanguageTypeNameForSpecType(field.type)} ${field.name} = ${helper.getNullValueForType(field.type)};
-        if(${field.conditionExpression}) {
+        JexlExpression ex${field.name?cap_first} = jexl.createExpression("${field.conditionExpression}");
+        if(ex${field.name?cap_first}.evaluate(jc) == Boolean.TRUE) {
             ${field.name} = <#if helper.isSimpleType(field.type)>io.${helper.getReadBufferReadMethodCall(field.type)}<#else>${field.type.name}IO.parse(io);</#if>;
         }
         jc.set("${field.name}", ${field.name});
@@ -205,7 +206,8 @@ public class ${typeName}IO  {
     <#case "optional">
 
         // Optional Field (Can be skipped, if a given expression evaluates to false)
-        if(value.get${field.name?cap_first}() != null) {
+        JexlExpression ex${field.name?cap_first} = jexl.createExpression("${field.conditionExpression}");
+        if(ex${field.name?cap_first}.evaluate(jc) == Boolean.TRUE) {
             <#if helper.isSimpleType(field.type)>
             io.${helper.getWriteBufferReadMethodCall(field.type, "value.get" + field.name?cap_first + "()")};
             <#else>


[plc4x] 03/03: - Fixed an obvious bug in the code generation for the pojos addressing the discriminator-values.

Posted by cd...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

cdutz pushed a commit to branch feature/code-gen
in repository https://gitbox.apache.org/repos/asf/plc4x.git

commit 213929e96598cd9200c72de2b3bae504d2cbd0cc
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Mon Jun 3 13:34:24 2019 +0200

    - Fixed an obvious bug in the code generation for the pojos addressing the discriminator-values.
---
 .../src/main/resources/templates/java/pojo-template.ftlh                | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sandbox/code-generation/language-template-java/src/main/resources/templates/java/pojo-template.ftlh b/sandbox/code-generation/language-template-java/src/main/resources/templates/java/pojo-template.ftlh
index 7582c63..2beed05 100644
--- a/sandbox/code-generation/language-template-java/src/main/resources/templates/java/pojo-template.ftlh
+++ b/sandbox/code-generation/language-template-java/src/main/resources/templates/java/pojo-template.ftlh
@@ -42,7 +42,7 @@ public<#if type.abstract> abstract</#if> class ${typeName}<#if type.parentType??
 <#if helper.isDiscriminatedType(type)>
 
     // Discriminator values used by the parser to determine the type to be used. All values have to apply.
-    public static final Object[] DISCRIMINATOR_VALUES = new String[] {
+    public static final Object[] DISCRIMINATOR_VALUES = new Object[] {
     <#list type.discriminatorValues as discriminatorValue>
         ${discriminatorValue}<#sep>, </#sep>
     </#list>