objdictgen/gen_cfile.py
changeset 421 6221b4db8c42
parent 420 a42335b39bf4
child 422 43a4d6deb007
equal deleted inserted replaced
420:a42335b39bf4 421:6221b4db8c42
   229                         comment = ""
   229                         comment = ""
   230                         if subIndex > 0:
   230                         if subIndex > 0:
   231                             if subIndex == len(values)-1:
   231                             if subIndex == len(values)-1:
   232                                 sep = ""
   232                                 sep = ""
   233                             if typeinfos[2] == "visible_string":
   233                             if typeinfos[2] == "visible_string":
   234                                 value = "\"%s\""%value
   234                                 value = "\"%s%s\""%(value, "\\0" * (default_string_size - len(value)))
   235                             elif typeinfos[2] == "domain":
   235                             elif typeinfos[2] == "domain":
   236                                 value = "\"%s\""%''.join(["\\x%2.2x"%ord(char) for char in value])
   236                                 value = "\"%s\""%''.join(["\\x%2.2x"%ord(char) for char in value])
   237                             else:
   237                             else:
   238                                 comment = "\t/* %s */"%str(value)
   238                                 comment = "\t/* %s */"%str(value)
   239                                 value = "0x%X"%value
   239                                 value = "0x%X"%value
   246                         comment = ""
   246                         comment = ""
   247                         if subIndex > 0:
   247                         if subIndex > 0:
   248                             if subIndex == len(values)-1:
   248                             if subIndex == len(values)-1:
   249                                 sep = ""
   249                                 sep = ""
   250                             if typeinfos[2] == "visible_string":
   250                             if typeinfos[2] == "visible_string":
   251                                 value = "\"%s\""%value
   251                                 value = "\"%s%s\""%(value, "\\0" * (default_string_size - len(value)))
   252                             elif typeinfos[2] == "domain":
   252                             elif typeinfos[2] == "domain":
   253                                 value = "\"%s\""%''.join(["\\x%2.2x"%ord(char) for char in value])
   253                                 value = "\"%s\""%''.join(["\\x%2.2x"%ord(char) for char in value])
   254                             else:
   254                             else:
   255                                 comment = "\t/* %s */"%str(value)
   255                                 comment = "\t/* %s */"%str(value)
   256                                 value = "0x%X"%value
   256                                 value = "0x%X"%value
   270                         if typeinfos[1] is not None:
   270                         if typeinfos[1] is not None:
   271                             texts["suffixe"] = "[%d]"%typeinfos[1]
   271                             texts["suffixe"] = "[%d]"%typeinfos[1]
   272                         else:
   272                         else:
   273                             texts["suffixe"] = ""
   273                             texts["suffixe"] = ""
   274                         if typeinfos[2] == "visible_string":
   274                         if typeinfos[2] == "visible_string":
   275                             texts["value"] = "\"%s\""%value
   275                             texts["value"] = "\"%s%s\""%(value, "\\0" * (default_string_size - len(value)))
   276                             texts["comment"] = ""
   276                             texts["comment"] = ""
   277                         elif typeinfos[2] == "domain":
   277                         elif typeinfos[2] == "domain":
   278                             texts["value"] = "\"%s\""%''.join(["\\x%2.2x"%ord(char) for char in value])
   278                             texts["value"] = "\"%s\""%''.join(["\\x%2.2x"%ord(char) for char in value])
   279                             texts["comment"] = ""			
   279                             texts["comment"] = ""			
   280                         else:
   280                         else:
   331             else:
   331             else:
   332                 if index in variablelist:
   332                 if index in variablelist:
   333                     name = FormatName("%s_%s"%(entry_infos["name"],subentry_infos["name"]))
   333                     name = FormatName("%s_%s"%(entry_infos["name"],subentry_infos["name"]))
   334                 else:
   334                 else:
   335                     name = "%s_obj%04X_%s"%(texts["NodeName"], texts["index"], FormatName(subentry_infos["name"]))
   335                     name = "%s_obj%04X_%s"%(texts["NodeName"], texts["index"], FormatName(subentry_infos["name"]))
   336             if typeinfos[2] in ["visible_string", "domain"]:
   336             if typeinfos[2] == "visible_string":
   337                 sizeof = typeinfos[1]
   337                 sizeof = str(max(len(values[subIndex]), default_string_size))
       
   338             elif typeinfos[2] == "domain":
       
   339                 sizeof = str(len(values[subIndex]))
   338             else:
   340             else:
   339                 sizeof = "sizeof (%s)"%typeinfos[0]
   341                 sizeof = "sizeof (%s)"%typeinfos[0]
   340             params = Node.GetParamsEntry(index, subIndex)
   342             params = Node.GetParamsEntry(index, subIndex)
   341             if params["save"]:
   343             if params["save"]:
   342                 save = "|TO_BE_SAVE"
   344                 save = "|TO_BE_SAVE"