mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 23:16:14 +01:00
giarginfo: Return indexes as uints
As with previous commits, don’t use up half the return value space to indicate an invalid index. Signed-off-by: Philip Withnall <pwithnall@gnome.org> Helps: #3155
This commit is contained in:
parent
fe6f9a661b
commit
9fcec66115
@ -262,50 +262,63 @@ gi_arg_info_get_scope (GIArgInfo *info)
|
||||
/**
|
||||
* gi_arg_info_get_closure_index:
|
||||
* @info: a #GIArgInfo
|
||||
* @out_closure_index: (out) (optional): return location for the closure index
|
||||
*
|
||||
* Obtain the index of the user data argument. This is only valid
|
||||
* for arguments which are callbacks.
|
||||
*
|
||||
* Returns: Index of the user data argument or `-1` if there is none
|
||||
* Returns: `TRUE` if the argument has a user data argument
|
||||
* Since: 2.80
|
||||
*/
|
||||
gssize
|
||||
gi_arg_info_get_closure_index (GIArgInfo *info)
|
||||
gboolean
|
||||
gi_arg_info_get_closure_index (GIArgInfo *info,
|
||||
unsigned int *out_closure_index)
|
||||
{
|
||||
GIRealInfo *rinfo = (GIRealInfo *)info;
|
||||
ArgBlob *blob;
|
||||
gboolean has_closure_index;
|
||||
|
||||
g_return_val_if_fail (info != NULL, -1);
|
||||
g_return_val_if_fail (GI_IS_ARG_INFO (info), -1);
|
||||
g_return_val_if_fail (info != NULL, FALSE);
|
||||
g_return_val_if_fail (GI_IS_ARG_INFO (info), FALSE);
|
||||
|
||||
blob = (ArgBlob *)&rinfo->typelib->data[rinfo->offset];
|
||||
|
||||
return blob->closure;
|
||||
has_closure_index = (blob->closure >= 0);
|
||||
|
||||
if (out_closure_index != NULL)
|
||||
*out_closure_index = has_closure_index ? blob->closure : 0;
|
||||
return has_closure_index;
|
||||
}
|
||||
|
||||
/**
|
||||
* gi_arg_info_get_destroy_index:
|
||||
* @info: a #GIArgInfo
|
||||
* @out_destroy_index: (out) (optional): return location for the destroy index
|
||||
*
|
||||
* Obtains the index of the [type@GLib.DestroyNotify] argument. This is only
|
||||
* valid for arguments which are callbacks.
|
||||
*
|
||||
* Returns: Index of the [type@GLib.DestroyNotify] argument or `-1` if there is
|
||||
* none
|
||||
* Returns: `TRUE` if the argument has a [type@GLib.DestroyNotify] argument
|
||||
* Since: 2.80
|
||||
*/
|
||||
gssize
|
||||
gi_arg_info_get_destroy_index (GIArgInfo *info)
|
||||
gboolean
|
||||
gi_arg_info_get_destroy_index (GIArgInfo *info,
|
||||
unsigned int *out_destroy_index)
|
||||
{
|
||||
GIRealInfo *rinfo = (GIRealInfo *)info;
|
||||
ArgBlob *blob;
|
||||
gboolean has_destroy_index;
|
||||
|
||||
g_return_val_if_fail (info != NULL, -1);
|
||||
g_return_val_if_fail (GI_IS_ARG_INFO (info), -1);
|
||||
g_return_val_if_fail (info != NULL, FALSE);
|
||||
g_return_val_if_fail (GI_IS_ARG_INFO (info), FALSE);
|
||||
|
||||
blob = (ArgBlob *)&rinfo->typelib->data[rinfo->offset];
|
||||
|
||||
return blob->destroy;
|
||||
has_destroy_index = (blob->destroy >= 0);
|
||||
|
||||
if (out_destroy_index != NULL)
|
||||
*out_destroy_index = has_destroy_index ? blob->destroy : 0;
|
||||
return has_destroy_index;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -69,10 +69,12 @@ GI_AVAILABLE_IN_ALL
|
||||
GIScopeType gi_arg_info_get_scope (GIArgInfo *info);
|
||||
|
||||
GI_AVAILABLE_IN_ALL
|
||||
gssize gi_arg_info_get_closure_index (GIArgInfo *info);
|
||||
gboolean gi_arg_info_get_closure_index (GIArgInfo *info,
|
||||
unsigned int *out_closure_index);
|
||||
|
||||
GI_AVAILABLE_IN_ALL
|
||||
gssize gi_arg_info_get_destroy_index (GIArgInfo *info);
|
||||
gboolean gi_arg_info_get_destroy_index (GIArgInfo *info,
|
||||
unsigned int *out_destroy_index);
|
||||
|
||||
GI_AVAILABLE_IN_ALL
|
||||
GITypeInfo * gi_arg_info_get_type_info (GIArgInfo *info);
|
||||
|
@ -490,6 +490,7 @@ write_callable_info (const char *ns,
|
||||
for (unsigned int i = 0; i < gi_callable_info_get_n_args (info); i++)
|
||||
{
|
||||
GIArgInfo *arg = gi_callable_info_get_arg (info, i);
|
||||
unsigned int closure_index, destroy_index;
|
||||
|
||||
xml_start_element (file, "parameter");
|
||||
xml_printf (file, " name=\"%s\"",
|
||||
@ -541,13 +542,11 @@ write_callable_info (const char *ns,
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
if (gi_arg_info_get_closure_index (arg) >= 0)
|
||||
xml_printf (file, " closure=\"%" G_GSSIZE_FORMAT "\"",
|
||||
gi_arg_info_get_closure_index (arg));
|
||||
if (gi_arg_info_get_closure_index (arg, &closure_index))
|
||||
xml_printf (file, " closure=\"%u\"", closure_index);
|
||||
|
||||
if (gi_arg_info_get_destroy_index (arg) >= 0)
|
||||
xml_printf (file, " destroy=\"%" G_GSSIZE_FORMAT "\"",
|
||||
gi_arg_info_get_destroy_index (arg));
|
||||
if (gi_arg_info_get_destroy_index (arg, &destroy_index))
|
||||
xml_printf (file, " destroy=\"%u\"", destroy_index);
|
||||
|
||||
if (gi_arg_info_is_skip (arg))
|
||||
xml_printf (file, " skip=\"1\"");
|
||||
|
Loading…
Reference in New Issue
Block a user