mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
decompiler: GUInt properties for gunichar needs conversion
Fix #148 Signed-off-by: Hubert Figuière <hub@figuiere.net>
This commit is contained in:
parent
d47955c5a2
commit
7823b5b2a8
4 changed files with 27 additions and 0 deletions
|
@ -118,6 +118,15 @@ class DecompileCtx:
|
|||
|
||||
if type is None:
|
||||
self.print(f"{name}: {escape_quote(value)};")
|
||||
elif type.assignable_to(UIntType()):
|
||||
try:
|
||||
val = int(value)
|
||||
self.print(f"{name}: {value};")
|
||||
except:
|
||||
# Properties like 'invisible-char' are a unicode char
|
||||
# in a guint, so we convert manually. Unlike in format.
|
||||
val = ord(value)
|
||||
self.print(f"{name}: {val};")
|
||||
elif type.assignable_to(FloatType()):
|
||||
self.print(f"{name}: {value};")
|
||||
elif type.assignable_to(BoolType()):
|
||||
|
|
5
tests/samples/entry.blp
Normal file
5
tests/samples/entry.blp
Normal file
|
@ -0,0 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
Entry {
|
||||
invisible-char: 9679;
|
||||
}
|
7
tests/samples/entry.ui
Normal file
7
tests/samples/entry.ui
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<requires lib="gtk" version="4.0"/>
|
||||
<object class="GtkEntry">
|
||||
<property name="invisible-char">●</property>
|
||||
</object>
|
||||
</interface>
|
|
@ -174,6 +174,9 @@ class TestSamples(unittest.TestCase):
|
|||
for sample in samples:
|
||||
REQUIRE_ADW_1_4 = ["adw_breakpoint"]
|
||||
REQUIRE_ADW_1_5 = ["adw_alertdialog_responses"]
|
||||
# Those test case that don't round trip due to ambiguous notation.
|
||||
# So `assert_sample` fail on these.
|
||||
AMBIGUOUS = ["entry"]
|
||||
|
||||
SKIP_RUN = [
|
||||
"expr_closure",
|
||||
|
@ -195,6 +198,8 @@ class TestSamples(unittest.TestCase):
|
|||
continue
|
||||
if sample in REQUIRE_ADW_1_5 and not self.have_adw_1_5:
|
||||
continue
|
||||
if sample in AMBIGUOUS:
|
||||
continue
|
||||
|
||||
with self.subTest(sample):
|
||||
self.assert_sample(sample, skip_run=sample in SKIP_RUN)
|
||||
|
@ -222,6 +227,7 @@ class TestSamples(unittest.TestCase):
|
|||
self.assert_decompile("adw_alertdialog_responses")
|
||||
self.assert_decompile("adw_messagedialog_responses")
|
||||
self.assert_decompile("child_type")
|
||||
self.assert_decompile("entry")
|
||||
self.assert_decompile("file_filter")
|
||||
self.assert_decompile("flags")
|
||||
self.assert_decompile("id_prop")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue