Commit 3a4b17e8 authored by Jehan's avatar Jehan

libgimpmath: make GimpVector[23] boxed types.

This way, all functions using these types are now introspectable.
parent 0411c7ef
Pipeline #100724 passed with stages
in 14 minutes and 41 seconds
......@@ -81,6 +81,16 @@ struct _GimpVector2
gdouble x, y;
};
/**
* GIMP_TYPE_VECTOR2:
*
* Boxed type representing a two-dimensional vector.
*/
#define GIMP_TYPE_VECTOR2 (gimp_vector2_get_type ())
GType gimp_vector2_get_type (void) G_GNUC_CONST;
/**
* GimpVector3:
* @x: the x axis
......@@ -94,6 +104,16 @@ struct _GimpVector3
gdouble x, y, z;
};
/**
* GIMP_TYPE_VECTOR3:
*
* Boxed type representing a three-dimensional vector.
*/
#define GIMP_TYPE_VECTOR3 (gimp_vector3_get_type ())
GType gimp_vector3_get_type (void) G_GNUC_CONST;
/**
* GimpVector4:
* @x: the x axis
......
......@@ -43,6 +43,12 @@
**/
static gpointer gimp_vector2_copy (gpointer boxed);
static void gimp_vector2_free (gpointer boxed);
static gpointer gimp_vector3_copy (gpointer boxed);
static void gimp_vector3_free (gpointer boxed);
/*************************/
/* Some useful constants */
/*************************/
......@@ -1127,3 +1133,52 @@ gimp_vector_3d_to_2d (gint sx,
*y = (gdouble) sy + (p->y * (gdouble) h);
}
}
/* Private functions for boxed type. */
static gpointer
gimp_vector2_copy (gpointer boxed)
{
GimpVector2 *vector = boxed;
GimpVector2 *new_v;
new_v = g_slice_new (GimpVector2);
new_v->x = vector->x;
new_v->y = vector->y;
return new_v;
}
static void
gimp_vector2_free (gpointer boxed)
{
g_slice_free (GimpVector2, boxed);
}
G_DEFINE_BOXED_TYPE (GimpVector2, gimp_vector2,
gimp_vector2_copy,
gimp_vector2_free)
static gpointer
gimp_vector3_copy (gpointer boxed)
{
GimpVector3 *vector = boxed;
GimpVector3 *new_v;
new_v = g_slice_new (GimpVector3);
new_v->x = vector->x;
new_v->y = vector->y;
new_v->y = vector->z;
return new_v;
}
static void
gimp_vector3_free (gpointer boxed)
{
g_slice_free (GimpVector3, boxed);
}
G_DEFINE_BOXED_TYPE (GimpVector3, gimp_vector3,
gimp_vector3_copy,
gimp_vector3_free)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment