mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
Fix uint properties
This commit is contained in:
parent
3f55aae7de
commit
f2b7d3bd95
6 changed files with 28 additions and 0 deletions
|
@ -377,6 +377,14 @@ class LiteralValue(Value):
|
||||||
except:
|
except:
|
||||||
raise CompileError(f"Cannot convert {self.tokens['value']} to integer")
|
raise CompileError(f"Cannot convert {self.tokens['value']} to integer")
|
||||||
|
|
||||||
|
elif isinstance(type, gir.UIntType):
|
||||||
|
try:
|
||||||
|
int(self.tokens["value"])
|
||||||
|
if int(self.tokens["value"]) < 0:
|
||||||
|
raise Exception()
|
||||||
|
except:
|
||||||
|
raise CompileError(f"Cannot convert {self.tokens['value']} to unsigned integer")
|
||||||
|
|
||||||
elif isinstance(type, gir.FloatType):
|
elif isinstance(type, gir.FloatType):
|
||||||
try:
|
try:
|
||||||
float(self.tokens["value"])
|
float(self.tokens["value"])
|
||||||
|
|
5
tests/sample_errors/uint.blp
Normal file
5
tests/sample_errors/uint.blp
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
using Gtk 4.0;
|
||||||
|
|
||||||
|
FlowBox {
|
||||||
|
column-spacing: -2;
|
||||||
|
}
|
1
tests/sample_errors/uint.err
Normal file
1
tests/sample_errors/uint.err
Normal file
|
@ -0,0 +1 @@
|
||||||
|
4,19,2,Cannot convert -2 to unsigned integer
|
5
tests/samples/uint.blp
Normal file
5
tests/samples/uint.blp
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
using Gtk 4.0;
|
||||||
|
|
||||||
|
FlowBox {
|
||||||
|
column-spacing: 2;
|
||||||
|
}
|
7
tests/samples/uint.ui
Normal file
7
tests/samples/uint.ui
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<interface>
|
||||||
|
<requires lib="gtk" version="4.0"/>
|
||||||
|
<object class="GtkFlowBox">
|
||||||
|
<property name="column-spacing">2</property>
|
||||||
|
</object>
|
||||||
|
</interface>
|
|
@ -110,6 +110,7 @@ class TestSamples(unittest.TestCase):
|
||||||
self.assert_sample("style")
|
self.assert_sample("style")
|
||||||
self.assert_sample("template")
|
self.assert_sample("template")
|
||||||
self.assert_sample("translated")
|
self.assert_sample("translated")
|
||||||
|
self.assert_sample("uint")
|
||||||
self.assert_sample("using")
|
self.assert_sample("using")
|
||||||
|
|
||||||
|
|
||||||
|
@ -136,5 +137,6 @@ class TestSamples(unittest.TestCase):
|
||||||
self.assert_sample_error("size_group_obj_dne")
|
self.assert_sample_error("size_group_obj_dne")
|
||||||
self.assert_sample_error("styles_in_non_widget")
|
self.assert_sample_error("styles_in_non_widget")
|
||||||
self.assert_sample_error("two_templates")
|
self.assert_sample_error("two_templates")
|
||||||
|
self.assert_sample_error("uint")
|
||||||
self.assert_sample_error("using_invalid_namespace")
|
self.assert_sample_error("using_invalid_namespace")
|
||||||
self.assert_sample_error("widgets_in_non_size_group")
|
self.assert_sample_error("widgets_in_non_size_group")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue