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/05/26 19:42:25 UTC
[plc4x] branch develop updated: - Made the template use plc4c_list
elements for variable array
This is an automated email from the ASF dual-hosted git repository.
cdutz pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git
The following commit(s) were added to refs/heads/develop by this push:
new 1227b0a - Made the template use plc4c_list elements for variable array
1227b0a is described below
commit 1227b0af78ef9edaffdc1acf7bf9e228fdd41fe2
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Tue May 26 21:42:19 2020 +0200
- Made the template use plc4c_list elements for variable array
---
.../java/org/apache/plc4x/language/c/CLanguageTemplateHelper.java | 8 ++++++--
.../src/main/resources/templates/c/pojo-template-h.ftlh | 1 +
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/build-utils/language-c/src/main/java/org/apache/plc4x/language/c/CLanguageTemplateHelper.java b/build-utils/language-c/src/main/java/org/apache/plc4x/language/c/CLanguageTemplateHelper.java
index 049f524..87e7d8d 100644
--- a/build-utils/language-c/src/main/java/org/apache/plc4x/language/c/CLanguageTemplateHelper.java
+++ b/build-utils/language-c/src/main/java/org/apache/plc4x/language/c/CLanguageTemplateHelper.java
@@ -130,17 +130,21 @@ public class CLanguageTemplateHelper implements FreemarkerLanguageTemplateHelper
* @return type name we should use in C
*/
public String getLanguageTypeNameForField(TypedField field) {
- // If the referenced type is a DataIo type, the value is of type PlcValue.
+ // If the referenced type is a DataIo type, the value is of type plc4c_data.
if (field instanceof PropertyField) {
PropertyField propertyField = (PropertyField) field;
if (propertyField.getType() instanceof ComplexTypeReference) {
ComplexTypeReference complexTypeReference = (ComplexTypeReference) propertyField.getType();
final TypeDefinition typeDefinition = types.get(complexTypeReference.getName());
if (typeDefinition instanceof DataIoTypeDefinition) {
- return "PlcValue";
+ return "plc4c_data*";
}
}
}
+ // If this is an array with variable length, then we have to use our "plc4c_list" to store the data.
+ if((field instanceof ArrayField) && (!isFixedValueExpression(((ArrayField) field).getLoopExpression()))) {
+ return "plc4c_list";
+ }
TypeReference typeReference = field.getType();
return getLanguageTypeName(typeReference);
}
diff --git a/build-utils/language-c/src/main/resources/templates/c/pojo-template-h.ftlh b/build-utils/language-c/src/main/resources/templates/c/pojo-template-h.ftlh
index aec596a..b74bce7 100644
--- a/build-utils/language-c/src/main/resources/templates/c/pojo-template-h.ftlh
+++ b/build-utils/language-c/src/main/resources/templates/c/pojo-template-h.ftlh
@@ -43,6 +43,7 @@ extern "C" {
#include <stdbool.h>
#include <stdint.h>
+#include <plc4c/utils/list.h>
<#if helper.getComplexTypeReferencesInFields()?has_content>
<#list helper.getComplexTypeReferencesInFields() as complexType>
#include "${helper.camelCaseToSnakeCase(complexType.getName())}.h"