decompiler: Implement support for bindings

The .ui files for tests were taken from GTK test suite.
This commit is contained in:
Jan Tojnar 2023-11-18 21:06:03 +01:00
parent 479fe17589
commit 7fc367e644
18 changed files with 172 additions and 0 deletions

View file

@ -357,6 +357,45 @@ def decompile_property(
return gir
@decompiler("binding")
def decompile_binding(ctx: DecompileCtx, gir, name):
name = name.replace("_", "-")
ctx.print(f"{name}: bind ", newline=False)
ctx.end_block_with(";")
return gir
@decompiler("lookup", cdata=True)
def decompile_lookup(ctx: DecompileCtx, gir, name, cdata, type=None):
name = name.replace("_", "-")
if cdata is not None:
ctx.print(cdata, newline=False)
cast = f" as <{type}>" if type is not None else ""
ctx.end_block_with(f"{cast}.{name}", newline_after=False, indent=False)
return gir
@decompiler("constant", cdata=True)
def decompile_constant(ctx: DecompileCtx, gir, cdata, type=None):
cast = f" as <{type}>" if type is not None else ""
ctx.print(f"{cdata}{cast}", newline=False, indent=False)
return gir
@decompiler("closure")
def decompile_closure(ctx: DecompileCtx, gir, function, type):
ctx.print(f"{function}(", newline=False)
ctx.separate_block_elements_with(f", ")
cast = f" as <{type}>"
ctx.end_block_with(f"){cast}", newline_after=False, indent=False)
return gir
@decompiler("attribute", cdata=True)
def decompile_attribute(
ctx, gir, name, cdata, translatable="false", comments=None, context=None