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 2020/10/06 16:50:20 UTC

[plc4x] branch feature/plc4go updated: - Added parsers and serializers to the code-generation

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

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


The following commit(s) were added to refs/heads/feature/plc4go by this push:
     new b1bc946  - Added parsers and serializers to the code-generation
b1bc946 is described below

commit b1bc9468914fe7521d9059495ce691de1b631cad
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Tue Oct 6 18:50:13 2020 +0200

    - Added parsers and serializers to the code-generation
---
 .../templates/go/enum-package-info-template.ftlh   | 47 ----------------------
 .../main/resources/templates/go/enum-template.ftlh | 10 +++++
 .../plc4go/go/modbus/readwrite/ModbusDataType.go   | 10 +++++
 3 files changed, 20 insertions(+), 47 deletions(-)

diff --git a/build-utils/language-go/src/main/resources/templates/go/enum-package-info-template.ftlh b/build-utils/language-go/src/main/resources/templates/go/enum-package-info-template.ftlh
deleted file mode 100644
index d5a4373..0000000
--- a/build-utils/language-go/src/main/resources/templates/go/enum-package-info-template.ftlh
+++ /dev/null
@@ -1,47 +0,0 @@
-<#--
-  Licensed to the Apache Software Foundation (ASF) under one
-  or more contributor license agreements.  See the NOTICE file
-  distributed with this work for additional information
-  regarding copyright ownership.  The ASF licenses this file
-  to you under the Apache License, Version 2.0 (the
-  "License"); you may not use this file except in compliance
-  with the License.  You may obtain a copy of the License at
-
-      http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing,
-  software distributed under the License is distributed on an
-  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  KIND, either express or implied.  See the License for the
-  specific language governing permissions and limitations
-  under the License.
--->
-<#-- Prevent freemarker from escaping stuff -->
-<#outputformat "undefined">
-<#-- Declare the name and type of variables passed in to the template -->
-<#-- @ftlvariable name="languageName" type="java.lang.String" -->
-<#-- @ftlvariable name="protocolName" type="java.lang.String" -->
-<#-- @ftlvariable name="outputFlavor" type="java.lang.String" -->
-<#-- @ftlvariable name="helper" type="org.apache.plc4x.language.go.GoLanguageTemplateHelper" -->
-${helper.packageName(protocolName, languageName, outputFlavor)?replace(".", "/")}/types/package-info.java
-/*
-  Licensed to the Apache Software Foundation (ASF) under one
-  or more contributor license agreements.  See the NOTICE file
-  distributed with this work for additional information
-  regarding copyright ownership.  The ASF licenses this file
-  to you under the Apache License, Version 2.0 (the
-  "License"); you may not use this file except in compliance
-  with the License.  You may obtain a copy of the License at
-
-      http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing,
-  software distributed under the License is distributed on an
-  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  KIND, either express or implied.  See the License for the
-  specific language governing permissions and limitations
-  under the License.
-*/
-
-package ${helper.packageName(protocolName, languageName, outputFlavor)}.types;
-</#outputformat>
\ No newline at end of file
diff --git a/build-utils/language-go/src/main/resources/templates/go/enum-template.ftlh b/build-utils/language-go/src/main/resources/templates/go/enum-template.ftlh
index 8a662f6..6e6733e 100644
--- a/build-utils/language-go/src/main/resources/templates/go/enum-template.ftlh
+++ b/build-utils/language-go/src/main/resources/templates/go/enum-template.ftlh
@@ -78,4 +78,14 @@ func (e ${type.name}) Get${constantName?cap_first}() ${helper.getLanguageTypeNam
 }
     </#list>
 </#if>
+
+<#if type.type?has_content>
+func (e ${type.name}) Parse(io spi.ReadBuffer) {
+    // TODO: Implement ...
+}
+
+func (e ${type.name}) Serialize(io spi.WriteBuffer) {
+    // TODO: Implement ...
+}
+</#if>
 </#outputformat>
\ No newline at end of file
diff --git a/sandbox/plc4go/generated-sources/plc4go/go/modbus/readwrite/ModbusDataType.go b/sandbox/plc4go/generated-sources/plc4go/go/modbus/readwrite/ModbusDataType.go
index 9c20cd0..345e872 100644
--- a/sandbox/plc4go/generated-sources/plc4go/go/modbus/readwrite/ModbusDataType.go
+++ b/sandbox/plc4go/generated-sources/plc4go/go/modbus/readwrite/ModbusDataType.go
@@ -18,6 +18,8 @@
 //
 package readwrite
 
+import "plc4x.apache.org/plc4go-modbus-driver/0.8.0/src/plc4go/spi"
+
 type ModbusDataType uint8
 
 const (
@@ -171,3 +173,11 @@ func (e ModbusDataType) GetDataTypeSize() uint8 {
 		}
 	}
 }
+
+func (e ModbusDataType) Parse(io spi.ReadBuffer) {
+	// TODO: Implement ...
+}
+
+func (e ModbusDataType) Serialize(io spi.WriteBuffer) {
+	// TODO: Implement ...
+}