Fix comments and add the wizard info.
[bertos.git] / wizard / bertos_utils.py
index d405130fe3741f4319db2743435e05671906c1ff..3854f9f269682ff7c6c02ca0f5f8838b2c9228ff 100644 (file)
@@ -55,6 +55,8 @@ def createBertosProject(projectInfos):
         string = open(sourcesDir + "/" + key, "r").read()
         for parameter, infos in value.items():
             value = infos["value"]
+            if "unsigned" in infos["informations"].keys() and infos["informations"]["unsigned"]:
+                value += "U"
             if "long" in infos["informations"].keys() and infos["informations"]["long"]:
                 value += "L"
             string = sub(string, parameter, value)
@@ -210,6 +212,12 @@ def loadConfigurationInfos(path):
             configurationInfos[name] = {}
             configurationInfos[name]["value"] = value
             configurationInfos[name]["informations"] = informations
+            if configurationInfos[name]["informations"]["type"] == "int" and configurationInfos[name]["value"].find("L") != -1:
+                configurationInfos[name]["informations"]["long"] = True
+                configurationInfos[name]["value"] = configurationInfos[name]["value"].replace("L", "")
+            if configurationInfos[name]["informations"]["type"] == "int" and configurationInfos[name]["value"].find("U") != -1:
+                configurationInfos[name]["informations"]["unsigned"] = True
+                configurationInfos[name]["value"] = configurationInfos[name]["value"].replace("U", "")
             configurationInfos[name]["description"] = description
         return configurationInfos
     except SyntaxError:
@@ -285,3 +293,39 @@ def sub(string, parameter, value):
     Substitute the given value at the given parameter define in the given string
     """
     return re.sub(r"(?P<define>#define\s+" + parameter + r"\s+)([^\s]+)", r"\g<define>" + value, string)
+
+def isInt(value):
+    """
+    Return True if the value is a simple int.
+    """
+    if "long" not in value["informations"].keys() and "unsigned" not in value["informations"].keys():
+        return True
+    else:
+        return False
+
+def isLong(value):
+    """
+    Return True if the value is a long.
+    """
+    if "long" in value["informations"].keys() and value["informations"]["long"] and "unsigned" not in value["informations"].keys():
+        return True
+    else:
+        return False
+
+def isUnsigned(value):
+    """
+    Return True if the value is an unsigned.
+    """
+    if "unsigned" in value["informations"].keys() and value["informations"]["unsigned"] and "long" not in value["informations"].keys():
+        return True
+    else:
+        return False
+
+def isUnsignedLong(value):
+    """
+    Return True if the value is an unsigned long.
+    """
+    if "unsigned" in value["informations"].keys() and "long" in value["informations"].keys() and value["informations"]["unsigned"] and value["informations"]["long"]:
+        return True
+    else:
+        return False
\ No newline at end of file