glib/girepository/girnode-private.h

401 lines
8.1 KiB
C
Raw Normal View History

2012-02-03 19:42:56 +01:00
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
* GObject introspection: Parsed GIR
*
* Copyright (C) 2005 Matthias Clasen
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#pragma once
#include <glib.h>
#include "girmodule-private.h"
G_BEGIN_DECLS
typedef struct _GIIrNode GIIrNode;
typedef struct _GIIrNodeFunction GIIrNodeFunction;
typedef struct _GIIrNodeParam GIIrNodeParam;
typedef struct _GIIrNodeType GIIrNodeType;
typedef struct _GIIrNodeInterface GIIrNodeInterface;
typedef struct _GIIrNodeSignal GIIrNodeSignal;
typedef struct _GIIrNodeProperty GIIrNodeProperty;
typedef struct _GIIrNodeVFunc GIIrNodeVFunc;
typedef struct _GIIrNodeField GIIrNodeField;
typedef struct _GIIrNodeValue GIIrNodeValue;
typedef struct _GIIrNodeEnum GIIrNodeEnum;
typedef struct _GIIrNodeBoxed GIIrNodeBoxed;
typedef struct _GIIrNodeStruct GIIrNodeStruct;
typedef struct _GIIrNodeConstant GIIrNodeConstant;
typedef struct _GIIrNodeXRef GIIrNodeXRef;
typedef struct _GIIrNodeUnion GIIrNodeUnion;
typedef enum
{
GI_IR_NODE_INVALID = 0,
GI_IR_NODE_FUNCTION = 1,
GI_IR_NODE_CALLBACK = 2,
GI_IR_NODE_STRUCT = 3,
GI_IR_NODE_BOXED = 4,
GI_IR_NODE_ENUM = 5,
GI_IR_NODE_FLAGS = 6,
GI_IR_NODE_OBJECT = 7,
GI_IR_NODE_INTERFACE = 8,
GI_IR_NODE_CONSTANT = 9,
GI_IR_NODE_INVALID_0 = 10, /* DELETED - used to be ERROR_DOMAIN */
GI_IR_NODE_UNION = 11,
GI_IR_NODE_PARAM = 12,
GI_IR_NODE_TYPE = 13,
GI_IR_NODE_PROPERTY = 14,
GI_IR_NODE_SIGNAL = 15,
GI_IR_NODE_VALUE = 16,
GI_IR_NODE_VFUNC = 17,
GI_IR_NODE_FIELD = 18,
GI_IR_NODE_XREF = 19
} GIIrNodeTypeId;
struct _GIIrNode
{
GIIrNodeTypeId type;
gchar *name;
GIIrModule *module;
guint32 offset; /* Assigned as we build the typelib */
GHashTable *attributes;
};
struct _GIIrNodeXRef
{
GIIrNode node;
gchar *namespace;
};
struct _GIIrNodeFunction
{
GIIrNode node;
gboolean deprecated;
gboolean is_varargs; /* Not in typelib yet */
gboolean is_method;
gboolean is_setter;
gboolean is_getter;
gboolean is_constructor;
gboolean wraps_vfunc;
gboolean throws;
gboolean instance_transfer_full;
gchar *symbol;
char *property;
GIIrNodeParam *result;
GList *parameters;
};
struct _GIIrNodeType
{
GIIrNode node;
gboolean is_pointer;
gboolean is_basic;
gboolean is_array;
gboolean is_glist;
gboolean is_gslist;
gboolean is_ghashtable;
gboolean is_interface;
gboolean is_error;
gint tag;
gchar *unparsed;
gboolean zero_terminated;
gboolean has_length;
gint length;
gboolean has_size;
gint size;
gint array_type;
GIIrNodeType *parameter_type1;
GIIrNodeType *parameter_type2;
gchar *giinterface;
gchar **errors;
};
struct _GIIrNodeParam
{
GIIrNode node;
gboolean in;
gboolean out;
gboolean caller_allocates;
gboolean optional;
gboolean retval;
gboolean nullable;
gboolean skip;
gboolean transfer;
gboolean shallow_transfer;
Bug 556489 – callback annotations 2008-01-03 Andreas Rottmann <a.rottmann@gmx.at> Bug 556489 – callback annotations * giscanner/transformer.py * tools/generate.c (write_callable_info): Write out the new scope, closure and destroy attributes. * giscanner/transformer.py (Transformer._type_is_callback): New method, checking if a given type is a callback. (Transformer._augment_callback_params): New method; adds information (closure, destroy) to callback parameters. (Transformer._handle_closure, Transformer._handle_destroy): New methods, auxiliary to _augment_callback_params. (Transformer._create_function): Call _augment_callback_params(). (Transformer._create_parameter): Handle scope option. (Transformer._create_typedef_callback): New method, creates a callback, and registers it in the typedef namespace (Transformer._create_typedef): Use _create_typedef_callback() instead of the plain _create_callback(). * giscanner/ast.py (Parameter): Added callback-related fields. * giscanner/girwriter.py: Write out new Parameter fields. * girepository/girnode.h (GIrNodeParam): Added fields scope, closure and destroy. * girepository/gtypelib.h (ArgBlob): Ditto. * girepository/girparser.c (start_parameter): Handle new fields. * girepository/girmodule.c (g_ir_module_build_typelib): Adjust arg_blob_size, bump major version due to this change. * girepository/girnode.c (g_ir_node_get_full_size_internal) (g_ir_node_build_typelib) * girepository/gtypelib.c (g_typelib_check_sanity): ArgBlob size adjustments. (g_ir_node_build_typelib): Fill in new ArgBlob flags from param. * girepository/girepository.h (GIScope): New enumeration, listing the different possible scopes for callbacks. * girepository/ginfo.c (g_arg_info_get_scope) (g_arg_info_get_closure, g_arg_info_get_destroy): Accessors for callback-related argument indices (callback scope, closure for a callback, destroy notification for a callback). * tests/scanner/: Added testcases for new features. svn path=/trunk/; revision=998
2009-01-03 14:44:42 +01:00
GIScopeType scope;
Bug 556489 – callback annotations 2008-01-03 Andreas Rottmann <a.rottmann@gmx.at> Bug 556489 – callback annotations * giscanner/transformer.py * tools/generate.c (write_callable_info): Write out the new scope, closure and destroy attributes. * giscanner/transformer.py (Transformer._type_is_callback): New method, checking if a given type is a callback. (Transformer._augment_callback_params): New method; adds information (closure, destroy) to callback parameters. (Transformer._handle_closure, Transformer._handle_destroy): New methods, auxiliary to _augment_callback_params. (Transformer._create_function): Call _augment_callback_params(). (Transformer._create_parameter): Handle scope option. (Transformer._create_typedef_callback): New method, creates a callback, and registers it in the typedef namespace (Transformer._create_typedef): Use _create_typedef_callback() instead of the plain _create_callback(). * giscanner/ast.py (Parameter): Added callback-related fields. * giscanner/girwriter.py: Write out new Parameter fields. * girepository/girnode.h (GIrNodeParam): Added fields scope, closure and destroy. * girepository/gtypelib.h (ArgBlob): Ditto. * girepository/girparser.c (start_parameter): Handle new fields. * girepository/girmodule.c (g_ir_module_build_typelib): Adjust arg_blob_size, bump major version due to this change. * girepository/girnode.c (g_ir_node_get_full_size_internal) (g_ir_node_build_typelib) * girepository/gtypelib.c (g_typelib_check_sanity): ArgBlob size adjustments. (g_ir_node_build_typelib): Fill in new ArgBlob flags from param. * girepository/girepository.h (GIScope): New enumeration, listing the different possible scopes for callbacks. * girepository/ginfo.c (g_arg_info_get_scope) (g_arg_info_get_closure, g_arg_info_get_destroy): Accessors for callback-related argument indices (callback scope, closure for a callback, destroy notification for a callback). * tests/scanner/: Added testcases for new features. svn path=/trunk/; revision=998
2009-01-03 14:44:42 +01:00
gint8 closure;
gint8 destroy;
GIIrNodeType *type;
};
struct _GIIrNodeProperty
{
GIIrNode node;
gboolean deprecated;
gchar *name;
gboolean readable;
gboolean writable;
gboolean construct;
gboolean construct_only;
gboolean transfer;
gboolean shallow_transfer;
Add introspection data for property accessors A GObject property can be accessed generically through the GObject API, e.g. g_object_set_property() and g_object_get_property(). Properties typically also have public accessor functions, which are (according to our own best practices) called through the generic API. The introspection data is currently missing the relation between a property and its public accessor functions. With this information, a language binding could, for instance, avoid exposing the C API entirely, thus minimizing the chances of collisions between property names and accessor functions; alternatively, a binding could call the C API directly instead of going through the generic GObject API, thus avoiding the boxing and unboxing from a native type to a GIArgument and finally into a GValue, and vice versa. In the GIR, we add two new attributes to the `property` element: - setter="SYMBOL" - getter="SYMBOL" where "symbol" is the C function identifier of the setter and getter functions, respectively. The `setter` attribute is only applied to writable, non-construct-only properties; the `getter` attribute is only applied to readable properties. We maintain the ABI compatibility of the typelib data by using 20 bits of the 25 reserved bits inside the PropertyBlob structure. The data is exposed through two new GIPropertyInfo methods: - g_property_info_get_setter() - g_property_info_get_getter() which return the GIFunctionInfo for the setter and getter functions, respectively.
2021-06-17 14:07:35 +02:00
char *setter;
char *getter;
GIIrNodeType *type;
};
struct _GIIrNodeSignal
{
GIIrNode node;
gboolean deprecated;
gboolean run_first;
gboolean run_last;
gboolean run_cleanup;
gboolean no_recurse;
gboolean detailed;
gboolean action;
gboolean no_hooks;
gboolean instance_transfer_full;
gboolean has_class_closure;
gboolean true_stops_emit;
gint class_closure;
GList *parameters;
GIIrNodeParam *result;
};
struct _GIIrNodeVFunc
{
GIIrNode node;
gboolean is_varargs; /* Not in typelib yet */
gboolean must_chain_up;
gboolean must_be_implemented;
gboolean must_not_be_implemented;
gboolean is_class_closure;
gboolean throws;
gboolean instance_transfer_full;
char *invoker;
GList *parameters;
GIIrNodeParam *result;
gint offset;
};
struct _GIIrNodeField
{
GIIrNode node;
gboolean readable;
gboolean writable;
gint bits;
gint offset;
GIIrNodeFunction *callback;
GIIrNodeType *type;
};
struct _GIIrNodeInterface
{
GIIrNode node;
gboolean abstract;
gboolean deprecated;
gboolean fundamental;
gboolean final_;
gchar *gtype_name;
gchar *gtype_init;
gchar *ref_func;
gchar *unref_func;
gchar *set_value_func;
gchar *get_value_func;
gchar *parent;
gchar *glib_type_struct;
GList *interfaces;
GList *prerequisites;
gint alignment;
gint size;
GList *members;
};
struct _GIIrNodeValue
{
GIIrNode node;
gboolean deprecated;
gint64 value;
};
struct _GIIrNodeConstant
{
GIIrNode node;
gboolean deprecated;
GIIrNodeType *type;
gchar *value;
};
struct _GIIrNodeEnum
{
GIIrNode node;
gboolean deprecated;
gint storage_type;
gchar *gtype_name;
gchar *gtype_init;
gchar *error_domain;
GList *values;
GList *methods;
};
struct _GIIrNodeBoxed
{
GIIrNode node;
gboolean deprecated;
gchar *gtype_name;
gchar *gtype_init;
gint alignment;
gint size;
GList *members;
};
struct _GIIrNodeStruct
{
GIIrNode node;
gboolean deprecated;
gboolean disguised;
gboolean opaque;
gboolean pointer;
gboolean is_gtype_struct;
gboolean foreign;
gchar *gtype_name;
gchar *gtype_init;
gchar *copy_func;
gchar *free_func;
gint alignment;
gint size;
GList *members;
};
struct _GIIrNodeUnion
{
GIIrNode node;
gboolean deprecated;
GList *members;
GList *discriminators;
gchar *gtype_name;
gchar *gtype_init;
gchar *copy_func;
gchar *free_func;
gint alignment;
gint size;
gint discriminator_offset;
GIIrNodeType *discriminator_type;
};
GIIrNode *gi_ir_node_new (GIIrNodeTypeId type,
GIIrModule *module);
void gi_ir_node_free (GIIrNode *node);
guint32 gi_ir_node_get_size (GIIrNode *node);
guint32 gi_ir_node_get_full_size (GIIrNode *node);
void gi_ir_node_build_typelib (GIIrNode *node,
GIIrNode *parent,
GIIrTypelibBuild *build,
guint32 *offset,
guint32 *offset2,
guint16 *count2);
int gi_ir_node_cmp (GIIrNode *node,
GIIrNode *other);
gboolean gi_ir_node_can_have_member (GIIrNode *node);
void gi_ir_node_add_member (GIIrNode *node,
GIIrNodeFunction *member);
guint32 gi_ir_write_string (const gchar *str,
GHashTable *strings,
guchar *data,
guint32 *offset);
const gchar * gi_ir_node_param_direction_string (GIIrNodeParam * node);
const gchar * gi_ir_node_type_to_string (GIIrNodeTypeId type);
GIIrNode *gi_ir_find_node (GIIrTypelibBuild *build,
GIIrModule *module,
const char *name);
/* In giroffsets.c */
void gi_ir_node_compute_offsets (GIIrTypelibBuild *build,
GIIrNode *node);
G_END_DECLS