提交 d2e226df 编写于 作者: R Radostin Stoyanov 提交者: Daniel P. Berrangé

apibuild: Simplify type checking of literals

Reduce the number of if-statements used to assign a literals
to corresponding class variables.
Reviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
Signed-off-by: NRadostin Stoyanov <rstoyanov1@gmail.com>
上级 06462d79
...@@ -283,24 +283,19 @@ class index: ...@@ -283,24 +283,19 @@ class index:
d.set_static(1) d.set_static(1)
if d is not None and name is not None and type is not None: if d is not None and name is not None and type is not None:
if type == "function": type_map = {
self.functions[name] = d "function": self.functions,
elif type == "functype": "functype": self.functions,
self.functions[name] = d "variable": self.variables,
elif type == "variable": "include": self.includes,
self.variables[name] = d "struct": self.structs,
elif type == "include": "union": self.unions,
self.includes[name] = d "enum": self.enums,
elif type == "struct": "typedef": self.typedefs,
self.structs[name] = d "macro": self.macros
elif type == "union": }
self.unions[name] = d if type in type_map:
elif type == "enum": type_map[type][name] = d
self.enums[name] = d
elif type == "typedef":
self.typedefs[name] = d
elif type == "macro":
self.macros[name] = d
else: else:
self.warning("Unable to register type ", type) self.warning("Unable to register type ", type)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册