Skip to content

Commit e0b5fcb

Browse files
committed
Generate GObject enum/flags types
1 parent 2b37f64 commit e0b5fcb

8 files changed

+115
-13
lines changed

Makefile.am

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
NULL =
22
ACLOCAL_AMFLAGS = -I m4
3-
SUBDIRS = data libmsi tests po .
3+
SUBDIRS = include data libmsi tests po .
44

55
libmsiincludedir = $(includedir)/libmsi-1.0
6-
dist_libmsiinclude_HEADERS = \
7-
include/libmsi.h \
8-
include/libmsi-database.h \
9-
include/libmsi-query.h \
10-
include/libmsi-record.h \
11-
include/libmsi-summary-info.h \
12-
include/libmsi-types.h
6+
dist_libmsiinclude_HEADERS = \
7+
include/libmsi-database.h \
8+
include/libmsi-enums.h \
9+
include/libmsi-query.h \
10+
include/libmsi-record.h \
11+
include/libmsi-summary-info.h \
12+
include/libmsi-types.h \
13+
include/libmsi.h \
14+
$(NULL)
1315

1416
AM_CPPFLAGS = -Iinclude -I$(srcdir)/include \
1517
$(GLIB_CFLAGS) $(GSF_CFLAGS) $(UUID_CFLAGS) \

configure.ac

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ AC_CONFIG_FILES([tests/package.m4.tmp:tests/package.m4.in],
5757

5858
AC_CONFIG_FILES([
5959
Makefile
60+
include/Makefile
6061
data/Makefile
6162
po/Makefile.in
6263
libmsi/Makefile

include/libmsi-enums.h.etemplate

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*** BEGIN file-header ***/
2+
/*
3+
* Copyright (C) 2002,2003 Mike McCormack
4+
*
5+
* This library is free software; you can redistribute it and/or
6+
* modify it under the terms of the GNU Lesser General Public
7+
* License as published by the Free Software Foundation; either
8+
* version 2.1 of the License, or (at your option) any later version.
9+
*
10+
* This library is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
* Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public
16+
* License along with this library; if not, write to the Free Software
17+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18+
*/
19+
20+
#ifndef LIBMSI_ENUMS_H
21+
#define LIBMSI_ENUMS_H
22+
23+
#include <glib-object.h>
24+
25+
G_BEGIN_DECLS
26+
/*** END file-header ***/
27+
28+
/*** BEGIN value-header ***/
29+
GType @enum_name@_get_type (void) G_GNUC_CONST;
30+
#define LIBMSI_TYPE_@ENUMSHORT@ (@enum_name@_get_type ())
31+
/*** END value-header ***/
32+
33+
/*** BEGIN file-tail ***/
34+
G_END_DECLS
35+
36+
#endif
37+
/*** END file-tail ***/

include/libmsi-types.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ typedef struct _LibmsiSummaryInfo LibmsiSummaryInfo;
3636

3737
typedef enum LibmsiResultError
3838
{
39-
LIBMSI_RESULT_SUCCESS, // FIXME: remove me
39+
LIBMSI_RESULT_SUCCESS, /* FIXME: remove me */
4040
LIBMSI_RESULT_ACCESS_DENIED,
4141
LIBMSI_RESULT_INVALID_HANDLE,
4242
LIBMSI_RESULT_NOT_ENOUGH_MEMORY,
@@ -82,7 +82,7 @@ typedef enum LibmsiColInfo
8282

8383
typedef enum LibmsiDBError
8484
{
85-
LIBMSI_DB_ERROR_SUCCESS, // FIXME: remove me
85+
LIBMSI_DB_ERROR_SUCCESS, /* FIXME: remove me */
8686
LIBMSI_DB_ERROR_INVALIDARG,
8787
LIBMSI_DB_ERROR_MOREDATA,
8888
LIBMSI_DB_ERROR_FUNCTIONERROR,

include/libmsi.h

+1
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@
2424
#include <libmsi-query.h>
2525
#include <libmsi-record.h>
2626
#include <libmsi-summary-info.h>
27+
#include <libmsi-enums.h>
2728

2829
#endif /* _LIBMSI_H */

libmsi/Makefile.am

+7-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ libmsi_la_SOURCES = \
2020
drop.c \
2121
insert.c \
2222
libmsi-database.c \
23+
libmsi-enums.c \
2324
libmsi-istream.h \
2425
libmsi-istream.c \
2526
libmsi-query.c \
@@ -44,6 +45,8 @@ libmsi_la_LDFLAGS = -no-undefined -rpath $(libdir) \
4445

4546
libmsi_la_LIBADD = $(GLIB_LIBS) $(GSF_LIBS) $(GOBJECT_LIBS)
4647

48+
EXTRA_DIST = libmsi-enums.c.etemplate
49+
4750
INTROSPECTION_SCANNER_ARGS = --warn-all
4851

4952
if GIR
@@ -57,16 +60,18 @@ Libmsi_1_0_gir_CFLAGS = $(AM_CPPFLAGS)
5760
Libmsi_1_0_gir_INCLUDES = GObject-2.0 GLib-2.0 Gio-2.0
5861
Libmsi_1_0_gir_LIBS = libmsi.la
5962
Libmsi_1_0_gir_FILES = \
60-
$(top_srcdir)/include/libmsi.h \
61-
$(top_srcdir)/include/libmsi-types.h \
6263
$(top_srcdir)/include/libmsi-database.h \
6364
$(top_srcdir)/include/libmsi-query.h \
6465
$(top_srcdir)/include/libmsi-record.h \
6566
$(top_srcdir)/include/libmsi-summary-info.h \
67+
$(top_srcdir)/include/libmsi-types.h \
68+
$(top_srcdir)/include/libmsi.h \
6669
$(top_srcdir)/libmsi/libmsi-database.c \
6770
$(top_srcdir)/libmsi/libmsi-query.c \
6871
$(top_srcdir)/libmsi/libmsi-record.c \
6972
$(top_srcdir)/libmsi/libmsi-summary-info.c \
73+
$(top_builddir)/include/libmsi-enums.h \
74+
libmsi-enums.c \
7075
$(NULL)
7176
Libmsi_1_0_gir_EXPORT_PACKAGES = libmsi-1.0
7277
Libmsi_1_0_gir_SCANNERFLAGS = --c-include="libmsi.h"

libmsi/libmsi-enums.c.etemplate

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*** BEGIN file-header ***/
2+
/*
3+
* Copyright (C) 2002,2003 Mike McCormack
4+
*
5+
* This library is free software; you can redistribute it and/or
6+
* modify it under the terms of the GNU Lesser General Public
7+
* License as published by the Free Software Foundation; either
8+
* version 2.1 of the License, or (at your option) any later version.
9+
*
10+
* This library is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
* Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public
16+
* License along with this library; if not, write to the Free Software
17+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18+
*/
19+
20+
#include "libmsi-enums.h"
21+
22+
/*** END file-header ***/
23+
24+
/*** BEGIN file-production ***/
25+
#include "@filename@"
26+
/*** END file-production ***/
27+
28+
29+
/*** BEGIN value-header ***/
30+
31+
GType
32+
@enum_name@_get_type (void)
33+
{
34+
static volatile gsize g_define_type_id__volatile = 0;
35+
36+
if (g_once_init_enter (&g_define_type_id__volatile))
37+
{
38+
static const G@Type@Value values[] = {
39+
/*** END value-header ***/
40+
41+
/*** BEGIN value-production ***/
42+
{ @VALUENAME@, "@VALUENAME@", "@valuenick@" },
43+
/*** END value-production ***/
44+
45+
/*** BEGIN value-tail ***/
46+
{ 0, NULL, NULL }
47+
};
48+
GType g_define_type_id =
49+
g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);
50+
g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
51+
}
52+
53+
return g_define_type_id__volatile;
54+
}
55+
56+
/*** END value-tail ***/

tests/Makefile.am

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
AM_CPPFLAGS = -I$(top_srcdir)/include -I$(srcdir) -I. \
1+
AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include -I$(srcdir) -I. \
22
$(GLIB_CFLAGS) $(GOBJECT_CFLAGS)
33

44
dist_noinst_HEADERS = test.h

0 commit comments

Comments
 (0)