Fixed unitialized parameter in instances_path stylesheet, leading to
authorEdouard Tisserant
Tue, 24 Sep 2019 11:55:59 +0200
changeset 2626 39d78c530cbb
parent 2625 e5ce6c4a8672
child 2627 3ba6a2d26507
child 2784 35eeb1ed105f
Fixed unitialized parameter in instances_path stylesheet, leading to
calls to add_instance with no data when passing datatypes insteatd of project
root. That bug was making exceptions (for exemple when editing type) when
having arrays of derivated types in project.
plcopen/instances_path.xslt
plcopen/instances_path.ysl2
tests/python/plc.xml
--- a/plcopen/instances_path.xslt	Sun Jul 14 08:43:12 2019 +0200
+++ b/plcopen/instances_path.xslt	Tue Sep 24 11:55:59 2019 +0200
@@ -62,9 +62,9 @@
     </xsl:apply-templates>
   </xsl:template>
   <xsl:template match="ppx:dataType">
-    <xsl:param name="instance_path"/>
+    <xsl:param name="instance_path" select="concat('#',@name)"/>
     <xsl:apply-templates select="ppx:baseType/*[self::ppx:derived or self::ppx:struct or self::ppx:array]">
-      <xsl:with-param name="parent_path">
+      <xsl:with-param name="variable_path">
         <xsl:value-of select="$instance_path"/>
       </xsl:with-param>
     </xsl:apply-templates>
@@ -108,12 +108,12 @@
         <xsl:text>.</xsl:text>
         <xsl:value-of select="@name"/>
       </xsl:variable>
+      <xsl:apply-templates select="ppx:type/*[self::ppx:derived or self::ppx:struct or self::ppx:array]">
+        <xsl:with-param name="variable_path">
+          <xsl:value-of select="$element_path"/>
+        </xsl:with-param>
+      </xsl:apply-templates>
     </xsl:for-each>
-    <xsl:apply-templates select="ppx:type/*[self::ppx:derived or self::ppx:struct or self::ppx:array]">
-      <xsl:with-param name="variable_path">
-        <xsl:value-of select="$element_path"/>
-      </xsl:with-param>
-    </xsl:apply-templates>
   </xsl:template>
   <xsl:template match="ppx:array">
     <xsl:param name="variable_path"/>
--- a/plcopen/instances_path.ysl2	Sun Jul 14 08:43:12 2019 +0200
+++ b/plcopen/instances_path.ysl2	Tue Sep 24 11:55:59 2019 +0200
@@ -60,9 +60,9 @@
     }
     
     template "ppx:dataType" {
-        param "instance_path";
+        param "instance_path","concat('#',@name)";
         apply "ppx:baseType/*[self::ppx:derived or self::ppx:struct or self::ppx:array]" {
-            with "parent_path" > «$instance_path»
+            with "variable_path" > «$instance_path»
         }
     }
     
@@ -94,9 +94,9 @@
         param "variable_path";
         foreach "ppx:variable[ppx:type/ppx:derived or ppx:type/ppx:struct or ppx:type/ppx:array]" {
             variable "element_path" > «$variable_path».«@name»
-        }
-        apply "ppx:type/*[self::ppx:derived or self::ppx:struct or self::ppx:array]" {
-            with "variable_path" > «$element_path»
+            apply "ppx:type/*[self::ppx:derived or self::ppx:struct or self::ppx:array]" {
+                with "variable_path" > «$element_path»
+            }
         }
     }
     
--- a/tests/python/plc.xml	Sun Jul 14 08:43:12 2019 +0200
+++ b/tests/python/plc.xml	Tue Sep 24 11:55:59 2019 +0200
@@ -1,7 +1,7 @@
 <?xml version='1.0' encoding='utf-8'?>
 <project xmlns="http://www.plcopen.org/xml/tc6_0201" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xsi:schemaLocation="http://www.plcopen.org/xml/tc6_0201">
   <fileHeader companyName="" productName="Beremiz" productVersion="0.0" creationDateTime="2008-12-14T16:21:19" contentDescription="This example shows many features in Beremiz:&#10;&#10;   1. How to implement python extensions.&#10;   2. How to implement basic C extension.&#10;   3. How to use C code in IEC POUs.&#10;   4. How to call C functions from python code.&#10;   5. How to avoid race conditions between IEC, C and python code.&#10;   6. How to convert betweet different IEC types.&#10;"/>
-  <contentHeader name="Beremiz Python Support Tests" modificationDateTime="2018-09-26T13:15:28">
+  <contentHeader name="Beremiz Python Support Tests" modificationDateTime="2019-09-24T11:49:14">
     <coordinateInfo>
       <pageSize x="1024" y="1024"/>
       <fbd>
@@ -49,6 +49,16 @@
           <BOOL/>
         </baseType>
       </dataType>
+      <dataType name="blups">
+        <baseType>
+          <array>
+            <dimension lower="0" upper="31"/>
+            <baseType>
+              <derived name="CPLX_TYPE"/>
+            </baseType>
+          </array>
+        </baseType>
+      </dataType>
     </dataTypes>
     <pous>
       <pou name="main_pytest" pouType="program">
@@ -61,6 +71,9 @@
               <initialValue>
                 <simpleValue value="3"/>
               </initialValue>
+              <documentation>
+                <xhtml:p><![CDATA[blah]]></xhtml:p>
+              </documentation>
             </variable>
             <variable name="mux2_sel">
               <type>
@@ -1351,6 +1364,11 @@
                 <derived name="RS"/>
               </type>
             </variable>
+            <variable name="Dudiduda">
+              <type>
+                <derived name="blups"/>
+              </type>
+            </variable>
           </externalVars>
         </interface>
         <body>
@@ -1372,6 +1390,9 @@
 }}
 (* If you do not use GetFbVar and SetFbVar macros, expect unexpected behaviour*)
 Global_RS();
+
+(* testing access to global struct array *)
+Dudiduda[2].FIRSTBYTE := 0;
 ]]></xhtml:p>
           </ST>
         </body>
@@ -1442,6 +1463,11 @@
               <derived name="RS"/>
             </type>
           </variable>
+          <variable name="Dudiduda">
+            <type>
+              <derived name="blups"/>
+            </type>
+          </variable>
           <variable name="TUTU">
             <type>
               <INT/>