# HG changeset patch # User Edouard Tisserant # Date 1518987093 -3600 # Node ID 90bf6bd94b94a7c7a0978b7f9ba1b9f9508b0eeb # Parent 6162e34fb246ff3cadd412d40d56da8e3e1fc2b2 Fixed earlier XSLT optimizations. Some/most results were missing. diff -r 6162e34fb246 -r 90bf6bd94b94 plcopen/POUVariablesCollector.py --- a/plcopen/POUVariablesCollector.py Sun Feb 18 21:30:48 2018 +0100 +++ b/plcopen/POUVariablesCollector.py Sun Feb 18 21:51:33 2018 +0100 @@ -63,9 +63,14 @@ XSLTModelQuery.__init__(self, controller, "pou_variables.xslt", - [(name, lambda *x : getattr(self.factory, name)(*x)) + [(name, self.FactoryCaller(name)) for name in ["SetRoot", "AddVariable"]]) + def FactoryCaller(self, funcname): + def CallFactory(*args): + return getattr(self.factory, funcname)(*args) + return CallFactory + def Collect(self, root, debug): self.factory = VariablesTreeInfosFactory() self._process_xslt(root, debug) diff -r 6162e34fb246 -r 90bf6bd94b94 plcopen/XSLTModelQuery.py --- a/plcopen/XSLTModelQuery.py Sun Feb 18 21:30:48 2018 +0100 +++ b/plcopen/XSLTModelQuery.py Sun Feb 18 21:51:33 2018 +0100 @@ -21,7 +21,7 @@ # merge xslt extensions for library access to query specific ones xsltext = [ ("GetProject", lambda *_ignored: - controller.GetProject(self.debug)), + [controller.GetProject(self.debug)]), ("GetStdLibs", lambda *_ignored: [lib for lib in StdBlckLibs.values()]), ("GetExtensions", lambda *_ignored: diff -r 6162e34fb246 -r 90bf6bd94b94 plcopen/instances_path.xslt --- a/plcopen/instances_path.xslt Sun Feb 18 21:30:48 2018 +0100 +++ b/plcopen/instances_path.xslt Sun Feb 18 21:51:33 2018 +0100 @@ -45,7 +45,7 @@ - + @@ -92,7 +92,7 @@ - + diff -r 6162e34fb246 -r 90bf6bd94b94 plcopen/instances_path.ysl2 --- a/plcopen/instances_path.ysl2 Sun Feb 18 21:30:48 2018 +0100 +++ b/plcopen/instances_path.ysl2 Sun Feb 18 21:51:33 2018 +0100 @@ -45,8 +45,8 @@ } otherwise { variable "type_name" > «@typeName» - apply """$all/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] | - $all/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name]""" { + apply """$all/ppx:types/ppx:pous/ppx:pou[@name=$type_name] | + $all/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name]""" { with "instance_path" > «$pou_instance_path» } } @@ -83,8 +83,8 @@ } otherwise { variable "type_name" > «@name» - apply """$all/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] | - $all/ppx:project/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name]""" { + apply """$all/ppx:types/ppx:pous/ppx:pou[@name=$type_name] | + $all/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name]""" { with "instance_path" > «$variable_path» } } diff -r 6162e34fb246 -r 90bf6bd94b94 plcopen/pou_variables.xslt --- a/plcopen/pou_variables.xslt Sun Feb 18 21:30:48 2018 +0100 +++ b/plcopen/pou_variables.xslt Sun Feb 18 21:51:33 2018 +0100 @@ -9,6 +9,7 @@ + @@ -204,7 +205,7 @@ - + @@ -245,7 +246,7 @@ - + true @@ -263,9 +264,9 @@ - + - + diff -r 6162e34fb246 -r 90bf6bd94b94 plcopen/pou_variables.ysl2 --- a/plcopen/pou_variables.ysl2 Sun Feb 18 21:30:48 2018 +0100 +++ b/plcopen/pou_variables.ysl2 Sun Feb 18 21:51:33 2018 +0100 @@ -16,6 +16,8 @@ variable "stdlib", "ns:GetStdLibs()"; variable "extensions", "ns:GetExtensions()"; + + variable "all", "$project | $stdlib | $extensions"; function "add_root" { param "class"; @@ -171,7 +173,7 @@ template "*[self::ppx:type or self::ppx:baseType]/ppx:derived", mode="var_class" { param "default_class"; variable "type_name", "@name"; - variable "pou_infos", "($project|$stdlib|$extensions)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name]"; + variable "pou_infos", "$all/ppx:types/ppx:pous/ppx:pou[@name=$type_name]"; choose { when "$pou_infos" { apply "$pou_infos", mode="var_class"; @@ -218,7 +220,7 @@ template "*[self::ppx:type or self::ppx:baseType]/ppx:derived", mode="var_edit" { variable "type_name", "@name"; - variable "pou_infos", "$project/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name]"; + variable "pou_infos", "$project/ppx:types/ppx:pous/ppx:pou[@name=$type_name]"; choose { when "$pou_infos" > true otherwise > false @@ -235,9 +237,12 @@ template "*[self::ppx:type or self::ppx:baseType]/ppx:derived", mode="var_debug" { variable "type_name", "@name"; - variable "datatype_infos", "($project|$stdlib|$extensions)/ppx:project/ppx:types/ppx:pous/ppx:pou[@name=$type_name]"; + variable "datatype_infos", """ + $project/ppx:types/ppx:pous/ppx:pou[@name=$type_name] | + $all/ppx:types/ppx:dataTypes/ppx:dataType[@name=$type_name] + """; choose { - when "$datatype_infos != ''" { + when "$datatype_infos" { apply "$datatype_infos", mode="var_debug"; } otherwise > false