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