/soc/2013/ankitkv/gobjectification: 98c540811600: A bit of refac...
Ankit Vani
a at nevitus.org
Sun Jul 14 17:24:30 EDT 2013
Changeset: 98c540811600418e58064d42946c779efcfaa29f
Author: Ankit Vani <a at nevitus.org>
Date: 2013-07-15 02:54 +0530
Branch: soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/98c540811600
Description:
A bit of refactoring to eliminate the use of PurpleValue
diffstat:
libpurple/plugins/mono/loader/mono-helper.c | 22 +++----------
libpurple/plugins/perl/perl-common.c | 47 +++++++++++++++-------------
libpurple/signals.c | 4 +-
3 files changed, 32 insertions(+), 41 deletions(-)
diffs (145 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
@@ -14,7 +14,6 @@
#include <string.h>
#include "mono-helper.h"
#include "mono-glue.h"
-#include "value.h"
#include "debug.h"
static gboolean _runtime_active = FALSE;
@@ -159,25 +158,14 @@ 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:
- obj = purple_blist_build_buddy_object(data);
- break;
- case PURPLE_SUBTYPE_STATUS:
- obj = purple_status_build_status_object(data);
- break;
- default:
- break;
- }
+ 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);
return obj;
}
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,5 +1,4 @@
#include "debug.h"
-#include "value.h"
#include "perl-common.h"
@@ -379,30 +378,34 @@ purple_perl_sv_from_value(const PurpleVa
#endif
void *
-purple_perl_data_from_sv(PurpleValue *value, SV *sv)
+purple_perl_data_from_sv(GType type, SV *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;
- }
+ 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);
return NULL;
}
static SV *
-purple_perl_sv_from_subtype(const PurpleValue *value, void *arg)
+purple_perl_sv_from_purple_type(const GType type, void *arg)
{
const char *stash = "Purple"; /* ? */
@@ -473,7 +476,7 @@ purple_perl_sv_from_subtype(const Purple
}
SV *
-purple_perl_sv_from_vargs(const PurpleValue *value, va_list *args, void ***copy_arg)
+purple_perl_sv_from_vargs(const GType type, va_list *args, void ***copy_arg)
{
if (purple_value_is_outgoing(value)) {
switch (purple_value_get_type(value)) {
@@ -481,7 +484,7 @@ purple_perl_sv_from_vargs(const PurpleVa
if ((*copy_arg = va_arg(*args, void **)) == NULL)
return &PL_sv_undef;
- return purple_perl_sv_from_subtype(value, *(void **)*copy_arg);
+ return purple_perl_sv_from_purple_type(type, *(void **)*copy_arg);
case PURPLE_TYPE_BOOLEAN:
if ((*copy_arg = (void *)va_arg(*args, gboolean *)) == NULL)
@@ -557,7 +560,7 @@ purple_perl_sv_from_vargs(const PurpleVa
if ((*copy_arg = va_arg(*args, void *)) == NULL)
return &PL_sv_undef;
- return purple_perl_sv_from_subtype(value, *copy_arg);
+ return purple_perl_sv_from_purple_type(type, *copy_arg);
case PURPLE_TYPE_BOOLEAN:
*copy_arg = GINT_TO_POINTER( va_arg(*args, gboolean) );
diff --git a/libpurple/signals.c b/libpurple/signals.c
--- a/libpurple/signals.c
+++ b/libpurple/signals.c
@@ -51,8 +51,8 @@ typedef struct
PurpleSignalMarshalFunc marshal;
int num_values;
- PurpleValue **values;
- PurpleValue *ret_value;
+ GType *value_types;
+ GType ret_type;
GList *handlers;
size_t handler_count;
More information about the Commits
mailing list