diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2012-04-17 13:25:27 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-07-03 15:47:21 +0200 |
commit | 6ab3b7c32a14649b3c224edf43673afd2bef22dc (patch) | |
tree | c58cd15dfe2f05644078fbf0a049a85cc2985ded | |
parent | 5520616c9d5a94f5e43e363b10b10a09dde4865c (diff) | |
download | external_libqmi-6ab3b7c32a14649b3c224edf43673afd2bef22dc.zip external_libqmi-6ab3b7c32a14649b3c224edf43673afd2bef22dc.tar.gz external_libqmi-6ab3b7c32a14649b3c224edf43673afd2bef22dc.tar.bz2 |
errors: setup a new QMI core error domain
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | build-aux/Makefile.am | 4 | ||||
-rw-r--r-- | build-aux/qmi-error-types-template.c | 44 | ||||
-rw-r--r-- | build-aux/qmi-error-types-template.h | 23 | ||||
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | src/Makefile.am | 20 | ||||
-rw-r--r-- | src/libqmi-glib.h | 2 | ||||
-rw-r--r-- | src/qmi-errors.h | 40 |
9 files changed, 138 insertions, 3 deletions
@@ -34,3 +34,5 @@ src/.deps src/Makefile src/Makefile.in src/libqmi-glib.la +src/qmi-error-types.c +src/qmi-error-types.h diff --git a/Makefile.am b/Makefile.am index d297704..57a3b87 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = . src +SUBDIRS = . build-aux src ACLOCAL_AMFLAGS = -I m4 diff --git a/build-aux/Makefile.am b/build-aux/Makefile.am new file mode 100644 index 0000000..452a91b --- /dev/null +++ b/build-aux/Makefile.am @@ -0,0 +1,4 @@ + +EXTRA_DIST = \ + qmi-error-types-template.h \ + qmi-error-types-template.c diff --git a/build-aux/qmi-error-types-template.c b/build-aux/qmi-error-types-template.c new file mode 100644 index 0000000..e248279 --- /dev/null +++ b/build-aux/qmi-error-types-template.c @@ -0,0 +1,44 @@ +/*** BEGIN file-header ***/ +/*** END file-header ***/ + +/*** BEGIN file-production ***/ +/* enumerations from "@filename@" */ +/*** END file-production ***/ + +/*** BEGIN value-header ***/ + +GQuark +@enum_name@_quark (void) +{ + return g_quark_from_static_string ("@enum_name@_quark"); +} + +GType +@enum_name@_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + static const G@Type@Value values[] = { +/*** END value-header ***/ + +/*** BEGIN value-production ***/ + { @VALUENAME@, "@VALUENAME@", "@valuenick@" }, +/*** END value-production ***/ + +/*** BEGIN value-tail ***/ + { 0, NULL, NULL } + }; + GType g_define_type_id = + g_@type@_register_static (g_intern_static_string ("@EnumName@"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} + +/*** END value-tail ***/ + +/*** BEGIN file-tail ***/ +/*** END file-tail ***/ diff --git a/build-aux/qmi-error-types-template.h b/build-aux/qmi-error-types-template.h new file mode 100644 index 0000000..a0da4b0 --- /dev/null +++ b/build-aux/qmi-error-types-template.h @@ -0,0 +1,23 @@ +/*** BEGIN file-header ***/ + +#include <glib-object.h> + +G_BEGIN_DECLS +/*** END file-header ***/ + +/*** BEGIN file-production ***/ + +/* enumerations from "@filename@" */ +/*** END file-production ***/ + +/*** BEGIN value-header ***/ +GQuark @enum_name@_quark (void); +GType @enum_name@_get_type (void) G_GNUC_CONST; +#define @ENUMNAME@ (@enum_name@_quark ()) +#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type ()) +/*** END value-header ***/ + +/*** BEGIN file-tail ***/ +G_END_DECLS + +/*** END file-tail ***/ diff --git a/configure.ac b/configure.ac index 10110ae..1611c24 100644 --- a/configure.ac +++ b/configure.ac @@ -31,7 +31,11 @@ PKG_CHECK_MODULES(LIBQMI_GLIB, AC_SUBST(LIBQMI_GLIB_CFLAGS) AC_SUBST(LIBQMI_GLIB_LIBS) +GLIB_MKENUMS=`pkg-config --variable=glib_mkenums glib-2.0` +AC_SUBST(GLIB_MKENUMS) + AC_CONFIG_FILES([Makefile + build-aux/Makefile src/Makefile]) AC_OUTPUT diff --git a/src/Makefile.am b/src/Makefile.am index 9bb46ad..5a5e858 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -8,12 +8,28 @@ libqmi_glib_la_CPPFLAGS = \ -I$(top_srcdir)/src \ -I$(top_builddir)/src +# Error types +qmi-error-types.h: qmi-errors.h $(top_srcdir)/build-aux/qmi-error-types-template.h + $(AM_V_GEN) $(GLIB_MKENUMS) \ + --fhead "#ifndef __LIBQMI_GLIB_ERROR_TYPES_H__\n#define __LIBQMI_GLIB_ERROR_TYPES_H__\n#include \"qmi-errors.h\"\n" \ + --template $(top_srcdir)/build-aux/qmi-error-types-template.h \ + --ftail "#endif /* __LIBQMI_GLIB_ERROR_TYPES_H__ */\n" \ + qmi-errors.h > $@ + +qmi-error-types.c: qmi-errors.h qmi-error-types.h $(top_srcdir)/build-aux/qmi-error-types-template.c + $(AM_V_GEN) $(GLIB_MKENUMS) \ + --fhead "#include \"qmi-errors.h\"\n#include \"qmi-error-types.h\"\n" \ + --template $(top_srcdir)/build-aux/qmi-error-types-template.c \ + qmi-errors.h > $@ + libqmi_glib_la_SOURCES = \ - libqmi-glib.h + libqmi-glib.h \ + qmi-errors.h qmi-error-types.h qmi-error-types.c libqmi_glib_la_LIBADD = \ $(LIBQMI_GLIB_LIBS) includedir = @includedir@/libqmi-glib include_HEADERS = \ - libqmi-glib.h + libqmi-glib.h \ + qmi-errors.h qmi-error-types.h diff --git a/src/libqmi-glib.h b/src/libqmi-glib.h index 9b938a7..5f3d63f 100644 --- a/src/libqmi-glib.h +++ b/src/libqmi-glib.h @@ -23,5 +23,7 @@ #ifndef _LIBQMI_GLIB_H_ #define _LIBQMI_GLIB_H_ +#include "qmi-errors.h" +#include "qmi-error-types.h" #endif /* _LIBQMI_GLIB_H_ */ diff --git a/src/qmi-errors.h b/src/qmi-errors.h new file mode 100644 index 0000000..bba8411 --- /dev/null +++ b/src/qmi-errors.h @@ -0,0 +1,40 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * libqmi-glib -- GLib/GIO based library to control QMI devices + * + * 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 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, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + * Copyright (C) 2012 Aleksander Morgado <aleksander@lanedo.com> + */ + +#ifndef _LIBQMI_GLIB_QMI_ERRORS_H_ +#define _LIBQMI_GLIB_QMI_ERRORS_H_ + +/** + * QmiCoreError: + * @QMI_CORE_ERROR_FAILED: Operation failed. + * @QMI_CORE_ERROR_WRONG_STATE: Operation cannot be executed in the current state. + * @QMI_CORE_ERROR_INVALID_ARGS: Invalid arguments given. + * + * Common errors that may be reported by libqmi-glib. + */ +typedef enum { + QMI_CORE_ERROR_FAILED, + QMI_CORE_ERROR_WRONG_STATE, + QMI_CORE_ERROR_INVALID_ARGS, +} QmiCoreError; + +#endif /* _LIBQMI_GLIB_QMI_ERRORS_H_ */ |