Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 359 lines (249 sloc) 8.938 kb
c64e58f pmc docs update 3
Michael Scott authored
1 /*
e69d2a4 @petdance Made pcc_params be static. Removed unused arg from build_func. Header…
petdance authored
2 Copyright (C) 2001-2010, Parrot Foundation.
c64e58f pmc docs update 3
Michael Scott authored
3 $Id$
4
5 =head1 NAME
6
f474cd7 @bschmalhofer [perl #38235] Rename (dyn)?classes to (dyn)?pmc
bschmalhofer authored
7 src/pmc/nci.pmc - Native Call Interface
c64e58f pmc docs update 3
Michael Scott authored
8
9 =head1 DESCRIPTION
10
11 The vtable functions for the native C call functions.
12
13 =head2 Methods
14
15 =over 4
16
17 =cut
18
19 */
2a2c19b Added in code to properly do native calls to library routines loaded via
Dan Sugalski authored
20
6bdd5f9 @petdance headerizer now runs on PMC files
petdance authored
21 /* HEADERIZER HFILE: none */
22 /* HEADERIZER BEGIN: static */
e69d2a4 @petdance Made pcc_params be static. Removed unused arg from build_func. Header…
petdance authored
23 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
24
1e5a8ee @plobsing eliminate use of libffi-specific nci.pmc
plobsing authored
25 PARROT_IGNORABLE_RESULT
26 static nci_thunk_t /*@alt void@*/
27 build_func(PARROT_INTERP,
a90f6d7 @plobsing switch ffi nci.pmc over to standard signature parser
plobsing authored
28 ARGMOD(Parrot_NCI_attributes *nci))
f631eb3 @plobsing remove private2 (raw) flag from nci-ffi.pmc
plobsing authored
29 __attribute__nonnull__(1)
30 __attribute__nonnull__(2)
a90f6d7 @plobsing switch ffi nci.pmc over to standard signature parser
plobsing authored
31 FUNC_MODIFIES(*nci);
32
1e5a8ee @plobsing eliminate use of libffi-specific nci.pmc
plobsing authored
33 #define ASSERT_ARGS_build_func __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
f631eb3 @plobsing remove private2 (raw) flag from nci-ffi.pmc
plobsing authored
34 PARROT_ASSERT_ARG(interp) \
a90f6d7 @plobsing switch ffi nci.pmc over to standard signature parser
plobsing authored
35 , PARROT_ASSERT_ARG(nci))
e69d2a4 @petdance Made pcc_params be static. Removed unused arg from build_func. Header…
petdance authored
36 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
6bdd5f9 @petdance headerizer now runs on PMC files
petdance authored
37 /* HEADERIZER END: static */
38
75d67e7 @plobsing avoid rebuilding the pcc cif every call
plobsing authored
39 /*
40
1e5a8ee @plobsing eliminate use of libffi-specific nci.pmc
plobsing authored
41 =item C<static nci_thunk_t build_func(PARROT_INTERP, Parrot_NCI_attributes
42 *nci)>
75d67e7 @plobsing avoid rebuilding the pcc cif every call
plobsing authored
43
1e5a8ee @plobsing eliminate use of libffi-specific nci.pmc
plobsing authored
44 Actually build the NCI thunk.
75d67e7 @plobsing avoid rebuilding the pcc cif every call
plobsing authored
45
46 =cut
47
48 */
49
1e5a8ee @plobsing eliminate use of libffi-specific nci.pmc
plobsing authored
50 PARROT_IGNORABLE_RESULT
51 static nci_thunk_t
52 build_func(PARROT_INTERP, ARGMOD(Parrot_NCI_attributes *nci))
f631eb3 @plobsing remove private2 (raw) flag from nci-ffi.pmc
plobsing authored
53 {
1e5a8ee @plobsing eliminate use of libffi-specific nci.pmc
plobsing authored
54 ASSERT_ARGS(build_func)
f631eb3 @plobsing remove private2 (raw) flag from nci-ffi.pmc
plobsing authored
55
a90f6d7 @plobsing switch ffi nci.pmc over to standard signature parser
plobsing authored
56 nci->signature = Parrot_nci_parse_signature(interp, nci->sig_str);
57
58 Parrot_nci_sig_to_pcc(interp, nci->signature,
59 &nci->pcc_params_signature,
60 &nci->pcc_return_signature);
f631eb3 @plobsing remove private2 (raw) flag from nci-ffi.pmc
plobsing authored
61
a90f6d7 @plobsing switch ffi nci.pmc over to standard signature parser
plobsing authored
62 /* Arity is length of the signature minus one (the return type). */
63 nci->arity = VTABLE_elements(interp, nci->signature) - 1;
f631eb3 @plobsing remove private2 (raw) flag from nci-ffi.pmc
plobsing authored
64
1e5a8ee @plobsing eliminate use of libffi-specific nci.pmc
plobsing authored
65 /* Build call function. */
66 nci->fb_info = build_call_func(interp, nci->sig_str);
67 nci->func = F2DPTR(VTABLE_get_pointer(interp, nci->fb_info));
68
69 return (nci_thunk_t)nci->func;
f631eb3 @plobsing remove private2 (raw) flag from nci-ffi.pmc
plobsing authored
70 }
71
1e5a8ee @plobsing eliminate use of libffi-specific nci.pmc
plobsing authored
72
336b07c @bacek Add 'does invokable' to all PMCs with VTABLE_invoke (except Object). …
bacek authored
73 pmclass NCI auto_attrs provides invokable {
9d723e0 @plobsing update NCI signature parsing to emit new (half year old) PCC param an…
plobsing authored
74 /* NCI thunk handling attributes */
1e5a8ee @plobsing eliminate use of libffi-specific nci.pmc
plobsing authored
75 ATTR PMC *signature; /* parsed signature */
76 ATTR STRING *sig_str; /* signature string */
77 ATTR void *func; /* function pointer to call */
78 ATTR PMC *fb_info; /* frame-builder info */
79 ATTR void *orig_func; /* pointer to wrapped function */
0c5f9c3 GSoC: The majority of my NCI changes in 1 commit.
John Harrison authored
80
9d723e0 @plobsing update NCI signature parsing to emit new (half year old) PCC param an…
plobsing authored
81 /* Parrot Sub-ish attributes */
82 ATTR STRING *pcc_params_signature;
83 ATTR STRING *pcc_return_signature;
2d5eeb8 @plobsing eliminate some unnecessary attributes
plobsing authored
84 ATTR INTVAL arity;
9d723e0 @plobsing update NCI signature parsing to emit new (half year old) PCC param an…
plobsing authored
85
86 /* MMD fields */
1e5a8ee @plobsing eliminate use of libffi-specific nci.pmc
plobsing authored
87 ATTR STRING *long_signature;
88 ATTR PMC *multi_sig;
2a2c19b Added in code to properly do native calls to library routines loaded via
Dan Sugalski authored
89
c64e58f pmc docs update 3
Michael Scott authored
90 /*
91
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
92 =item C<METHOD get_multisig()>
1415cda add introspection method get_multisig
Leopold Toetsch authored
93
1e5a8ee @plobsing eliminate use of libffi-specific nci.pmc
plobsing authored
94 Return the MMD signature PMC, if any or C<PMCNULL>.
1415cda add introspection method get_multisig
Leopold Toetsch authored
95
96 =cut
97
98 */
99
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
100 METHOD get_multisig() {
26f7d7b @cotto [PMC] replace PMC_pmc_val with an ATTR in the NCI PMC
cotto authored
101 PMC *sig;
102 GET_ATTR_multi_sig(INTERP, SELF, sig);
83dd9f2 @NotFound [core] partial fix for TT #667, examples/namespace/namespace_dump.pi…
NotFound authored
103 if (PMC_IS_NULL(sig))
26f7d7b @cotto [PMC] replace PMC_pmc_val with an ATTR in the NCI PMC
cotto authored
104 sig = PMCNULL;
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
105 RETURN(PMC *sig);
1415cda add introspection method get_multisig
Leopold Toetsch authored
106 }
107
108 /*
109
c64e58f pmc docs update 3
Michael Scott authored
110 =item C<void init()>
111
112 Initializes the NCI with a C<NULL> function pointer.
113
114 =cut
115
116 */
117
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
118 VTABLE void init() {
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored
119 PObj_custom_mark_SET(SELF);
f7fc86b nci
Leopold Toetsch authored
120 }
121
1e5a8ee @plobsing eliminate use of libffi-specific nci.pmc
plobsing authored
122 VTABLE void *get_pointer() {
123 return PARROT_NCI(SELF)->orig_func;
124 }
125
c64e58f pmc docs update 3
Michael Scott authored
126 /*
127
380c0ba fix NCI related DOD problem
Leopold Toetsch authored
128 =item C<void set_pointer_keyed_str(STRING *key, void *func)>
c64e58f pmc docs update 3
Michael Scott authored
129
380c0ba fix NCI related DOD problem
Leopold Toetsch authored
130 Sets the specified function pointer and signature (C<*key>).
c64e58f pmc docs update 3
Michael Scott authored
131
132 =cut
133
134 */
135
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
136 VTABLE void set_pointer_keyed_str(STRING *key, void *func) {
1764f4c @chromatic [PMC] Optimized NCI registration signature handling slightly by avoiding
chromatic authored
137 Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
637246f @jnthn Refactor the NCI PMC to have an underlying structure, in preparation …
jnthn authored
138
62e3049 @petdance consting, and fixed embedded tabs
petdance authored
139 /* Store the original function and signature. */
1e5a8ee @plobsing eliminate use of libffi-specific nci.pmc
plobsing authored
140 SET_ATTR_orig_func(INTERP, SELF, func);
c4cd281 @chromatic [PMC] Avoided an unnecessary STRING copying and creation in NCI's
chromatic authored
141
142 /* ensure that the STRING signature is constant */
143 if (!PObj_constant_TEST(key)) {
8832378 @chromatic [PMC] Delayed NCI thunk initialization until absolutely necessary. This
chromatic authored
144 char * const key_c = Parrot_str_to_cstring(INTERP, key);
e69d2a4 @petdance Made pcc_params be static. Removed unused arg from build_func. Header…
petdance authored
145 const size_t key_length = Parrot_str_byte_length(interp, key);
1e5a8ee @plobsing eliminate use of libffi-specific nci.pmc
plobsing authored
146 key = Parrot_str_new_init(interp, key_c, key_length,
147 Parrot_default_encoding_ptr, PObj_constant_FLAG);
c4cd281 @chromatic [PMC] Avoided an unnecessary STRING copying and creation in NCI's
chromatic authored
148 Parrot_str_free_cstring(key_c);
149 }
150
a90f6d7 @plobsing switch ffi nci.pmc over to standard signature parser
plobsing authored
151 nci_info->sig_str = key;
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored
152 }
03918bc @chromatic [PMC] Fixed a read of unitialized memory in NCI PMC reported by Valgr…
chromatic authored
153
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored
154 /*
155
156 =item C<void mark()>
157
158 Mark any referenced strings and PMCs.
159
160 =cut
161
162 */
163 VTABLE void mark() {
1e5a8ee @plobsing eliminate use of libffi-specific nci.pmc
plobsing authored
164 if (PARROT_NCI(SELF)) {
165 Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
f631eb3 @plobsing remove private2 (raw) flag from nci-ffi.pmc
plobsing authored
166
1e5a8ee @plobsing eliminate use of libffi-specific nci.pmc
plobsing authored
167 Parrot_gc_mark_PMC_alive(interp, nci_info->signature);
168 Parrot_gc_mark_PMC_alive(interp, nci_info->fb_info);
169 Parrot_gc_mark_PMC_alive(interp, nci_info->multi_sig);
f631eb3 @plobsing remove private2 (raw) flag from nci-ffi.pmc
plobsing authored
170
1e5a8ee @plobsing eliminate use of libffi-specific nci.pmc
plobsing authored
171 Parrot_gc_mark_STRING_alive(interp, nci_info->sig_str);
172 Parrot_gc_mark_STRING_alive(interp, nci_info->long_signature);
173 Parrot_gc_mark_STRING_alive(interp, nci_info->pcc_params_signature);
174 Parrot_gc_mark_STRING_alive(interp, nci_info->pcc_return_signature);
f631eb3 @plobsing remove private2 (raw) flag from nci-ffi.pmc
plobsing authored
175 }
176 }
177
178 /*
179
c64e58f pmc docs update 3
Michael Scott authored
180 =item C<PMC *clone()>
181
182 Creates and returns a clone of the NCI.
183
184 =cut
185
186 */
187
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
188 VTABLE PMC *clone() {
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored
189 Parrot_NCI_attributes * const nci_info_self = PARROT_NCI(SELF);
190 Parrot_NCI_attributes *nci_info_ret;
1e5a8ee @plobsing eliminate use of libffi-specific nci.pmc
plobsing authored
191 void *orig_func;
62e3049 @petdance consting, and fixed embedded tabs
petdance authored
192
083213a @Whiteknight start rename of pmc_new to Parrot_pmc_new
Whiteknight authored
193 PMC * const ret = Parrot_pmc_new(INTERP, SELF->vtable->base_type);
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
194 nci_info_ret = PARROT_NCI(ret);
82c7cf6 @chromatic [PMC] Minor cleanups and tidyings.
chromatic authored
195
c64e58f pmc docs update 3
Michael Scott authored
196 /* FIXME if data is malloced (JIT/i386!) then we need
197 * the length of data here, to memcpy it
198 * ManagedStruct or Buffer?
199 */
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored
200 nci_info_ret->func = nci_info_self->func;
3b094c7 @plobsing add NCI.fb_info for frame buffer info
plobsing authored
201 nci_info_ret->fb_info = nci_info_self->fb_info;
811a7df @cotto [PMC] make NCI PMCs use ATTRs, with one temporary workaround for i386…
cotto authored
202 nci_info_ret->orig_func = nci_info_self->orig_func;
1e5a8ee @plobsing eliminate use of libffi-specific nci.pmc
plobsing authored
203 nci_info_ret->signature = nci_info_self->signature;
a90f6d7 @plobsing switch ffi nci.pmc over to standard signature parser
plobsing authored
204 nci_info_ret->sig_str = nci_info_self->sig_str;
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored
205 nci_info_ret->pcc_params_signature = nci_info_self->pcc_params_signature;
9d723e0 @plobsing update NCI signature parsing to emit new (half year old) PCC param an…
plobsing authored
206 nci_info_ret->pcc_return_signature = nci_info_self->pcc_params_signature;
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored
207 nci_info_ret->arity = nci_info_self->arity;
1e5a8ee @plobsing eliminate use of libffi-specific nci.pmc
plobsing authored
208 PObj_get_FLAGS(ret) = PObj_get_FLAGS(SELF);
82c7cf6 @chromatic [PMC] Minor cleanups and tidyings.
chromatic authored
209
c64e58f pmc docs update 3
Michael Scott authored
210 return ret;
2a2c19b Added in code to properly do native calls to library routines loaded via
Dan Sugalski authored
211 }
212
c64e58f pmc docs update 3
Michael Scott authored
213 /*
214
215 =item C<INTVAL defined()>
216
217 Returns whether the NCI is defined.
218
219 =cut
220
221 */
222
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
223 VTABLE INTVAL defined() {
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored
224 Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
8832378 @chromatic [PMC] Delayed NCI thunk initialization until absolutely necessary. This
chromatic authored
225 return nci_info->orig_func != NULL;
2a2c19b Added in code to properly do native calls to library routines loaded via
Dan Sugalski authored
226 }
227
c64e58f pmc docs update 3
Michael Scott authored
228 /*
229
0ae5d55 @paultcochrane Patch courtesy of Steve Peters <steve at fisharerojo dot org>, his co…
paultcochrane authored
230 =item C<opcode_t *invoke(void *next)>
c64e58f pmc docs update 3
Michael Scott authored
231
8832378 @chromatic [PMC] Delayed NCI thunk initialization until absolutely necessary. This
chromatic authored
232 Calls the associated C function, returning C<*next>. If the invocant is a
233 class, the PMC arguments are shifted down.
c64e58f pmc docs update 3
Michael Scott authored
234
235 =cut
236
237 */
238
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
239 VTABLE opcode_t *invoke(void *next) {
1e5a8ee @plobsing eliminate use of libffi-specific nci.pmc
plobsing authored
240 Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
241 nci_thunk_t func;
242 PMC *fb_info;
bbd8ef4 @cotto [strings] first of many patches from darbelo++ getting rid of ->strst…
cotto authored
243 char *sig_str;
1e5a8ee @plobsing eliminate use of libffi-specific nci.pmc
plobsing authored
244 void *orig_func;
811a7df @cotto [PMC] make NCI PMCs use ATTRs, with one temporary workaround for i386…
cotto authored
245 PMC *cont;
1e5a8ee @plobsing eliminate use of libffi-specific nci.pmc
plobsing authored
246
247 GET_ATTR_orig_func(INTERP, SELF, orig_func);
248 func = (nci_thunk_t)D2FPTR(nci_info->func);
249
250 if (!func) {
c64fa8d @plobsing split NCI signature parser out from nci.pmc
plobsing authored
251 /* build the thunk only when necessary */
1e5a8ee @plobsing eliminate use of libffi-specific nci.pmc
plobsing authored
252 func = build_func(interp, nci_info);
82c7cf6 @chromatic [PMC] Minor cleanups and tidyings.
chromatic authored
253
1e5a8ee @plobsing eliminate use of libffi-specific nci.pmc
plobsing authored
254 if (!func)
c64fa8d @plobsing split NCI signature parser out from nci.pmc
plobsing authored
255 Parrot_ex_throw_from_c_args(INTERP, NULL,
256 EXCEPTION_INVALID_OPERATION,
257 "attempt to call NULL function");
8832378 @chromatic [PMC] Delayed NCI thunk initialization until absolutely necessary. This
chromatic authored
258 }
2646951 @tewk [gsoc_nci] gsoc_nci_001 merge
tewk authored
259
1e5a8ee @plobsing eliminate use of libffi-specific nci.pmc
plobsing authored
260 GET_ATTR_fb_info(INTERP, SELF, fb_info);
f631eb3 @plobsing remove private2 (raw) flag from nci-ffi.pmc
plobsing authored
261
1e5a8ee @plobsing eliminate use of libffi-specific nci.pmc
plobsing authored
262 func(INTERP, SELF, fb_info);
92c390d Fix tailcalls to NCI, #38724
Leopold Toetsch authored
263 cont = INTERP->current_cont;
82c7cf6 @chromatic [PMC] Minor cleanups and tidyings.
chromatic authored
264
8838c7f builtins 1 - first shot
Leopold Toetsch authored
265 /*
92c390d Fix tailcalls to NCI, #38724
Leopold Toetsch authored
266 * If the NCI function was tailcalled, the return result
267 * is already passed back to the caller of this frame
268 * - see Parrot_init_ret_nci(). We therefore invoke the
269 * return continuation here, which gets rid of this frame
270 * and returns the real return address
8838c7f builtins 1 - first shot
Leopold Toetsch authored
271 */
8832378 @chromatic [PMC] Delayed NCI thunk initialization until absolutely necessary. This
chromatic authored
272 if (cont && cont != NEED_CONTINUATION
273 && (PObj_get_FLAGS(cont) & SUB_FLAG_TAILCALL)) {
540d4c3 @bacek Merge context_pmc3 branch into trunk.
bacek authored
274 cont = Parrot_pcc_get_continuation(interp, CURRENT_CONTEXT(interp));
92c390d Fix tailcalls to NCI, #38724
Leopold Toetsch authored
275 next = VTABLE_invoke(INTERP, cont, next);
276 }
82c7cf6 @chromatic [PMC] Minor cleanups and tidyings.
chromatic authored
277
e063e49 @chromatic Continuing Parrot/C++ cleanups (Steve Peters, RT #42746).
chromatic authored
278 return (opcode_t *)next;
2a2c19b Added in code to properly do native calls to library routines loaded via
Dan Sugalski authored
279 }
380c0ba fix NCI related DOD problem
Leopold Toetsch authored
280
c64e58f pmc docs update 3
Michael Scott authored
281 /*
282
283 =item C<INTVAL get_integer()>
284
285 Returns the function pointer as an integer.
286
287 =cut
288
289 */
290
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
291 VTABLE INTVAL get_integer() {
1e5a8ee @plobsing eliminate use of libffi-specific nci.pmc
plobsing authored
292 Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
293 if (!nci_info->func)
294 build_func(INTERP, nci_info);
295 return (INTVAL)nci_info->func;
3168931 Forth can now generate code for words on the fly and execute them.
Dan Sugalski authored
296 }
297
f35b03c @rubys Initial support for sort
rubys authored
298 /*
299
300 =item C<INTVAL get_bool()>
301
302 Returns the boolean value of the pointer.
303
304 =cut
305
306 */
307
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
308 VTABLE INTVAL get_bool() {
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored
309 Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
1e5a8ee @plobsing eliminate use of libffi-specific nci.pmc
plobsing authored
310 return (0 != (INTVAL)nci_info->orig_func);
f35b03c @rubys Initial support for sort
rubys authored
311 }
312
6586a2c @jnthn Implement arity method on NCI PMCs, plus a test for it.
jnthn authored
313 /*
314
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
315 =item C<METHOD arity()>
6586a2c @jnthn Implement arity method on NCI PMCs, plus a test for it.
jnthn authored
316
01e804c @Util [pmc] Typo corrections
Util authored
317 Return the arity of the NCI (the number of arguments).
6586a2c @jnthn Implement arity method on NCI PMCs, plus a test for it.
jnthn authored
318
319 =cut
320
321 */
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
322 METHOD arity() {
971e997 @NotFound rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
NotFound authored
323 Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
48d2796 @NotFound Another unreachable warning, codingstd in jit_emit ppc
NotFound authored
324 INTVAL arity = 0;
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
325
8832378 @chromatic [PMC] Delayed NCI thunk initialization until absolutely necessary. This
chromatic authored
326 if (nci_info) {
1e5a8ee @plobsing eliminate use of libffi-specific nci.pmc
plobsing authored
327 if (!nci_info->func)
328 build_func(INTERP, nci_info);
329 if (nci_info->func) {
c64fa8d @plobsing split NCI signature parser out from nci.pmc
plobsing authored
330 arity = nci_info->arity;
331 RETURN(INTVAL arity);
8832378 @chromatic [PMC] Delayed NCI thunk initialization until absolutely necessary. This
chromatic authored
332 }
333 }
6586a2c @jnthn Implement arity method on NCI PMCs, plus a test for it.
jnthn authored
334
8832378 @chromatic [PMC] Delayed NCI thunk initialization until absolutely necessary. This
chromatic authored
335 Parrot_ex_throw_from_c_args(INTERP, NULL,
336 EXCEPTION_INVALID_OPERATION,
337 "You cannot get the arity of an undefined NCI.");
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored
338 }
2a2c19b Added in code to properly do native calls to library routines loaded via
Dan Sugalski authored
339 }
c64e58f pmc docs update 3
Michael Scott authored
340
341 /*
342
343 =back
344
345 =head1 SEE ALSO
346
1e5a8ee @plobsing eliminate use of libffi-specific nci.pmc
plobsing authored
347 F<docs/pdds/pdd03_calling_conventions.pod>.
f631eb3 @plobsing remove private2 (raw) flag from nci-ffi.pmc
plobsing authored
348
c64e58f pmc docs update 3
Michael Scott authored
349 =cut
350
351 */
352
0eb3eb3 added formatting footer and detabbed
Michael Scott authored
353 /*
354 * Local variables:
72575ae @bschmalhofer #40481: [PATCH] C-code coda in pmc files
bschmalhofer authored
355 * c-file-style: "parrot"
0eb3eb3 added formatting footer and detabbed
Michael Scott authored
356 * End:
357 * vim: expandtab shiftwidth=4:
72575ae @bschmalhofer #40481: [PATCH] C-code coda in pmc files
bschmalhofer authored
358 */
Something went wrong with that request. Please try again.