[gegl] operation: use base_init and not class_init for key hashtable
- From: Ãyvind KolÃs <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] operation: use base_init and not class_init for key hashtable
- Date: Thu, 29 Mar 2012 20:07:04 +0000 (UTC)
commit 0ded3d950b8572403ef86204d8abed412e20e4fb
Author: Ãyvind KolÃs <pippin gimp org>
Date: Thu Mar 29 19:49:00 2012 +0100
operation: use base_init and not class_init for key hashtable
gegl/operation/gegl-operation.c | 65 ++++++++++++++++++++++++++++++---------
gegl/operation/gegl-operation.h | 5 ++-
2 files changed, 53 insertions(+), 17 deletions(-)
---
diff --git a/gegl/operation/gegl-operation.c b/gegl/operation/gegl-operation.c
index 97814f5..dc24e61 100644
--- a/gegl/operation/gegl-operation.c
+++ b/gegl/operation/gegl-operation.c
@@ -43,13 +43,41 @@ static GeglRectangle get_required_for_output (GeglOperation *self,
const gchar *input_pad,
const GeglRectangle *region);
-G_DEFINE_TYPE (GeglOperation, gegl_operation, G_TYPE_OBJECT)
+static void gegl_operation_class_init (GeglOperationClass *klass);
+static void gegl_operation_base_init (GeglOperationClass *klass);
+static void gegl_operation_init (GeglOperation *self);
+
+GType
+gegl_operation_get_type (void)
+{
+ static GType type = 0;
+
+ if (! type)
+ {
+ const GTypeInfo info =
+ {
+ sizeof (GeglOperationClass),
+ (GBaseInitFunc) gegl_operation_base_init,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) gegl_operation_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (GeglOperation),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) gegl_operation_init,
+ };
+
+ type = g_type_register_static (G_TYPE_OBJECT,
+ "GeglOperation",
+ &info, 0);
+ }
+ return type;
+}
+
static void
gegl_operation_class_init (GeglOperationClass *klass)
{
- /* XXX: leaked for now, should replace G_DEFINE_TYPE with the expanded one */
- klass->keys = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
klass->name = NULL; /* an operation class with
* name == NULL is not
* included when doing
@@ -67,6 +95,13 @@ gegl_operation_class_init (GeglOperationClass *klass)
}
static void
+gegl_operation_base_init (GeglOperationClass *klass)
+{
+ /* XXX: leaked for now, should replace G_DEFINE_TYPE with the expanded one */
+ klass->keys = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+}
+
+static void
gegl_operation_init (GeglOperation *self)
{
}
@@ -497,21 +532,21 @@ gegl_operation_class_set_key (GeglOperationClass *klass,
const gchar *key_name,
const gchar *key_value)
{
- if (!strcmp (key_name, "name"))
+ if (!key_value)
{
- if (klass->name)
- {
- g_warning ("tried changing name of op %s to %s",
- klass->name, key_value);
- return;
- }
- klass->name = g_strdup (key_value);
+ g_hash_table_remove (klass->keys, key_name);
+ return;
}
- if (key_value)
- g_hash_table_remove (klass->keys, key_name);
else
- g_hash_table_insert (klass->keys, g_strdup (key_name),
- g_strdup (key_value));
+ {
+ key_value = g_strdup (key_value);
+ g_hash_table_insert (klass->keys, g_strdup (key_name),
+ (void*)key_value);
+ }
+ if (!strcmp (key_name, "name"))
+ {
+ klass->name = key_value;
+ }
}
void
diff --git a/gegl/operation/gegl-operation.h b/gegl/operation/gegl-operation.h
index 39100f0..3c11930 100644
--- a/gegl/operation/gegl-operation.h
+++ b/gegl/operation/gegl-operation.h
@@ -76,7 +76,8 @@ struct _GeglOperationClass
GObjectClass parent_class;
const gchar *name; /* name(string) used to create/identify
- this type of operation in GEGL*/
+ this type of operation in GEGL, should be
+ set through gegl_operation_class_set_key(s) */
const gchar *compat_name; /* allows specifying an alias that the op is
also known as */
GHashTable *keys; /* hashtable used for storing meta-data about an op */
@@ -144,7 +145,7 @@ struct _GeglOperationClass
GeglNode* (*detect) (GeglOperation *operation,
gint x,
gint y);
- gpointer pad[8];
+ gpointer pad[10];
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]