mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
Change template syntax
Templates now use a TypeName instead of an identifier, which makes it clearer that it's an extern symbol (or that it's a Gtk.ListItem).
This commit is contained in:
parent
aebf8be278
commit
04509e4b2e
31 changed files with 175 additions and 55 deletions
|
@ -1,4 +1,4 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
template MyWidget : Gtk.Widget {}
|
||||
template $MyWidget : Gtk.Widget {}
|
||||
Gtk.Widget {}
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
template TestTemplate : Gtk.NotARealClass {}
|
||||
template $TestTemplate : Gtk.NotARealClass {}
|
||||
|
|
|
@ -1 +1 @@
|
|||
3,29,13,Namespace Gtk does not contain a type called NotARealClass
|
||||
3,30,13,Namespace Gtk does not contain a type called NotARealClass
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
template GtkListItem {
|
||||
Label {
|
||||
label: bind GtkListItem.item.label;
|
||||
}
|
||||
$MyObject object {
|
||||
foo: bind object.bar.baz;
|
||||
}
|
|
@ -1 +1 @@
|
|||
5,34,5,Could not determine the type of the preceding expression
|
||||
4,24,3,Could not determine the type of the preceding expression
|
10
tests/sample_errors/legacy_template.blp
Normal file
10
tests/sample_errors/legacy_template.blp
Normal file
|
@ -0,0 +1,10 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
template TestTemplate : ApplicationWindow {
|
||||
test-property: "Hello, world";
|
||||
test-signal => $on_test_signal();
|
||||
}
|
||||
|
||||
Dialog {
|
||||
transient-for: TestTemplate;
|
||||
}
|
2
tests/sample_errors/legacy_template.err
Normal file
2
tests/sample_errors/legacy_template.err
Normal file
|
@ -0,0 +1,2 @@
|
|||
3,10,12,Use type syntax here (introduced in blueprint 0.8.0)
|
||||
9,18,12,Use 'template' instead of the class name (introduced in 0.8.0)
|
|
@ -1,3 +1,3 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
template TestTemplate : Gtk.Orientable {}
|
||||
template $TestTemplate : Gtk.Orientable {}
|
||||
|
|
|
@ -1 +1 @@
|
|||
3,25,14,Gtk.Orientable is an interface, not a class
|
||||
3,26,14,Gtk.Orientable is an interface, not a class
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
template TestTemplate : Adw.ApplicationWindow {}
|
||||
template $TestTemplate : Adw.ApplicationWindow {}
|
||||
|
|
|
@ -1 +1 @@
|
|||
3,25,3,Namespace Adw was not imported
|
||||
3,26,3,Namespace Adw was not imported
|
||||
|
|
3
tests/sample_errors/template_parent.blp
Normal file
3
tests/sample_errors/template_parent.blp
Normal file
|
@ -0,0 +1,3 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
template Gtk.ListItem : $WrongParent {}
|
1
tests/sample_errors/template_parent.err
Normal file
1
tests/sample_errors/template_parent.err
Normal file
|
@ -0,0 +1 @@
|
|||
3,1,39,Parent type may only be specified if the template type is extern
|
|
@ -1,4 +1,6 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
template ClassName : Gtk.Button {}
|
||||
template ClassName2 : Gtk.Button {}
|
||||
template $ClassName : Gtk.Button {}
|
||||
template $ClassName2 : Gtk.Button {}
|
||||
|
||||
Label template {}
|
|
@ -1 +1,2 @@
|
|||
4,10,10,Only one template may be defined per file, but this file contains 2
|
||||
6,7,8,Duplicate object ID 'template'
|
||||
4,1,8,Only one template may be defined per file, but this file contains 2
|
|
@ -1,10 +1,10 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
template TestTemplate : ApplicationWindow {
|
||||
template $TestTemplate : ApplicationWindow {
|
||||
test-property: "Hello, world";
|
||||
test-signal => $on_test_signal();
|
||||
}
|
||||
|
||||
Dialog {
|
||||
transient-for: TestTemplate;
|
||||
transient-for: template;
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
template MyTemplate : Box {
|
||||
prop1: bind MyTemplate.prop2 as <$MyObject>.prop3;
|
||||
template $MyTemplate : Box {
|
||||
prop1: bind template.prop2 as <$MyObject>.prop3;
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
template MyTemplate : $MyParentClass {
|
||||
prop1: bind MyTemplate.prop2 as <$MyObject>.prop3;
|
||||
template $MyTemplate : $MyParentClass {
|
||||
prop1: bind template.prop2 as <$MyObject>.prop3;
|
||||
}
|
|
@ -1,3 +1,3 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
template GtkListItem {}
|
||||
template Gtk.ListItem {}
|
||||
|
|
|
@ -266,6 +266,7 @@ class TestSamples(unittest.TestCase):
|
|||
self.assert_sample_error("inline_menu")
|
||||
self.assert_sample_error("invalid_bool")
|
||||
self.assert_sample_error("layout_in_non_widget")
|
||||
self.assert_sample_error("legacy_template")
|
||||
self.assert_sample_error("menu_no_id")
|
||||
self.assert_sample_error("menu_toplevel_attribute")
|
||||
self.assert_sample_error("no_import_version")
|
||||
|
@ -284,6 +285,7 @@ class TestSamples(unittest.TestCase):
|
|||
self.assert_sample_error("strv")
|
||||
self.assert_sample_error("styles_in_non_widget")
|
||||
self.assert_sample_error("subscope")
|
||||
self.assert_sample_error("template_parent")
|
||||
self.assert_sample_error("two_templates")
|
||||
self.assert_sample_error("uint")
|
||||
self.assert_sample_error("using_invalid_namespace")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue