/soc/2013/ankitkv/gobjectification: e3277f6c9c03: Removed the us...

Ankit Vani a at nevitus.org
Thu Oct 10 17:37:17 EDT 2013


Changeset: e3277f6c9c0319c0aabadbc2c889ee0828a6024a
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-10-11 02:09 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/e3277f6c9c03

Description:

Removed the use of PurpleValue/PurpleType from mono

diffstat:

 libpurple/plugins/mono/loader/mono-helper.c |  11 ++------
 libpurple/plugins/mono/loader/mono-helper.h |   4 +--
 libpurple/plugins/mono/loader/signal-glue.c |  35 +++++++++++-----------------
 3 files changed, 18 insertions(+), 32 deletions(-)

diffs (123 lines):

diff --git a/libpurple/plugins/mono/loader/mono-helper.c b/libpurple/plugins/mono/loader/mono-helper.c
--- a/libpurple/plugins/mono/loader/mono-helper.c
+++ b/libpurple/plugins/mono/loader/mono-helper.c
@@ -158,20 +158,15 @@ gboolean ml_is_api_dll(MonoImage *image)
 	return FALSE;
 }
 
-MonoObject* ml_object_from_purple_type(PurpleType type, gpointer data)
-{
-	return NULL;
-}
-
-MonoObject* ml_object_from_purple_subtype(PurpleSubType type, gpointer data)
+MonoObject* ml_object_from_purple_type(GType type, gpointer data)
 {
 	MonoObject *obj = NULL;
 
 	switch (type) {
-		case PURPLE_SUBTYPE_BLIST_BUDDY:
+		case PURPLE_TYPE_BUDDY:
 			obj = purple_blist_build_buddy_object(data);
 		break;
-		case PURPLE_SUBTYPE_STATUS:
+		case PURPLE_TYPE_STATUS:
 			obj = purple_status_build_status_object(data);
 		break;
 		default:
diff --git a/libpurple/plugins/mono/loader/mono-helper.h b/libpurple/plugins/mono/loader/mono-helper.h
--- a/libpurple/plugins/mono/loader/mono-helper.h
+++ b/libpurple/plugins/mono/loader/mono-helper.h
@@ -49,9 +49,7 @@ void ml_set_domain(MonoDomain *d);
 
 void ml_init_internal_calls(void);
 
-MonoObject* ml_object_from_purple_type(PurpleType type, gpointer data);
-
-MonoObject* ml_object_from_purple_subtype(PurpleSubType type, gpointer data);
+MonoObject* ml_object_from_purple_type(GType type, gpointer data);
 
 MonoObject* ml_create_api_object(char *class_name);
 
diff --git a/libpurple/plugins/mono/loader/signal-glue.c b/libpurple/plugins/mono/loader/signal-glue.c
--- a/libpurple/plugins/mono/loader/signal-glue.c
+++ b/libpurple/plugins/mono/loader/signal-glue.c
@@ -7,8 +7,8 @@
 typedef struct {
 	MonoObject *func;
 	char *signal;
-	PurpleValue **values;
-	PurpleValue *ret_value;
+	GType *types;
+	GType ret_type;
 	int num_vals;
 } SignalData;
 
@@ -29,15 +29,9 @@ static gpointer dispatch_callback(Signal
 	array = mono_array_new(ml_get_domain(), mono_get_object_class(), num_vals);
 
 	for (i = 0; i < num_vals; i++) {
-		if (purple_value_get_type(sig_data->values[i]) == PURPLE_TYPE_SUBTYPE) {
-			purple_obj = va_arg(args, gpointer);
-			obj = ml_object_from_purple_subtype(purple_value_get_subtype(sig_data->values[i]), purple_obj);
-			mono_array_set(array, MonoObject*, i, obj);
-		} else {
-			purple_obj = va_arg(args, gpointer);
-			obj = ml_object_from_purple_type(purple_value_get_type(sig_data->values[i]), purple_obj);
-			mono_array_set(array, MonoObject*, i, obj);
-		}
+		purple_obj = va_arg(args, gpointer);
+		obj = ml_object_from_purple_type(sig_data->types[i], purple_obj);
+		mono_array_set(array, MonoObject*, i, obj);
 	}
 
 	va_end(args);
@@ -76,7 +70,7 @@ int purple_signal_connect_glue(MonoObjec
 	sig_data->func = func;
 	sig_data->signal = sig;
 
-	purple_signal_get_values(*instance, sig, &sig_data->ret_value, &sig_data->num_vals, &sig_data->values);
+	purple_signal_get_types(*instance, sig, &sig_data->ret_type, &sig_data->num_vals, &sig_data->types);
 
 	klass = mono_object_get_class(plugin);
 
@@ -87,17 +81,16 @@ int purple_signal_connect_glue(MonoObjec
 	return purple_signal_connect(*instance, sig, (gpointer)klass, get_callback(sig_data), (gpointer)sig_data);
 }
 
-static int determine_index(PurpleType type)
+static int determine_index(GType type)
 {
 	switch (type) {
-		case PURPLE_TYPE_SUBTYPE:
-		case PURPLE_TYPE_STRING:
-		case PURPLE_TYPE_OBJECT:
-		case PURPLE_TYPE_POINTER:
-		case PURPLE_TYPE_BOXED:
+		case G_TYPE_STRING:
+		case G_TYPE_POINTER:
 			return 1;
 		break;
 		default:
+			if (G_TYPE_IS_OBJECT(type) || G_TYPE_IS_BOXED(type))
+				return 1;
 			return type;
 		break;
 	}
@@ -117,13 +110,13 @@ static PurpleCallback get_callback(Signa
 {
 	int i, index = 0;
 
-	if (sig_data->ret_value == NULL)
+	if (sig_data->ret_type == NULL)
 		index = 0;
 	else
-		index = determine_index(purple_value_get_type(sig_data->ret_value));
+		index = determine_index(sig_data->ret_type);
 
 	for (i = 0; i < sig_data->num_vals; i++) {
-		index += determine_index(purple_value_get_type(sig_data->values[i]));
+		index += determine_index(sig_data->types[i]);
 	}
 
 	purple_debug(PURPLE_DEBUG_INFO, "mono", "get_callback index = %d\n", index);



More information about the Commits mailing list