From 3b6dcf072d6766b04a025a3f13283c2c497fcd19 Mon Sep 17 00:00:00 2001 From: James Westman Date: Sat, 19 Oct 2024 10:21:13 -0500 Subject: [PATCH] typelib: Fix field offsets for attributes This fixes a bug where the decompiler could not recognize enums by their C identifiers because it could not correctly read attributes. Fixes #177. --- blueprintcompiler/typelib.py | 4 ++-- tests/samples/issue_177.blp | 5 +++++ tests/samples/issue_177.ui | 12 ++++++++++++ tests/test_samples.py | 2 +- 4 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 tests/samples/issue_177.blp create mode 100644 tests/samples/issue_177.ui diff --git a/blueprintcompiler/typelib.py b/blueprintcompiler/typelib.py index 145bf57..be22eb1 100644 --- a/blueprintcompiler/typelib.py +++ b/blueprintcompiler/typelib.py @@ -148,8 +148,8 @@ class Typelib: SIGNATURE_ARGUMENTS = Field(0x8, "offset") ATTR_OFFSET = Field(0x0, "u32") - ATTR_NAME = Field(0x0, "string") - ATTR_VALUE = Field(0x0, "string") + ATTR_NAME = Field(0x4, "string") + ATTR_VALUE = Field(0x8, "string") TYPE_BLOB_TAG = Field(0x0, "u8", 3, 5) TYPE_BLOB_INTERFACE = Field(0x2, "dir_entry") diff --git a/tests/samples/issue_177.blp b/tests/samples/issue_177.blp new file mode 100644 index 0000000..0a0f613 --- /dev/null +++ b/tests/samples/issue_177.blp @@ -0,0 +1,5 @@ +using Gtk 4.0; + +Box { + orientation: horizontal; +} diff --git a/tests/samples/issue_177.ui b/tests/samples/issue_177.ui new file mode 100644 index 0000000..53f9b60 --- /dev/null +++ b/tests/samples/issue_177.ui @@ -0,0 +1,12 @@ + + + + + + GTK_ORIENTATION_HORIZONTAL + + \ No newline at end of file diff --git a/tests/test_samples.py b/tests/test_samples.py index 1d1e17f..00ef72a 100644 --- a/tests/test_samples.py +++ b/tests/test_samples.py @@ -207,7 +207,7 @@ class TestSamples(unittest.TestCase): ] # Decompiler-only tests - SKIP_COMPILE = ["translator_comments"] + SKIP_COMPILE = ["issue_177", "translator_comments"] SKIP_DECOMPILE = [ # Comments are not preserved in either direction