Struct/union inheritence
Submitted by Johan Dahlin
Link to original bug (#560692)
Description
There are a couple of structs and unions which uses inheritance in our stack that is currently quite problematic to introspection.
Non-complete list:
- GdkEvent (gdk)
- GMenuTreeItem (gmenu)
- GIBaseInfo (gobject-introspection itself)
- cairo_surface (cairo)
What they have in common is the following pattern:
typedef enum { BANANA_STRUCT = 1; APPLE_STRUCT = 2; } StructKind;
StructKind base_struct_get_kind (BaseStruct *base);
BananaStruct { BaseStruct base; ... };
AppleStruct { BaseStruct base; ... };
To support this we'd need the following:
- An annotation for each sub struct adding a relationg to the base struct, eg: BananaStruct: (child-of BaseStruct 1) AppleStruct: (child-of BaseStruct 2) The name of the struct and the type/kind value representation for that struct
- The type getter, eg: BaseStruct: (child-getter base_struct_get_kind)
We'd need to extend the GIR and the typelib to support that as well.
Task list:
- implement/decide annotations
- update gir
- update typelib
- add tests
- document annotation
Blocking
Edited by Corentin Noël