mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
language: Change extern type syntax
Use a '$' instead of a '.' to indicate a type provided in application code. The reason for the change is to have a consistent "extern" symbol that isn't widely used elsewhere and isn't ambiguous in expressions.
This commit is contained in:
parent
be284de879
commit
0b402db4d5
11 changed files with 41 additions and 13 deletions
|
@ -31,33 +31,41 @@ class TypeName(AstNode):
|
|||
UseIdent("class_name"),
|
||||
],
|
||||
[
|
||||
".",
|
||||
AnyOf("$", [".", UseLiteral("old_extern", True)]),
|
||||
UseIdent("class_name"),
|
||||
UseLiteral("ignore_gir", True),
|
||||
UseLiteral("extern", True),
|
||||
],
|
||||
UseIdent("class_name"),
|
||||
)
|
||||
|
||||
@validate()
|
||||
def old_extern(self):
|
||||
if self.tokens["old_extern"]:
|
||||
raise UpgradeWarning(
|
||||
"Use the '$' extern syntax introduced in blueprint 0.8.0",
|
||||
actions=[CodeAction("Use '$' syntax", "$" + self.tokens["class_name"])],
|
||||
)
|
||||
|
||||
@validate("class_name")
|
||||
def type_exists(self):
|
||||
if not self.tokens["ignore_gir"] and self.gir_ns is not None:
|
||||
if not self.tokens["extern"] and self.gir_ns is not None:
|
||||
self.root.gir.validate_type(
|
||||
self.tokens["class_name"], self.tokens["namespace"]
|
||||
)
|
||||
|
||||
@validate("namespace")
|
||||
def gir_ns_exists(self):
|
||||
if not self.tokens["ignore_gir"]:
|
||||
if not self.tokens["extern"]:
|
||||
self.root.gir.validate_ns(self.tokens["namespace"])
|
||||
|
||||
@property
|
||||
def gir_ns(self):
|
||||
if not self.tokens["ignore_gir"]:
|
||||
if not self.tokens["extern"]:
|
||||
return self.root.gir.namespaces.get(self.tokens["namespace"] or "Gtk")
|
||||
|
||||
@property
|
||||
def gir_type(self) -> gir.GirType:
|
||||
if self.tokens["class_name"] and not self.tokens["ignore_gir"]:
|
||||
if self.tokens["class_name"] and not self.tokens["extern"]:
|
||||
return self.root.gir.get_type(
|
||||
self.tokens["class_name"], self.tokens["namespace"]
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue