/soc/2013/ankitkv/gobjectification: f029b9598b8e: Undo initial r...

Ankit Vani a at nevitus.org
Tue Jul 16 15:28:25 EDT 2013


Changeset: f029b9598b8e775aa431879a6dd0a0bf74b59b12
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-07-17 00:58 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/f029b9598b8e

Description:

Undo initial replacement of PurpleValue

diffstat:

 libpurple/dbus-server.h                     |    5 +-
 libpurple/plugin.h                          |   18 +-
 libpurple/plugins/mono/loader/mono-helper.c |   21 +++-
 libpurple/plugins/mono/loader/mono-helper.h |    4 +-
 libpurple/plugins/perl/perl-common.c        |  139 ++++++++++++++++-----------
 libpurple/plugins/perl/perl-common.h        |    4 +-
 libpurple/plugins/tcl/tcl_purple.h          |    4 +-
 libpurple/signals.c                         |    4 +-
 libpurple/signals.h                         |   19 ++-
 libpurple/status.h                          |   10 +-
 10 files changed, 134 insertions(+), 94 deletions(-)

diffs (truncated from 432 to 300 lines):

diff --git a/libpurple/dbus-server.h b/libpurple/dbus-server.h
--- a/libpurple/dbus-server.h
+++ b/libpurple/dbus-server.h
@@ -140,11 +140,12 @@ void purple_dbus_unregister_pointer(gpoi
 
     @param name        The name of the signal ("bla-bla-blaa")
     @param num_values  The number of parameters.
-    @param types       Array of the types of the parameters.
+    @param values      Array of pointers to #PurpleValue objects representing
+                       the types of the parameters.
     @param vargs       A va_list containing the actual parameters.
   */
 void purple_dbus_signal_emit_purple(const char *name, int num_values,
-				GType *types, va_list vargs);
+				PurpleValue **values, va_list vargs);
 
 /**
  * Returns whether Purple's D-BUS subsystem is up and running.  If it's
diff --git a/libpurple/plugin.h b/libpurple/plugin.h
--- a/libpurple/plugin.h
+++ b/libpurple/plugin.h
@@ -446,7 +446,7 @@ const gchar *purple_plugin_get_homepage(
  * @param command    The name of the command.
  * @param func       The function to execute.
  * @param marshal    The marshalling function.
- * @param ret_type   The return type.
+ * @param ret_value  The return value type.
  * @param num_params The number of parameters.
  * @param ...        The parameter types.
  *
@@ -456,7 +456,7 @@ const gchar *purple_plugin_get_homepage(
 gboolean purple_plugin_ipc_register(PurplePlugin *plugin, const char *command,
 								  PurpleCallback func,
 								  PurpleSignalMarshalFunc marshal,
-								  GType ret_type, int num_params, ...);
+								  PurpleValue *ret_value, int num_params, ...);
 
 /**
  * Unregisters an IPC command in a plugin.
@@ -476,17 +476,17 @@ void purple_plugin_ipc_unregister_all(Pu
 /**
  * Returns a list of value types used for an IPC command.
  *
- * @param plugin      The plugin.
- * @param command     The name of the command.
- * @param ret_value   The returned return type.
- * @param num_params  The returned number of parameters.
- * @param param_types The returned list of parameter types.
+ * @param plugin     The plugin.
+ * @param command    The name of the command.
+ * @param ret_value  The returned return value.
+ * @param num_params The returned number of parameters.
+ * @param params     The returned list of parameters.
  *
  * @return TRUE if the command was found, or FALSE otherwise.
  */
 gboolean purple_plugin_ipc_get_params(PurplePlugin *plugin, const char *command,
-									GType *ret_value, int *num_params,
-									GType **param_types);
+									PurpleValue **ret_value, int *num_params,
+									PurpleValue ***params);
 
 /**
  * Executes an IPC command.
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,14 +158,25 @@ gboolean ml_is_api_dll(MonoImage *image)
 	return FALSE;
 }
 
-MonoObject* ml_object_from_purple_type(GType type, gpointer data)
+MonoObject* ml_object_from_purple_type(PurpleType type, gpointer data)
+{
+	return NULL;
+}
+
+MonoObject* ml_object_from_purple_subtype(PurpleSubType type, gpointer data)
 {
 	MonoObject *obj = NULL;
 
-	if (type == PURPLE_TYPE_BUDDY)
-		obj = purple_blist_build_buddy_object(data);
-	else if (type == PURPLE_TYPE_STATUS)
-		obj = purple_status_build_status_object(data);
+	switch (type) {
+		case PURPLE_SUBTYPE_BLIST_BUDDY:
+			obj = purple_blist_build_buddy_object(data);
+		break;
+		case PURPLE_SUBTYPE_STATUS:
+			obj = purple_status_build_status_object(data);
+		break;
+		default:
+		break;
+	}
 
 	return obj;
 }
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,7 +49,9 @@ void ml_set_domain(MonoDomain *d);
 
 void ml_init_internal_calls(void);
 
-MonoObject* ml_object_from_purple_type(GType type, gpointer data);
+MonoObject* ml_object_from_purple_type(PurpleType type, gpointer data);
+
+MonoObject* ml_object_from_purple_subtype(PurpleSubType type, gpointer data);
 
 MonoObject* ml_create_api_object(char *class_name);
 
diff --git a/libpurple/plugins/perl/perl-common.c b/libpurple/plugins/perl/perl-common.c
--- a/libpurple/plugins/perl/perl-common.c
+++ b/libpurple/plugins/perl/perl-common.c
@@ -1,9 +1,8 @@
+#include "debug.h"
+#include "value.h"
+
 #include "perl-common.h"
 
-#include "cipher.h"
-#include "debug.h"
-#include "savedstatuses.h"
-
 extern PerlInterpreter *my_perl;
 
 static GHashTable *object_stashes = NULL;
@@ -380,20 +379,20 @@ purple_perl_sv_from_value(const PurpleVa
 #endif
 
 void *
-purple_perl_data_from_sv(GType type, SV *sv)
+purple_perl_data_from_sv(PurpleValue *value, SV *sv)
 {
 
-	switch (type) {
-		case G_TYPE_BOOLEAN: return (void *)SvIV(sv);
-		case G_TYPE_INT:     return (void *)SvIV(sv);
-		case G_TYPE_UINT:    return (void *)SvUV(sv);
-		case G_TYPE_LONG:    return (void *)SvIV(sv);
-		case G_TYPE_ULONG:   return (void *)SvUV(sv);
-		case G_TYPE_INT64:   return (void *)SvIV(sv);
-		case G_TYPE_UINT64:  return (void *)SvUV(sv);
-		case G_TYPE_STRING:  return g_strdup(SvPVutf8_nolen(sv));
-		case G_TYPE_POINTER: return (void *)SvIV(sv);
-		case G_TYPE_BOXED:   return (void *)SvIV(sv);
+	switch (purple_value_get_type(value)) {
+		case PURPLE_TYPE_BOOLEAN: return (void *)SvIV(sv);
+		case PURPLE_TYPE_INT:     return (void *)SvIV(sv);
+		case PURPLE_TYPE_UINT:    return (void *)SvUV(sv);
+		case PURPLE_TYPE_LONG:    return (void *)SvIV(sv);
+		case PURPLE_TYPE_ULONG:   return (void *)SvUV(sv);
+		case PURPLE_TYPE_INT64:   return (void *)SvIV(sv);
+		case PURPLE_TYPE_UINT64:  return (void *)SvUV(sv);
+		case PURPLE_TYPE_STRING:  return g_strdup(SvPVutf8_nolen(sv));
+		case PURPLE_TYPE_POINTER: return (void *)SvIV(sv);
+		case PURPLE_TYPE_BOXED:   return (void *)SvIV(sv);
 
 		default:
 			return NULL;
@@ -403,54 +402,78 @@ purple_perl_data_from_sv(GType type, SV 
 }
 
 static SV *
-purple_perl_sv_from_purple_type(const GType type, void *arg)
+purple_perl_sv_from_subtype(const PurpleValue *value, void *arg)
 {
 	const char *stash = "Purple"; /* ? */
 
-	if (type == PURPLE_TYPE_ACCOUNT)
-		stash = "Purple::Account";
-	else if (type == PURPLE_TYPE_BUDDY_LIST)
-		stash = "Purple::BuddyList";
-	else if (type == PURPLE_TYPE_BUDDY)
-		stash = "Purple::BuddyList::Buddy";
-	else if (type == PURPLE_TYPE_GROUP)
-		stash = "Purple::BuddyList::Group";
-	else if (type == PURPLE_TYPE_CHAT)
-		stash = "Purple::BuddyList::Chat";
-	else if (type == PURPLE_TYPE_BUDDY_ICON)
-		stash = "Purple::Buddy::Icon";
-	else if (type == PURPLE_TYPE_CONNECTION)
-		stash = "Purple::Connection";
-	else if (type == PURPLE_TYPE_CONVERSATION)
-		stash = "Purple::Conversation";
-	else if (type == PURPLE_TYPE_PLUGIN)
-		stash = "Purple::Plugin";
-	else if (type == PURPLE_TYPE_BLIST_NODE)
-		stash = "Purple::BuddyList::Node";
-	else if (type == PURPLE_TYPE_CIPHER)
-		stash = "Purple::Cipher";
-	else if (type == PURPLE_TYPE_STATUS)
-		stash = "Purple::Status";
-	else if (type == PURPLE_TYPE_SAVEDSTATUS)
-		stash = "Purple::SavedStatus";
-	else if (type == PURPLE_TYPE_LOG)
-		stash = "Purple::Log";
-	else if (type == PURPLE_TYPE_XFER)
-		stash = "Purple::Xfer";
-	else if (type == PURPLE_TYPE_XMLNODE)
-		stash = "Purple::XMLNode";
-	else if (type == PURPLE_TYPE_NOTIFY_USER_INFO)
- 		stash = "Purple::NotifyUserInfo";
-	else if (type == PURPLE_TYPE_STORED_IMAGE)
- 		stash = "Purple::StoredImage";
-	else if (type == PURPLE_TYPE_CERTIFICATE_POOL)
- 		stash = "Purple::Certificate::Pool";
+	switch (purple_value_get_subtype(value)) {
+		case PURPLE_SUBTYPE_ACCOUNT:
+			stash = "Purple::Account";
+			break;
+		case PURPLE_SUBTYPE_BLIST:
+			stash = "Purple::BuddyList";
+			break;
+		case PURPLE_SUBTYPE_BLIST_BUDDY:
+			stash = "Purple::BuddyList::Buddy";
+			break;
+		case PURPLE_SUBTYPE_BLIST_GROUP:
+			stash = "Purple::BuddyList::Group";
+			break;
+		case PURPLE_SUBTYPE_BLIST_CHAT:
+			stash = "Purple::BuddyList::Chat";
+			break;
+		case PURPLE_SUBTYPE_BUDDY_ICON:
+			stash = "Purple::Buddy::Icon";
+			break;
+		case PURPLE_SUBTYPE_CONNECTION:
+			stash = "Purple::Connection";
+			break;
+		case PURPLE_SUBTYPE_CONVERSATION:
+			stash = "Purple::Conversation";
+			break;
+		case PURPLE_SUBTYPE_PLUGIN:
+			stash = "Purple::Plugin";
+			break;
+		case PURPLE_SUBTYPE_BLIST_NODE:
+			stash = "Purple::BuddyList::Node";
+			break;
+		case PURPLE_SUBTYPE_CIPHER:
+			stash = "Purple::Cipher";
+			break;
+		case PURPLE_SUBTYPE_STATUS:
+			stash = "Purple::Status";
+			break;
+		case PURPLE_SUBTYPE_SAVEDSTATUS:
+			stash = "Purple::SavedStatus";
+			break;
+		case PURPLE_SUBTYPE_LOG:
+			stash = "Purple::Log";
+			break;
+		case PURPLE_SUBTYPE_XFER:
+			stash = "Purple::Xfer";
+			break;
+		case PURPLE_SUBTYPE_XMLNODE:
+			stash = "Purple::XMLNode";
+			break;
+ 		case PURPLE_SUBTYPE_USERINFO:
+ 			stash = "Purple::NotifyUserInfo";
+ 			break;
+ 		case PURPLE_SUBTYPE_STORED_IMAGE:
+ 			stash = "Purple::StoredImage";
+ 			break;
+ 		case PURPLE_SUBTYPE_CERTIFICATEPOOL:
+ 			stash = "Purple::Certificate::Pool";
+ 			break;
+ 		case PURPLE_SUBTYPE_UNKNOWN:
+ 			stash = "Purple::Unknown";
+ 			break;
+  	}
 
 	return sv_2mortal(purple_perl_bless_object(arg, stash));
 }
 
 SV *
-purple_perl_sv_from_vargs(const GType type, va_list *args, void ***copy_arg)
+purple_perl_sv_from_vargs(const PurpleValue *value, va_list *args, void ***copy_arg)
 {
 	if (purple_value_is_outgoing(value)) {
 		switch (purple_value_get_type(value)) {
@@ -458,7 +481,7 @@ purple_perl_sv_from_vargs(const GType ty
 				if ((*copy_arg = va_arg(*args, void **)) == NULL)
 					return &PL_sv_undef;
 
-				return purple_perl_sv_from_purple_type(type, *(void **)*copy_arg);
+				return purple_perl_sv_from_subtype(value, *(void **)*copy_arg);
 
 			case PURPLE_TYPE_BOOLEAN:
 				if ((*copy_arg = (void *)va_arg(*args, gboolean *)) == NULL)
@@ -534,7 +557,7 @@ purple_perl_sv_from_vargs(const GType ty
 				if ((*copy_arg = va_arg(*args, void *)) == NULL)
 					return &PL_sv_undef;
 
-				return purple_perl_sv_from_purple_type(type, *copy_arg);
+				return purple_perl_sv_from_subtype(value, *copy_arg);
 
 			case PURPLE_TYPE_BOOLEAN:
 				*copy_arg = GINT_TO_POINTER( va_arg(*args, gboolean) );
diff --git a/libpurple/plugins/perl/perl-common.h b/libpurple/plugins/perl/perl-common.h
--- a/libpurple/plugins/perl/perl-common.h



More information about the Commits mailing list