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