[gegl] Avoid needing to duplicate filenames for source inclusion



commit 04bdf79feb1e26f8025b538060dac411364a5a3f
Author: Jon Nordby <jononor gmail com>
Date:   Sun Jan 11 17:05:23 2015 +0100

    Avoid needing to duplicate filenames for source inclusion
    
    Uses cpp macro magic instead. Can now use GEGL_OP_C_SOURCE
    to include source in operation, or GEGL_OP_C_FILE to not
    include it.

 gegl/gegl-op.h                   |   16 ++++++++++++++--
 operations/core/cache.c          |    3 +--
 operations/core/cast-format.c    |    3 +--
 operations/core/clone.c          |    3 +--
 operations/core/convert-format.c |    3 +--
 operations/core/crop.c           |    3 +--
 operations/core/nop.c            |    3 +--
 7 files changed, 20 insertions(+), 14 deletions(-)
---
diff --git a/gegl/gegl-op.h b/gegl/gegl-op.h
index fe4cd63..6bd6913 100644
--- a/gegl/gegl-op.h
+++ b/gegl/gegl-op.h
@@ -22,6 +22,16 @@
  * 2006-2008 © Øyvind Kolås.
  */
 
+
+#ifdef GEGL_OP_C_SOURCE
+#define __GEGL_HEADER(x) #x
+#define _GEGL_HEADER(x) __GEGL_HEADER(x)
+#define GEGL_HEADER(x) _GEGL_HEADER(x)
+
+#define GEGL_OP_C_FILE GEGL_HEADER(GEGL_OP_C_SOURCE)
+#define GEGL_OP_C_FILE_SOURCE GEGL_HEADER(GEGL_OP_C_SOURCE.h)
+#endif
+
 #ifndef GEGL_OP_C_FILE
 #ifdef GEGL_CHANT_C_FILE
 #error   GEGL_OP_C_FILE not defined, %s/GEGL_CHANT_C_FILE/GEGL_OP_C_FILE/
@@ -53,7 +63,6 @@ static void gegl_op_init_properties     (GeglOp   *self);
 static void gegl_op_class_intern_init   (gpointer     klass);
 static gpointer gegl_op_parent_class = NULL;
 
-#define GEGL_DEFINE_DYNAMIC_OPERATION(T_P)  GEGL_DEFINE_DYNAMIC_OPERATION_EXTENDED (GEGL_OP_C_FILE, GeglOp, 
gegl_op, T_P, 0, {})
 #define GEGL_DEFINE_DYNAMIC_OPERATION_EXTENDED(C_FILE, TypeName, type_name, TYPE_PARENT, flags, CODE) \
 static void     type_name##_init              (TypeName        *self);  \
 static void     type_name##_class_init        (TypeName##Class *klass); \
@@ -89,7 +98,7 @@ type_name##_register_type (GTypeModule *type_module)                    \
       NULL    /* value_table */                                         \
     };                                                                  \
     g_snprintf (tempname, sizeof (tempname),                            \
-                "%s", #TypeName GEGL_OP_C_FILE);                        \
+                "%s", #TypeName C_FILE);                                \
     for (p = tempname; *p; p++)                                         \
       if (*p=='.') *p='_';                                              \
                                                                         \
@@ -101,6 +110,9 @@ type_name##_register_type (GTypeModule *type_module)                    \
     { CODE ; }                                                          \
   }
 
+#define GEGL_DEFINE_DYNAMIC_OPERATION_(T_P, C_FILE) GEGL_DEFINE_DYNAMIC_OPERATION_EXTENDED(C_FILE, GeglOp, 
gegl_op, T_P, 0, {})
+#define GEGL_DEFINE_DYNAMIC_OPERATION(T_P) GEGL_DEFINE_DYNAMIC_OPERATION_(T_P, GEGL_OP_C_FILE)
+
 
 #define GEGL_PROPERTIES(op) ((GeglProperties *) (((GeglOp*)(op))->properties))
 
diff --git a/operations/core/cache.c b/operations/core/cache.c
index 6377519..4162635 100644
--- a/operations/core/cache.c
+++ b/operations/core/cache.c
@@ -27,8 +27,7 @@
 #else
 
 #define GEGL_OP_POINT_FILTER
-#define GEGL_OP_C_FILE "cache.c"
-#define GEGL_OP_C_FILE_SOURCE "cache.c.h"
+#define GEGL_OP_C_SOURCE cache.c
 
 #include "gegl-op.h"
 
diff --git a/operations/core/cast-format.c b/operations/core/cast-format.c
index f48fa76..633e3cf 100644
--- a/operations/core/cast-format.c
+++ b/operations/core/cast-format.c
@@ -30,8 +30,7 @@ property_format (output_format, _("Output format"), NULL)
 #else
 
 #define GEGL_OP_FILTER
-#define GEGL_OP_C_FILE "cast-format.c"
-#define GEGL_OP_C_FILE_SOURCE "cast-format.c.h"
+#define GEGL_OP_C_SOURCE cast-format.c
 
 #include "gegl-op.h"
 
diff --git a/operations/core/clone.c b/operations/core/clone.c
index 21a55d2..13ef6aa 100644
--- a/operations/core/clone.c
+++ b/operations/core/clone.c
@@ -28,8 +28,7 @@ property_string (ref, _("Reference"), "ID")
 #else
 
 #define GEGL_OP_FILTER
-#define GEGL_OP_C_FILE        "clone.c"
-#define GEGL_OP_C_FILE_SOURCE "clone.c.h"
+#define GEGL_OP_C_SOURCE        clone.c
 
 #include "gegl-op.h"
 #include <math.h>
diff --git a/operations/core/convert-format.c b/operations/core/convert-format.c
index ec2a037..d1f3c0d 100644
--- a/operations/core/convert-format.c
+++ b/operations/core/convert-format.c
@@ -30,8 +30,7 @@ property_format (format, _("Output format"), NULL)
 #else
 
 #define GEGL_OP_FILTER
-#define GEGL_OP_C_FILE "convert-format.c"
-#define GEGL_OP_C_FILE_SOURCE "convert-format.c.h"
+#define GEGL_OP_C_SOURCE convert-format.c
 
 #include "gegl-op.h"
 
diff --git a/operations/core/crop.c b/operations/core/crop.c
index 3687c35..f83e589 100644
--- a/operations/core/crop.c
+++ b/operations/core/crop.c
@@ -45,8 +45,7 @@ property_double (height, _("Height"), 10.0 )
 #else
 
 #define GEGL_OP_FILTER
-#define GEGL_OP_C_FILE "crop.c"
-#define GEGL_OP_C_FILE_SOURCE "crop.c.h"
+#define GEGL_OP_C_SOURCE crop.c
 
 #include "gegl-op.h"
 #include <math.h>
diff --git a/operations/core/nop.c b/operations/core/nop.c
index c6a407e..323f970 100644
--- a/operations/core/nop.c
+++ b/operations/core/nop.c
@@ -27,8 +27,7 @@
 #else
 
 #define GEGL_OP_FILTER
-#define GEGL_OP_C_FILE        "nop.c"
-#define GEGL_OP_C_FILE_SOURCE "nop.c.h"
+#define GEGL_OP_C_SOURCE        nop.c
 
 #include "gegl-op.h"
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]