mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
Fix enums with "-"/"_" in the name
This commit is contained in:
parent
f2b7d3bd95
commit
c4beb6841c
5 changed files with 21 additions and 1 deletions
|
@ -408,7 +408,10 @@ class FlagsValue(Value):
|
|||
|
||||
class IdentValue(Value):
|
||||
def emit_xml(self, xml: XmlEmitter):
|
||||
xml.put_text(self.tokens["value"])
|
||||
if isinstance(self.parent.value_type, gir.Enumeration):
|
||||
xml.put_text(self.parent.value_type.members[self.tokens["value"]].nick)
|
||||
else:
|
||||
xml.put_text(self.tokens["value"])
|
||||
|
||||
@validate()
|
||||
def validate_for_type(self):
|
||||
|
|
|
@ -291,6 +291,10 @@ class EnumMember(GirNode):
|
|||
def value(self):
|
||||
return self._value
|
||||
|
||||
@property
|
||||
def nick(self):
|
||||
return self.xml["glib:nick"]
|
||||
|
||||
@property
|
||||
def signature(self):
|
||||
return f"enum member {self.full_name} = {self.value}"
|
||||
|
|
5
tests/samples/enum.blp
Normal file
5
tests/samples/enum.blp
Normal file
|
@ -0,0 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
ScrolledWindow {
|
||||
window-placement: top_left;
|
||||
}
|
7
tests/samples/enum.ui
Normal file
7
tests/samples/enum.ui
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<requires lib="gtk" version="4.0"/>
|
||||
<object class="GtkScrolledWindow">
|
||||
<property name="window-placement">top-left</property>
|
||||
</object>
|
||||
</interface>
|
|
@ -96,6 +96,7 @@ class TestSamples(unittest.TestCase):
|
|||
self.assert_sample("binding")
|
||||
self.assert_sample("child_type")
|
||||
self.assert_sample("combo_box_text")
|
||||
self.assert_sample("enum")
|
||||
self.assert_sample("file_filter")
|
||||
self.assert_sample("flags")
|
||||
self.assert_sample("id_prop")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue