diff --git a/JsonGenerator/source/header_loader.py b/JsonGenerator/source/header_loader.py index 296dcb3..32f12fa 100644 --- a/JsonGenerator/source/header_loader.py +++ b/JsonGenerator/source/header_loader.py @@ -248,17 +248,16 @@ def ConvertType(var): enum_spec = { "enum": [e.meta.text if e.meta.text else e.name for e in cppType.items] } else: enum_spec = { "enum": [e.meta.text if e.meta.text else e.name.replace("_"," ").title().replace(" ","") for e in cppType.items] } + enum_spec["ids"] = [e.name for e in cppType.items] - enum_spec["hint"] = var.type.Type().name + + if not cppType.items[0].auto_value: + enum_spec["values"] = [e.value for e in cppType.items] for e in cppType.items: if "endmarker" in e.meta.decorators: enum_spec["endmarker"] = e.name break; - - if not cppType.items[0].auto_value: - enum_spec["values"] = [e.value for e in cppType.items] - if "bitmask" in var.meta.decorators or "bitmask" in var.type.Type().meta.decorators: enum_spec["bitmask"] = True enum_spec["type"] = "string" diff --git a/JsonGenerator/source/json_loader.py b/JsonGenerator/source/json_loader.py index 30d315d..60fda92 100644 --- a/JsonGenerator/source/json_loader.py +++ b/JsonGenerator/source/json_loader.py @@ -207,11 +207,13 @@ def actual_name(self): @property def cpp_name(self): # C++ name of the object if self.new_name: - return (self.new_name[0].upper() + self.new_name[1:]) + _name = self.new_name elif self.original_name: - return (self.original_name[0].upper() + self.original_name[1:]) + _name = self.original_name else: - return (self.name[0].upper() + self.name[1:]) + _name = self.name + + return (_name[0].upper() + _name[1:]) @property def cpp_type(self): # C++ type of the object (e.g. may be array) @@ -448,7 +450,7 @@ def __DetermineClassName(self): classname = self.original_type elif "class" in self.schema: # Override class name if "class" property present - classname = self.schema["class"].capitalize + classname = self.schema["class"].capitalize() elif "hint" in self.schema: # Override class name if "hint" property present classname = self.schema["hint"] @@ -554,7 +556,7 @@ def cpp_name(self): if self.is_renamed: return super().cpp_name elif isinstance(self.parent, JsonMethod): - return self.parent.cpp_name + super().cpp_name + return self.parent.actual_name.capitalize() + super().cpp_name elif isinstance(self.parent, JsonArray): return self.parent.cpp_name else: @@ -765,8 +767,23 @@ def result(self): def function_name(self): if "hint" in self.schema: return self.schema["hint"] + elif self.original_name: + return self.original_name + else: + return self.actual_name[0].upper() + self.actual_name[1:] + + @property + def cpp_name(self): # C++ name of the object + if self.new_name: + _name = self.new_name + elif self.original_name: + _name = self.original_name + elif "hint" in self.schema: + _name = self.schema["hint"] else: - return self.actual_name + _name = self.name + + return (_name[0].upper() + _name[1:]) def Headline(self): return "'%s'%s%s" % (self.json_name, (" - " + self.summary.split(".", 1)[0]) if self.summary else "",