mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
gir: Fix signatures for properties and signals
Add arguments to signal signatures and fix property signatures
This commit is contained in:
parent
3d79f9560c
commit
4eaf735732
2 changed files with 52 additions and 10 deletions
|
@ -318,7 +318,7 @@ class Property(GirNode):
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def signature(self):
|
def signature(self):
|
||||||
return f"{self.full_name} {self.container.name}.{self.name}"
|
return f"{self.type.full_name} {self.container.name}:{self.name}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def writable(self) -> bool:
|
def writable(self) -> bool:
|
||||||
|
@ -329,27 +329,56 @@ class Property(GirNode):
|
||||||
return self.tl.PROP_CONSTRUCT_ONLY == 1
|
return self.tl.PROP_CONSTRUCT_ONLY == 1
|
||||||
|
|
||||||
|
|
||||||
class Parameter(GirNode):
|
class Argument(GirNode):
|
||||||
def __init__(self, container: GirNode, tl: typelib.Typelib) -> None:
|
def __init__(self, container: GirNode, tl: typelib.Typelib) -> None:
|
||||||
super().__init__(container, tl)
|
super().__init__(container, tl)
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def name(self) -> str:
|
||||||
|
return self.tl.ARG_NAME
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def type(self) -> GirType:
|
||||||
|
return self.get_containing(Repository)._resolve_type_id(self.tl.ARG_TYPE)
|
||||||
|
|
||||||
|
|
||||||
|
class Signature(GirNode):
|
||||||
|
def __init__(self, container: GirNode, tl: typelib.Typelib) -> None:
|
||||||
|
super().__init__(container, tl)
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def args(self) -> T.List[Argument]:
|
||||||
|
n_arguments = self.tl.SIGNATURE_N_ARGUMENTS
|
||||||
|
blob_size = self.tl.header.HEADER_ARG_BLOB_SIZE
|
||||||
|
result = []
|
||||||
|
for i in range(n_arguments):
|
||||||
|
entry = self.tl.SIGNATURE_ARGUMENTS[i * blob_size]
|
||||||
|
result.append(Argument(self, entry))
|
||||||
|
return result
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def return_type(self) -> GirType:
|
||||||
|
return self.get_containing(Repository)._resolve_type_id(
|
||||||
|
self.tl.SIGNATURE_RETURN_TYPE
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class Signal(GirNode):
|
class Signal(GirNode):
|
||||||
def __init__(
|
def __init__(
|
||||||
self, klass: T.Union["Class", "Interface"], tl: typelib.Typelib
|
self, klass: T.Union["Class", "Interface"], tl: typelib.Typelib
|
||||||
) -> None:
|
) -> None:
|
||||||
super().__init__(klass, tl)
|
super().__init__(klass, tl)
|
||||||
# if parameters := xml.get_elements('parameters'):
|
|
||||||
# self.params = [Parameter(self, child) for child in parameters[0].get_elements('parameter')]
|
@cached_property
|
||||||
# else:
|
def gir_signature(self) -> Signature:
|
||||||
# self.params = []
|
return Signature(self, self.tl.SIGNAL_SIGNATURE)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def signature(self):
|
def signature(self):
|
||||||
# TODO: fix
|
args = ", ".join(
|
||||||
# args = ", ".join([f"{p.type_name} {p.name}" for p in self.params])
|
[f"{a.type.full_name} {a.name}" for a in self.gir_signature.args]
|
||||||
args = ""
|
)
|
||||||
return f"signal {self.container.name}.{self.name} ({args})"
|
return f"signal {self.container.full_name}::{self.name} ({args})"
|
||||||
|
|
||||||
|
|
||||||
class Interface(GirNode, GirType):
|
class Interface(GirNode, GirType):
|
||||||
|
|
|
@ -118,6 +118,7 @@ class Typelib:
|
||||||
HEADER_FUNCTION_BLOB_SIZE = Field(0x3E, "u16")
|
HEADER_FUNCTION_BLOB_SIZE = Field(0x3E, "u16")
|
||||||
HEADER_CALLBACK_BLOB_SIZE = Field(0x40, "u16")
|
HEADER_CALLBACK_BLOB_SIZE = Field(0x40, "u16")
|
||||||
HEADER_SIGNAL_BLOB_SIZE = Field(0x42, "u16")
|
HEADER_SIGNAL_BLOB_SIZE = Field(0x42, "u16")
|
||||||
|
HEADER_ARG_BLOB_SIZE = Field(0x46, "u16")
|
||||||
HEADER_PROPERTY_BLOB_SIZE = Field(0x48, "u16")
|
HEADER_PROPERTY_BLOB_SIZE = Field(0x48, "u16")
|
||||||
HEADER_FIELD_BLOB_SIZE = Field(0x4A, "u16")
|
HEADER_FIELD_BLOB_SIZE = Field(0x4A, "u16")
|
||||||
HEADER_VALUE_BLOB_SIZE = Field(0x4C, "u16")
|
HEADER_VALUE_BLOB_SIZE = Field(0x4C, "u16")
|
||||||
|
@ -132,6 +133,13 @@ class Typelib:
|
||||||
DIR_ENTRY_OFFSET = Field(0x8, "pointer")
|
DIR_ENTRY_OFFSET = Field(0x8, "pointer")
|
||||||
DIR_ENTRY_NAMESPACE = Field(0x8, "string")
|
DIR_ENTRY_NAMESPACE = Field(0x8, "string")
|
||||||
|
|
||||||
|
ARG_NAME = Field(0x0, "string")
|
||||||
|
ARG_TYPE = Field(0xC, "u32")
|
||||||
|
|
||||||
|
SIGNATURE_RETURN_TYPE = Field(0x0, "u32")
|
||||||
|
SIGNATURE_N_ARGUMENTS = Field(0x6, "u16")
|
||||||
|
SIGNATURE_ARGUMENTS = Field(0x8, "offset")
|
||||||
|
|
||||||
ATTR_OFFSET = Field(0x0, "u32")
|
ATTR_OFFSET = Field(0x0, "u32")
|
||||||
ATTR_NAME = Field(0x0, "string")
|
ATTR_NAME = Field(0x0, "string")
|
||||||
ATTR_VALUE = Field(0x0, "string")
|
ATTR_VALUE = Field(0x0, "string")
|
||||||
|
@ -180,6 +188,11 @@ class Typelib:
|
||||||
PROP_CONSTRUCT_ONLY = Field(0x4, "u32", 4, 1)
|
PROP_CONSTRUCT_ONLY = Field(0x4, "u32", 4, 1)
|
||||||
PROP_TYPE = Field(0xC, "u32")
|
PROP_TYPE = Field(0xC, "u32")
|
||||||
|
|
||||||
|
SIGNAL_DEPRECATED = Field(0x0, "u16", 0, 1)
|
||||||
|
SIGNAL_DETAILED = Field(0x0, "u16", 5, 1)
|
||||||
|
SIGNAL_NAME = Field(0x4, "string")
|
||||||
|
SIGNAL_SIGNATURE = Field(0xC, "pointer")
|
||||||
|
|
||||||
VALUE_NAME = Field(0x4, "string")
|
VALUE_NAME = Field(0x4, "string")
|
||||||
VALUE_VALUE = Field(0x8, "i32")
|
VALUE_VALUE = Field(0x8, "i32")
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue