diff options
author | Daniel P. Berrangé <berrange@redhat.com> | 2022-03-24 12:23:46 +0000 |
---|---|---|
committer | Daniel P. Berrangé <berrange@redhat.com> | 2022-04-21 12:32:51 +0100 |
commit | 054c9e9b739e49898dbf96675dd268bd8898caff (patch) | |
tree | 8e7d2d969a1a41c3c76ad6b75ca4e388f07948fa | |
parent | 6b2cef6182c37d1be753d04847a1cf990356d0dd (diff) | |
download | libvirt-python-054c9e9b739e49898dbf96675dd268bd8898caff.tar.gz |
generator: use single function for registering all functions
Now that we only use a single dict for tracking all functions, we
only need a single function for registering them.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
-rwxr-xr-x | generator.py | 50 |
1 files changed, 11 insertions, 39 deletions
diff --git a/generator.py b/generator.py index d3928ef..ed1eb0e 100755 --- a/generator.py +++ b/generator.py @@ -117,37 +117,21 @@ class docParser(xml.sax.handler.ContentHandler): # functions come from source files, hence 'virerror.c' if self.function: assert self.function_return - if self.function_module in libvirt_headers + \ - ["event", "virevent", "virerror", "virterror"]: - function(self.function, self.function_descr, - self.function_return, self.function_args, - self.function_file, self.function_module, - self.function_cond) - elif self.function_module == "libvirt-lxc": - lxc_function(self.function, self.function_descr, - self.function_return, self.function_args, - self.function_file, self.function_module, - self.function_cond) - elif self.function_module == "libvirt-qemu": - qemu_function(self.function, self.function_descr, - self.function_return, self.function_args, - self.function_file, self.function_module, - self.function_cond) - elif self.function_file == "python": + + modules = libvirt_headers + ["event", + "virevent", + "virerror", + "virterror", + "libvirt-lxc", + "libvirt-qemu"] + files = ["python", "python-lxc", "python-qemu"] + + if (self.function_module in modules or + self.function_file in files): function(self.function, self.function_descr, self.function_return, self.function_args, self.function_file, self.function_module, self.function_cond) - elif self.function_file == "python-lxc": - lxc_function(self.function, self.function_descr, - self.function_return, self.function_args, - self.function_file, self.function_module, - self.function_cond) - elif self.function_file == "python-qemu": - qemu_function(self.function, self.function_descr, - self.function_return, self.function_args, - self.function_file, self.function_module, - self.function_cond) self.in_function = False elif tag == 'arg': if self.in_function: @@ -177,18 +161,6 @@ def function(name: str, desc: str, ret: ArgumentType, args: List[ArgumentType], functions[name] = (desc, ret, args, file, module, cond) -def qemu_function(name: str, desc: str, ret: ArgumentType, args: List[ArgumentType], file: str, module: str, cond: str) -> None: - if onlyOverrides and name not in functions: - return - functions[name] = (desc, ret, args, file, module, cond) - - -def lxc_function(name: str, desc: str, ret: ArgumentType, args: List[ArgumentType], file: str, module: str, cond: str) -> None: - if onlyOverrides and name not in functions: - return - functions[name] = (desc, ret, args, file, module, cond) - - def enum(type: str, name: str, value: EnumValue) -> None: if (name.startswith('VIR_DOMAIN_EVENT_ID_') or name.startswith('VIR_NETWORK_EVENT_ID_')): |