objdictgen/gen_cfile.py
changeset 176 5d57fe1e3a5b
parent 160 636d875c85dd
child 182 988f2b302aa6
--- a/objdictgen/gen_cfile.py	Tue Apr 24 16:49:40 2007 +0200
+++ b/objdictgen/gen_cfile.py	Mon Apr 30 16:56:21 2007 +0200
@@ -61,6 +61,8 @@
                 return "UNS8", "[10]", "visible_string"
             else:
                 return "UNS8", "[%s]"%values[1], "visible_string"
+        elif values[0] == "DOMAIN":
+        	return "UNS8*", "", "domain"
     return None
 
 def WriteFile(filepath, content):
@@ -213,6 +215,8 @@
                                 sep = ""
                             if typeinfos[2] == "visible_string":
                                 value = "\"%s\""%value
+                            if typeinfos[2] == "domain":
+                                value = "\"%s\""%''.join(["\\x%2.2x"%ord(char) for char in value])
                             else:
                                 comment = "\t/* %s */"%str(value)
                                 value = "0x%X"%value
@@ -294,16 +298,16 @@
                     name = FormatName("%s_%s"%(entry_infos["name"],subentry_infos["name"]))
                 else:
                     name = "%s_obj%04X_%s"%(texts["NodeName"], texts["index"], FormatName(subentry_infos["name"]))
-            if subIndexType == "visible_string":
-                sizeof = name
-            else:
-                sizeof = typeinfos[0]
+            if subIndexType in ["visible_string", "domain"]:
+                sizeof = str(len(values[subIndex]))
+            else:
+                sizeof = "sizeof (%s)"%typeinfos[0]
             params = Manager.GetCurrentParamsEntry(index, subIndex)
             if params["save"]:
                 save = "|TO_BE_SAVE"
             else:
                 save = ""
-            strIndex += "                       { %s%s, %s, sizeof (%s), (void*)&%s }%s\n"%(subentry_infos["access"].upper(),save,subIndexType,sizeof,name,sep)
+            strIndex += "                       { %s%s, %s, %s, (void*)&%s }%s\n"%(subentry_infos["access"].upper(),save,subIndexType,sizeof,name,sep)
         strIndex += "                     };\n"
         indexContents[index] = strIndex