summaryrefslogtreecommitdiff
path: root/examples/glib-print.c
blob: 4e117d9df1ac7bac6e75e900bf8c93be12a9f628 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <girepository.h>

int
main (void)
{
  GIRepository *repository;
  GError *error = NULL;
  GIBaseInfo *base_info;
  GIArgument in_args[5];
  GIArgument retval;

  repository = g_irepository_get_default ();
  g_irepository_require (repository, "GLib", "2.0", 0, &error);
  if (error)
    {
      g_error ("ERROR: %s\n", error->message);
      return 1;
    }

  base_info = g_irepository_find_by_name (repository, "GLib", "assertion_message");
  if (!base_info)
    {
      g_error ("ERROR: %s\n", "Could not find GLib.warn_message");
      return 1;
    }

  in_args[0].v_pointer = "domain";
  in_args[1].v_pointer = "glib-print.c";
  in_args[2].v_pointer = "30";
  in_args[3].v_pointer = "main";
  in_args[4].v_pointer = "hello world";

  if (!g_function_info_invoke ((GIFunctionInfo *) base_info,
                               (const GIArgument *) &in_args,
                               5,
                               NULL,
                               0,
                               &retval,
                               &error))
    {
      g_error ("ERROR: %s\n", error->message);
      return 1;
    }

  g_base_info_unref (base_info);

  return 0;
}