mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-22 20:26:17 +01:00
girepository: Fix declaration of ‘find using interfaces’ methods
Fix the declaration and documentation of `gi_object_info_find_method_using_interfaces()` and `gi_object_info_find_vfunc_using_interfaces()`. The documentation was wrong when I wrote it: the value returned is the object or interface which declares the method or vfunc, not the one which implements it. The returned declarer info may be a `GIObjectInfo` or a `GIInterfaceInfo`. Since those two types have no subtype relation between them, the return type has to be changed to `GIBaseInfo`. Using `GIObjectInfo` would have been fine in girepository-1.0 because all `*Info` types were aliases of each other — but since the move to `GTypeInstance` this is no longer true. A unit test will be in the following commit. Signed-off-by: Philip Withnall <pwithnall@gnome.org> Fixes: #3246
This commit is contained in:
parent
702719dee9
commit
7acef299c2
@ -53,6 +53,7 @@ your code if integer type warnings are enabled.
|
||||
| `g_callable_info_invoke` arguments | `is_method` and `throws` dropped in [method@GIRepository.CallableInfo.invoke] |
|
||||
| `g_constant_info_get_type` | [method@GIRepository.ConstantInfo.get_type_info] |
|
||||
| `g_field_info_get_type` | [method@GIRepository.FieldInfo.get_type_info] |
|
||||
| `g_object_info_find_method_using_interfaces` and `g_object_info_find_vfunc_using_interfaces` | The `implementor` out argument has been renamed to `declarer` and is now of type [type@GIRepository.BaseInfo] |
|
||||
| `g_object_info_get_type_init` | [method@GIRepository.ObjectInfo.get_type_init_function_name] |
|
||||
| `g_object_info_get_ref_function` | [method@GIRepository.ObjectInfo.get_ref_function_name] |
|
||||
| `g_object_info_get_unref_function` | [method@GIRepository.ObjectInfo.get_unref_function_name] |
|
||||
|
@ -496,9 +496,10 @@ gi_object_info_find_method (GIObjectInfo *info,
|
||||
* gi_object_info_find_method_using_interfaces:
|
||||
* @info: a #GIObjectInfo
|
||||
* @name: name of method to obtain
|
||||
* @implementor: (out) (transfer full) (optional) (nullable): The implementor of
|
||||
* the interface, or `NULL` to ignore. If no method is found, this will return
|
||||
* `NULL`.
|
||||
* @declarer: (out) (transfer full) (optional) (nullable): The
|
||||
* [class@GIRepository.ObjectInfo] or [class@GIRepository.InterfaceInfo] which
|
||||
* declares the method, or `NULL` to ignore. If no method is found, this will
|
||||
* return `NULL`.
|
||||
*
|
||||
* Obtain a method of the object given a @name, searching both the
|
||||
* object @info and any interfaces it implements.
|
||||
@ -516,14 +517,14 @@ gi_object_info_find_method (GIObjectInfo *info,
|
||||
GIFunctionInfo *
|
||||
gi_object_info_find_method_using_interfaces (GIObjectInfo *info,
|
||||
const char *name,
|
||||
GIObjectInfo **implementor)
|
||||
GIBaseInfo **declarer)
|
||||
{
|
||||
GIFunctionInfo *result = NULL;
|
||||
GIObjectInfo *implementor_result = NULL;
|
||||
GIBaseInfo *declarer_result = NULL;
|
||||
|
||||
result = gi_object_info_find_method (info, name);
|
||||
if (result)
|
||||
implementor_result = (GIObjectInfo *) gi_base_info_ref ((GIBaseInfo*) info);
|
||||
declarer_result = gi_base_info_ref (info);
|
||||
|
||||
if (result == NULL)
|
||||
{
|
||||
@ -541,17 +542,19 @@ gi_object_info_find_method_using_interfaces (GIObjectInfo *info,
|
||||
|
||||
if (result != NULL)
|
||||
{
|
||||
implementor_result = (GIObjectInfo *) iface_info;
|
||||
declarer_result = GI_BASE_INFO (g_steal_pointer (&iface_info));
|
||||
break;
|
||||
}
|
||||
gi_base_info_unref ((GIBaseInfo*) iface_info);
|
||||
}
|
||||
}
|
||||
if (implementor)
|
||||
*implementor = implementor_result;
|
||||
else if (implementor_result != NULL)
|
||||
gi_base_info_unref ((GIBaseInfo*) implementor_result);
|
||||
return result;
|
||||
|
||||
if (declarer)
|
||||
*declarer = g_steal_pointer (&declarer_result);
|
||||
|
||||
g_clear_pointer (&declarer_result, gi_base_info_unref);
|
||||
|
||||
return g_steal_pointer (&result);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -766,9 +769,10 @@ gi_object_info_find_vfunc (GIObjectInfo *info,
|
||||
* gi_object_info_find_vfunc_using_interfaces:
|
||||
* @info: a #GIObjectInfo
|
||||
* @name: name of vfunc to obtain
|
||||
* @implementor: (out) (transfer full) (optional) (nullable): The implementor of
|
||||
* the interface, or `NULL` to ignore. If no vfunc is found, this will return
|
||||
* `NULL`.
|
||||
* @declarer: (out) (transfer full) (optional) (nullable): The
|
||||
* [class@GIRepository.ObjectInfo] or [class@GIRepository.InterfaceInfo] which
|
||||
* declares the vfunc, or `NULL` to ignore. If no vfunc is found, this will
|
||||
* return `NULL`.
|
||||
*
|
||||
* Locate a virtual function slot with name @name, searching both the object
|
||||
* @info and any interfaces it implements.
|
||||
@ -791,14 +795,14 @@ gi_object_info_find_vfunc (GIObjectInfo *info,
|
||||
GIVFuncInfo *
|
||||
gi_object_info_find_vfunc_using_interfaces (GIObjectInfo *info,
|
||||
const char *name,
|
||||
GIObjectInfo **implementor)
|
||||
GIBaseInfo **declarer)
|
||||
{
|
||||
GIVFuncInfo *result = NULL;
|
||||
GIObjectInfo *implementor_result = NULL;
|
||||
GIBaseInfo *declarer_result = NULL;
|
||||
|
||||
result = gi_object_info_find_vfunc (info, name);
|
||||
if (result)
|
||||
implementor_result = (GIObjectInfo *) gi_base_info_ref ((GIBaseInfo*) info);
|
||||
declarer_result = gi_base_info_ref (info);
|
||||
|
||||
if (result == NULL)
|
||||
{
|
||||
@ -816,17 +820,19 @@ gi_object_info_find_vfunc_using_interfaces (GIObjectInfo *info,
|
||||
|
||||
if (result != NULL)
|
||||
{
|
||||
implementor_result = (GIObjectInfo *) iface_info;
|
||||
declarer_result = GI_BASE_INFO (g_steal_pointer (&iface_info));
|
||||
break;
|
||||
}
|
||||
gi_base_info_unref ((GIBaseInfo*) iface_info);
|
||||
}
|
||||
}
|
||||
if (implementor)
|
||||
*implementor = implementor_result;
|
||||
else if (implementor_result != NULL)
|
||||
gi_base_info_unref ((GIBaseInfo*) implementor_result);
|
||||
return result;
|
||||
|
||||
if (declarer)
|
||||
*declarer = g_steal_pointer (&declarer_result);
|
||||
|
||||
g_clear_pointer (&declarer_result, gi_base_info_unref);
|
||||
|
||||
return g_steal_pointer (&result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -156,7 +156,7 @@ GIFunctionInfo * gi_object_info_find_method (GIObjectInfo *info,
|
||||
GI_AVAILABLE_IN_ALL
|
||||
GIFunctionInfo * gi_object_info_find_method_using_interfaces (GIObjectInfo *info,
|
||||
const char *name,
|
||||
GIObjectInfo **implementor);
|
||||
GIBaseInfo **declarer);
|
||||
|
||||
|
||||
GI_AVAILABLE_IN_ALL
|
||||
@ -186,7 +186,7 @@ GIVFuncInfo * gi_object_info_find_vfunc (GIObjectInfo *info,
|
||||
GI_AVAILABLE_IN_ALL
|
||||
GIVFuncInfo * gi_object_info_find_vfunc_using_interfaces (GIObjectInfo *info,
|
||||
const char *name,
|
||||
GIObjectInfo **implementor);
|
||||
GIBaseInfo **declarer);
|
||||
|
||||
GI_AVAILABLE_IN_ALL
|
||||
unsigned int gi_object_info_get_n_constants (GIObjectInfo *info);
|
||||
|
Loading…
Reference in New Issue
Block a user