annotate plugins/perl/perl-common.c @ 14077:034a3ffa09de

[gaim-migrate @ 16698] CID 218 Also a win32 compile fix. committer: Tailor Script <tailor@pidgin.im>
author Daniel Atallah <daniel.atallah@gmail.com>
date Fri, 11 Aug 2006 02:20:18 +0000
parents d0f7f698b6de
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6520
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
1 #include "debug.h"
6566
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
2 #include "value.h"
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
3
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
4 #include "perl-common.h"
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
5
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
6 extern PerlInterpreter *my_perl;
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
7
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
8 static GHashTable *object_stashes = NULL;
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
9
11170
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 8735
diff changeset
10 void gaim_perl_normalize_script_name(char *name)
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 8735
diff changeset
11 {
12871
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
12 char *c;
11170
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 8735
diff changeset
13
12871
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
14 c = strrchr(name, '.');
11170
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 8735
diff changeset
15
12871
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
16 if (c != NULL)
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
17 *c = '\0';
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
18
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
19 for (c = name; *c != '\0'; c++) {
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
20 if (*c != '_' && !g_ascii_isalnum(*c))
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
21 *c = '_';
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
22 }
11170
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 8735
diff changeset
23 }
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents: 8735
diff changeset
24
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
25 static int
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
26 magic_free_object(pTHX_ SV *sv, MAGIC *mg)
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
27 {
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
28 sv_setiv(sv, 0);
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
29
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
30 return 0;
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
31 }
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
32
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
33 static MGVTBL vtbl_free_object =
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
34 {
11318
519dc2186438 [gaim-migrate @ 13521]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11290
diff changeset
35 NULL, NULL, NULL, NULL, magic_free_object, NULL, NULL
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
36 };
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
37
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
38 static SV *
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
39 create_sv_ptr(void *object)
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
40 {
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
41 SV *sv;
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
42
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
43 sv = newSViv((IV)object);
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
44
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
45 sv_magic(sv, NULL, '~', NULL, 0);
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
46
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
47 SvMAGIC(sv)->mg_private = 0x1551; /* HF */
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
48 SvMAGIC(sv)->mg_virtual = &vtbl_free_object;
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
49
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
50 return sv;
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
51 }
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
52
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
53 SV *
6566
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
54 newSVGChar(const char *str)
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
55 {
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
56 SV *sv;
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
57
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
58 if (str == NULL)
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
59 return &PL_sv_undef;
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
60
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
61 sv = newSVpv(str, 0);
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
62 SvUTF8_on(sv);
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
63
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
64 return sv;
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
65 }
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
66
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
67 SV *
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
68 gaim_perl_bless_object(void *object, const char *stash_name)
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
69 {
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
70 HV *stash;
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
71 HV *hv;
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
72
8593
ba075b939aa6 [gaim-migrate @ 9344]
Christian Hammond <chipx86@chipx86.com>
parents: 7386
diff changeset
73 if (object == NULL)
ba075b939aa6 [gaim-migrate @ 9344]
Christian Hammond <chipx86@chipx86.com>
parents: 7386
diff changeset
74 return NULL;
ba075b939aa6 [gaim-migrate @ 9344]
Christian Hammond <chipx86@chipx86.com>
parents: 7386
diff changeset
75
12871
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
76 if (object_stashes == NULL) {
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
77 object_stashes = g_hash_table_new(g_direct_hash, g_direct_equal);
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
78 }
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
79
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
80 stash = gv_stashpv(stash_name, 1);
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
81
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
82 hv = newHV();
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
83 hv_store(hv, "_gaim", 5, create_sv_ptr(object), 0);
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
84
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
85 return sv_bless(newRV_noinc((SV *)hv), stash);
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
86 }
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
87
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
88 gboolean
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
89 gaim_perl_is_ref_object(SV *o)
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
90 {
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
91 SV **sv;
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
92 HV *hv;
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
93
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
94 hv = hvref(o);
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
95
12871
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
96 if (hv != NULL) {
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
97 sv = hv_fetch(hv, "_gaim", 5, 0);
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
98
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
99 if (sv != NULL)
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
100 return TRUE;
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
101 }
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
102
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
103 return FALSE;
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
104 }
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
105
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
106 void *
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
107 gaim_perl_ref_object(SV *o)
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
108 {
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
109 SV **sv;
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
110 HV *hv;
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
111 void *p;
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
112
8593
ba075b939aa6 [gaim-migrate @ 9344]
Christian Hammond <chipx86@chipx86.com>
parents: 7386
diff changeset
113 if (o == NULL)
ba075b939aa6 [gaim-migrate @ 9344]
Christian Hammond <chipx86@chipx86.com>
parents: 7386
diff changeset
114 return NULL;
ba075b939aa6 [gaim-migrate @ 9344]
Christian Hammond <chipx86@chipx86.com>
parents: 7386
diff changeset
115
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
116 hv = hvref(o);
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
117
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
118 if (hv == NULL)
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
119 return NULL;
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
120
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
121 sv = hv_fetch(hv, "_gaim", 5, 0);
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
122
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
123 if (sv == NULL)
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
124 croak("variable is damaged");
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
125
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
126 p = GINT_TO_POINTER(SvIV(*sv));
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
127
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
128 return p;
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
129 }
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
130
6520
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
131 /*
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
132 2003/02/06: execute_perl modified by Mark Doliner <mark@kingant.net>
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
133 Pass parameters by pushing them onto the stack rather than
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
134 passing an array of strings. This way, perl scripts can
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
135 modify the parameters and we can get the changed values
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
136 and then shoot ourselves. I mean, uh, use them.
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
137
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
138 2001/06/14: execute_perl replaced by Martin Persson <mep@passagen.se>
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
139 previous use of perl_eval leaked memory, replaced with
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
140 a version that uses perl_call instead
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
141
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
142 30/11/2002: execute_perl modified by Eric Timme <timothy@voidnet.com>
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
143 args changed to char** so that we can have preparsed
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
144 arguments again, and many headaches ensued! This essentially
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
145 means we replaced one hacked method with a messier hacked
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
146 method out of perceived necessity. Formerly execute_perl
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
147 required a single char_ptr, and it would insert it into an
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
148 array of character pointers and NULL terminate the new array.
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
149 Now we have to pass in pre-terminated character pointer arrays
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
150 to accomodate functions that want to pass in multiple arguments.
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
151
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
152 Previously arguments were preparsed because an argument list
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
153 was constructed in the form 'arg one','arg two' and was
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
154 executed via a call like &funcname(arglist) (see .59.x), so
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
155 the arglist was magically pre-parsed because of the method.
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
156 With Martin Persson's change to perl_call we now need to
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
157 use a null terminated list of character pointers for arguments
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
158 if we wish them to be parsed. Lacking a better way to allow
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
159 for both single arguments and many I created a NULL terminated
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
160 array in every function that called execute_perl and passed
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
161 that list into the function. In the former version a single
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
162 character pointer was passed in, and was placed into an array
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
163 of character pointers with two elements, with a NULL element
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
164 tacked onto the back, but this method no longer seemed prudent.
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
165
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
166 Enhancements in the future might be to get rid of pre-declaring
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
167 the array sizes? I am not comfortable enough with this
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
168 subject to attempt it myself and hope it to stand the test
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
169 of time.
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
170 */
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
171 int
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
172 execute_perl(const char *function, int argc, char **args)
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
173 {
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
174 int count = 0, i, ret_value = 1;
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
175 SV *sv_args[argc];
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
176 STRLEN na;
11318
519dc2186438 [gaim-migrate @ 13521]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11290
diff changeset
177 dSP;
519dc2186438 [gaim-migrate @ 13521]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11290
diff changeset
178 PERL_SET_CONTEXT(my_perl);
6520
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
179 /*
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
180 * Set up the perl environment, push arguments onto the
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
181 * perl stack, then call the given function
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
182 */
11318
519dc2186438 [gaim-migrate @ 13521]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11290
diff changeset
183 SPAGAIN;
6520
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
184 ENTER;
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
185 SAVETMPS;
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
186 PUSHMARK(sp);
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
187
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
188 for (i = 0; i < argc; i++) {
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
189 if (args[i]) {
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
190 sv_args[i] = sv_2mortal(newSVpv(args[i], 0));
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
191 XPUSHs(sv_args[i]);
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
192 }
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
193 }
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
194
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
195 PUTBACK;
12871
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
196 PERL_SET_CONTEXT(my_perl);
6520
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
197 count = call_pv(function, G_EVAL | G_SCALAR);
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
198 SPAGAIN;
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
199
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
200 /*
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
201 * Check for "die," make sure we have 1 argument, and set our
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
202 * return value.
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
203 */
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
204 if (SvTRUE(ERRSV)) {
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
205 gaim_debug(GAIM_DEBUG_ERROR, "perl",
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
206 "Perl function %s exited abnormally: %s\n",
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
207 function, SvPV(ERRSV, na));
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
208 POPs;
12871
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
209 } else if (count != 1) {
6520
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
210 /*
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
211 * This should NEVER happen. G_SCALAR ensures that we WILL
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
212 * have 1 parameter.
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
213 */
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
214 gaim_debug(GAIM_DEBUG_ERROR, "perl",
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
215 "Perl error from %s: expected 1 return value, "
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
216 "but got %d\n", function, count);
12871
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
217 } else
6520
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
218 ret_value = POPi;
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
219
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
220 /* Check for changed arguments */
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
221 for (i = 0; i < argc; i++) {
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
222 if (args[i] && strcmp(args[i], SvPVX(sv_args[i]))) {
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
223 /*
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
224 * Shizzel. So the perl script changed one of the parameters,
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
225 * and we want this change to affect the original parameters.
8735
92cbf9713795 [gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents: 8593
diff changeset
226 * args[i] is just a temporary little list of pointers. We don't
6520
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
227 * want to free args[i] here because the new parameter doesn't
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
228 * overwrite the data that args[i] points to. That is done by
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
229 * the function that called execute_perl. I'm not explaining this
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
230 * very well. See, it's aggregate... Oh, but if 2 perl scripts
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
231 * both modify the data, _that's_ a memleak. This is really kind
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
232 * of hackish. I should fix it. Look how long this comment is.
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
233 * Holy crap.
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
234 */
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
235 args[i] = g_strdup(SvPV(sv_args[i], na));
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
236 }
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
237 }
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
238
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
239 PUTBACK;
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
240 FREETMPS;
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
241 LEAVE;
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
242
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
243 return ret_value;
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
244 }
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
245
6566
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
246 #if 0
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
247 gboolean
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
248 gaim_perl_value_from_sv(GaimValue *value, SV *sv)
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
249 {
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
250 switch (gaim_value_get_type(value))
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
251 {
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
252 case GAIM_TYPE_CHAR:
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
253 if ((tmp = SvGChar(sv)) != NULL)
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
254 gaim_value_set_char(value, tmp[0]);
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
255 else
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
256 return FALSE;
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
257 break;
6520
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
258
6566
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
259 case GAIM_TYPE_UCHAR:
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
260 if ((tmp = SvPV_nolen(sv)) != NULL)
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
261 gaim_value_set_uchar(value, tmp[0]);
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
262 else
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
263 return FALSE;
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
264 break;
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
265
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
266 case GAIM_TYPE_BOOLEAN:
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
267 gaim_value_set_boolean(value, SvTRUE(sv));
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
268 break;
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
269
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
270 case GAIM_TYPE_INT:
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
271 gaim_value_set_int(value, SvIV(sv));
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
272 break;
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
273
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
274 case GAIM_TYPE_UINT:
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
275 gaim_value_set_uint(value, SvIV(sv));
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
276 break;
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
277
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
278 case GAIM_TYPE_LONG:
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
279 gaim_value_set_long(value, SvIV(sv));
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
280 break;
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
281
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
282 case GAIM_TYPE_ULONG:
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
283 gaim_value_set_ulong(value, SvIV(sv));
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
284 break;
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
285
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
286 case GAIM_TYPE_INT64:
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
287 gaim_value_set_int64(value, SvIV(sv));
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
288 break;
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
289
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
290 case GAIM_TYPE_UINT64:
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
291 gaim_value_set_uint64(value, SvIV(sv));
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
292 break;
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
293
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
294 case GAIM_TYPE_STRING:
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
295 gaim_value_set_string(value, SvGChar(sv));
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
296 break;
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
297
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
298 case GAIM_TYPE_POINTER:
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
299 gaim_value_set_pointer(value, (void *)SvIV(sv));
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
300 break;
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
301
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
302 case GAIM_TYPE_BOXED:
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
303 if (!strcmp(gaim_value_get_specific_type(value), "SV"))
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
304 gaim_value_set_boxed(value, (sv == &PL_sv_undef ? NULL : sv));
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
305 else
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
306 gaim_value_set_boxed(value, sv);
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
307 break;
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
308
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
309 default:
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
310 return FALSE;
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
311 }
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
312
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
313 return TRUE;
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
314 }
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
315
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
316 SV *
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
317 gaim_perl_sv_from_value(const GaimValue *value, va_list list)
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
318 {
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
319 switch (gaim_value_get_type(value))
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
320 {
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
321 case GAIM_TYPE_BOOLEAN:
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
322 return newSViv(gaim_value_get_boolean(value));
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
323 break;
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
324
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
325 case GAIM_TYPE_INT:
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
326 return newSViv(gaim_value_get_int(value));
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
327 break;
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
328
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
329 case GAIM_TYPE_UINT:
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
330 return newSVuv(gaim_value_get_uint(value));
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
331 break;
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
332
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
333 case GAIM_TYPE_LONG:
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
334 return newSViv(gaim_value_get_long(value));
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
335 break;
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
336
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
337 case GAIM_TYPE_ULONG:
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
338 return newSVuv(gaim_value_get_ulong(value));
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
339 break;
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
340
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
341 case GAIM_TYPE_INT64:
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
342 return newSViv(gaim_value_get_int64(value));
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
343 break;
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
344
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
345 case GAIM_TYPE_UINT64:
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
346 return newSVuv(gaim_value_get_int64(value));
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
347 break;
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
348
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
349 case GAIM_TYPE_STRING:
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
350 return newSVGChar(gaim_value_get_string(value));
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
351 break;
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
352
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
353 case GAIM_TYPE_POINTER:
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
354 return newSViv((IV)gaim_value_get_pointer(value));
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
355 break;
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
356
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
357 case GAIM_TYPE_BOXED:
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
358 if (!strcmp(gaim_value_get_specific_type(value), "SV"))
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
359 {
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
360 SV *sv = (SV *)gaim_perl_get_boxed(value);
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
361
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
362 return (sv == NULL ? &PL_sv_undef : sv);
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
363 }
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
364
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
365 /* Uh.. I dunno. Try this? */
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
366 return sv_2mortal(gaim_perl_bless_object(
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
367 gaim_perl_get_boxed(value),
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
368 gaim_value_get_specific_type(value)));
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
369
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
370 default:
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
371 return FALSE;
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
372 }
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
373
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
374 return TRUE;
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
375 }
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
376 #endif
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
377
6920
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
378 void *
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
379 gaim_perl_data_from_sv(GaimValue *value, SV *sv)
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
380 {
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
381 STRLEN na;
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
382
12871
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
383 switch (gaim_value_get_type(value)) {
6920
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
384 case GAIM_TYPE_BOOLEAN: return (void *)SvIV(sv);
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
385 case GAIM_TYPE_INT: return (void *)SvIV(sv);
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
386 case GAIM_TYPE_UINT: return (void *)SvUV(sv);
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
387 case GAIM_TYPE_LONG: return (void *)SvIV(sv);
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
388 case GAIM_TYPE_ULONG: return (void *)SvUV(sv);
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
389 case GAIM_TYPE_INT64: return (void *)SvIV(sv);
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
390 case GAIM_TYPE_UINT64: return (void *)SvUV(sv);
6921
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
391 case GAIM_TYPE_STRING: return g_strdup((void *)SvPV(sv, na));
6920
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
392 case GAIM_TYPE_POINTER: return (void *)SvIV(sv);
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
393 case GAIM_TYPE_BOXED: return (void *)SvIV(sv);
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
394
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
395 default:
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
396 return NULL;
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
397 }
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
398
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
399 return NULL;
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
400 }
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
401
6566
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
402 static SV *
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
403 gaim_perl_sv_from_subtype(const GaimValue *value, void *arg)
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
404 {
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
405 const char *stash = NULL;
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
406
12871
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
407 switch (gaim_value_get_subtype(value)) {
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
408 case GAIM_SUBTYPE_ACCOUNT:
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
409 stash = "Gaim::Account";
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
410 break;
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
411 case GAIM_SUBTYPE_BLIST:
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
412 stash = "Gaim::BuddyList";
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
413 break;
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
414 case GAIM_SUBTYPE_BLIST_BUDDY:
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
415 stash = "Gaim::BuddyList::Buddy";
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
416 break;
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
417 case GAIM_SUBTYPE_BLIST_GROUP:
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
418 stash = "Gaim::BuddyList::Group";
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
419 break;
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
420 case GAIM_SUBTYPE_BLIST_CHAT:
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
421 stash = "Gaim::BuddyList::Chat";
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
422 break;
12891
a58540b16f41 [gaim-migrate @ 15244]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12871
diff changeset
423 case GAIM_SUBTYPE_BUDDY_ICON:
a58540b16f41 [gaim-migrate @ 15244]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12871
diff changeset
424 stash = "Gaim::Buddy::Icon";
a58540b16f41 [gaim-migrate @ 15244]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12871
diff changeset
425 break;
12871
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
426 case GAIM_SUBTYPE_CONNECTION:
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
427 stash = "Gaim::Connection";
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
428 break;
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
429 case GAIM_SUBTYPE_CONVERSATION:
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
430 stash = "Gaim::Conversation";
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
431 break;
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
432 case GAIM_SUBTYPE_PLUGIN:
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
433 stash = "Gaim::Plugin";
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
434 break;
12891
a58540b16f41 [gaim-migrate @ 15244]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12871
diff changeset
435 case GAIM_SUBTYPE_BLIST_NODE:
12893
31e3c4f78aa4 [gaim-migrate @ 15246]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12891
diff changeset
436 stash = "Gaim::BuddyList::Node";
12891
a58540b16f41 [gaim-migrate @ 15244]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12871
diff changeset
437 break;
a58540b16f41 [gaim-migrate @ 15244]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12871
diff changeset
438 case GAIM_SUBTYPE_CIPHER:
a58540b16f41 [gaim-migrate @ 15244]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12871
diff changeset
439 stash = "Gaim::Cipher";
a58540b16f41 [gaim-migrate @ 15244]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12871
diff changeset
440 break;
a58540b16f41 [gaim-migrate @ 15244]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12871
diff changeset
441 case GAIM_SUBTYPE_STATUS:
a58540b16f41 [gaim-migrate @ 15244]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12871
diff changeset
442 stash = "Gaim::Status";
a58540b16f41 [gaim-migrate @ 15244]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12871
diff changeset
443 break;
a58540b16f41 [gaim-migrate @ 15244]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12871
diff changeset
444 case GAIM_SUBTYPE_LOG:
a58540b16f41 [gaim-migrate @ 15244]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12871
diff changeset
445 stash = "Gaim::Log";
a58540b16f41 [gaim-migrate @ 15244]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12871
diff changeset
446 break;
13219
d0f7f698b6de [gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents: 12893
diff changeset
447 case GAIM_SUBTYPE_XFER:
d0f7f698b6de [gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents: 12893
diff changeset
448 stash = "Gaim::Xfer";
d0f7f698b6de [gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents: 12893
diff changeset
449 break;
6566
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
450
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
451 default:
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
452 stash = "Gaim"; /* ? */
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
453 }
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
454
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
455 return sv_2mortal(gaim_perl_bless_object(arg, stash));
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
456 }
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
457
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
458 SV *
12871
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
459 gaim_perl_sv_from_vargs(const GaimValue *value, va_list *args, void ***copy_arg)
6566
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
460 {
12871
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
461 if (gaim_value_is_outgoing(value)) {
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
462 switch (gaim_value_get_type(value)) {
6898
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
463 case GAIM_TYPE_SUBTYPE:
6920
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
464 if ((*copy_arg = va_arg(*args, void **)) == NULL)
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
465 return &PL_sv_undef;
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
466
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
467 return gaim_perl_sv_from_subtype(value, *(void **)*copy_arg);
6898
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
468
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
469 case GAIM_TYPE_BOOLEAN:
6921
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
470 if ((*copy_arg = (void *)va_arg(*args, gboolean *)) == NULL)
6920
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
471 return &PL_sv_undef;
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
472
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
473 return newSViv(*(gboolean *)*copy_arg);
6566
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
474
6898
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
475 case GAIM_TYPE_INT:
6921
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
476 if ((*copy_arg = (void *)va_arg(*args, int *)) == NULL)
6920
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
477 return &PL_sv_undef;
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
478
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
479 return newSViv(*(int *)*copy_arg);
6898
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
480
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
481 case GAIM_TYPE_UINT:
6921
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
482 if ((*copy_arg = (void *)va_arg(*args, unsigned int *)) == NULL)
6920
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
483 return &PL_sv_undef;
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
484
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
485 return newSVuv(*(unsigned int *)*copy_arg);
6898
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
486
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
487 case GAIM_TYPE_LONG:
6921
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
488 if ((*copy_arg = (void *)va_arg(*args, long *)) == NULL)
6920
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
489 return &PL_sv_undef;
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
490
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
491 return newSViv(*(long *)*copy_arg);
6566
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
492
6898
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
493 case GAIM_TYPE_ULONG:
6921
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
494 if ((*copy_arg = (void *)va_arg(*args,
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
495 unsigned long *)) == NULL)
6920
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
496 return &PL_sv_undef;
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
497
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
498 return newSVuv(*(unsigned long *)*copy_arg);
6566
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
499
6898
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
500 case GAIM_TYPE_INT64:
6921
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
501 if ((*copy_arg = (void *)va_arg(*args, gint64 *)) == NULL)
6920
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
502 return &PL_sv_undef;
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
503
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
504 return newSViv(*(gint64 *)*copy_arg);
6898
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
505
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
506 case GAIM_TYPE_UINT64:
6921
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
507 if ((*copy_arg = (void *)va_arg(*args, guint64 *)) == NULL)
6920
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
508 return &PL_sv_undef;
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
509
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
510 return newSVuv(*(guint64 *)*copy_arg);
6566
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
511
6898
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
512 case GAIM_TYPE_STRING:
6921
11d05ddf30a3 [gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents: 6920
diff changeset
513 if ((*copy_arg = (void *)va_arg(*args, char **)) == NULL)
6920
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
514 return &PL_sv_undef;
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
515
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
516 return newSVGChar(*(char **)*copy_arg);
6898
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
517
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
518 case GAIM_TYPE_POINTER:
6920
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
519 if ((*copy_arg = va_arg(*args, void **)) == NULL)
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
520 return &PL_sv_undef;
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
521
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
522 return newSViv((IV)*(void **)*copy_arg);
6566
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
523
6898
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
524 case GAIM_TYPE_BOXED:
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
525 /* Uh.. I dunno. Try this? */
6920
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
526 if ((*copy_arg = va_arg(*args, void **)) == NULL)
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
527 return &PL_sv_undef;
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
528
6898
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
529 return sv_2mortal(gaim_perl_bless_object(
6920
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
530 *(void **)*copy_arg,
6898
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
531 gaim_value_get_specific_type(value)));
6566
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
532
6898
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
533 default:
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
534 /* If this happens, things are going to get screwed up... */
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
535 return NULL;
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
536 }
12871
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
537 } else {
2422097a7a5e [gaim-migrate @ 15223]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12837
diff changeset
538 switch (gaim_value_get_type(value)) {
6898
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
539 case GAIM_TYPE_SUBTYPE:
6920
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
540 if ((*copy_arg = va_arg(*args, void *)) == NULL)
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
541 return &PL_sv_undef;
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
542
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
543 return gaim_perl_sv_from_subtype(value, *copy_arg);
6566
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
544
6898
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
545 case GAIM_TYPE_BOOLEAN:
7386
414c701ef1ff [gaim-migrate @ 7981]
Luke Schierer <lschiere@pidgin.im>
parents: 7240
diff changeset
546 *copy_arg = GINT_TO_POINTER( va_arg(*args, gboolean) );
6920
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
547
7386
414c701ef1ff [gaim-migrate @ 7981]
Luke Schierer <lschiere@pidgin.im>
parents: 7240
diff changeset
548 return newSViv((gboolean)GPOINTER_TO_INT(*copy_arg));
6898
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
549
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
550 case GAIM_TYPE_INT:
7386
414c701ef1ff [gaim-migrate @ 7981]
Luke Schierer <lschiere@pidgin.im>
parents: 7240
diff changeset
551 *copy_arg = GINT_TO_POINTER( va_arg(*args, int) );
6920
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
552
7386
414c701ef1ff [gaim-migrate @ 7981]
Luke Schierer <lschiere@pidgin.im>
parents: 7240
diff changeset
553 return newSViv(GPOINTER_TO_INT(*copy_arg));
6566
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
554
6898
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
555 case GAIM_TYPE_UINT:
7386
414c701ef1ff [gaim-migrate @ 7981]
Luke Schierer <lschiere@pidgin.im>
parents: 7240
diff changeset
556 *copy_arg = GUINT_TO_POINTER(va_arg(*args, unsigned int));
6920
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
557
7386
414c701ef1ff [gaim-migrate @ 7981]
Luke Schierer <lschiere@pidgin.im>
parents: 7240
diff changeset
558 return newSVuv(GPOINTER_TO_UINT(*copy_arg));
6898
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
559
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
560 case GAIM_TYPE_LONG:
6920
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
561 *copy_arg = (void *)va_arg(*args, long);
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
562
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
563 return newSViv((long)*copy_arg);
6566
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
564
6898
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
565 case GAIM_TYPE_ULONG:
6920
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
566 *copy_arg = (void *)va_arg(*args, unsigned long);
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
567
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
568 return newSVuv((unsigned long)*copy_arg);
6898
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
569
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
570 case GAIM_TYPE_INT64:
6920
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
571 #if 0
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
572 /* XXX This yells and complains. */
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
573 *copy_arg = va_arg(*args, gint64);
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
574
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
575 return newSViv(*copy_arg);
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
576 #endif
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
577 break;
6898
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
578
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
579 case GAIM_TYPE_UINT64:
6920
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
580 /* XXX This also yells and complains. */
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
581 #if 0
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
582 *copy_arg = (void *)va_arg(*args, guint64);
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
583
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
584 return newSVuv(*copy_arg);
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
585 #endif
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
586 break;
6898
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
587
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
588 case GAIM_TYPE_STRING:
6920
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
589 if ((*copy_arg = (void *)va_arg(*args, char *)) == NULL)
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
590 return &PL_sv_undef;
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
591
7240
d3a7ff6a91bb [gaim-migrate @ 7815]
Christian Hammond <chipx86@chipx86.com>
parents: 7239
diff changeset
592 return newSVGChar((char *)*copy_arg);
6566
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
593
6898
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
594 case GAIM_TYPE_POINTER:
6920
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
595 if ((*copy_arg = (void *)va_arg(*args, void *)) == NULL)
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
596 return &PL_sv_undef;
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
597
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
598 return newSViv((IV)*copy_arg);
6566
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
599
6898
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
600 case GAIM_TYPE_BOXED:
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
601 /* Uh.. I dunno. Try this? */
6920
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
602 if ((*copy_arg = (void *)va_arg(*args, void *)) == NULL)
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
603 return &PL_sv_undef;
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
604
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
605 return sv_2mortal(gaim_perl_bless_object(*copy_arg,
6898
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
606 gaim_value_get_specific_type(value)));
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
607
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
608 default:
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
609 /* If this happens, things are going to get screwed up... */
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
610 return NULL;
806f6e950e76 [gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents: 6897
diff changeset
611 }
6566
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
612 }
6920
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
613
13f78c350cd3 [gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents: 6898
diff changeset
614 return NULL;
6566
f6c2a7b5afa7 [gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
615 }