Add some class factory function to ease declaration of simple POU libraries in customizations (i.e. TC6 XML file only, no special C code generation)
authorEdouard Tisserant
Wed, 31 Jan 2018 15:22:43 +0100
changeset 1917 d51d14719392
parent 1916 b69bea00765a
child 1918 e7b6478b4ebc
Add some class factory function to ease declaration of simple POU libraries in customizations (i.e. TC6 XML file only, no special C code generation)
NativeLib.py
POULibrary.py
--- a/NativeLib.py	Wed Jan 31 15:20:42 2018 +0100
+++ b/NativeLib.py	Wed Jan 31 15:22:43 2018 +0100
@@ -26,9 +26,7 @@
 
 from __future__ import absolute_import
 import util.paths as paths
-from POULibrary import POULibrary
+from POULibrary import SimplePOULibraryFactory
 
-
-class NativeLibrary(POULibrary):
-    def GetLibraryPath(self):
-        return paths.AbsNeighbourFile(__file__, "NativeLib.xml")
+NativeLibrary = SimplePOULibraryFactory(
+    paths.AbsNeighbourFile(__file__, "NativeLib.xml"))
--- a/POULibrary.py	Wed Jan 31 15:20:42 2018 +0100
+++ b/POULibrary.py	Wed Jan 31 15:22:43 2018 +0100
@@ -58,3 +58,10 @@
     def Generate_C(self, buildpath, varlist, IECCFLAGS):
         # Pure python or IEC libs doesn't produce C code
         return ((""), [], False), ""
+
+
+def SimplePOULibraryFactory(path):
+    class SimplePOULibrary(POULibrary):
+        def GetLibraryPath(self):
+            return path
+    return SimplePOULibrary