Wrong out parameter type in gi_object_info_find_method_using_interfaces
There is a GIObjectInfo out parameter in gi_object_info_find_method_using_interfaces
which according to the documentation is the implementor of the method.
I don't think this is correct. It seems to fill the out parameter with the interface which the method belongs to:
GIObjectInfo *implementor_info;
GIObjectInfo *class_info = GI_OBJECT_INFO (gi_repository_find_by_name (repository, "Gio", "DBusProxy"));
GIFunctionInfo *method_info = gi_object_info_find_method_using_interfaces (class_info, "init", &implementor_info);
After executing this code, implementor_info
contains the GIInterfaceInfo for GInitable. The implementor of the method would be GDBusProxy itself, in this case. (But if a method was implemented on a parent class, the implementor would be that parent class.) This is also a legitimate thing to return in an out parameter, but is not what is actually returned.
Either the documentation and the type of the out parameter should be changed, or the method should be changed to return what it is documented to return. (Or a second out parameter should be added to return both of these things.)
Here's a `tests/object-info.c` that you could use to test this:
/*
* Copyright 2024 Philip Chimento <philip.chimento@gmail.com>
*
* 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.1 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, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "girepository.h"
#include "test-common.h"
static void
test_object_info_find_method_using_interfaces (RepositoryFixture *fx,
const void *unused)
{
GIObjectInfo *class_info = NULL;
GIFunctionInfo *method_info = NULL;
GIObjectInfo *implementor_info = NULL;
class_info = GI_OBJECT_INFO (gi_repository_find_by_name (fx->repository, "Gio", "DBusProxy"));
g_assert_nonnull (class_info);
method_info = gi_object_info_find_method_using_interfaces (class_info, "init", &implementor_info);
g_assert_nonnull (implementor_info);
g_assert_cmpstr (gi_base_info_get_namespace (GI_BASE_INFO (implementor_info)), ==, "Gio");
g_assert_cmpstr (gi_base_info_get_name (GI_BASE_INFO (implementor_info)), ==, "Initable");
g_assert_true (GI_IS_INTERFACE_INFO (implementor_info));
g_clear_pointer (&class_info, gi_base_info_unref);
g_clear_pointer (&method_info, gi_base_info_unref);
g_clear_pointer (&implementor_info, gi_base_info_unref);
}
int
main (int argc,
char *argv[])
{
repository_init (&argc, &argv);
ADD_REPOSITORY_TEST ("/object-info/find-method-using-interfaces", test_object_info_find_method_using_interfaces, &typelib_load_spec_gio);
return g_test_run ();
}