1
0
mirror of https://gitlab.com/libvirt/libvirt-python.git synced 2024-10-26 07:55:06 +03:00

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>
This commit is contained in:
Daniel P. Berrangé 2022-03-24 12:23:46 +00:00
parent 6b2cef6182
commit 054c9e9b73

View File

@ -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"]:
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_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":
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_')):