Tue, 16 Jul 2013 01:45:39 +0530
Added boxed types for PurpleStatus and PurpleSavedStatus
|
6520
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
1 | #include "debug.h" |
| 6508 | 2 | |
| 3 | #include "perl-common.h" | |
| 4 | ||
| 5 | extern PerlInterpreter *my_perl; | |
| 6 | ||
| 7 | static GHashTable *object_stashes = NULL; | |
| 8 | ||
| 15884 | 9 | void purple_perl_normalize_script_name(char *name) |
| 11170 | 10 | { |
| 12871 | 11 | char *c; |
| 11170 | 12 | |
| 12871 | 13 | c = strrchr(name, '.'); |
| 11170 | 14 | |
| 12871 | 15 | if (c != NULL) |
| 16 | *c = '\0'; | |
| 17 | ||
| 18 | for (c = name; *c != '\0'; c++) { | |
| 19 | if (*c != '_' && !g_ascii_isalnum(*c)) | |
| 20 | *c = '_'; | |
| 21 | } | |
| 11170 | 22 | } |
| 23 | ||
| 6508 | 24 | static int |
| 25 | magic_free_object(pTHX_ SV *sv, MAGIC *mg) | |
| 26 | { | |
| 27 | sv_setiv(sv, 0); | |
| 28 | ||
| 29 | return 0; | |
| 30 | } | |
| 31 | ||
| 32 | static MGVTBL vtbl_free_object = | |
| 33 | { | |
|
23915
b62601fd6e7d
Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents:
22839
diff
changeset
|
34 | 0, 0, 0, 0, magic_free_object, 0, 0 |
|
b62601fd6e7d
Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents:
22839
diff
changeset
|
35 | #if PERL_API_REVISION > 5 || (PERL_API_REVISION == 5 && PERL_API_VERSION >= 10) |
|
b62601fd6e7d
Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents:
22839
diff
changeset
|
36 | , 0 |
|
b62601fd6e7d
Update the Perl plugin loader to work with Perl 5.10.
Daniel Atallah <datallah@pidgin.im>
parents:
22839
diff
changeset
|
37 | #endif |
| 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
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
56 | newSVGChar(const char *str) |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
57 | { |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
58 | SV *sv; |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
59 | |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
60 | if (str == NULL) |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
61 | return &PL_sv_undef; |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
62 | |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
63 | sv = newSVpv(str, 0); |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
64 | SvUTF8_on(sv); |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
65 | |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
66 | return sv; |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
67 | } |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
68 | |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
69 | SV * |
| 15884 | 70 | purple_perl_bless_object(void *object, const char *stash_name) |
| 6508 | 71 | { |
| 72 | HV *stash; | |
| 73 | HV *hv; | |
| 74 | ||
|
8593
ad96ca5bde01
[gaim-migrate @ 9344]
Christian Hammond <chipx86@chipx86.com>
parents:
7386
diff
changeset
|
75 | if (object == NULL) |
|
ad96ca5bde01
[gaim-migrate @ 9344]
Christian Hammond <chipx86@chipx86.com>
parents:
7386
diff
changeset
|
76 | return NULL; |
|
ad96ca5bde01
[gaim-migrate @ 9344]
Christian Hammond <chipx86@chipx86.com>
parents:
7386
diff
changeset
|
77 | |
| 12871 | 78 | if (object_stashes == NULL) { |
| 6508 | 79 | object_stashes = g_hash_table_new(g_direct_hash, g_direct_equal); |
| 80 | } | |
| 81 | ||
| 82 | stash = gv_stashpv(stash_name, 1); | |
| 83 | ||
| 84 | hv = newHV(); | |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
29341
diff
changeset
|
85 | if (hv_store(hv, "_purple", 7, create_sv_ptr(object), 0) == NULL) |
|
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
29341
diff
changeset
|
86 | purple_debug_error("perl", "hv_store failed\n"); |
| 6508 | 87 | |
| 88 | return sv_bless(newRV_noinc((SV *)hv), stash); | |
| 89 | } | |
| 90 | ||
| 91 | gboolean | |
| 15884 | 92 | purple_perl_is_ref_object(SV *o) |
| 6508 | 93 | { |
| 94 | SV **sv; | |
| 95 | HV *hv; | |
| 96 | ||
| 97 | hv = hvref(o); | |
| 98 | ||
| 12871 | 99 | if (hv != NULL) { |
|
17208
30553e3612f8
Update some perl magic numbers, like in the tcl code. This doesn't actually do
Etan Reisner <deryni@pidgin.im>
parents:
15884
diff
changeset
|
100 | sv = hv_fetch(hv, "_purple", 7, 0); |
| 6508 | 101 | |
| 102 | if (sv != NULL) | |
| 103 | return TRUE; | |
| 104 | } | |
| 105 | ||
| 106 | return FALSE; | |
| 107 | } | |
| 108 | ||
| 109 | void * | |
| 15884 | 110 | purple_perl_ref_object(SV *o) |
| 6508 | 111 | { |
| 112 | SV **sv; | |
| 113 | HV *hv; | |
| 114 | void *p; | |
| 115 | ||
|
8593
ad96ca5bde01
[gaim-migrate @ 9344]
Christian Hammond <chipx86@chipx86.com>
parents:
7386
diff
changeset
|
116 | if (o == NULL) |
|
ad96ca5bde01
[gaim-migrate @ 9344]
Christian Hammond <chipx86@chipx86.com>
parents:
7386
diff
changeset
|
117 | return NULL; |
|
ad96ca5bde01
[gaim-migrate @ 9344]
Christian Hammond <chipx86@chipx86.com>
parents:
7386
diff
changeset
|
118 | |
| 6508 | 119 | hv = hvref(o); |
| 120 | ||
| 121 | if (hv == NULL) | |
| 122 | return NULL; | |
| 123 | ||
|
17208
30553e3612f8
Update some perl magic numbers, like in the tcl code. This doesn't actually do
Etan Reisner <deryni@pidgin.im>
parents:
15884
diff
changeset
|
124 | sv = hv_fetch(hv, "_purple", 7, 0); |
| 6508 | 125 | |
| 126 | if (sv == NULL) | |
| 127 | croak("variable is damaged"); | |
| 128 | ||
| 129 | p = GINT_TO_POINTER(SvIV(*sv)); | |
| 130 | ||
| 131 | return p; | |
| 132 | } | |
| 133 | ||
|
6520
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
134 | /* |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
135 | 2003/02/06: execute_perl modified by Mark Doliner <mark@kingant.net> |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
136 | Pass parameters by pushing them onto the stack rather than |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
137 | passing an array of strings. This way, perl scripts can |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
138 | modify the parameters and we can get the changed values |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
139 | and then shoot ourselves. I mean, uh, use them. |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
140 | |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
141 | 2001/06/14: execute_perl replaced by Martin Persson <mep@passagen.se> |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
142 | previous use of perl_eval leaked memory, replaced with |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
143 | a version that uses perl_call instead |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
144 | |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
145 | 30/11/2002: execute_perl modified by Eric Timme <timothy@voidnet.com> |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
146 | args changed to char** so that we can have preparsed |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
147 | arguments again, and many headaches ensued! This essentially |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
148 | means we replaced one hacked method with a messier hacked |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
149 | method out of perceived necessity. Formerly execute_perl |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
150 | required a single char_ptr, and it would insert it into an |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
151 | array of character pointers and NULL terminate the new array. |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
152 | Now we have to pass in pre-terminated character pointer arrays |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
153 | to accomodate functions that want to pass in multiple arguments. |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
154 | |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
155 | Previously arguments were preparsed because an argument list |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
156 | was constructed in the form 'arg one','arg two' and was |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
157 | executed via a call like &funcname(arglist) (see .59.x), so |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
158 | the arglist was magically pre-parsed because of the method. |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
159 | With Martin Persson's change to perl_call we now need to |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
160 | use a null terminated list of character pointers for arguments |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
161 | if we wish them to be parsed. Lacking a better way to allow |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
162 | for both single arguments and many I created a NULL terminated |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
163 | array in every function that called execute_perl and passed |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
164 | that list into the function. In the former version a single |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
165 | character pointer was passed in, and was placed into an array |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
166 | of character pointers with two elements, with a NULL element |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
167 | tacked onto the back, but this method no longer seemed prudent. |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
168 | |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
169 | Enhancements in the future might be to get rid of pre-declaring |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
170 | the array sizes? I am not comfortable enough with this |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
171 | subject to attempt it myself and hope it to stand the test |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
172 | of time. |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
173 | */ |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
174 | int |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
175 | execute_perl(const char *function, int argc, char **args) |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
176 | { |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
177 | int count = 0, i, ret_value = 1; |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
178 | SV *sv_args[argc]; |
|
11318
13fa1d5134f3
[gaim-migrate @ 13521]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11290
diff
changeset
|
179 | dSP; |
|
13fa1d5134f3
[gaim-migrate @ 13521]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11290
diff
changeset
|
180 | PERL_SET_CONTEXT(my_perl); |
|
6520
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
181 | /* |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
182 | * Set up the perl environment, push arguments onto the |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
183 | * perl stack, then call the given function |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
184 | */ |
|
11318
13fa1d5134f3
[gaim-migrate @ 13521]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11290
diff
changeset
|
185 | SPAGAIN; |
|
6520
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
186 | ENTER; |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
187 | SAVETMPS; |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
188 | PUSHMARK(sp); |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
189 | |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
190 | for (i = 0; i < argc; i++) { |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
191 | if (args[i]) { |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
192 | sv_args[i] = sv_2mortal(newSVpv(args[i], 0)); |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
193 | XPUSHs(sv_args[i]); |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
194 | } |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
195 | } |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
196 | |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
197 | PUTBACK; |
| 12871 | 198 | PERL_SET_CONTEXT(my_perl); |
|
6520
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
199 | count = call_pv(function, G_EVAL | G_SCALAR); |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
200 | SPAGAIN; |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
201 | |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
202 | /* |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
203 | * Check for "die," make sure we have 1 argument, and set our |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
204 | * return value. |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
205 | */ |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
206 | if (SvTRUE(ERRSV)) { |
| 15884 | 207 | purple_debug(PURPLE_DEBUG_ERROR, "perl", |
|
6520
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
208 | "Perl function %s exited abnormally: %s\n", |
|
23980
a38cbb35eecf
Some cleanup and a couple leak fixes.
Daniel Atallah <datallah@pidgin.im>
parents:
23915
diff
changeset
|
209 | function, SvPVutf8_nolen(ERRSV)); |
|
17471
fcb31ec08595
A change from o_sukhodolsky:
Richard Laager <rlaager@pidgin.im>
parents:
17208
diff
changeset
|
210 | (void)POPs; |
| 12871 | 211 | } else if (count != 1) { |
|
6520
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
212 | /* |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
213 | * This should NEVER happen. G_SCALAR ensures that we WILL |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
214 | * have 1 parameter. |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
215 | */ |
| 15884 | 216 | purple_debug(PURPLE_DEBUG_ERROR, "perl", |
|
6520
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
217 | "Perl error from %s: expected 1 return value, " |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
218 | "but got %d\n", function, count); |
| 12871 | 219 | } else |
|
6520
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
220 | ret_value = POPi; |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
221 | |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
222 | /* Check for changed arguments */ |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
223 | for (i = 0; i < argc; i++) { |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
224 | if (args[i] && strcmp(args[i], SvPVX(sv_args[i]))) { |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
225 | /* |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
226 | * Shizzel. So the perl script changed one of the parameters, |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
227 | * and we want this change to affect the original parameters. |
|
8735
01248ea222d3
[gaim-migrate @ 9490]
Jonathan Champ <royanee@users.sourceforge.net>
parents:
8593
diff
changeset
|
228 | * args[i] is just a temporary little list of pointers. We don't |
|
6520
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
229 | * want to free args[i] here because the new parameter doesn't |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
230 | * overwrite the data that args[i] points to. That is done by |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
231 | * the function that called execute_perl. I'm not explaining this |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
232 | * very well. See, it's aggregate... Oh, but if 2 perl scripts |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
233 | * both modify the data, _that's_ a memleak. This is really kind |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
234 | * of hackish. I should fix it. Look how long this comment is. |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
235 | * Holy crap. |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
236 | */ |
|
23980
a38cbb35eecf
Some cleanup and a couple leak fixes.
Daniel Atallah <datallah@pidgin.im>
parents:
23915
diff
changeset
|
237 | args[i] = g_strdup(SvPVutf8_nolen(sv_args[i])); |
|
6520
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
238 | } |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
239 | } |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
240 | |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
241 | PUTBACK; |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
242 | FREETMPS; |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
243 | LEAVE; |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
244 | |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
245 | return ret_value; |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
246 | } |
|
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
247 | |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
248 | #if 0 |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
249 | gboolean |
| 15884 | 250 | purple_perl_value_from_sv(PurpleValue *value, SV *sv) |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
251 | { |
| 15884 | 252 | switch (purple_value_get_type(value)) |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
253 | { |
| 15884 | 254 | case PURPLE_TYPE_CHAR: |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
255 | if ((tmp = SvGChar(sv)) != NULL) |
| 15884 | 256 | purple_value_set_char(value, tmp[0]); |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
257 | else |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
258 | return FALSE; |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
259 | break; |
|
6520
5386692555c9
[gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents:
6508
diff
changeset
|
260 | |
| 15884 | 261 | case PURPLE_TYPE_UCHAR: |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
262 | if ((tmp = SvPV_nolen(sv)) != NULL) |
| 15884 | 263 | purple_value_set_uchar(value, tmp[0]); |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
264 | else |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
265 | return FALSE; |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
266 | break; |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
267 | |
| 15884 | 268 | case PURPLE_TYPE_BOOLEAN: |
| 269 | purple_value_set_boolean(value, SvTRUE(sv)); | |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
270 | break; |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
271 | |
| 15884 | 272 | case PURPLE_TYPE_INT: |
| 273 | purple_value_set_int(value, SvIV(sv)); | |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
274 | break; |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
275 | |
| 15884 | 276 | case PURPLE_TYPE_UINT: |
| 277 | purple_value_set_uint(value, SvIV(sv)); | |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
278 | break; |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
279 | |
| 15884 | 280 | case PURPLE_TYPE_LONG: |
| 281 | purple_value_set_long(value, SvIV(sv)); | |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
282 | break; |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
283 | |
| 15884 | 284 | case PURPLE_TYPE_ULONG: |
| 285 | purple_value_set_ulong(value, SvIV(sv)); | |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
286 | break; |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
287 | |
| 15884 | 288 | case PURPLE_TYPE_INT64: |
| 289 | purple_value_set_int64(value, SvIV(sv)); | |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
290 | break; |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
291 | |
| 15884 | 292 | case PURPLE_TYPE_UINT64: |
| 293 | purple_value_set_uint64(value, SvIV(sv)); | |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
294 | break; |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
295 | |
| 15884 | 296 | case PURPLE_TYPE_STRING: |
| 297 | purple_value_set_string(value, SvGChar(sv)); | |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
298 | break; |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
299 | |
| 15884 | 300 | case PURPLE_TYPE_POINTER: |
| 301 | purple_value_set_pointer(value, (void *)SvIV(sv)); | |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
302 | break; |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
303 | |
| 15884 | 304 | case PURPLE_TYPE_BOXED: |
| 305 | if (!strcmp(purple_value_get_specific_type(value), "SV")) | |
| 306 | purple_value_set_boxed(value, (sv == &PL_sv_undef ? NULL : sv)); | |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
307 | else |
| 15884 | 308 | purple_value_set_boxed(value, sv); |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
309 | break; |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
310 | |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
311 | default: |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
312 | return FALSE; |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
313 | } |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
314 | |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
315 | return TRUE; |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
316 | } |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
317 | |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
318 | SV * |
| 15884 | 319 | purple_perl_sv_from_value(const PurpleValue *value, va_list list) |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
320 | { |
| 15884 | 321 | switch (purple_value_get_type(value)) |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
322 | { |
| 15884 | 323 | case PURPLE_TYPE_BOOLEAN: |
| 324 | return newSViv(purple_value_get_boolean(value)); | |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
325 | break; |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
326 | |
| 15884 | 327 | case PURPLE_TYPE_INT: |
| 328 | return newSViv(purple_value_get_int(value)); | |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
329 | break; |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
330 | |
| 15884 | 331 | case PURPLE_TYPE_UINT: |
| 332 | return newSVuv(purple_value_get_uint(value)); | |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
333 | break; |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
334 | |
| 15884 | 335 | case PURPLE_TYPE_LONG: |
| 336 | return newSViv(purple_value_get_long(value)); | |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
337 | break; |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
338 | |
| 15884 | 339 | case PURPLE_TYPE_ULONG: |
| 340 | return newSVuv(purple_value_get_ulong(value)); | |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
341 | break; |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
342 | |
| 15884 | 343 | case PURPLE_TYPE_INT64: |
| 344 | return newSViv(purple_value_get_int64(value)); | |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
345 | break; |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
346 | |
| 15884 | 347 | case PURPLE_TYPE_UINT64: |
| 348 | return newSVuv(purple_value_get_int64(value)); | |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
349 | break; |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
350 | |
| 15884 | 351 | case PURPLE_TYPE_STRING: |
| 352 | return newSVGChar(purple_value_get_string(value)); | |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
353 | break; |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
354 | |
| 15884 | 355 | case PURPLE_TYPE_POINTER: |
| 356 | return newSViv((IV)purple_value_get_pointer(value)); | |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
357 | break; |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
358 | |
| 15884 | 359 | case PURPLE_TYPE_BOXED: |
| 360 | if (!strcmp(purple_value_get_specific_type(value), "SV")) | |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
361 | { |
| 15884 | 362 | SV *sv = (SV *)purple_perl_get_boxed(value); |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
363 | |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
364 | return (sv == NULL ? &PL_sv_undef : sv); |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
365 | } |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
366 | |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
367 | /* Uh.. I dunno. Try this? */ |
| 15884 | 368 | return sv_2mortal(purple_perl_bless_object( |
| 369 | purple_perl_get_boxed(value), | |
| 370 | purple_value_get_specific_type(value))); | |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
371 | |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
372 | default: |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
373 | return FALSE; |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
374 | } |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
375 | |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
376 | return TRUE; |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
377 | } |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
378 | #endif |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
379 | |
|
6920
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
380 | void * |
|
34779
98c540811600
A bit of refactoring to eliminate the use of PurpleValue
Ankit Vani <a@nevitus.org>
parents:
33892
diff
changeset
|
381 | purple_perl_data_from_sv(GType type, SV *sv) |
|
6920
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
382 | { |
|
34784
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
383 | |
|
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
384 | switch (type) { |
|
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
385 | case G_TYPE_BOOLEAN: return (void *)SvIV(sv); |
|
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
386 | case G_TYPE_INT: return (void *)SvIV(sv); |
|
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
387 | case G_TYPE_UINT: return (void *)SvUV(sv); |
|
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
388 | case G_TYPE_LONG: return (void *)SvIV(sv); |
|
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
389 | case G_TYPE_ULONG: return (void *)SvUV(sv); |
|
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
390 | case G_TYPE_INT64: return (void *)SvIV(sv); |
|
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
391 | case G_TYPE_UINT64: return (void *)SvUV(sv); |
|
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
392 | case G_TYPE_STRING: return g_strdup(SvPVutf8_nolen(sv)); |
|
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
393 | case G_TYPE_POINTER: return (void *)SvIV(sv); |
|
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
394 | case G_TYPE_BOXED: return (void *)SvIV(sv); |
|
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
395 | |
|
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
396 | default: |
|
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
397 | return NULL; |
|
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
398 | } |
|
6920
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
399 | |
|
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
400 | return NULL; |
|
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
401 | } |
|
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
402 | |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
403 | static SV * |
|
34779
98c540811600
A bit of refactoring to eliminate the use of PurpleValue
Ankit Vani <a@nevitus.org>
parents:
33892
diff
changeset
|
404 | purple_perl_sv_from_purple_type(const GType type, void *arg) |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
405 | { |
|
26826
eef9f07b6874
Patch from Zsombor Welker to expand the list of PurpleValue valid subtypes.
Ethan Blanton <elb@pidgin.im>
parents:
23980
diff
changeset
|
406 | const char *stash = "Purple"; /* ? */ |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
407 | |
|
34784
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
408 | if (type == PURPLE_TYPE_ACCOUNT) |
|
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
409 | stash = "Purple::Account"; |
|
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
410 | else if (type == PURPLE_TYPE_BUDDY_LIST) |
|
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
411 | stash = "Purple::BuddyList"; |
|
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
412 | else if (type == PURPLE_TYPE_BUDDY) |
|
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
413 | stash = "Purple::BuddyList::Buddy"; |
|
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
414 | else if (type == PURPLE_TYPE_GROUP) |
|
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
415 | stash = "Purple::BuddyList::Group"; |
|
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
416 | else if (type == PURPLE_TYPE_CHAT) |
|
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
417 | stash = "Purple::BuddyList::Chat"; |
|
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
418 | else if (type == PURPLE_TYPE_BUDDY_ICON) |
|
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
419 | stash = "Purple::Buddy::Icon"; |
|
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
420 | else if (type == PURPLE_TYPE_CONNECTION) |
|
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
421 | stash = "Purple::Connection"; |
|
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
422 | else if (type == PURPLE_TYPE_CONVERSATION) |
|
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
423 | stash = "Purple::Conversation"; |
|
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
424 | else if (type == PURPLE_TYPE_PLUGIN) |
|
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
425 | stash = "Purple::Plugin"; |
|
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
426 | else if (type == PURPLE_TYPE_BLIST_NODE) |
|
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
427 | stash = "Purple::BuddyList::Node"; |
|
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
428 | else if (type == PURPLE_TYPE_CIPHER) |
|
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
429 | stash = "Purple::Cipher"; |
|
34785
99bcdb44c75f
Added boxed types for PurpleStatus and PurpleSavedStatus
Ankit Vani <a@nevitus.org>
parents:
34784
diff
changeset
|
430 | else if (type == PURPLE_TYPE_STATUS) |
|
34784
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
431 | stash = "Purple::Status"; |
|
34785
99bcdb44c75f
Added boxed types for PurpleStatus and PurpleSavedStatus
Ankit Vani <a@nevitus.org>
parents:
34784
diff
changeset
|
432 | else if (type == PURPLE_TYPE_SAVEDSTATUS) |
|
34784
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
433 | stash = "Purple::SavedStatus"; |
|
34785
99bcdb44c75f
Added boxed types for PurpleStatus and PurpleSavedStatus
Ankit Vani <a@nevitus.org>
parents:
34784
diff
changeset
|
434 | else if (type == PURPLE_TYPE_LOG) |
|
34784
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
435 | stash = "Purple::Log"; |
|
34785
99bcdb44c75f
Added boxed types for PurpleStatus and PurpleSavedStatus
Ankit Vani <a@nevitus.org>
parents:
34784
diff
changeset
|
436 | else if (type == PURPLE_TYPE_XFER) |
|
34784
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
437 | stash = "Purple::Xfer"; |
|
34785
99bcdb44c75f
Added boxed types for PurpleStatus and PurpleSavedStatus
Ankit Vani <a@nevitus.org>
parents:
34784
diff
changeset
|
438 | else if (type == PURPLE_TYPE_XMLNODE) |
|
34784
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
439 | stash = "Purple::XMLNode"; |
|
34785
99bcdb44c75f
Added boxed types for PurpleStatus and PurpleSavedStatus
Ankit Vani <a@nevitus.org>
parents:
34784
diff
changeset
|
440 | else if (type == PURPLE_TYPE_USERINFO) |
|
34784
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
441 | stash = "Purple::NotifyUserInfo"; |
|
34785
99bcdb44c75f
Added boxed types for PurpleStatus and PurpleSavedStatus
Ankit Vani <a@nevitus.org>
parents:
34784
diff
changeset
|
442 | else if (type == PURPLE_TYPE_STORED_IMAGE) |
|
34784
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
443 | stash = "Purple::StoredImage"; |
|
34785
99bcdb44c75f
Added boxed types for PurpleStatus and PurpleSavedStatus
Ankit Vani <a@nevitus.org>
parents:
34784
diff
changeset
|
444 | else if (type == PURPLE_TYPE_CERTIFICATEPOOL) |
|
34784
d0eafa17c727
More work on perl plugins to use GValues instead of PurpleValues
Ankit Vani <a@nevitus.org>
parents:
34779
diff
changeset
|
445 | stash = "Purple::Certificate::Pool"; |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
446 | |
| 15884 | 447 | return sv_2mortal(purple_perl_bless_object(arg, stash)); |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
448 | } |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
449 | |
|
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
450 | SV * |
|
34779
98c540811600
A bit of refactoring to eliminate the use of PurpleValue
Ankit Vani <a@nevitus.org>
parents:
33892
diff
changeset
|
451 | purple_perl_sv_from_vargs(const GType type, va_list *args, void ***copy_arg) |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
452 | { |
| 15884 | 453 | if (purple_value_is_outgoing(value)) { |
| 454 | switch (purple_value_get_type(value)) { | |
| 455 | case PURPLE_TYPE_SUBTYPE: | |
|
29341
8df545432476
disapproval of revision '1073f46cfe21069efa8e3be8f158fc2f841240cd'
Mark Doliner <markdoliner@pidgin.im>
parents:
29340
diff
changeset
|
456 | if ((*copy_arg = va_arg(*args, void **)) == NULL) |
|
6920
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
457 | return &PL_sv_undef; |
|
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
458 | |
|
34779
98c540811600
A bit of refactoring to eliminate the use of PurpleValue
Ankit Vani <a@nevitus.org>
parents:
33892
diff
changeset
|
459 | return purple_perl_sv_from_purple_type(type, *(void **)*copy_arg); |
|
6898
e58d18e13126
[gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents:
6897
diff
changeset
|
460 | |
| 15884 | 461 | case PURPLE_TYPE_BOOLEAN: |
|
29341
8df545432476
disapproval of revision '1073f46cfe21069efa8e3be8f158fc2f841240cd'
Mark Doliner <markdoliner@pidgin.im>
parents:
29340
diff
changeset
|
462 | if ((*copy_arg = (void *)va_arg(*args, gboolean *)) == NULL) |
|
6920
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
463 | return &PL_sv_undef; |
|
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
464 | |
|
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
465 | return newSViv(*(gboolean *)*copy_arg); |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
466 | |
| 15884 | 467 | case PURPLE_TYPE_INT: |
|
29341
8df545432476
disapproval of revision '1073f46cfe21069efa8e3be8f158fc2f841240cd'
Mark Doliner <markdoliner@pidgin.im>
parents:
29340
diff
changeset
|
468 | if ((*copy_arg = (void *)va_arg(*args, int *)) == NULL) |
|
6920
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
469 | return &PL_sv_undef; |
|
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
470 | |
|
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
471 | return newSViv(*(int *)*copy_arg); |
|
6898
e58d18e13126
[gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents:
6897
diff
changeset
|
472 | |
| 15884 | 473 | case PURPLE_TYPE_UINT: |
|
29341
8df545432476
disapproval of revision '1073f46cfe21069efa8e3be8f158fc2f841240cd'
Mark Doliner <markdoliner@pidgin.im>
parents:
29340
diff
changeset
|
474 | if ((*copy_arg = (void *)va_arg(*args, unsigned int *)) == NULL) |
|
6920
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
475 | return &PL_sv_undef; |
|
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
476 | |
|
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
477 | return newSVuv(*(unsigned int *)*copy_arg); |
|
6898
e58d18e13126
[gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents:
6897
diff
changeset
|
478 | |
| 15884 | 479 | case PURPLE_TYPE_LONG: |
|
29341
8df545432476
disapproval of revision '1073f46cfe21069efa8e3be8f158fc2f841240cd'
Mark Doliner <markdoliner@pidgin.im>
parents:
29340
diff
changeset
|
480 | if ((*copy_arg = (void *)va_arg(*args, long *)) == NULL) |
|
6920
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
481 | return &PL_sv_undef; |
|
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
482 | |
|
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
483 | return newSViv(*(long *)*copy_arg); |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
484 | |
| 15884 | 485 | case PURPLE_TYPE_ULONG: |
|
29341
8df545432476
disapproval of revision '1073f46cfe21069efa8e3be8f158fc2f841240cd'
Mark Doliner <markdoliner@pidgin.im>
parents:
29340
diff
changeset
|
486 | if ((*copy_arg = (void *)va_arg(*args, |
|
6921
3d49b89fc920
[gaim-migrate @ 7468]
Christian Hammond <chipx86@chipx86.com>
parents:
6920
diff
changeset
|
487 | unsigned long *)) == NULL) |
|
6920
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
488 | return &PL_sv_undef; |
|
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
489 | |
|
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
490 | return newSVuv(*(unsigned long *)*copy_arg); |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
491 | |
| 15884 | 492 | case PURPLE_TYPE_INT64: |
|
29341
8df545432476
disapproval of revision '1073f46cfe21069efa8e3be8f158fc2f841240cd'
Mark Doliner <markdoliner@pidgin.im>
parents:
29340
diff
changeset
|
493 | if ((*copy_arg = (void *)va_arg(*args, gint64 *)) == NULL) |
|
6920
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
494 | return &PL_sv_undef; |
|
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
495 | |
|
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
496 | return newSViv(*(gint64 *)*copy_arg); |
|
6898
e58d18e13126
[gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents:
6897
diff
changeset
|
497 | |
| 15884 | 498 | case PURPLE_TYPE_UINT64: |
|
29341
8df545432476
disapproval of revision '1073f46cfe21069efa8e3be8f158fc2f841240cd'
Mark Doliner <markdoliner@pidgin.im>
parents:
29340
diff
changeset
|
499 | if ((*copy_arg = (void *)va_arg(*args, guint64 *)) == NULL) |
|
6920
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
500 | return &PL_sv_undef; |
|
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
501 | |
|
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
502 | return newSVuv(*(guint64 *)*copy_arg); |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
503 | |
| 15884 | 504 | case PURPLE_TYPE_STRING: |
|
29341
8df545432476
disapproval of revision '1073f46cfe21069efa8e3be8f158fc2f841240cd'
Mark Doliner <markdoliner@pidgin.im>
parents:
29340
diff
changeset
|
505 | if ((*copy_arg = (void *)va_arg(*args, char **)) == NULL) |
|
6920
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
506 | return &PL_sv_undef; |
|
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
507 | |
|
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
508 | return newSVGChar(*(char **)*copy_arg); |
|
6898
e58d18e13126
[gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents:
6897
diff
changeset
|
509 | |
| 15884 | 510 | case PURPLE_TYPE_POINTER: |
|
29341
8df545432476
disapproval of revision '1073f46cfe21069efa8e3be8f158fc2f841240cd'
Mark Doliner <markdoliner@pidgin.im>
parents:
29340
diff
changeset
|
511 | if ((*copy_arg = va_arg(*args, void **)) == NULL) |
|
6920
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
512 | return &PL_sv_undef; |
|
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
513 | |
|
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
514 | return newSViv((IV)*(void **)*copy_arg); |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
515 | |
| 15884 | 516 | case PURPLE_TYPE_BOXED: |
|
6898
e58d18e13126
[gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents:
6897
diff
changeset
|
517 | /* Uh.. I dunno. Try this? */ |
|
29341
8df545432476
disapproval of revision '1073f46cfe21069efa8e3be8f158fc2f841240cd'
Mark Doliner <markdoliner@pidgin.im>
parents:
29340
diff
changeset
|
518 | if ((*copy_arg = va_arg(*args, void **)) == NULL) |
|
6920
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
519 | return &PL_sv_undef; |
|
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
520 | |
| 15884 | 521 | return sv_2mortal(purple_perl_bless_object( |
|
6920
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
522 | *(void **)*copy_arg, |
| 15884 | 523 | purple_value_get_specific_type(value))); |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
524 | |
|
6898
e58d18e13126
[gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents:
6897
diff
changeset
|
525 | default: |
|
e58d18e13126
[gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents:
6897
diff
changeset
|
526 | /* If this happens, things are going to get screwed up... */ |
|
e58d18e13126
[gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents:
6897
diff
changeset
|
527 | return NULL; |
|
e58d18e13126
[gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents:
6897
diff
changeset
|
528 | } |
| 12871 | 529 | } else { |
| 15884 | 530 | switch (purple_value_get_type(value)) { |
| 531 | case PURPLE_TYPE_SUBTYPE: | |
|
29341
8df545432476
disapproval of revision '1073f46cfe21069efa8e3be8f158fc2f841240cd'
Mark Doliner <markdoliner@pidgin.im>
parents:
29340
diff
changeset
|
532 | if ((*copy_arg = va_arg(*args, void *)) == NULL) |
|
6920
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
533 | return &PL_sv_undef; |
|
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
534 | |
|
34779
98c540811600
A bit of refactoring to eliminate the use of PurpleValue
Ankit Vani <a@nevitus.org>
parents:
33892
diff
changeset
|
535 | return purple_perl_sv_from_purple_type(type, *copy_arg); |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
536 | |
| 15884 | 537 | case PURPLE_TYPE_BOOLEAN: |
|
29341
8df545432476
disapproval of revision '1073f46cfe21069efa8e3be8f158fc2f841240cd'
Mark Doliner <markdoliner@pidgin.im>
parents:
29340
diff
changeset
|
538 | *copy_arg = GINT_TO_POINTER( va_arg(*args, gboolean) ); |
|
6920
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
539 | |
| 7386 | 540 | return newSViv((gboolean)GPOINTER_TO_INT(*copy_arg)); |
|
6898
e58d18e13126
[gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents:
6897
diff
changeset
|
541 | |
| 15884 | 542 | case PURPLE_TYPE_INT: |
|
29341
8df545432476
disapproval of revision '1073f46cfe21069efa8e3be8f158fc2f841240cd'
Mark Doliner <markdoliner@pidgin.im>
parents:
29340
diff
changeset
|
543 | *copy_arg = GINT_TO_POINTER( va_arg(*args, int) ); |
|
6920
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
544 | |
| 7386 | 545 | return newSViv(GPOINTER_TO_INT(*copy_arg)); |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
546 | |
| 15884 | 547 | case PURPLE_TYPE_UINT: |
|
29341
8df545432476
disapproval of revision '1073f46cfe21069efa8e3be8f158fc2f841240cd'
Mark Doliner <markdoliner@pidgin.im>
parents:
29340
diff
changeset
|
548 | *copy_arg = GUINT_TO_POINTER(va_arg(*args, unsigned int)); |
|
6920
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
549 | |
| 7386 | 550 | return newSVuv(GPOINTER_TO_UINT(*copy_arg)); |
|
6898
e58d18e13126
[gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents:
6897
diff
changeset
|
551 | |
| 15884 | 552 | case PURPLE_TYPE_LONG: |
|
29341
8df545432476
disapproval of revision '1073f46cfe21069efa8e3be8f158fc2f841240cd'
Mark Doliner <markdoliner@pidgin.im>
parents:
29340
diff
changeset
|
553 | *copy_arg = (void *)va_arg(*args, long); |
|
6920
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
554 | |
|
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
555 | return newSViv((long)*copy_arg); |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
556 | |
| 15884 | 557 | case PURPLE_TYPE_ULONG: |
|
29341
8df545432476
disapproval of revision '1073f46cfe21069efa8e3be8f158fc2f841240cd'
Mark Doliner <markdoliner@pidgin.im>
parents:
29340
diff
changeset
|
558 | *copy_arg = (void *)va_arg(*args, unsigned long); |
|
6920
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
559 | |
|
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
560 | return newSVuv((unsigned long)*copy_arg); |
|
6898
e58d18e13126
[gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents:
6897
diff
changeset
|
561 | |
| 15884 | 562 | case PURPLE_TYPE_INT64: |
|
6920
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
563 | #if 0 |
|
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
564 | /* XXX This yells and complains. */ |
|
29341
8df545432476
disapproval of revision '1073f46cfe21069efa8e3be8f158fc2f841240cd'
Mark Doliner <markdoliner@pidgin.im>
parents:
29340
diff
changeset
|
565 | *copy_arg = va_arg(*args, gint64); |
|
6920
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
566 | |
|
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
567 | return newSViv(*copy_arg); |
|
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
568 | #endif |
|
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
569 | break; |
|
6898
e58d18e13126
[gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents:
6897
diff
changeset
|
570 | |
| 15884 | 571 | case PURPLE_TYPE_UINT64: |
|
6920
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
572 | /* XXX This also yells and complains. */ |
|
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
573 | #if 0 |
|
29341
8df545432476
disapproval of revision '1073f46cfe21069efa8e3be8f158fc2f841240cd'
Mark Doliner <markdoliner@pidgin.im>
parents:
29340
diff
changeset
|
574 | *copy_arg = (void *)va_arg(*args, guint64); |
|
6920
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
575 | |
|
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
576 | return newSVuv(*copy_arg); |
|
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
577 | #endif |
|
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
578 | break; |
|
6898
e58d18e13126
[gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents:
6897
diff
changeset
|
579 | |
| 15884 | 580 | case PURPLE_TYPE_STRING: |
|
29341
8df545432476
disapproval of revision '1073f46cfe21069efa8e3be8f158fc2f841240cd'
Mark Doliner <markdoliner@pidgin.im>
parents:
29340
diff
changeset
|
581 | if ((*copy_arg = (void *)va_arg(*args, char *)) == NULL) |
|
6920
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
582 | return &PL_sv_undef; |
|
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
583 | |
|
7240
40e3e9919771
[gaim-migrate @ 7815]
Christian Hammond <chipx86@chipx86.com>
parents:
7239
diff
changeset
|
584 | return newSVGChar((char *)*copy_arg); |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
585 | |
| 15884 | 586 | case PURPLE_TYPE_POINTER: |
|
29341
8df545432476
disapproval of revision '1073f46cfe21069efa8e3be8f158fc2f841240cd'
Mark Doliner <markdoliner@pidgin.im>
parents:
29340
diff
changeset
|
587 | if ((*copy_arg = (void *)va_arg(*args, void *)) == NULL) |
|
6920
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
588 | return &PL_sv_undef; |
|
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
589 | |
|
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
590 | return newSViv((IV)*copy_arg); |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
591 | |
| 15884 | 592 | case PURPLE_TYPE_BOXED: |
|
6898
e58d18e13126
[gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents:
6897
diff
changeset
|
593 | /* Uh.. I dunno. Try this? */ |
|
29341
8df545432476
disapproval of revision '1073f46cfe21069efa8e3be8f158fc2f841240cd'
Mark Doliner <markdoliner@pidgin.im>
parents:
29340
diff
changeset
|
594 | if ((*copy_arg = (void *)va_arg(*args, void *)) == NULL) |
|
6920
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
595 | return &PL_sv_undef; |
|
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
596 | |
| 15884 | 597 | return sv_2mortal(purple_perl_bless_object(*copy_arg, |
| 598 | purple_value_get_specific_type(value))); | |
|
6898
e58d18e13126
[gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents:
6897
diff
changeset
|
599 | |
|
e58d18e13126
[gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents:
6897
diff
changeset
|
600 | default: |
|
e58d18e13126
[gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents:
6897
diff
changeset
|
601 | /* If this happens, things are going to get screwed up... */ |
|
e58d18e13126
[gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents:
6897
diff
changeset
|
602 | return NULL; |
|
e58d18e13126
[gaim-migrate @ 7445]
Christian Hammond <chipx86@chipx86.com>
parents:
6897
diff
changeset
|
603 | } |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
604 | } |
|
6920
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
605 | |
|
4f4931b005cb
[gaim-migrate @ 7467]
Christian Hammond <chipx86@chipx86.com>
parents:
6898
diff
changeset
|
606 | return NULL; |
|
6566
61eb35202526
[gaim-migrate @ 7088]
Christian Hammond <chipx86@chipx86.com>
parents:
6531
diff
changeset
|
607 | } |
|
22839
3ee4247ebbbd
Use the same fix for Purple::Util::fetch_url (from 4b6378d5e) for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17471
diff
changeset
|
608 | |
|
3ee4247ebbbd
Use the same fix for Purple::Util::fetch_url (from 4b6378d5e) for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17471
diff
changeset
|
609 | SV *purple_perl_sv_from_fun(PurplePlugin *plugin, SV *callback) |
|
3ee4247ebbbd
Use the same fix for Purple::Util::fetch_url (from 4b6378d5e) for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17471
diff
changeset
|
610 | { |
|
3ee4247ebbbd
Use the same fix for Purple::Util::fetch_url (from 4b6378d5e) for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17471
diff
changeset
|
611 | SV *sv = NULL; |
|
3ee4247ebbbd
Use the same fix for Purple::Util::fetch_url (from 4b6378d5e) for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17471
diff
changeset
|
612 | |
|
3ee4247ebbbd
Use the same fix for Purple::Util::fetch_url (from 4b6378d5e) for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17471
diff
changeset
|
613 | if (SvTYPE(callback) == SVt_RV) { |
|
3ee4247ebbbd
Use the same fix for Purple::Util::fetch_url (from 4b6378d5e) for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17471
diff
changeset
|
614 | SV *cbsv = SvRV(callback); |
|
3ee4247ebbbd
Use the same fix for Purple::Util::fetch_url (from 4b6378d5e) for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17471
diff
changeset
|
615 | |
|
3ee4247ebbbd
Use the same fix for Purple::Util::fetch_url (from 4b6378d5e) for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17471
diff
changeset
|
616 | if (SvTYPE(cbsv) == SVt_PVCV) { |
|
3ee4247ebbbd
Use the same fix for Purple::Util::fetch_url (from 4b6378d5e) for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17471
diff
changeset
|
617 | sv = newSVsv(callback); |
|
3ee4247ebbbd
Use the same fix for Purple::Util::fetch_url (from 4b6378d5e) for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17471
diff
changeset
|
618 | } |
|
3ee4247ebbbd
Use the same fix for Purple::Util::fetch_url (from 4b6378d5e) for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17471
diff
changeset
|
619 | } else if (SvTYPE(callback) == SVt_PV) { |
|
3ee4247ebbbd
Use the same fix for Purple::Util::fetch_url (from 4b6378d5e) for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17471
diff
changeset
|
620 | PurplePerlScript *gps; |
|
3ee4247ebbbd
Use the same fix for Purple::Util::fetch_url (from 4b6378d5e) for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17471
diff
changeset
|
621 | |
|
3ee4247ebbbd
Use the same fix for Purple::Util::fetch_url (from 4b6378d5e) for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17471
diff
changeset
|
622 | gps = (PurplePerlScript *)PURPLE_PLUGIN_LOADER_INFO(plugin); |
|
3ee4247ebbbd
Use the same fix for Purple::Util::fetch_url (from 4b6378d5e) for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17471
diff
changeset
|
623 | sv = newSVpvf("%s::%s", gps->package, SvPV_nolen(callback)); |
|
3ee4247ebbbd
Use the same fix for Purple::Util::fetch_url (from 4b6378d5e) for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17471
diff
changeset
|
624 | } else { |
|
3ee4247ebbbd
Use the same fix for Purple::Util::fetch_url (from 4b6378d5e) for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17471
diff
changeset
|
625 | purple_debug_warning("perl", "Callback not a valid type, only strings and coderefs allowed.\n"); |
|
3ee4247ebbbd
Use the same fix for Purple::Util::fetch_url (from 4b6378d5e) for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17471
diff
changeset
|
626 | } |
|
3ee4247ebbbd
Use the same fix for Purple::Util::fetch_url (from 4b6378d5e) for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17471
diff
changeset
|
627 | |
|
3ee4247ebbbd
Use the same fix for Purple::Util::fetch_url (from 4b6378d5e) for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17471
diff
changeset
|
628 | return sv; |
|
3ee4247ebbbd
Use the same fix for Purple::Util::fetch_url (from 4b6378d5e) for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17471
diff
changeset
|
629 | } |
|
3ee4247ebbbd
Use the same fix for Purple::Util::fetch_url (from 4b6378d5e) for
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17471
diff
changeset
|
630 |