Allow stack allocating GIBaseInfo, add stack retrieval variants

We don't want to malloc each GIBaseInfo when they can be used in
function invocation; instead, allow stack allocation.

There were a lot of structure typedefs which were actually just
exactly the same as GIBaseInfo, with the one exception of GITypeInfo.

Instead, just put the single GITypeInfo boolean inside GIBaseInfo
as a bit in a bitfield.

GIBaseInfo is still opaque publicly; GIRealInfo is the new
internal structure.

Using this, add new functions to retrieve arguments and argument types
on the stack.

https://bugzilla.gnome.org/show_bug.cgi?id=604074
This commit is contained in:
Colin Walters
2009-12-07 18:35:06 -05:00
parent f2f0625622
commit e6ac69fccd
2 changed files with 691 additions and 617 deletions

1237
ginfo.c

File diff suppressed because it is too large Load Diff

View File

@@ -27,37 +27,55 @@
G_BEGIN_DECLS G_BEGIN_DECLS
#define G_TYPE_IREPOSITORY (g_irepository_get_type ()) #define G_TYPE_IREPOSITORY (g_irepository_get_type ())
#define G_IREPOSITORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_IREPOSITORY, GIRepository)) #define G_IREPOSITORY(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), G_TYPE_IREPOSITORY, GIRepository))
#define G_IREPOSITORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), G_TYPE_IREPOSITORY, GIRepositoryClass))
#define G_IS_IREPOSITORY(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), G_TYPE_IREPOSITORY))
#define G_IS_IREPOSITORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), G_TYPE_IREPOSITORY))
#define G_IREPOSITORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), G_TYPE_IREPOSITORY, GIRepositoryClass))
typedef struct _GIRepository GIRepository; typedef struct _GIRepository GIRepository;
typedef struct _GIRepositoryClass GIRepositoryClass; typedef struct _GIRepositoryClass GIRepositoryClass;
typedef struct _GIRepositoryPrivate GIRepositoryPrivate; typedef struct _GIRepositoryPrivate GIRepositoryPrivate;
typedef struct _GIBaseInfo GIBaseInfo;
typedef struct _GICallableInfo GICallableInfo; typedef struct _GIBaseInfoStub GIBaseInfo;
typedef struct _GIFunctionInfo GIFunctionInfo;
typedef struct _GICallbackInfo GICallbackInfo; struct _GIBaseInfoStub {
typedef struct _GIRegisteredTypeInfo GIRegisteredTypeInfo; gint32 dummy1;
typedef struct _GIStructInfo GIStructInfo; gint32 dummy2;
typedef struct _GIUnionInfo GIUnionInfo; gpointer dummy3;
typedef struct _GIEnumInfo GIEnumInfo; gpointer dummy4;
typedef struct _GIObjectInfo GIObjectInfo; gpointer dummy5;
typedef struct _GIInterfaceInfo GIInterfaceInfo; guint32 dummy6;
typedef struct _GIConstantInfo GIConstantInfo; guint32 dummy7;
typedef struct _GIValueInfo GIValueInfo; gpointer padding[4];
typedef struct _GISignalInfo GISignalInfo; };
typedef struct _GIVFuncInfo GIVFuncInfo;
typedef struct _GIPropertyInfo GIPropertyInfo; typedef GIBaseInfo GICallableInfo;
typedef struct _GIFieldInfo GIFieldInfo; typedef GIBaseInfo GIFunctionInfo;
typedef struct _GIArgInfo GIArgInfo; typedef GIBaseInfo GICallbackInfo;
typedef struct _GITypeInfo GITypeInfo; typedef GIBaseInfo GIRegisteredTypeInfo;
typedef struct _GIErrorDomainInfo GIErrorDomainInfo; typedef GIBaseInfo GIStructInfo;
typedef GIBaseInfo GIUnionInfo;
typedef GIBaseInfo GIEnumInfo;
typedef GIBaseInfo GIObjectInfo;
typedef GIBaseInfo GIInterfaceInfo;
typedef GIBaseInfo GIConstantInfo;
typedef GIBaseInfo GIValueInfo;
typedef GIBaseInfo GISignalInfo;
typedef GIBaseInfo GIVFuncInfo;
typedef GIBaseInfo GIPropertyInfo;
typedef GIBaseInfo GIFieldInfo;
typedef GIBaseInfo GIArgInfo;
typedef GIBaseInfo GITypeInfo;
typedef GIBaseInfo GIErrorDomainInfo;
typedef struct _GIUnresolvedInfo GIUnresolvedInfo; typedef struct _GIUnresolvedInfo GIUnresolvedInfo;
typedef struct _GTypelib GTypelib; typedef struct _GTypelib GTypelib;
struct _GIRepository struct _GIRepository
{ {
GObject parent; GObject parent;
/*< private >*/ /*< private >*/
GIRepositoryPrivate *priv; GIRepositoryPrivate *priv;
@@ -282,11 +300,16 @@ typedef enum {
} GITransfer; } GITransfer;
GITypeInfo * g_callable_info_get_return_type (GICallableInfo *info); GITypeInfo * g_callable_info_get_return_type (GICallableInfo *info);
void g_callable_info_load_return_type (GICallableInfo *info,
GITypeInfo *type);
GITransfer g_callable_info_get_caller_owns (GICallableInfo *info); GITransfer g_callable_info_get_caller_owns (GICallableInfo *info);
gboolean g_callable_info_may_return_null (GICallableInfo *info); gboolean g_callable_info_may_return_null (GICallableInfo *info);
gint g_callable_info_get_n_args (GICallableInfo *info); gint g_callable_info_get_n_args (GICallableInfo *info);
GIArgInfo * g_callable_info_get_arg (GICallableInfo *info, GIArgInfo * g_callable_info_get_arg (GICallableInfo *info,
gint n); gint n);
void g_callable_info_load_arg (GICallableInfo *info,
gint n,
GIArgInfo *arg);
/* GIArgInfo */ /* GIArgInfo */
@@ -317,6 +340,8 @@ GIScopeType g_arg_info_get_scope (GIArgInfo *info);
gint g_arg_info_get_closure (GIArgInfo *info); gint g_arg_info_get_closure (GIArgInfo *info);
gint g_arg_info_get_destroy (GIArgInfo *info); gint g_arg_info_get_destroy (GIArgInfo *info);
GITypeInfo * g_arg_info_get_type (GIArgInfo *info); GITypeInfo * g_arg_info_get_type (GIArgInfo *info);
void g_arg_info_load_type (GIArgInfo *info,
GITypeInfo *type);
/* GITypeInfo */ /* GITypeInfo */