[model/wip/api-redesign] Removed ModelObject in favor of GObject
- From: Alberto Ruiz <aruiz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [model/wip/api-redesign] Removed ModelObject in favor of GObject
- Date: Fri, 26 Oct 2012 22:15:10 +0000 (UTC)
commit 01dca82a58ada30f32befd631e0ba68acb85e7e6
Author: Alberto Ruiz <aruiz gnome org>
Date: Fri Oct 26 23:50:09 2012 +0200
Removed ModelObject in favor of GObject
model/Makefile.am | 3 +-
model/model-abstract-sorted-list.c | 10 +++---
model/model-basictypes.c | 64 ++++++++++++++++++------------------
model/model-dictionary.c | 8 ++--
model/model-implementation.h | 18 +++++-----
model/model-list.c | 10 +++---
model/model-object.c | 45 -------------------------
model/model-simple-list.c | 52 ++++++++++++++--------------
model/model.h | 47 ++++----------------------
9 files changed, 90 insertions(+), 167 deletions(-)
---
diff --git a/model/Makefile.am b/model/Makefile.am
index 243564f..d6d2059 100644
--- a/model/Makefile.am
+++ b/model/Makefile.am
@@ -4,7 +4,6 @@ libmodel_la_LIBADD = $(gobject_LIBS)
libmodel_la_SOURCES = \
model-abstract-sorted-list.c \
model-dictionary.c \
- model-object.c \
model-simple-list.c \
model-basictypes.c \
model-list.c
@@ -15,7 +14,7 @@ Model-0.2.typelib: Model-0.2.gir libmodel.la
g-ir-compiler -o $@ --shared-library=libmodel $<
Model-0.2.gir: model.h model-implementation.h $(libmodel_la_SOURCES) libmodel.la
- g-ir-scanner --namespace Model --nsversion=0.2 --output $@ \
+ g-ir-scanner --warn-all --namespace Model --nsversion=0.2 --output $@ \
--c-include=model-implementation.h --libtool="$(LIBTOOL)" \
--library=model --pkg-export=model --include=GObject-2.0 \
$(libmodel_la_CFLAGS) $^
diff --git a/model/model-abstract-sorted-list.c b/model/model-abstract-sorted-list.c
index 06abc67..e91cb63 100644
--- a/model/model-abstract-sorted-list.c
+++ b/model/model-abstract-sorted-list.c
@@ -83,7 +83,7 @@ G_DEFINE_ABSTRACT_TYPE (ModelAbstractSortedList,
MODEL_TYPE_LIST)
struct _ModelAbstractSortedListPrivate
{
- ModelObject **objects;
+ GObject **objects;
gpointer *keys;
gulong n_items;
};
@@ -128,7 +128,7 @@ model_abstract_sorted_list_merge (ModelAbstractSortedList *sorted,
gulong change_position = 0, change_removed = 0, change_inserted = 0;
ModelAbstractSortedListClass *class;
gboolean in_change_set = FALSE;
- ModelObject **old_objects;
+ GObject **old_objects;
gpointer *old_keys;
gulong old_n_items;
gulong i, j, k;
@@ -144,7 +144,7 @@ model_abstract_sorted_list_merge (ModelAbstractSortedList *sorted,
{
gulong max_len = sorted->priv->n_items + n_keys;
- sorted->priv->objects = g_new (ModelObject *, max_len);
+ sorted->priv->objects = g_new (GObject *, max_len);
sorted->priv->keys = g_new (gpointer, max_len);
}
@@ -265,7 +265,7 @@ model_abstract_sorted_list_merge (ModelAbstractSortedList *sorted,
}
}
- sorted->priv->objects = g_renew (ModelObject *, sorted->priv->objects, k);
+ sorted->priv->objects = g_renew (GObject *, sorted->priv->objects, k);
sorted->priv->keys = g_renew (gpointer, sorted->priv->keys, k);
sorted->priv->n_items = k;
@@ -285,7 +285,7 @@ model_abstract_sorted_list_n_children (ModelList *list)
return sorted->priv->n_items;
}
-static ModelObject *
+static GObject *
model_abstract_sorted_list_get_child (ModelList *list,
gulong index)
{
diff --git a/model/model-basictypes.c b/model/model-basictypes.c
index e3b5156..ccb83f1 100644
--- a/model/model-basictypes.c
+++ b/model/model-basictypes.c
@@ -18,10 +18,10 @@
/**
* SECTION:string
- * @Short_Description: a #ModelObject containing a string
+ * @Short_Description: a #GObject containing a string
* @Image: string.png
*
- * #ModelString is a simple #ModelObject subclass containing an
+ * #ModelString is a simple #GObject subclass containing an
* immutable non-%NULL string.
**/
@@ -30,13 +30,13 @@
*
* This is an opaque structure; it may not be accessed directly.
**/
-typedef ModelObjectClass ModelStringClass;
+typedef GObjectClass ModelStringClass;
struct _ModelString
{
- ModelObject parent_instance;
+ GObject parent_instance;
gchar *value;
};
-G_DEFINE_TYPE (ModelString, model_string, MODEL_TYPE_OBJECT);
+G_DEFINE_TYPE (ModelString, model_string, G_TYPE_OBJECT);
/**
* model_string_get:
@@ -75,13 +75,13 @@ model_string_peek (ModelString *object)
/**
* model_string_new:
* @value: a string, non-%NULL
- * @Returns: a new #ModelObject
+ * @Returns: a new #GObject
*
* Creates a #ModelString, containing @value.
*
* This function should only be called by model implementations.
**/
-ModelObject *
+GObject *
model_string_new (const gchar *value)
{
ModelString *object;
@@ -91,7 +91,7 @@ model_string_new (const gchar *value)
object = g_object_new (MODEL_TYPE_STRING, NULL);
object->value = g_strdup (value);
- return (ModelObject *) object;
+ return (GObject *) object;
}
static void
@@ -120,10 +120,10 @@ model_string_init (ModelString *object)
/**
* SECTION:integer
- * @Short_Description: a #ModelObject containing a #gint
+ * @Short_Description: a #GObject containing a #gint
* @Image: integer.png
*
- * #ModelInteger is a simple #ModelObject subclass containing an
+ * #ModelInteger is a simple #GObject subclass containing an
* immutable #gint value.
**/
@@ -132,13 +132,13 @@ model_string_init (ModelString *object)
*
* This is an opaque structure; it may not be accessed directly.
**/
-typedef ModelObjectClass ModelIntegerClass;
+typedef GObjectClass ModelIntegerClass;
struct _ModelInteger
{
- ModelObject parent_instance;
+ GObject parent_instance;
gint value;
};
-G_DEFINE_TYPE (ModelInteger, model_integer, MODEL_TYPE_OBJECT);
+G_DEFINE_TYPE (ModelInteger, model_integer, G_TYPE_OBJECT);
/**
* model_integer_get:
@@ -158,13 +158,13 @@ model_integer_get (ModelInteger *object)
/**
* model_integer_new:
* @value: an integer
- * @Returns: a new #ModelObject
+ * @Returns: a new #GObject
*
* Creates a #ModelInteger, containing @value.
*
* This function should only be called by model implementations.
**/
-ModelObject *
+GObject *
model_integer_new (gint value)
{
ModelInteger *object;
@@ -172,7 +172,7 @@ model_integer_new (gint value)
object = g_object_new (MODEL_TYPE_INTEGER, NULL);
object->value = value;
- return (ModelObject *) object;
+ return (GObject *) object;
}
static void
@@ -187,10 +187,10 @@ model_integer_init (ModelInteger *object)
/**
* SECTION:float
- * @Short_Description: a #ModelObject containing a #gdouble
+ * @Short_Description: a #GObject containing a #gdouble
* @Image: float.png
*
- * #ModelFloat is a simple #ModelObject subclass containing an immutable
+ * #ModelFloat is a simple #GObject subclass containing an immutable
* #gdouble value.
**/
@@ -199,13 +199,13 @@ model_integer_init (ModelInteger *object)
*
* This is an opaque structure; it may not be accessed directly.
**/
-typedef ModelObjectClass ModelFloatClass;
+typedef GObjectClass ModelFloatClass;
struct _ModelFloat
{
- ModelObject parent_instance;
+ GObject parent_instance;
gdouble value;
};
-G_DEFINE_TYPE (ModelFloat, model_float, MODEL_TYPE_OBJECT);
+G_DEFINE_TYPE (ModelFloat, model_float, G_TYPE_OBJECT);
/**
* model_float_get:
@@ -225,13 +225,13 @@ model_float_get (ModelFloat *object)
/**
* model_float_new:
* @value: a double precision floating point value
- * @Returns: a new #ModelObject
+ * @Returns: a new #GObject
*
* Creates a #ModelFloat, containing @value.
*
* This function should only be called by model implementations.
**/
-ModelObject *
+GObject *
model_float_new (gdouble value)
{
ModelFloat *object;
@@ -239,7 +239,7 @@ model_float_new (gdouble value)
object = g_object_new (MODEL_TYPE_FLOAT, NULL);
object->value = value;
- return (ModelObject *) object;
+ return (GObject *) object;
}
static void
@@ -254,10 +254,10 @@ model_float_init (ModelFloat *object)
/**
* SECTION:boolean
- * @Short_Description: a #ModelObject containing a #gboolean
+ * @Short_Description: a #GObject containing a #gboolean
* @Image: boolean.png
*
- * #ModelBoolean is a simple #ModelObject subclass containing an
+ * #ModelBoolean is a simple #GObject subclass containing an
* immutable #gboolean value.
**/
@@ -266,13 +266,13 @@ model_float_init (ModelFloat *object)
*
* This is an opaque structure; it may not be accessed directly.
**/
-typedef ModelObjectClass ModelBooleanClass;
+typedef GObjectClass ModelBooleanClass;
struct _ModelBoolean
{
- ModelObject parent_instance;
+ GObject parent_instance;
gboolean value;
};
-G_DEFINE_TYPE (ModelBoolean, model_boolean, MODEL_TYPE_OBJECT);
+G_DEFINE_TYPE (ModelBoolean, model_boolean, G_TYPE_OBJECT);
/**
* model_boolean_get:
@@ -292,13 +292,13 @@ model_boolean_get (ModelBoolean *object)
/**
* model_boolean_new:
* @value: a boolean value
- * @Returns: a new #ModelObject
+ * @Returns: a new #GObject
*
* Creates a #ModelBoolean, containing @value.
*
* This function should only be called by model implementations.
**/
-ModelObject *
+GObject *
model_boolean_new (gboolean value)
{
ModelBoolean *object;
@@ -306,7 +306,7 @@ model_boolean_new (gboolean value)
object = g_object_new (MODEL_TYPE_BOOLEAN, NULL);
object->value = value;
- return (ModelObject *) object;
+ return (GObject *) object;
}
static void
diff --git a/model/model-dictionary.c b/model/model-dictionary.c
index 77937a2..630d20a 100644
--- a/model/model-dictionary.c
+++ b/model/model-dictionary.c
@@ -45,16 +45,16 @@
* The class structure for #ModelDictionary. All virtual functions must
* be implemented by each subclass.
**/
-G_DEFINE_ABSTRACT_TYPE (ModelDictionary, model_dictionary, MODEL_TYPE_OBJECT);
+G_DEFINE_ABSTRACT_TYPE (ModelDictionary, model_dictionary, G_TYPE_OBJECT);
/**
* model_dictionary_get_value:
* @dictionary: a #ModelDictionary
* @key: the key to fetch the reference for
- * @returns: a #ModelObject for the key, owned by the caller
+ * @returns: a #GObject for the key, owned by the caller
*
- * Gets a #ModelObject corresponding to the current value of @key on
+ * Gets a #GObject corresponding to the current value of @key on
* @dictionary. @key must be a valid key on the dictionary.
*
* This function is equivalent to calling
@@ -65,7 +65,7 @@ G_DEFINE_ABSTRACT_TYPE (ModelDictionary, model_dictionary, MODEL_TYPE_OBJECT);
* It is appropriate for the caller to call g_object_unref() on the
* return value.
**/
-ModelObject *
+GObject *
model_dictionary_get_value (ModelDictionary *dictionary,
const gchar *key)
{
diff --git a/model/model-implementation.h b/model/model-implementation.h
index 4950d96..d8316bf 100644
--- a/model/model-implementation.h
+++ b/model/model-implementation.h
@@ -18,10 +18,10 @@
G_BEGIN_DECLS
-ModelObject * model_string_new (const gchar *value);
-ModelObject * model_integer_new (gint value);
-ModelObject * model_float_new (gdouble value);
-ModelObject * model_boolean_new (gboolean value);
+GObject * model_string_new (const gchar *value);
+GObject * model_integer_new (gint value);
+GObject * model_float_new (gdouble value);
+GObject * model_boolean_new (gboolean value);
void model_list_changed (ModelList *list,
gulong position,
@@ -42,16 +42,16 @@ ModelSimpleList * model_simple_list_new (void);
void model_simple_list_splice (ModelSimpleList *list,
gulong position,
gulong n_removes,
- ModelObject * const *inserts,
+ GObject * const *inserts,
gulong n_inserts,
gboolean more);
void model_simple_list_remove (ModelSimpleList *list,
gulong position);
void model_simple_list_insert (ModelSimpleList *list,
gulong position,
- ModelObject *value);
+ GObject *value);
void model_simple_list_append (ModelSimpleList *list,
- ModelObject *value);
+ GObject *value);
@@ -87,13 +87,13 @@ struct _ModelAbstractSortedListClass
gconstpointer key,
gchar mode,
gulong current_index,
- ModelObject *value);
+ GObject *value);
void (*create_item) (ModelAbstractSortedList *list,
gulong index,
gconstpointer key,
gpointer *new_key,
- ModelObject **new_object);
+ GObject **new_object);
void (*free_key) (ModelAbstractSortedList *list,
gpointer key);
diff --git a/model/model-list.c b/model/model-list.c
index 0fb6e9b..159d823 100644
--- a/model/model-list.c
+++ b/model/model-list.c
@@ -18,10 +18,10 @@
/**
* SECTION:list
- * @Short_Description: a mutable list of #ModelObject instances
+ * @Short_Description: a mutable list of #GObject instances
* @Image: list.png
*
- * #ModelList is a mutable list of #ModelObject instances (items).
+ * #ModelList is a mutable list of #GObject instances (items).
* Items can be inserted and removed, changing the length and
* composition of the list.
*
@@ -48,7 +48,7 @@
* The class structure for #ModelList. All virtual functions must be
* implemented by each subclass.
**/
-G_DEFINE_ABSTRACT_TYPE (ModelList, model_list, MODEL_TYPE_OBJECT);
+G_DEFINE_ABSTRACT_TYPE (ModelList, model_list, G_TYPE_OBJECT);
struct _ModelListPrivate
{
@@ -85,7 +85,7 @@ model_list_n_children (ModelList *list)
* model_list_get_child:
* @list: a #modelList
* @index: the index of the child value to get
- * @returns: the #ModelObject for the child value, owned by the caller
+ * @returns: the #GObject for the child value, owned by the caller
*
* Gets the child value at position @index of @list. @index must be a
* valid index in the array (ie: strictly less than the result of
@@ -94,7 +94,7 @@ model_list_n_children (ModelList *list)
* It is appropriate for the caller to call g_object_unref() on the
* return value.
**/
-ModelObject *
+GObject *
model_list_get_child (ModelList *list,
gulong index)
{
diff --git a/model/model-simple-list.c b/model/model-simple-list.c
index 52f0962..159af0c 100644
--- a/model/model-simple-list.c
+++ b/model/model-simple-list.c
@@ -40,14 +40,14 @@ struct _ModelSimpleList
{
ModelList parent_instance;
- ModelObject **items;
+ GObject **items;
gulong n_items;
};
G_DEFINE_TYPE (ModelSimpleList, model_simple_list, MODEL_TYPE_LIST)
/**
* model_simple_list_splice:
- * @simple: a #ModelSimpleList
+ * @list: a #ModelSimpleList
* @position: the position at which to perform the splice
* @n_removes: the number of items to remove from @position
* @inserts: the list of items to insert at @position
@@ -62,29 +62,29 @@ G_DEFINE_TYPE (ModelSimpleList, model_simple_list, MODEL_TYPE_LIST)
*
* This function takes its own references to each of the items in
* @inserts, but does not modify the array.
- **/
+ **/
void
-model_simple_list_splice (ModelSimpleList *simple,
+model_simple_list_splice (ModelSimpleList *list,
gulong position,
gulong n_removes,
- ModelObject * const *inserts,
+ GObject * const *inserts,
gulong n_inserts,
gboolean more)
{
gulong new_count, old_count;
- ModelObject **old_items;
+ GObject **old_items;
- old_count = simple->n_items;
- old_items = simple->items;
+ old_count = list->n_items;
+ old_items = list->items;
new_count = old_count + n_inserts + n_removes;
if (new_count != old_count)
{
- ModelObject **new_items;
+ GObject **new_items;
gulong i;
- new_items = g_new (ModelObject *, new_count);
+ new_items = g_new (GObject *, new_count);
for (i = 0; i < position; i++)
new_items[i] = old_items[i];
@@ -95,30 +95,30 @@ model_simple_list_splice (ModelSimpleList *simple,
for (i = position + n_removes; i < old_count; i++)
new_items[i + n_inserts - n_removes] = old_items[i];
- g_free (simple->items);
+ g_free (list->items);
- simple->n_items = new_count;
- simple->items = new_items;
+ list->n_items = new_count;
+ list->items = new_items;
}
}
/**
* model_simple_list_remove:
- * @simple: a #ModelSimpleList
+ * @list: a #ModelSimpleList
* @position: the index of the item to remove
*
* Removes a single item from the list.
**/
void
-model_simple_list_remove (ModelSimpleList *simple,
+model_simple_list_remove (ModelSimpleList *list,
gulong position)
{
- model_simple_list_splice (simple, position, 1, NULL, 0, FALSE);
+ model_simple_list_splice (list, position, 1, NULL, 0, FALSE);
}
/**
* model_simple_list_insert:
- * @simple: a #ModelSimpleList
+ * @list: a #ModelSimpleList
* @position: the position to insert at
* @value: the item to insert into the list
*
@@ -126,25 +126,25 @@ model_simple_list_remove (ModelSimpleList *simple,
* item to insert before.
**/
void
-model_simple_list_insert (ModelSimpleList *simple,
+model_simple_list_insert (ModelSimpleList *list,
gulong position,
- ModelObject *value)
+ GObject *value)
{
- model_simple_list_splice (simple, position, 0, &value, 1, FALSE);
+ model_simple_list_splice (list, position, 0, &value, 1, FALSE);
}
/**
* model_simple_list_append:
- * @simple: a #ModelSimpleList
+ * @list: a #ModelSimpleList
* @value: the item to insert into the list
*
* Appends an item to the end of the list.
**/
void
-model_simple_list_append (ModelSimpleList *simple,
- ModelObject *value)
+model_simple_list_append (ModelSimpleList *list,
+ GObject *value)
{
- model_simple_list_splice (simple, simple->n_items, 0, &value, 1, FALSE);
+ model_simple_list_splice (list, list->n_items, 0, &value, 1, FALSE);
}
static gulong
@@ -155,7 +155,7 @@ model_simple_list_n_children (ModelList *list)
return simple->n_items;
}
-static ModelObject *
+static GObject *
model_simple_list_get_child (ModelList *list,
gulong index)
{
@@ -182,7 +182,7 @@ model_simple_list_finalize (GObject *object)
}
static void
-model_simple_list_init (ModelSimpleList *simple)
+model_simple_list_init (ModelSimpleList *list)
{
}
diff --git a/model/model.h b/model/model.h
index 2013a92..c87f481 100644
--- a/model/model.h
+++ b/model/model.h
@@ -18,35 +18,6 @@
G_BEGIN_DECLS
-#define MODEL_TYPE_OBJECT model_object_get_type ()
-#define MODEL_OBJECT(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
- MODEL_TYPE_OBJECT, ModelObject))
-#define MODEL_OBJECT_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \
- MODEL_TYPE_OBJECT, ModelObjectClass))
-#define MODEL_IS_OBJECT(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \
- MODEL_TYPE_OBJECT))
-#define MODEL_IS_OBJECT_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \
- MODEL_TYPE_OBJECT))
-#define MODEL_OBJECT_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \
- MODEL_TYPE_OBJECT, ModelObjectClass))
-
-typedef struct _ModelObjectPrivate ModelObjectPrivate;
-typedef struct _ModelObjectClass ModelObjectClass;
-typedef struct _ModelObject ModelObject;
-
-struct _ModelObjectClass
-{
- GObjectClass parent_class;
-};
-
-struct _ModelObject
-{
- GObject parent_instance;
-
- /*< private >*/
- ModelObjectPrivate *priv;
-};
-
#define MODEL_TYPE_DICTIONARY model_dictionary_get_type ()
#define MODEL_DICTIONARY(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
MODEL_TYPE_DICTIONARY, ModelDictionary))
@@ -65,9 +36,9 @@ typedef struct _ModelDictionary ModelDictionary;
struct _ModelDictionaryClass
{
- ModelObjectClass parent_class;
+ GObjectClass parent_class;
- ModelObject * (*get_value) (ModelDictionary *dictionary,
+ GObject * (*get_value) (ModelDictionary *dictionary,
const gchar *key);
gchar ** (*list_keys) (ModelDictionary *dictionary,
gint *length);
@@ -75,7 +46,7 @@ struct _ModelDictionaryClass
struct _ModelDictionary
{
- ModelObject parent_instance;
+ GObject parent_instance;
/*< private >*/
ModelDictionaryPrivate *priv;
@@ -99,16 +70,16 @@ typedef struct _ModelList ModelList;
struct _ModelListClass
{
- ModelObjectClass parent_class;
+ GObjectClass parent_class;
gulong (*n_children) (ModelList *list);
- ModelObject * (*get_child) (ModelList *list,
+ GObject * (*get_child) (ModelList *list,
gulong index);
};
struct _ModelList
{
- ModelObject parent_instance;
+ GObject parent_instance;
/*< private >*/
ModelListPrivate *priv;
@@ -147,17 +118,15 @@ typedef struct _ModelFloat ModelFloat;
typedef struct _ModelBoolean ModelBoolean;
-GType model_object_get_type (void);
-
GType model_dictionary_get_type (void);
-ModelObject * model_dictionary_get_value (ModelDictionary *dictionary,
+GObject * model_dictionary_get_value (ModelDictionary *dictionary,
const gchar *key);
gchar ** model_dictionary_list_keys (ModelDictionary *dictionary,
gint *length);
GType model_list_get_type (void);
gulong model_list_n_children (ModelList *list);
-ModelObject * model_list_get_child (ModelList *list,
+GObject * model_list_get_child (ModelList *list,
gulong index);
GType model_string_get_type (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]