[gegl] add a proper automatic registration for enum using glib-mkenums
- From: Michael Murà <mmure src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] add a proper automatic registration for enum using glib-mkenums
- Date: Sun, 4 Sep 2011 17:37:07 +0000 (UTC)
commit ea1b95910955b6f15f110e8e1676179468cd816b
Author: Michael Murà <batolettre gmail com>
Date: Sun Sep 4 18:18:01 2011 +0200
add a proper automatic registration for enum using glib-mkenums
configure.ac | 6 ++++++
gegl/Makefile.am | 20 +++++++++++++++++++-
gegl/gegl-enums.c | 31 +++++++++++++++++++++++++++++++
gegl/gegl-enums.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++
gegl/gegl-types.h | 13 ++-----------
5 files changed, 104 insertions(+), 12 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index fe3bd9d..9f8971a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -390,6 +390,12 @@ fi
CFLAGS="$CFLAGS $MMX_EXTRA_CFLAGS $SSE_EXTRA_CFLAGS"
+################
+# Check for perl
+################
+
+AC_PATH_PROGS(PERL,perl5 perl perl5.005 perl5.004,perl)
+
########################
# Check GObject Introspection
########################
diff --git a/gegl/Makefile.am b/gegl/Makefile.am
index b027cd6..7a58137 100644
--- a/gegl/Makefile.am
+++ b/gegl/Makefile.am
@@ -38,6 +38,7 @@ GEGL_publicdir = $(includedir)/gegl-$(GEGL_API_VERSION)
GEGL_introspectable_headers = \
gegl.h \
gegl-types.h \
+ gegl-enums.h \
gegl-utils.h \
gegl-matrix.h \
gegl-lookup.h \
@@ -64,11 +65,11 @@ GEGL_introspectable_sources = \
gegl-cpuaccel.c \
gegl-dot.c \
gegl-dot-visitor.c \
+ gegl-enums.c \
gegl-init.c \
gegl-instrument.c \
gegl-utils.c \
gegl-lookup.c \
- gegl-types.c \
gegl-xml.c \
gegl-matrix.c \
\
@@ -135,3 +136,20 @@ endif # HAVE_VALA
endif # HAVE_INTROSPECTION
+#
+# rules to generate built sources
+#
+# setup autogeneration dependencies
+gen_sources = xgen-tec
+CLEANFILES = $(gen_sources)
+
+gegl-enums.c: $(srcdir)/gegl-enums.h
+ glib-mkenums \
+ --fhead "/* This is a generated file, do not edit directly */\n\n#include \"config.h\"\n#include <glib-object.h>\n#include \"gegl-enums.h\"" \
+ --fprod "\n/* enumerations from \"@filename \" */" \
+ --vhead "GType\n enum_name@_get_type (void)\n{\n static GType etype = 0;\n if (etype == 0) {\n static const G Type@Value values[] = {" \
+ --vprod " { @VALUENAME@, \"@valuenick \", \"@valuenick \" }," \
+ --vtail " { 0, NULL, NULL }\n };\n etype = g_ type@_register_static (\"@EnumName \", values);\n }\n return etype;\n}\n\n" \
+ $(srcdir)/gegl-enums.h > xgen-tec \
+ && cp xgen-tec $(@F) \
+ && rm -f xgen-tec
diff --git a/gegl/gegl-enums.c b/gegl/gegl-enums.c
new file mode 100644
index 0000000..acfd319
--- /dev/null
+++ b/gegl/gegl-enums.c
@@ -0,0 +1,31 @@
+
+/* Generated data (by glib-mkenums) */
+
+/* This is a generated file, do not edit directly */
+
+#include "config.h"
+#include <glib-object.h>
+#include "gegl-enums.h"
+
+/* enumerations from "./gegl-enums.h" */
+GType
+gegl_sampler_type_get_type (void)
+{
+ static GType etype = 0;
+ if (etype == 0) {
+ static const GEnumValue values[] = {
+ { GEGL_SAMPLER_NEAREST, "nearest", "nearest" },
+ { GEGL_SAMPLER_LINEAR, "linear", "linear" },
+ { GEGL_SAMPLER_CUBIC, "cubic", "cubic" },
+ { GEGL_SAMPLER_LANCZOS, "lanczos", "lanczos" },
+ { GEGL_SAMPLER_LOHALO, "lohalo", "lohalo" },
+ { 0, NULL, NULL }
+ };
+ etype = g_enum_register_static ("GeglSamplerType", values);
+ }
+ return etype;
+}
+
+
+/* Generated data ends here */
+
diff --git a/gegl/gegl-enums.h b/gegl/gegl-enums.h
new file mode 100644
index 0000000..9bc8242
--- /dev/null
+++ b/gegl/gegl-enums.h
@@ -0,0 +1,46 @@
+/* This file is part of GEGL
+ *
+ * GEGL 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 3 of the License, or (at your option) any later version.
+ *
+ * GEGL 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 GEGL; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright 2011 Michael Murà <batolettre gmail com>
+ *
+ */
+
+/* This file hold public enum from GEGL. A proper registration for them is
+ * generated automatically with glib-mkenums.
+ *
+ * TODO: currently, description are not supported by glib-mkenums, and therefore
+ * an often ugly name is generated, and i18n is not supported.
+ * gimp-mkenums support these description, with a custom system to allow i18n,
+ * so it could be a way to achieve this.
+ */
+
+#ifndef __GEGL_ENUMS_H__
+#define __GEGL_ENUMS_H__
+
+G_BEGIN_DECLS
+
+typedef enum {
+ GEGL_SAMPLER_NEAREST = 0, /*< desc="nearest" >*/
+ GEGL_SAMPLER_LINEAR, /*< desc="linear" >*/
+ GEGL_SAMPLER_CUBIC, /*< desc="cubic" >*/
+ GEGL_SAMPLER_LANCZOS, /*< desc="lanczos" >*/
+ GEGL_SAMPLER_LOHALO /*< desc="lohalo" >*/
+} GeglSamplerType;
+GType gegl_sampler_type_get_type (void) G_GNUC_CONST;
+#define GEGL_TYPE_SAMPLER_TYPE (gegl_sampler_type_get_type())
+
+G_END_DECLS
+
+#endif /* __GEGL_ENUMS_H__ */
\ No newline at end of file
diff --git a/gegl/gegl-types.h b/gegl/gegl-types.h
index 6e1f594..8ff5048 100644
--- a/gegl/gegl-types.h
+++ b/gegl/gegl-types.h
@@ -20,6 +20,8 @@
#ifndef __GEGL_TYPES_H__
#define __GEGL_TYPES_H__
+#include "gegl-enums.h"
+
G_BEGIN_DECLS
#define GEGL_AUTO_ROWSTRIDE 0
@@ -64,17 +66,6 @@ GType gegl_processor_get_type (void) G_GNUC_CONST;
#define GEGL_PROCESSOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEGL_TYPE_PROCESSOR, GeglProcessor))
#define GEGL_IS_PROCESSOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEGL_TYPE_PROCESSOR))
-typedef enum {
- GEGL_SAMPLER_NEAREST = 0,
- GEGL_SAMPLER_LINEAR,
- GEGL_SAMPLER_CUBIC,
- GEGL_SAMPLER_LANCZOS,
- GEGL_SAMPLER_LOHALO
-} GeglSamplerType;
-GType gegl_sampler_type_get_type (void) G_GNUC_CONST;
-#define GEGL_TYPE_SAMPLER_TYPE (gegl_sampler_type_get_type())
-
-
G_END_DECLS
#endif /* __GEGL_TYPES_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]