From 81b8058350328fc66db63001479652f8ca28aa39 Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Sat, 22 Nov 2014 14:53:43 +0100 Subject: [PATCH] Added introspection. --- .gitignore | 2 ++ Makefile.am | 2 +- configure.ac | 2 ++ src/Makefile.am | 27 +++++++++++++++++++++++++++ src/libconfi.c | 8 +++++--- src/libconfi.h | 4 +--- tests/Makefile.am | 2 ++ tests/gir.py | 10 ++++++++++ 8 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 tests/gir.py diff --git a/.gitignore b/.gitignore index b16b44f..4156f9f 100644 --- a/.gitignore +++ b/.gitignore @@ -52,3 +52,5 @@ Rules-quot tests/test *.csv gtk-doc.m4 +*.gir +*.typelib diff --git a/Makefile.am b/Makefile.am index 40fce2d..2a981fb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ -DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc +DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc --enable-introspection SUBDIRS = src tests data docs diff --git a/configure.ac b/configure.ac index 8d6388b..2c8a4e4 100644 --- a/configure.ac +++ b/configure.ac @@ -21,6 +21,8 @@ AC_PROG_CC AC_PROG_LIBTOOL GTK_DOC_CHECK(1.0) +GOBJECT_INTROSPECTION_CHECK([1.30.0]) + # Checks for libraries. PKG_CHECK_MODULES(LIBCONFI, [libgdaex >= 0.5.0]) diff --git a/src/Makefile.am b/src/Makefile.am index 9fc1bc6..58b7517 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -11,3 +11,30 @@ libconfi_la_SOURCES = libconfi.c libconfi_la_LDFLAGS = -no-undefined include_HEADERS = libconfi.h + +CLEANFILES = + +-include $(INTROSPECTION_MAKEFILE) +INTROSPECTION_GIRS = +INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir) --warn-all --accept-unprefixed --identifier-prefix="" +INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir) +INTROSPECTION_SCANNER_ENV = CC="$(CC)" + +if HAVE_INTROSPECTION +introspection_sources = $(libconfi_la_SOURCES) $(include_HEADERS) + +Confi-1.0.gir: libconfi.la +Confi_1_0_gir_INCLUDES = Gda-5.0 +Confi_1_0_gir_CFLAGS = $(AM_CPPFLAGS) +Confi_1_0_gir_LIBS = libconfi.la +Confi_1_0_gir_FILES = $(introspection_sources) +INTROSPECTION_GIRS += Confi-1.0.gir + +girdir = $(datadir)/gir-1.0 +gir_DATA = $(INTROSPECTION_GIRS) + +typelibdir = $(libdir)/girepository-1.0 +typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib) + +CLEANFILES += $(gir_DATA) $(typelib_DATA) +endif \ No newline at end of file diff --git a/src/libconfi.c b/src/libconfi.c index ceea107..780ecc2 100644 --- a/src/libconfi.c +++ b/src/libconfi.c @@ -22,6 +22,8 @@ #include +#include + #include "libconfi.h" enum @@ -115,10 +117,10 @@ confi_init (Confi *confi) * @cnc_string: the connection string to use to connect to database that * contains configuration. * @name: configuration's name. - * @root: + * @root: (nullable): * @create: whether create a config into database if @name doesn't exists. * - * Returns: the newly created #Confi object, or NULL if it fails. + * Returns: (transfer none): the newly created #Confi object, or NULL if it fails. */ Confi *confi_new (const gchar *cnc_string, @@ -206,7 +208,7 @@ Confi * contains configuration. * @filter: * - * Returns: a #GList of #Confi. If there's no configurations, returns a valid + * Returns: (element-type Confi) (transfer container): a #GList of #Confi. If there's no configurations, returns a valid * #GList but with a unique NULL element. */ GList diff --git a/src/libconfi.h b/src/libconfi.h index bcd97b5..4ebf8db 100644 --- a/src/libconfi.h +++ b/src/libconfi.h @@ -19,10 +19,8 @@ #ifndef __LIBCONFI_H__ #define __LIBCONFI_H__ -#include #include -#include G_BEGIN_DECLS @@ -59,7 +57,7 @@ typedef struct *path; } ConfiKey; -GType confi_get_type (void) G_GNUC_CONST; +GType confi_get_type (void); Confi *confi_new (const gchar *cnc_string, const gchar *name, diff --git a/tests/Makefile.am b/tests/Makefile.am index d7edfb4..c76e13f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -5,3 +5,5 @@ LIBS = $(LIBCONFI_LIBS) \ -L../src -lconfi noinst_PROGRAMS = test + +EXTRA_DIST = gir.py diff --git a/tests/gir.py b/tests/gir.py new file mode 100644 index 0000000..33a1948 --- /dev/null +++ b/tests/gir.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python2 + +from gi.repository import Confi + +# Create a new object +confi = Confi.Confi.new("PostgreSQL://postgres:postgres@HOST=localhost;DB_NAME=confi", "Default", None, False) + +value = confi.path_get_value ("folder/key1/key1_2"); + +print(value) \ No newline at end of file -- 2.49.0