diff options
author | Johan Dahlin <jdahlin@litl.com> | 2009-02-17 18:23:25 -0300 |
---|---|---|
committer | Johan Dahlin <johan@gnome.org> | 2009-02-17 18:23:25 -0300 |
commit | 2a8d36c3570f6c1d469a323e344b8ea480a71d3d (patch) | |
tree | c570aef2806936720ac495fa4176c0e37125238d | |
parent | 53104000372583319f7330fb036c096ca7af4a6b (diff) | |
download | gobject-introspection-2a8d36c3570f6c1d469a323e344b8ea480a71d3d.tar.gz |
Add a simple invokation example
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | examples/Makefile.am | 5 | ||||
-rw-r--r-- | examples/glib-print.c | 44 |
5 files changed, 52 insertions, 1 deletions
@@ -29,6 +29,7 @@ missing stamp-h1 ylwrap py-compile +examples/glib-print docs/reference/html docs/reference/xml gir/GIRepository-2.0.gir diff --git a/Makefile.am b/Makefile.am index 054ea14e..0ef83251 100644 --- a/Makefile.am +++ b/Makefile.am @@ -18,7 +18,7 @@ endif ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = girepository giscanner tools gir tests +SUBDIRS = girepository giscanner tools gir tests examples DIST_SUBDIRS = m4 $(SUBDIRS) man_MANS = \ diff --git a/configure.ac b/configure.ac index 4182a9dc..cbb0ec5e 100644 --- a/configure.ac +++ b/configure.ac @@ -204,6 +204,7 @@ tests/offsets/Makefile tests/scanner/Makefile tests/repository/Makefile tests/everything/Makefile +examples/Makefile docs/Makefile docs/reference/Makefile gobject-introspection-1.0.pc]) diff --git a/examples/Makefile.am b/examples/Makefile.am new file mode 100644 index 00000000..681a4ca6 --- /dev/null +++ b/examples/Makefile.am @@ -0,0 +1,5 @@ +noinst_PROGRAMS = glib-print + +glib_print_SOURCES = glib-print.c +glib_print_CFLAGS = $(GIREPO_CFLAGS) -I$(top_srcdir)/girepository +glib_print_LDADD = $(top_builddir)/girepository/libgirepository-1.0.la $(GIREPO_LIBS) diff --git a/examples/glib-print.c b/examples/glib-print.c new file mode 100644 index 00000000..f2f0d6bc --- /dev/null +++ b/examples/glib-print.c @@ -0,0 +1,44 @@ +#include <girepository.h> + +int main(void) +{ + GIRepository *repository; + GError *error = NULL; + GIBaseInfo *base_info; + GArgument in_args[5]; + GArgument retval; + + g_type_init(); + + 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 GArgument*)&in_args, + 5, + NULL, + 0, + &retval, + &error)) { + g_error("ERROR: %s\n", error->message); + return 1; + } + + return 0; +} |