[girffi] Clean up API, add g_function_info_prep_invoker
[gnome.gobject-introspection] / examples / glib-print.c
1 #include <girepository.h>
2
3 int main(void)
4 {
5     GIRepository *repository;
6     GError *error = NULL;
7     GIBaseInfo *base_info;
8     GArgument in_args[5];
9     GArgument retval;
10
11     g_type_init();
12
13     repository = g_irepository_get_default();
14     g_irepository_require(repository, "GLib", "2.0", 0, &error);
15     if (error) {
16       g_error("ERROR: %s\n", error->message);
17       return 1;
18     }
19
20     base_info = g_irepository_find_by_name(repository, "GLib", "assertion_message");
21     if (!base_info) {
22       g_error("ERROR: %s\n", "Could not find GLib.warn_message");
23       return 1;
24     }
25
26     in_args[0].v_pointer = "domain";
27     in_args[1].v_pointer = "glib-print.c";
28     in_args[2].v_pointer = "30";
29     in_args[3].v_pointer = "main";
30     in_args[4].v_pointer = "hello world";
31
32     if (!g_function_info_invoke ((GIFunctionInfo *)base_info,
33                                  (const GArgument*)&in_args,
34                                  5,
35                                  NULL,
36                                  0,
37                                  &retval,
38                                  &error)) {
39       g_error("ERROR: %s\n", error->message);
40       return 1;
41     }
42
43     g_base_info_unref (base_info);
44
45     return 0;
46 }