mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-02 07:23:41 +02:00
girepository: Expose GITypeInfo and GIArgInfo as stack allocatable
There are a handful of APIs in libgirepository which are used on performance-sensitive code paths in language bindings (such as looking at arguments when doing function calls). Historically libgirepository has provided a stack-allocated variant for them, which avoids returning a newly allocated `GIBaseInfo`. Since moving to glib.git and porting to `GTypeInstance`, that stack allocated version has been broken. This commit fixes it, by exposing obfuscated stack allocatable versions of `GITypeInfo` and `GIArgInfo`, which are the two `GIBaseInfo` subtypes which can be returned by the stack allocation functions. The commit includes unit tests for them. Signed-off-by: Philip Withnall <pwithnall@gnome.org> Fixes: #3217
This commit is contained in:
@@ -41,6 +41,17 @@ G_BEGIN_DECLS
|
||||
typedef struct _GIBaseInfo GIBaseInfo;
|
||||
typedef struct _GIBaseInfoClass GIBaseInfoClass;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/*< private >*/
|
||||
GTypeInstance parent_instance;
|
||||
|
||||
int dummy0;
|
||||
void *dummy1[3];
|
||||
uint32_t dummy2[2];
|
||||
void *dummy3[6];
|
||||
} GIBaseInfoStack;
|
||||
|
||||
/* Documented in gicallableinfo.c */
|
||||
typedef struct _GICallableInfo GICallableInfo;
|
||||
GI_AVAILABLE_IN_ALL GType gi_callable_info_get_type (void);
|
||||
@@ -110,11 +121,23 @@ typedef struct _GIFieldInfo GIFieldInfo;
|
||||
GI_AVAILABLE_IN_ALL GType gi_field_info_get_type (void);
|
||||
|
||||
/* Documented in giarginfo.c */
|
||||
typedef struct _GIArgInfo GIArgInfo;
|
||||
typedef struct
|
||||
{
|
||||
/*< private >*/
|
||||
GIBaseInfoStack parent;
|
||||
|
||||
void *padding[6];
|
||||
} GIArgInfo;
|
||||
GI_AVAILABLE_IN_ALL GType gi_arg_info_get_type (void);
|
||||
|
||||
/* Documented in gitypeinfo.c */
|
||||
typedef struct _GITypeInfo GITypeInfo;
|
||||
typedef struct
|
||||
{
|
||||
/*< private >*/
|
||||
GIBaseInfoStack parent;
|
||||
|
||||
void *padding[6];
|
||||
} GITypeInfo;
|
||||
GI_AVAILABLE_IN_ALL GType gi_type_info_get_type (void);
|
||||
|
||||
/* Documented in giunresolvedinfo.c */
|
||||
|
Reference in New Issue
Block a user