[Galago-commits] r1973 - in branches/libgalago/glib-port: . libgalago

galago-commits at freedesktop.org galago-commits at freedesktop.org
Wed Jun 22 23:14:45 PDT 2005


Author: chipx86
Date: 2005-06-22 23:14:41 -0700 (Wed, 22 Jun 2005)
New Revision: 1973

Modified:
   branches/libgalago/glib-port/ChangeLog
   branches/libgalago/glib-port/libgalago/galago-value.c
   branches/libgalago/glib-port/libgalago/galago-value.h
Log:
Made GalagoValue work with GTypes, even though I plan to nuke this whole thing before all this is released.


Modified: branches/libgalago/glib-port/ChangeLog
===================================================================
--- branches/libgalago/glib-port/ChangeLog	2005-06-23 05:04:46 UTC (rev 1972)
+++ branches/libgalago/glib-port/ChangeLog	2005-06-23 06:14:41 UTC (rev 1973)
@@ -1,3 +1,10 @@
+Wed Jun 22 23:13:13 PDT 2005  Christian Hammond <chipx86 at chipx86.com>
+
+	* libgalago/galago-value.c:
+	* libgalago/galago-value.h:
+	  - Made GalagoValue work with GTypes, even though I plan to nuke this
+	    whole thing before all this is released.
+
 Wed Jun 22 22:02:13 PDT 2005  Christian Hammond <chipx86 at chipx86.com>
 
 	* libgalago/galago-account.c:

Modified: branches/libgalago/glib-port/libgalago/galago-value.c
===================================================================
--- branches/libgalago/glib-port/libgalago/galago-value.c	2005-06-23 05:04:46 UTC (rev 1972)
+++ branches/libgalago/glib-port/libgalago/galago-value.c	2005-06-23 06:14:41 UTC (rev 1973)
@@ -29,10 +29,16 @@
 {
 	GalagoType type;
 	GalagoType subtype;
-	void *detail;
 
 	union
 	{
+		void *ptr;
+		GType gtype;
+
+	} detail;
+
+	union
+	{
 		char char_data;
 		unsigned char uchar_data;
 		gboolean boolean_data;
@@ -106,18 +112,11 @@
 	GalagoValue *value;
 
 	g_return_val_if_fail(type != GALAGO_VALUE_TYPE_UNKNOWN, NULL);
+	g_return_val_if_fail(type != GALAGO_VALUE_TYPE_OBJECT,  NULL);
 
-	if (type == GALAGO_VALUE_TYPE_OBJECT &&
-		(detail == NULL || !GALAGO_IS_CLASS(detail)))
-	{
-		galago_log_error("A valid class type must be passed for objects to "
-						 "galago_value_new\n");
-		return NULL;
-	}
-
 	value = g_new0(GalagoValue, 1);
-	value->type = type;
-	value->detail = detail;
+	value->type       = type;
+	value->detail.ptr = detail;
 
 	if (data != NULL)
 	{
@@ -152,6 +151,21 @@
 }
 
 GalagoValue *
+galago_value_new_object(GType type, const GObject *obj)
+{
+	GalagoValue *value;
+
+	value = g_new0(GalagoValue, 1);
+	value->type   = GALAGO_VALUE_TYPE_OBJECT;
+	value->detail.gtype = type;
+
+	if (obj != NULL)
+		galago_value_set_object(value, (void *)obj);
+
+	return value;
+}
+
+GalagoValue *
 galago_value_new_list(GalagoType type, GList *list, void *detail)
 {
 	GalagoValue *value;
@@ -161,14 +175,6 @@
 	value = galago_value_new(GALAGO_VALUE_TYPE_LIST, list, detail);
 	value->subtype = type;
 
-	if (type == GALAGO_VALUE_TYPE_OBJECT &&
-		(detail == NULL || !GALAGO_IS_CLASS(detail)))
-	{
-		galago_log_error("A valid class type must be passed for objects to "
-						 "galago_value_new\n");
-		return NULL;
-	}
-
 	return value;
 }
 
@@ -227,17 +233,17 @@
 	return value->subtype;
 }
 
-GalagoObjectClass *
-galago_value_get_object_class(const GalagoValue *value)
+GType
+galago_value_get_gtype(const GalagoValue *value)
 {
-	g_return_val_if_fail(value != NULL, NULL);
+	g_return_val_if_fail(value != NULL, 0);
 	g_return_val_if_fail(galago_value_get_type(value) ==
-							  GALAGO_VALUE_TYPE_OBJECT ||
-							  galago_value_get_subtype(value) ==
-							  GALAGO_VALUE_TYPE_OBJECT,
-							  NULL);
+						 GALAGO_VALUE_TYPE_OBJECT ||
+						 galago_value_get_subtype(value) ==
+						 GALAGO_VALUE_TYPE_OBJECT,
+						 0);
 
-	return (GalagoObjectClass *)value->detail;
+	return value->detail.gtype;
 }
 
 void
@@ -263,7 +269,7 @@
 	{
 		new_list = g_list_append(new_list,
 								 galago_value_new(subtype, &l->data,
-												  value->detail));
+												  value->detail.ptr));
 	}
 
 	value->data.list_data = new_list;

Modified: branches/libgalago/glib-port/libgalago/galago-value.h
===================================================================
--- branches/libgalago/glib-port/libgalago/galago-value.h	2005-06-23 05:04:46 UTC (rev 1972)
+++ branches/libgalago/glib-port/libgalago/galago-value.h	2005-06-23 06:14:41 UTC (rev 1973)
@@ -66,6 +66,17 @@
 GalagoValue *galago_value_new(GalagoType type, const void *data, void *detail);
 
 /**
+ * Creates a new, special GalagoValue that takes an object type and an
+ * optional object.
+ *
+ * @param type   The GType.
+ * @param obj    The object.
+ *
+ * @return The new value.
+ */
+GalagoValue *galago_value_new_object(GType type, const GObject *obj);
+
+/**
  * Creates a new, special GalagoValue that takes only a list of values
  * of the specified type.
  *
@@ -120,13 +131,13 @@
 GalagoType galago_value_get_subtype(const GalagoValue *value);
 
 /**
- * Returns the object's class type, if the value's type is GALAGO_VALUE_TYPE_OBJECT.
+ * Returns the object's GType, if the value's type is GALAGO_VALUE_TYPE_OBJECT.
  *
  * @param value The value.
  *
- * @return The object's class type, or NULL.
+ * @return The object's GType, or NULL.
  */
-GalagoObjectClass *galago_value_get_object_class(const GalagoValue *value);
+GType galago_value_get_gtype(const GalagoValue *value);
 
 /**
  * Sets the value's character data.



More information about the galago-commits mailing list