plugins/c_ext/c_ext.py
changeset 180 f7dc9acda79e
parent 146 ad2d8431104e
child 199 aa5f43bafad4
equal deleted inserted replaced
179:66a4dc7f534a 180:f7dc9acda79e
   265             else:
   265             else:
   266                 var["location"] = "__Q%s%s_%d"%(self.GetSizeOfType(var["Type"]), location_str, outputs)
   266                 var["location"] = "__Q%s%s_%d"%(self.GetSizeOfType(var["Type"]), location_str, outputs)
   267                 outputs += 1
   267                 outputs += 1
   268             vars.append(var)
   268             vars.append(var)
   269         text += "/* Beremiz c_ext plugin user variables definition */\n"
   269         text += "/* Beremiz c_ext plugin user variables definition */\n"
   270         text += "#ifdef _WINDOWS_H\n"
       
   271         base_types = self.GetPlugRoot().GetBaseTypes()
   270         base_types = self.GetPlugRoot().GetBaseTypes()
   272         for var in vars:
   271         for var in vars:
   273             if var["Type"] in base_types:
   272             if var["Type"] in base_types:
   274                 prefix = "IEC_"
   273                 prefix = "IEC_"
   275             else:
   274             else:
   276                 prefix = ""
   275                 prefix = ""
   277             text += "%s%s %s;\n"%(prefix, var["Type"], var["location"])
   276             text += "%s%s beremiz%s;\n"%(prefix, var["Type"], var["location"])
   278         text += "#else\n"
   277             text += "%s%s *%s = &beremiz%s;\n"%(prefix, var["Type"], var["location"], var["location"])
   279         for var in vars:
       
   280             text += "%s %s;\n"%(var["Type"], var["location"])
       
   281         text += "#endif\n\n"
       
   282         text += "/* User variables reference */\n"
   278         text += "/* User variables reference */\n"
   283         for var in vars:
   279         for var in vars:
   284             text += "#define %s %s\n"%(var["Name"], var["location"])
   280             text += "#define %s beremiz%s\n"%(var["Name"], var["location"])
   285         text += "\n"
   281         text += "\n"
   286         
   282         
   287         # Adding user global variables and routines
   283         # Adding user global variables and routines
   288         text += "/* User internal user variables and routines */\n"
   284         text += "/* User internal user variables and routines */\n"
   289         text += self.CFile.globals.gettext()
   285         text += self.CFile.globals.gettext()
   290         
   286         
   291         # Adding Beremiz plugin functions
   287         # Adding Beremiz plugin functions
   292         text += "/* Beremiz plugin functions */\n"
   288         text += "/* Beremiz plugin functions */\n"
   293         text += "int __init_%s(int argc,char **argv)\n{\n"%location_str
   289         text += "int __init_%s(int argc,char **argv)\n{\n"%location_str
   294         text += self.CFile.initFunction.gettext()
   290         text += self.CFile.initFunction.gettext()
       
   291         text += "  return 0;\n"
   295         text += "\n}\n\n"
   292         text += "\n}\n\n"
   296         
   293         
   297         text += "void __cleanup_%s()\n{\n"%location_str
   294         text += "void __cleanup_%s()\n{\n"%location_str
   298         text += self.CFile.cleanUpFunction.gettext()
   295         text += self.CFile.cleanUpFunction.gettext()
   299         text += "\n}\n\n"
   296         text += "\n}\n\n"