mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-24 09:58:54 +02:00
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
This commit is contained in:
committed by
Jürg Billeter
parent
bb9820839a
commit
b95d92aca0
22
girparser.c
22
girparser.c
@@ -837,6 +837,9 @@ start_parameter (GMarkupParseContext *context,
|
||||
const gchar *optional;
|
||||
const gchar *allow_none;
|
||||
const gchar *transfer;
|
||||
const gchar *scope;
|
||||
const gchar *closure;
|
||||
const gchar *destroy;
|
||||
GIrNodeParam *param;
|
||||
|
||||
if (!(strcmp (element_name, "parameter") == 0 &&
|
||||
@@ -850,7 +853,10 @@ start_parameter (GMarkupParseContext *context,
|
||||
optional = find_attribute ("optional", attribute_names, attribute_values);
|
||||
allow_none = find_attribute ("allow-none", attribute_names, attribute_values);
|
||||
transfer = find_attribute ("transfer-ownership", attribute_names, attribute_values);
|
||||
|
||||
scope = find_attribute ("scope", attribute_names, attribute_values);
|
||||
closure = find_attribute ("closure", attribute_names, attribute_values);
|
||||
destroy = find_attribute ("destroy", attribute_names, attribute_values);
|
||||
|
||||
if (name == NULL)
|
||||
name = "unknown";
|
||||
|
||||
@@ -899,6 +905,20 @@ start_parameter (GMarkupParseContext *context,
|
||||
|
||||
parse_param_transfer (param, transfer);
|
||||
|
||||
if (scope && strcmp (scope, "call") == 0)
|
||||
param->scope = GI_SCOPE_TYPE_CALL;
|
||||
else if (scope && strcmp (scope, "object") == 0)
|
||||
param->scope = GI_SCOPE_TYPE_OBJECT;
|
||||
else if (scope && strcmp (scope, "async") == 0)
|
||||
param->scope = GI_SCOPE_TYPE_ASYNC;
|
||||
else if (scope && strcmp (scope, "notified") == 0)
|
||||
param->scope = GI_SCOPE_TYPE_NOTIFIED;
|
||||
else
|
||||
param->scope = GI_SCOPE_TYPE_INVALID;
|
||||
|
||||
param->closure = closure ? atoi (closure) : -1;
|
||||
param->destroy = destroy ? atoi (destroy) : -1;
|
||||
|
||||
((GIrNode *)param)->name = g_strdup (name);
|
||||
|
||||
switch (ctx->current_node->type)
|
||||
|
Reference in New Issue
Block a user