[gegl] introspection: Add boxed type for GeglMatrix3



commit 02715ec8cc2f3dc9ecfe3b8d4ce99406d9ecf4dd
Author: Jon Nordby <jononor gmail com>
Date:   Thu Mar 31 21:29:24 2011 +0200

    introspection: Add boxed type for GeglMatrix3

 gegl/gegl-matrix.c |   22 +++++++++++++++++++++-
 gegl/gegl-matrix.h |   35 +++++++++++++++++++++++++++++------
 2 files changed, 50 insertions(+), 7 deletions(-)
---
diff --git a/gegl/gegl-matrix.c b/gegl/gegl-matrix.c
index 19a1c69..5b9c73c 100644
--- a/gegl/gegl-matrix.c
+++ b/gegl/gegl-matrix.c
@@ -41,11 +41,25 @@ static void gegl_matrix3_debug (GeglMatrix3 *matrix)
 #endif
 
 GeglMatrix3 *
-gegl_matrix3_new ()
+gegl_matrix3_new (void)
 {
   return g_new0(GeglMatrix3, 1);
 }
 
+GType
+gegl_matrix3_get_type (void)
+{
+  static GType matrix_type = 0;
+
+  if (!matrix_type) {
+    matrix_type = g_boxed_type_register_static ("GeglMatrix3",
+                                               (GBoxedCopyFunc) gegl_matrix3_copy,
+                                               (GBoxedFreeFunc) g_free);
+  }
+
+  return matrix_type;
+}
+
 void
 gegl_matrix3_identity (GeglMatrix3 *matrix)
 {
@@ -105,6 +119,12 @@ gegl_matrix3_copy_into (GeglMatrix3 *dst,
   memcpy (dst->coeff [2], src->coeff [2], 3 * sizeof (gdouble));
 }
 
+GeglMatrix3 *
+gegl_matrix3_copy (GeglMatrix3 *matrix)
+{
+  return (GeglMatrix3 *) g_memdup (matrix, sizeof (GeglMatrix3));
+}
+
 gdouble
 gegl_matrix3_determinant (GeglMatrix3 *matrix)
 {
diff --git a/gegl/gegl-matrix.h b/gegl/gegl-matrix.h
index 38ec003..6e36c2b 100644
--- a/gegl/gegl-matrix.h
+++ b/gegl/gegl-matrix.h
@@ -3,24 +3,39 @@
 
 
 #include <glib.h>
+#include <glib-object.h>
 
 G_BEGIN_DECLS
 
+/* Currenly only used internally.
+ * Note: If making use of this in public API, add a boxed type for introspection
+ */
+typedef struct {
+    gdouble coeff [2][2];
+} GeglMatrix2;
+
 /***
- * GeglMatrix:
+ * GeglMatrix3:
  *
- * #GeglMatrix a 3x3 matrix for GEGL represented by the structure:
+ * #GeglMatrix3 is a 3x3 matrix for GEGL.
  * Matrixes are currently used by #GeglPath and the affine operations,
  * they might be used more centrally in the core of GEGL later.
  *
  */
-
 typedef struct {
     gdouble coeff[3][3];
 } GeglMatrix3;
-typedef struct {
-    gdouble coeff [2][2];
-} GeglMatrix2;
+
+#define GEGL_TYPE_MATRIX3               (gegl_matrix3_get_type ())
+#define GEGL_VALUE_HOLDS_MATRIX3(value) (G_TYPE_CHECK_VALUE_TYPE ((value), GEGL_TYPE_MATRIX3))
+
+/**
+ * gegl_matrix3_get_type:
+ *
+ * Returns: the #GType for GeglMatrix3 objects
+ *
+ **/
+GType         gegl_matrix3_get_type     (void) G_GNUC_CONST;
 
 /**
  * gegl_matrix3_new:
@@ -90,6 +105,14 @@ void  gegl_matrix3_copy_into (GeglMatrix3 *dst,
                               GeglMatrix3 *src);
 
 /**
+ * gegl_matrix3_copy:
+ * @src: a #GeglMatrix
+ *
+ * Returns a copy of @src.
+ */
+GeglMatrix3 *   gegl_matrix3_copy (GeglMatrix3 *matrix);
+
+/**
  * gegl_matrix3_determinant:
  * @matrix: a #GeglMatrix
  *



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