line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#ifndef EASYXS_PERLCALL_H |
2
|
|
|
|
|
|
|
#define EASYXS_PERLCALL_H 1 |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
#include "init.h" |
5
|
|
|
|
|
|
|
|
6
|
0
|
|
|
|
|
|
static inline void _EASYXS_SET_ARGS (pTHX_ SV* object, SV** args) { |
7
|
0
|
|
|
|
|
|
dSP; |
8
|
|
|
|
|
|
|
|
9
|
0
|
|
|
|
|
|
unsigned argscount = 0; |
10
|
|
|
|
|
|
|
|
11
|
0
|
0
|
|
|
|
|
if (args) { |
12
|
0
|
0
|
|
|
|
|
while (args[argscount] != NULL) argscount++; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
|
|
|
ENTER; |
16
|
0
|
|
|
|
|
|
SAVETMPS; |
17
|
|
|
|
|
|
|
|
18
|
0
|
0
|
|
|
|
|
PUSHMARK(SP); |
19
|
|
|
|
|
|
|
|
20
|
0
|
0
|
|
|
|
|
if (object || argscount) { |
|
|
0
|
|
|
|
|
|
21
|
0
|
0
|
|
|
|
|
EXTEND(SP, (object ? 1 : 0) + argscount); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
0
|
0
|
|
|
|
|
if (object) PUSHs( sv_mortalcopy(object) ); |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
unsigned a=0; |
26
|
0
|
0
|
|
|
|
|
while (a < argscount) mPUSHs( args[a++] ); |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
PUTBACK; |
29
|
|
|
|
|
|
|
} |
30
|
0
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
#define exs_call_sv_void(sv, args) STMT_START { \ |
33
|
|
|
|
|
|
|
_EASYXS_SET_ARGS(aTHX_ NULL, args); \ |
34
|
|
|
|
|
|
|
call_sv(sv, G_DISCARD | G_VOID); \ |
35
|
|
|
|
|
|
|
FREETMPS; \ |
36
|
|
|
|
|
|
|
LEAVE; \ |
37
|
|
|
|
|
|
|
} STMT_END |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
#define exs_call_method_void(object, methname, args) STMT_START { \ |
40
|
|
|
|
|
|
|
_EASYXS_SET_ARGS(aTHX_ object, args); \ |
41
|
|
|
|
|
|
|
\ |
42
|
|
|
|
|
|
|
call_method( methname, G_DISCARD | G_VOID ); \ |
43
|
|
|
|
|
|
|
\ |
44
|
|
|
|
|
|
|
FREETMPS; \ |
45
|
|
|
|
|
|
|
LEAVE; \ |
46
|
|
|
|
|
|
|
} STMT_END |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
static inline SV* _easyxs_fetch_scalar_return (pTHX_ int count) { |
49
|
0
|
|
|
|
|
|
dSP; |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
SPAGAIN; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
SV* ret; |
54
|
|
|
|
|
|
|
|
55
|
0
|
0
|
|
|
|
|
if (count == 0) { |
56
|
0
|
|
|
|
|
|
ret = &PL_sv_undef; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
else { |
59
|
0
|
|
|
|
|
|
ret = SvREFCNT_inc(POPs); |
60
|
|
|
|
|
|
|
|
61
|
0
|
0
|
|
|
|
|
while (count-- > 1) PERL_UNUSED_VAR(POPs); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
PUTBACK; |
65
|
0
|
0
|
|
|
|
|
FREETMPS; |
66
|
0
|
|
|
|
|
|
LEAVE; |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
return ret; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
static inline SV** _easyxs_fetch_list_return (pTHX_ int count) { |
72
|
|
|
|
|
|
|
dSP; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
SPAGAIN; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
SV** ret; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Newx(ret, 1 + count, SV*); |
79
|
|
|
|
|
|
|
ret[count] = NULL; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
while (count-- > 0) { |
82
|
|
|
|
|
|
|
ret[count] = SvREFCNT_inc(POPs); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
PUTBACK; |
86
|
|
|
|
|
|
|
FREETMPS; |
87
|
|
|
|
|
|
|
LEAVE; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
SAVEFREEPV(ret); |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
return ret; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
static inline SV* _easyxs_call_method_scalar (pTHX_ SV* object, const char* methname, SV** args) { |
95
|
0
|
|
|
|
|
|
_EASYXS_SET_ARGS(aTHX_ object, args); |
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
int count = call_method(methname, G_SCALAR); |
98
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
|
return _easyxs_fetch_scalar_return(aTHX_ count); |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
#define exs_call_method_scalar(object, methname, args) \ |
103
|
|
|
|
|
|
|
_easyxs_call_method_scalar(aTHX_ object, methname, args) |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
static inline SV* _easyxs_call_sv_scalar (pTHX_ SV* cb, SV** args) { |
106
|
|
|
|
|
|
|
_EASYXS_SET_ARGS(aTHX_ NULL, args); |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
int count = call_sv(cb, G_SCALAR); |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
return _easyxs_fetch_scalar_return(aTHX_ count); |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
#define exs_call_sv_scalar(sv, args) \ |
114
|
|
|
|
|
|
|
_easyxs_call_sv_scalar(aTHX_ sv, args) |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
static inline SV** _easyxs_call_sv_list (pTHX_ SV* cb, SV** args) { |
117
|
|
|
|
|
|
|
_EASYXS_SET_ARGS(aTHX_ NULL, args); |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
int count = call_sv(cb, G_ARRAY); |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
return _easyxs_fetch_list_return(aTHX_ count); |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
#define exs_call_sv_list(sv, args) \ |
125
|
|
|
|
|
|
|
_easyxs_call_sv_list(aTHX_ sv, args) |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
#define _handle_trapped_error(count, err_p) STMT_START { \ |
128
|
|
|
|
|
|
|
dSP; \ |
129
|
|
|
|
|
|
|
SV* err_tmp = ERRSV; \ |
130
|
|
|
|
|
|
|
if (SvTRUE(err_tmp)) { \ |
131
|
|
|
|
|
|
|
while (count--) PERL_UNUSED_VAR(POPs); \ |
132
|
|
|
|
|
|
|
\ |
133
|
|
|
|
|
|
|
*err_p = newSVsv(err_tmp); \ |
134
|
|
|
|
|
|
|
\ |
135
|
|
|
|
|
|
|
PUTBACK; \ |
136
|
|
|
|
|
|
|
FREETMPS; \ |
137
|
|
|
|
|
|
|
LEAVE; \ |
138
|
|
|
|
|
|
|
} \ |
139
|
|
|
|
|
|
|
} STMT_END |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
static inline void _easyxs_call_sv_void_trapped (pTHX_ SV* cb, SV** args, SV** error) { |
142
|
|
|
|
|
|
|
_EASYXS_SET_ARGS(aTHX_ NULL, args); |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
int count = call_sv(cb, G_VOID | G_EVAL); |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
_handle_trapped_error(count, error); |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
#define exs_call_sv_void_trapped(sv, args, err_p) \ |
150
|
|
|
|
|
|
|
_easyxs_call_sv_void_trapped(aTHX_ sv, args, err_p) |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
static inline SV* _easyxs_call_sv_scalar_trapped (pTHX_ SV* cb, SV** args, SV** error) { |
153
|
|
|
|
|
|
|
_EASYXS_SET_ARGS(aTHX_ NULL, args); |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
int count = call_sv(cb, G_SCALAR | G_EVAL); |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
_handle_trapped_error(count, error); |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
if (SvTRUE(ERRSV)) return NULL; |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
return _easyxs_fetch_scalar_return(aTHX_ count); |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
#define exs_call_sv_scalar_trapped(sv, args, err_p) \ |
165
|
|
|
|
|
|
|
_easyxs_call_sv_scalar_trapped(aTHX_ sv, args, err_p) |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
static inline SV** _easyxs_call_sv_list_trapped (pTHX_ SV* cb, SV** args, SV** error) { |
168
|
|
|
|
|
|
|
_EASYXS_SET_ARGS(aTHX_ NULL, args); |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
int count = call_sv(cb, G_ARRAY | G_EVAL); |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
_handle_trapped_error(count, error); |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
if (SvTRUE(ERRSV)) return NULL; |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
return _easyxs_fetch_list_return(aTHX_ count); |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
#define exs_call_sv_list_trapped(sv, args, err_p) \ |
180
|
|
|
|
|
|
|
_easyxs_call_sv_list_trapped(aTHX_ sv, args, err_p) |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
#endif |