/soc/2013/ankitkv/gobjectification: d0eafa17c727: More work on p...

Ankit Vani a at nevitus.org
Mon Jul 15 10:15:42 EDT 2013


Changeset: d0eafa17c7273e0d5b1ee26af9985c4f5bed89e0
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-07-15 19:45 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/d0eafa17c727

Description:

More work on perl plugins to use GValues instead of PurpleValues

diffstat:

 libpurple/plugins/perl/perl-common.c |  136 +++++++++++++---------------------
 1 files changed, 54 insertions(+), 82 deletions(-)

diffs (153 lines):

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
@@ -380,26 +380,22 @@ purple_perl_sv_from_value(const PurpleVa
 void *
 purple_perl_data_from_sv(GType type, SV *sv)
 {
-	if (type == G_TYPE_BOOLEAN)
-		return (void *)SvIV(sv);
-	else if (type == G_TYPE_INT)
-		return (void *)SvIV(sv);
-	else if (type == G_TYPE_UINT)
-		return (void *)SvUV(sv);
-	else if (type == G_TYPE_LONG)
-		return (void *)SvIV(sv);
-	else if (type == G_TYPE_ULONG)
-		return (void *)SvUV(sv);
-	else if (type == G_TYPE_INT64)
-		return (void *)SvIV(sv);
-	else if (type == G_TYPE_UINT64)
-		return (void *)SvUV(sv);
-	else if (type == G_TYPE_STRING)
-		return g_strdup(SvPVutf8_nolen(sv));
-	else if (type == G_TYPE_POINTER)
-		return (void *)SvIV(sv);
-	else if (type == G_TYPE_BOXED)
-		return (void *)SvIV(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);
+
+		default:
+			return NULL;
+	}
 
 	return NULL;
 }
@@ -409,68 +405,44 @@ purple_perl_sv_from_purple_type(const GT
 {
 	const char *stash = "Purple"; /* ? */
 
-	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;
-  	}
+	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) /* TODO */
+		stash = "Purple::Status";
+	else if (type == PURPLE_TYPE_SAVEDSTATUS) /* TODO */
+		stash = "Purple::SavedStatus";
+	else if (type == PURPLE_TYPE_LOG) /* TODO */
+		stash = "Purple::Log";
+	else if (type == PURPLE_TYPE_XFER) /* TODO */
+		stash = "Purple::Xfer";
+	else if (type == PURPLE_TYPE_XMLNODE) /* TODO */
+		stash = "Purple::XMLNode";
+	else if (type == PURPLE_TYPE_USERINFO) /* TODO */
+ 		stash = "Purple::NotifyUserInfo";
+	else if (type == PURPLE_TYPE_STORED_IMAGE) /* TODO */
+ 		stash = "Purple::StoredImage";
+	else if (type == PURPLE_TYPE_CERTIFICATEPOOL) /* TODO */
+ 		stash = "Purple::Certificate::Pool";
 
 	return sv_2mortal(purple_perl_bless_object(arg, stash));
 }



More information about the Commits mailing list