Commit 895236d2 authored by Emmanuele Bassi's avatar Emmanuele Bassi 👣
Browse files

gir: Add "effective" records

Not all records are actually interesting to us. The class structures are
typically folded into the actual type class; and the "private", opaque
structures that end up in public headers are not really public
documentation.
parent 71bef5c4
......@@ -507,11 +507,13 @@ class Boxed(Type):
class Record(Type):
def __init__(self, name: str, ctype: str, symbol_prefix: str, gtype: T.Optional[GType] = None, struct_for: T.Optional[str] = None):
def __init__(self, name: str, ctype: str, symbol_prefix: str, gtype: T.Optional[GType] = None,
struct_for: T.Optional[str] = None, disguised: bool = False):
super().__init__(name, ctype)
self.symbol_prefix = symbol_prefix
self.gtype = gtype
self.struct_for = struct_for
self.disguised = disguised
self.constructors: T.List[Function] = []
self.methods: T.List[Method] = []
self.functions: T.List[Function] = []
......@@ -675,6 +677,16 @@ class Namespace:
def get_records(self) -> T.List[Record]:
return self._records
def get_effective_records(self) -> T.List[Record]:
def is_effective(r):
if "Private" in r.name and r.disguised:
return False
if r.struct_for is not None:
return False
return True
return [x for x in self._records if is_effective(x)]
def get_unions(self) -> T.List[Union]:
return self._unions
......
......@@ -712,12 +712,14 @@ class GirParser:
get_type: T.Optional[str] = node.attrib.get(_glibns('get-type'))
type_struct: T.Optional[str] = node.attrib.get(_glibns('type-struct'))
gtype_struct_for: T.Optional[str] = node.attrib.get(_glibns('is-gtype-struct-for'))
disguised: bool = node.attrib.get('disguised', '0') == '1'
gtype = None
if type_name is not None:
gtype = ast.GType(type_name=type_name, get_type=get_type, type_struct=type_struct)
res = ast.Record(name=name, symbol_prefix=symbol_prefix, ctype=ctype, gtype=gtype, struct_for=gtype_struct_for)
res = ast.Record(name=name, symbol_prefix=symbol_prefix, ctype=ctype, gtype=gtype,
struct_for=gtype_struct_for, disguised=disguised)
res.set_introspectable(node.attrib.get('introspectable', '1') != '0')
self._maybe_parse_docs(node, res)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment