c_ext/c_ext.py
changeset 1119 34db4294c177
parent 1114 1a97222ffee9
child 1124 b1705000eba1
equal deleted inserted replaced
1118:2c96a2f36295 1119:34db4294c177
    42         text = "/* Code generated by Beremiz c_ext confnode */\n\n"
    42         text = "/* Code generated by Beremiz c_ext confnode */\n\n"
    43         text += "#include <stdio.h>\n\n"
    43         text += "#include <stdio.h>\n\n"
    44         
    44         
    45         # Adding includes
    45         # Adding includes
    46         text += "/* User includes */\n"
    46         text += "/* User includes */\n"
    47         text += self.CodeFile.includes.gettext()
    47         text += self.CodeFile.includes.gettext().strip()
    48         text += "\n"
    48         text += "\n"
    49         
    49         
    50         text += '#include "iec_types_all.h"\n\n'
    50         text += '#include "iec_types_all.h"\n\n'
    51         
    51         
    52         # Adding variables
    52         # Adding variables
    62             text += "#define %(name)s %(global)s.value\n" % var_infos
    62             text += "#define %(name)s %(global)s.value\n" % var_infos
    63         text += "\n"
    63         text += "\n"
    64         
    64         
    65         # Adding user global variables and routines
    65         # Adding user global variables and routines
    66         text += "/* User internal user variables and routines */\n"
    66         text += "/* User internal user variables and routines */\n"
    67         text += self.CodeFile.globals.gettext()
    67         text += self.CodeFile.globals.gettext().strip()
    68         text += "\n"
    68         text += "\n"
    69         
    69         
    70         # Adding Beremiz confnode functions
    70         # Adding Beremiz confnode functions
    71         text += "/* Beremiz confnode functions */\n"
    71         text += "/* Beremiz confnode functions */\n"
    72         text += "int __init_%s(int argc,char **argv)\n{\n"%location_str
    72         text += "int __init_%s(int argc,char **argv)\n{\n"%location_str
    73         text += self.CodeFile.initFunction.gettext()
    73         text += self.CodeFile.initFunction.gettext().strip()
    74         text += "  return 0;\n"
    74         text += "  return 0;\n}\n\n"
    75         text += "\n}\n\n"
       
    76         
    75         
    77         text += "void __cleanup_%s(void)\n{\n"%location_str
    76         text += "void __cleanup_%s(void)\n{\n"%location_str
    78         text += self.CodeFile.cleanUpFunction.gettext()
    77         text += self.CodeFile.cleanUpFunction.gettext().strip()
    79         text += "\n}\n\n"
    78         text += "\n}\n\n"
    80         
    79         
    81         text += "void __retrieve_%s(void)\n{\n"%location_str
    80         text += "void __retrieve_%s(void)\n{\n"%location_str
    82         text += self.CodeFile.retrieveFunction.gettext()
    81         text += self.CodeFile.retrieveFunction.gettext().strip()
    83         text += "\n}\n\n"
    82         text += "\n}\n\n"
    84         
    83         
    85         text += "void __publish_%s(void)\n{\n"%location_str
    84         text += "void __publish_%s(void)\n{\n"%location_str
    86         text += self.CodeFile.publishFunction.gettext()
    85         text += self.CodeFile.publishFunction.gettext().strip()
    87         text += "\n}\n\n"
    86         text += "\n}\n\n"
    88         
    87         
    89         Gen_Cfile_path = os.path.join(buildpath, "CFile_%s.c"%location_str)
    88         Gen_Cfile_path = os.path.join(buildpath, "CFile_%s.c"%location_str)
    90         cfile = open(Gen_Cfile_path,'w')
    89         cfile = open(Gen_Cfile_path,'w')
    91         cfile.write(text)
    90         cfile.write(text)