Added pointer variable list in GenCfile.py, for use with Beremiz's generated code.
authoretisserant
Mon, 23 Jun 2008 17:55:11 +0200
changeset 484 f59d1cdde42b
parent 483 763ae2ca410a
child 485 24b506ea314b
Added pointer variable list in GenCfile.py, for use with Beremiz's generated code.
objdictgen/gen_cfile.py
--- a/objdictgen/gen_cfile.py	Mon Jun 23 17:54:18 2008 +0200
+++ b/objdictgen/gen_cfile.py	Mon Jun 23 17:55:11 2008 +0200
@@ -95,7 +95,10 @@
     cfile.write(content)
     cfile.close()
 
-def GenerateFileContent(Node, headerfilepath):
+def GenerateFileContent(Node, headerfilepath, pointers_dict = {}):
+    """
+    pointers_dict = {(Idx,Sidx):"VariableName",...}
+    """
     global type
     global internal_types
     global default_string_size
@@ -162,6 +165,7 @@
 #-------------------------------------------------------------------------------
 
     mappedVariableContent = ""
+    pointedVariableContent = ""
     strDeclareHeader = ""
     strDeclareCallback = ""
     indexContents = {}
@@ -319,9 +323,12 @@
             else:
                 save = ""
             strIndex += "                       { %s%s, %s, %s, (void*)&%s }%s\n"%(subentry_infos["access"].upper(),save,typeinfos[2],sizeof,name,sep)
+            pointer_name = pointers_dict.get((index, subIndex), None)
+            if pointer_name is not None:
+                pointedVariableContent += "%s* %s = &%s;\n"%(typeinfos[0], pointer_name, name)
         strIndex += "                     };\n"
         indexContents[index] = strIndex
-
+        
 #-------------------------------------------------------------------------------
 #                     Declaration of Particular Parameters
 #-------------------------------------------------------------------------------
@@ -430,13 +437,13 @@
 
     fileContent += """
 /**************************************************************************/
-/* Declaration of the mapped variables                                    */
+/* Declaration of mapped variables                                        */
 /**************************************************************************/
 """ + mappedVariableContent
 
     fileContent += """
 /**************************************************************************/
-/* Declaration of the value range types                                   */
+/* Declaration of value range types                                       */
 /**************************************************************************/
 """ + valueRangeContent
 
@@ -475,6 +482,12 @@
         fileContent += indexContents[index]
 
     fileContent += """
+/**************************************************************************/
+/* Declaration of pointed variables                                       */
+/**************************************************************************/
+""" + pointedVariableContent
+
+    fileContent += """
 const indextable %(NodeName)s_objdict[] = 
 {
 """%texts
@@ -542,10 +555,10 @@
 #                             Main Function
 #-------------------------------------------------------------------------------
 
-def GenerateFile(filepath, node):
+def GenerateFile(filepath, node, pointers_dict = {}):
     try:
         headerfilepath = os.path.splitext(filepath)[0]+".h"
-        content, header = GenerateFileContent(node, os.path.split(headerfilepath)[1])
+        content, header = GenerateFileContent(node, os.path.split(headerfilepath)[1], pointers_dict)
         WriteFile(filepath, content)
         WriteFile(headerfilepath, header)
         return None