[gegl/operation-source: 3/3] Avoid needing to duplicate filenames for source inclusion



commit f3e424fbdd4f1979378b0dc1f7d33d79a3e45d75
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                   |   14 ++++++++++++++
 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(+), 12 deletions(-)
---
diff --git a/gegl/gegl-op.h b/gegl/gegl-op.h
index fe4cd63..5dd82ab 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/
@@ -982,6 +992,10 @@ gegl_op_class_intern_init (gpointer klass)
 
 }
 
+#undef __GEGL_HEADER
+#undef _GEGL_HEADER
+#undef GEGL_HEADER
+
 static void
 gegl_op_init_properties (GeglOp *self)
 {
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]