Skip to content
This repository
Newer
Older
100644 440 lines (325 sloc) 11.786 kb
c64e58f7 »
2004-02-17 pmc docs update 3
1 /*
8832378c »
2009-08-20 [PMC] Delayed NCI thunk initialization until absolutely necessary. This
2 Copyright (C) 2001-2009, Parrot Foundation.
c64e58f7 »
2004-02-17 pmc docs update 3
3 $Id$
4
5 =head1 NAME
6
f474cd7f »
2006-01-18 [perl #38235] Rename (dyn)?classes to (dyn)?pmc
7 src/pmc/nci.pmc - Native Call Interface
c64e58f7 »
2004-02-17 pmc docs update 3
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 */
2a2c19b1 »
2002-11-21 Added in code to properly do native calls to library routines loaded via
20
811a7df5 »
2009-02-21 [PMC] make NCI PMCs use ATTRs, with one temporary workaround for i386…
21 typedef INTVAL (*nci_sub_t)(PARROT_INTERP, PMC *);
22 typedef INTVAL (*nci_jit_sub_t)(PARROT_INTERP, PMC *, char *);
23
695afac1 »
2009-08-16 fix codetest failure - line length in src/pmc/nci.pmc
24 void pcc_params(PARROT_INTERP, STRING *sig, Parrot_NCI_attributes * const nci_info,
25 size_t sig_length);
26 void pcc_params(PARROT_INTERP, STRING *sig, Parrot_NCI_attributes * const nci_info,
27 size_t sig_length) {
1764f4cd »
2009-08-16 [PMC] Optimized NCI registration signature handling slightly by avoiding
28 char param_buf[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
29 char *param_sig = sig_length <= 7
30 ? param_buf
31 : mem_allocate_n_typed(sig_length, char);
32 size_t j = 0;
c99ac3c6 »
2009-05-20 [PMC] Avoided some relatively expensive C string conversions and mall…
33 size_t i;
34
35 for (i = 1; i < sig_length; i++) {
36 INTVAL c = Parrot_str_indexed(interp, sig, i);
37
38 switch (c) {
8a70f138 »
2009-12-06 [cage] improve C indentation, see TT #1329
39 case (INTVAL)'0': /* null ptr or such - doesn't consume a reg */
40 break;
41 case (INTVAL)'f':
42 case (INTVAL)'N':
43 case (INTVAL)'d':
44 param_sig[j++] = 'N';
45 break;
46 case (INTVAL)'I': /* INTVAL */
47 case (INTVAL)'l': /* long */
48 case (INTVAL)'i': /* int */
49 case (INTVAL)'s': /* short */
50 case (INTVAL)'c': /* char */
51 param_sig[j++] = 'I';
52 break;
53 case (INTVAL)'S':
54 case (INTVAL)'t': /* string, pass a cstring */
55 param_sig[j++] = 'S';
56 break;
57 case (INTVAL)'J': /* interpreter */
58 break;
59 case (INTVAL)'p': /* push pmc->data */
60 case (INTVAL)'O': /* push PMC * object in P2 */
61 case (INTVAL)'P': /* push PMC * */
62 case (INTVAL)'V': /* push PMC * */
63 param_sig[j++] = 'P';
64 case (INTVAL)'v':
65 break;
66 /* I have no idea how to handle these */
67 case (INTVAL)'2':
68 case (INTVAL)'3':
69 case (INTVAL)'4':
70 param_sig[j++] = 'I';
71 break;
72 case (INTVAL)'@':
73 param_sig[j++] = '@';
74 break;
75 case (INTVAL)'b': /* buffer (void*) pass Buffer_bufstart(SReg) */
76 case (INTVAL)'B': /* buffer (void**) pass &Buffer_bufstart(SReg) */
77 param_sig[j++] = 'S';
78 break;
79 default:
80 if (sig_length > 7)
81 mem_sys_free(param_sig);
82 Parrot_ex_throw_from_c_args(interp, NULL,
c99ac3c6 »
2009-05-20 [PMC] Avoided some relatively expensive C string conversions and mall…
83 EXCEPTION_JIT_ERROR,
84 "Unknown param Signature %c\n", (char)c);
8a70f138 »
2009-12-06 [cage] improve C indentation, see TT #1329
85 break;
26469515 »
2008-08-22 [gsoc_nci] gsoc_nci_001 merge
86 }
c99ac3c6 »
2009-05-20 [PMC] Avoided some relatively expensive C string conversions and mall…
87 }
26469515 »
2008-08-22 [gsoc_nci] gsoc_nci_001 merge
88
c99ac3c6 »
2009-05-20 [PMC] Avoided some relatively expensive C string conversions and mall…
89 PARROT_ASSERT(j <= sig_length);
26469515 »
2008-08-22 [gsoc_nci] gsoc_nci_001 merge
90
c99ac3c6 »
2009-05-20 [PMC] Avoided some relatively expensive C string conversions and mall…
91 /* use only the signature-significant part of the string buffer */
92 if (j) {
93 nci_info->pcc_params_signature = string_make(interp, param_sig, j,
94 NULL, PObj_constant_FLAG);
26469515 »
2008-08-22 [gsoc_nci] gsoc_nci_001 merge
95 }
c99ac3c6 »
2009-05-20 [PMC] Avoided some relatively expensive C string conversions and mall…
96 else
97 nci_info->pcc_params_signature = CONST_STRING(interp, "");
98
1764f4cd »
2009-08-16 [PMC] Optimized NCI registration signature handling slightly by avoiding
99 if (sig_length > 7)
100 mem_sys_free(param_sig);
c99ac3c6 »
2009-05-20 [PMC] Avoided some relatively expensive C string conversions and mall…
101 }
26469515 »
2008-08-22 [gsoc_nci] gsoc_nci_001 merge
102
8832378c »
2009-08-20 [PMC] Delayed NCI thunk initialization until absolutely necessary. This
103 /* actually build the NCI thunk */
104 static nci_sub_t build_func(PARROT_INTERP, PMC *, Parrot_NCI_attributes *);
105
106 static
107 nci_sub_t build_func(PARROT_INTERP, PMC *pmc, Parrot_NCI_attributes *nci_info)
108 {
109 STRING *key = nci_info->signature;
110 size_t key_length = Parrot_str_byte_length(interp, key);
111 int jitted = 0;
112
113 pcc_params(interp, key, nci_info, key_length);
114
115 /* Arity is length of that string minus one (the return type). */
116 nci_info->arity = key_length - 1;
117
118 /* Build call function. */
02001b8a »
2009-08-21 [cage] fix c++ build
119 nci_info->func = (PMC *)(build_call_func(interp, pmc, key, &jitted));
8832378c »
2009-08-20 [PMC] Delayed NCI thunk initialization until absolutely necessary. This
120 nci_info->jitted = jitted;
121
02001b8a »
2009-08-21 [cage] fix c++ build
122 return (nci_sub_t)nci_info->func;
8832378c »
2009-08-20 [PMC] Delayed NCI thunk initialization until absolutely necessary. This
123 }
124
26469515 »
2008-08-22 [gsoc_nci] gsoc_nci_001 merge
125
6b817608 »
2009-08-23 [pmc] we don't need need_ext anymore, so BALEETED
126 pmclass NCI auto_attrs {
26469515 »
2008-08-22 [gsoc_nci] gsoc_nci_001 merge
127 ATTR STRING *signature; /* The signature. */
9ed2bdcf »
2009-05-14 [MMD] Changed MULTI initialization to delay generating type typles of…
128 ATTR void *func; /* Function pointer to call. */
129 ATTR void *orig_func; /* Function pointer
130 * used to create func */
26469515 »
2008-08-22 [gsoc_nci] gsoc_nci_001 merge
131 ATTR STRING *pcc_params_signature; /* The signature. */
9ed2bdcf »
2009-05-14 [MMD] Changed MULTI initialization to delay generating type typles of…
132 ATTR STRING *long_signature; /* The full signature. */
133 ATTR PMC *multi_sig; /* type tuple array (?) */
26469515 »
2008-08-22 [gsoc_nci] gsoc_nci_001 merge
134 ATTR INTVAL arity; /* Cached arity of the NCI. */
135 ATTR INTVAL jitted; /* Is this a jitted NCI stub. */
2a2c19b1 »
2002-11-21 Added in code to properly do native calls to library routines loaded via
136
c64e58f7 »
2004-02-17 pmc docs update 3
137 /*
138
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
139 =item C<METHOD get_multisig()>
1415cdab »
2006-03-21 add introspection method get_multisig
140
141 Return the MMD signature PMC, if any or a Null PMC.
142
143 =cut
144
145 */
146
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
147 METHOD get_multisig() {
26f7d7ba »
2009-02-19 [PMC] replace PMC_pmc_val with an ATTR in the NCI PMC
148 PMC *sig;
149 GET_ATTR_multi_sig(INTERP, SELF, sig);
83dd9f26 »
2009-05-18 [core] partial fix for TT #667, examples/namespace/namespace_dump.pir…
150 if (PMC_IS_NULL(sig))
26f7d7ba »
2009-02-19 [PMC] replace PMC_pmc_val with an ATTR in the NCI PMC
151 sig = PMCNULL;
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
152 RETURN(PMC *sig);
1415cdab »
2006-03-21 add introspection method get_multisig
153 }
154
155 /*
156
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
157 =item C<METHOD set_raw_nci_ptr(void *func)>
d1c84dd6 »
2007-01-17 [IMCC] added full calling conventions to C PMC methods.
158
159 Sets the specified function pointer and raw flag.
160
161 =cut
162
163 */
164
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
165 METHOD make_raw_nci(PMC *func) {
166 VTABLE_set_pointer(interp, SELF, (void *)func);
d1c84dd6 »
2007-01-17 [IMCC] added full calling conventions to C PMC methods.
167 }
168
169 /*
170
c64e58f7 »
2004-02-17 pmc docs update 3
171 =item C<void init()>
172
173 Initializes the NCI with a C<NULL> function pointer.
174
175 =cut
176
177 */
178
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
179 VTABLE void init() {
637246fc »
2007-12-15 Refactor the NCI PMC to have an underlying structure, in preparation …
180 /* Mark that we're not a raw NCI. */
d1c84dd6 »
2007-01-17 [IMCC] added full calling conventions to C PMC methods.
181 PObj_flag_CLEAR(private2, SELF);
26469515 »
2008-08-22 [gsoc_nci] gsoc_nci_001 merge
182 PObj_custom_mark_SET(SELF);
f7fc86b0 »
2003-01-21 nci
183 }
184
c64e58f7 »
2004-02-17 pmc docs update 3
185 /*
186
380c0ba5 »
2004-05-07 fix NCI related DOD problem
187 =item C<void set_pointer_keyed_str(STRING *key, void *func)>
c64e58f7 »
2004-02-17 pmc docs update 3
188
380c0ba5 »
2004-05-07 fix NCI related DOD problem
189 Sets the specified function pointer and signature (C<*key>).
c64e58f7 »
2004-02-17 pmc docs update 3
190
191 =cut
192
193 */
194
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
195 VTABLE void set_pointer(void *ptr) {
811a7df5 »
2009-02-21 [PMC] make NCI PMCs use ATTRs, with one temporary workaround for i386…
196 SET_ATTR_orig_func(INTERP, SELF, ptr);
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
197 PObj_flag_SET(private2, SELF);
198 }
199
4108fd8e »
2009-04-09 [JIT] remove undocumented dependency of jit code on PMC internals, fi…
200 VTABLE void *get_pointer() {
201 return PARROT_NCI(SELF)->orig_func;
202 }
203
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
204 VTABLE void set_pointer_keyed_str(STRING *key, void *func) {
1764f4cd »
2009-08-16 [PMC] Optimized NCI registration signature handling slightly by avoiding
205 Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
637246fc »
2007-12-15 Refactor the NCI PMC to have an underlying structure, in preparation …
206
62e30495 »
2007-12-17 consting, and fixed embedded tabs
207 /* Store the original function and signature. */
811a7df5 »
2009-02-21 [PMC] make NCI PMCs use ATTRs, with one temporary workaround for i386…
208 SET_ATTR_orig_func(INTERP, SELF, func);
c4cd2815 »
2009-05-14 [PMC] Avoided an unnecessary STRING copying and creation in NCI's
209
210 /* ensure that the STRING signature is constant */
211 if (!PObj_constant_TEST(key)) {
8832378c »
2009-08-20 [PMC] Delayed NCI thunk initialization until absolutely necessary. This
212 char * const key_c = Parrot_str_to_cstring(INTERP, key);
213 size_t key_length = Parrot_str_byte_length(interp, key);
214 key = string_make(interp, key_c, key_length,
215 NULL, PObj_constant_FLAG);
c4cd2815 »
2009-05-14 [PMC] Avoided an unnecessary STRING copying and creation in NCI's
216 Parrot_str_free_cstring(key_c);
217 }
218
8832378c »
2009-08-20 [PMC] Delayed NCI thunk initialization until absolutely necessary. This
219 nci_info->signature = key;
26469515 »
2008-08-22 [gsoc_nci] gsoc_nci_001 merge
220 }
03918bc6 »
2008-11-09 [PMC] Fixed a read of unitialized memory in NCI PMC reported by Valgr…
221
26469515 »
2008-08-22 [gsoc_nci] gsoc_nci_001 merge
222 /*
223
224 =item C<void mark()>
225
226 Mark any referenced strings and PMCs.
227
228 =cut
229
230 */
231 VTABLE void mark() {
232 if (PARROT_NCI(SELF)) {
971e9977 »
2008-09-08 rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
233 Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
26469515 »
2008-08-22 [gsoc_nci] gsoc_nci_001 merge
234
18dd1479 »
2009-09-24 [gc] add new mark_... _alive functions, use it in a lot of mark vtabl…
235 Parrot_gc_mark_STRING_alive(interp, nci_info->signature);
236 Parrot_gc_mark_STRING_alive(interp, nci_info->pcc_params_signature);
237 Parrot_gc_mark_STRING_alive(interp, nci_info->long_signature);
238 Parrot_gc_mark_PMC_alive(interp, nci_info->multi_sig);
26469515 »
2008-08-22 [gsoc_nci] gsoc_nci_001 merge
239 }
65bd9bfa »
2003-01-16 eval #1
240 }
11b723d9 »
2002-12-14 fixed memory leak in jitted i386 nci code; clone nci
241
c64e58f7 »
2004-02-17 pmc docs update 3
242 /*
243
244 =item C<PMC *clone()>
245
246 Creates and returns a clone of the NCI.
247
248 =cut
249
250 */
251
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
252 VTABLE PMC *clone() {
971e9977 »
2008-09-08 rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
253 Parrot_NCI_attributes * const nci_info_self = PARROT_NCI(SELF);
254 Parrot_NCI_attributes *nci_info_ret;
811a7df5 »
2009-02-21 [PMC] make NCI PMCs use ATTRs, with one temporary workaround for i386…
255 void *orig_func;
62e30495 »
2007-12-17 consting, and fixed embedded tabs
256
26f7d7ba »
2009-02-19 [PMC] replace PMC_pmc_val with an ATTR in the NCI PMC
257 PMC * const ret = pmc_new(INTERP, SELF->vtable->base_type);
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
258 nci_info_ret = PARROT_NCI(ret);
82c7cf65 »
2007-08-30 [PMC] Minor cleanups and tidyings.
259
c64e58f7 »
2004-02-17 pmc docs update 3
260 /* FIXME if data is malloced (JIT/i386!) then we need
261 * the length of data here, to memcpy it
262 * ManagedStruct or Buffer?
263 */
26469515 »
2008-08-22 [gsoc_nci] gsoc_nci_001 merge
264 nci_info_ret->func = nci_info_self->func;
811a7df5 »
2009-02-21 [PMC] make NCI PMCs use ATTRs, with one temporary workaround for i386…
265 nci_info_ret->orig_func = nci_info_self->orig_func;
26469515 »
2008-08-22 [gsoc_nci] gsoc_nci_001 merge
266 nci_info_ret->signature = nci_info_self->signature;
267 nci_info_ret->pcc_params_signature = nci_info_self->pcc_params_signature;
268 nci_info_ret->arity = nci_info_self->arity;
37fe6392 »
2008-11-09 [PMC] Fixed a memory leak in the NCI PMC introduced in r32463. Also f…
269 nci_info_ret->jitted = nci_info_self->jitted;
4108fd8e »
2009-04-09 [JIT] remove undocumented dependency of jit code on PMC internals, fi…
270 PObj_get_FLAGS(ret) |= (PObj_get_FLAGS(SELF) & 0x7);
82c7cf65 »
2007-08-30 [PMC] Minor cleanups and tidyings.
271
c64e58f7 »
2004-02-17 pmc docs update 3
272 return ret;
2a2c19b1 »
2002-11-21 Added in code to properly do native calls to library routines loaded via
273 }
274
c64e58f7 »
2004-02-17 pmc docs update 3
275 /*
276
277 =item C<INTVAL defined()>
278
279 Returns whether the NCI is defined.
280
281 =cut
282
283 */
284
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
285 VTABLE INTVAL defined() {
971e9977 »
2008-09-08 rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
286 Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
8832378c »
2009-08-20 [PMC] Delayed NCI thunk initialization until absolutely necessary. This
287 return nci_info->orig_func != NULL;
2a2c19b1 »
2002-11-21 Added in code to properly do native calls to library routines loaded via
288 }
289
c64e58f7 »
2004-02-17 pmc docs update 3
290 /*
291
0ae5d554 »
2007-03-30 Patch courtesy of Steve Peters <steve at fisharerojo dot org>, his co…
292 =item C<opcode_t *invoke(void *next)>
c64e58f7 »
2004-02-17 pmc docs update 3
293
8832378c »
2009-08-20 [PMC] Delayed NCI thunk initialization until absolutely necessary. This
294 Calls the associated C function, returning C<*next>. If the invocant is a
295 class, the PMC arguments are shifted down.
c64e58f7 »
2004-02-17 pmc docs update 3
296
297 =cut
298
299 */
300
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
301 VTABLE opcode_t *invoke(void *next) {
811a7df5 »
2009-02-21 [PMC] make NCI PMCs use ATTRs, with one temporary workaround for i386…
302 Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
303 nci_sub_t func;
bbd8ef43 »
2009-09-03 [strings] first of many patches from darbelo++ getting rid of ->strst…
304 char *sig_str;
811a7df5 »
2009-02-21 [PMC] make NCI PMCs use ATTRs, with one temporary workaround for i386…
305 void *orig_func;
306 PMC *cont;
82c7cf65 »
2007-08-30 [PMC] Minor cleanups and tidyings.
307
811a7df5 »
2009-02-21 [PMC] make NCI PMCs use ATTRs, with one temporary workaround for i386…
308 GET_ATTR_orig_func(INTERP, SELF, orig_func);
309 func = PObj_flag_TEST(private2, SELF)
310 ? (nci_sub_t) D2FPTR(orig_func)
637246fc »
2007-12-15 Refactor the NCI PMC to have an underlying structure, in preparation …
311 : (nci_sub_t) D2FPTR(nci_info->func);
82c7cf65 »
2007-08-30 [PMC] Minor cleanups and tidyings.
312
8832378c »
2009-08-20 [PMC] Delayed NCI thunk initialization until absolutely necessary. This
313 if (!func) {
314 /* build the thunk only when necessary */
315 func = build_func(interp, SELF, nci_info);
82c7cf65 »
2007-08-30 [PMC] Minor cleanups and tidyings.
316
8832378c »
2009-08-20 [PMC] Delayed NCI thunk initialization until absolutely necessary. This
317 if (!func)
318 Parrot_ex_throw_from_c_args(INTERP, NULL,
319 EXCEPTION_INVALID_OPERATION,
320 "attempt to call NULL function");
321 }
26469515 »
2008-08-22 [gsoc_nci] gsoc_nci_001 merge
322
8832378c »
2009-08-20 [PMC] Delayed NCI thunk initialization until absolutely necessary. This
323 if (nci_info->jitted) {
26469515 »
2008-08-22 [gsoc_nci] gsoc_nci_001 merge
324 nci_jit_sub_t jit_func = (nci_jit_sub_t) D2FPTR(nci_info->func);
325
326 /* Parrot_eprintf(interp, "JITTED %S\n", nci_info->signature); */
bbd8ef43 »
2009-09-03 [strings] first of many patches from darbelo++ getting rid of ->strst…
327 sig_str = Parrot_str_to_cstring(interp, nci_info->pcc_params_signature);
328 jit_func(INTERP, SELF, sig_str);
329 Parrot_str_free_cstring(sig_str);
26469515 »
2008-08-22 [gsoc_nci] gsoc_nci_001 merge
330 }
331 else {
332 if (PObj_flag_TEST(private2, SELF)) {
333 /* Parrot_eprintf(interp, "RAW NCI CALL\n"); */
334 }
335 else {
336 /* Parrot_eprintf(interp, "HACKED %S\n", nci_info->signature); */
337 }
338 func(INTERP, SELF);
339 }
92c390d5 »
2006-03-14 Fix tailcalls to NCI, #38724
340 cont = INTERP->current_cont;
82c7cf65 »
2007-08-30 [PMC] Minor cleanups and tidyings.
341
8838c7fb »
2005-03-19 builtins 1 - first shot
342 /*
92c390d5 »
2006-03-14 Fix tailcalls to NCI, #38724
343 * If the NCI function was tailcalled, the return result
344 * is already passed back to the caller of this frame
345 * - see Parrot_init_ret_nci(). We therefore invoke the
346 * return continuation here, which gets rid of this frame
347 * and returns the real return address
8838c7fb »
2005-03-19 builtins 1 - first shot
348 */
8832378c »
2009-08-20 [PMC] Delayed NCI thunk initialization until absolutely necessary. This
349 if (cont && cont != NEED_CONTINUATION
350 && (PObj_get_FLAGS(cont) & SUB_FLAG_TAILCALL)) {
540d4c31 »
2009-09-03 Merge context_pmc3 branch into trunk.
351 cont = Parrot_pcc_get_continuation(interp, CURRENT_CONTEXT(interp));
92c390d5 »
2006-03-14 Fix tailcalls to NCI, #38724
352 next = VTABLE_invoke(INTERP, cont, next);
353 }
82c7cf65 »
2007-08-30 [PMC] Minor cleanups and tidyings.
354
e063e497 »
2007-04-26 Continuing Parrot/C++ cleanups (Steve Peters, RT #42746).
355 return (opcode_t *)next;
2a2c19b1 »
2002-11-21 Added in code to properly do native calls to library routines loaded via
356 }
380c0ba5 »
2004-05-07 fix NCI related DOD problem
357
c64e58f7 »
2004-02-17 pmc docs update 3
358 /*
359
360 =item C<INTVAL get_integer()>
361
362 Returns the function pointer as an integer.
363
364 =cut
365
366 */
367
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
368 VTABLE INTVAL get_integer() {
971e9977 »
2008-09-08 rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
369 Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
8832378c »
2009-08-20 [PMC] Delayed NCI thunk initialization until absolutely necessary. This
370 if (!nci_info->func)
371 build_func(INTERP, SELF, nci_info);
637246fc »
2007-12-15 Refactor the NCI PMC to have an underlying structure, in preparation …
372 return (INTVAL)nci_info->func;
3168931a »
2003-10-24 Forth can now generate code for words on the fly and execute them.
373 }
374
f35b03c9 »
2004-12-20 Initial support for sort
375 /*
376
377 =item C<INTVAL get_bool()>
378
379 Returns the boolean value of the pointer.
380
381 =cut
382
383 */
384
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
385 VTABLE INTVAL get_bool() {
971e9977 »
2008-09-08 rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
386 Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
8832378c »
2009-08-20 [PMC] Delayed NCI thunk initialization until absolutely necessary. This
387 return (0 != (INTVAL)nci_info->orig_func);
f35b03c9 »
2004-12-20 Initial support for sort
388 }
389
6586a2ca »
2007-12-15 Implement arity method on NCI PMCs, plus a test for it.
390 /*
391
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
392 =item C<METHOD arity()>
6586a2ca »
2007-12-15 Implement arity method on NCI PMCs, plus a test for it.
393
01e804c8 »
2009-03-13 [pmc] Typo corrections
394 Return the arity of the NCI (the number of arguments).
6586a2ca »
2007-12-15 Implement arity method on NCI PMCs, plus a test for it.
395
396 =cut
397
398 */
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
399 METHOD arity() {
971e9977 »
2008-09-08 rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
400 Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
48d2796f »
2008-07-10 Another unreachable warning, codingstd in jit_emit ppc
401 INTVAL arity = 0;
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
402
8832378c »
2009-08-20 [PMC] Delayed NCI thunk initialization until absolutely necessary. This
403 if (nci_info) {
404 if (!nci_info->func)
405 build_func(INTERP, SELF, nci_info);
406 if (nci_info->func) {
407 arity = nci_info->arity;
408 RETURN(INTVAL arity);
409 }
410 }
6586a2ca »
2007-12-15 Implement arity method on NCI PMCs, plus a test for it.
411
8832378c »
2009-08-20 [PMC] Delayed NCI thunk initialization until absolutely necessary. This
412 Parrot_ex_throw_from_c_args(INTERP, NULL,
413 EXCEPTION_INVALID_OPERATION,
414 "You cannot get the arity of an undefined NCI.");
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
415 }
2a2c19b1 »
2002-11-21 Added in code to properly do native calls to library routines loaded via
416 }
c64e58f7 »
2004-02-17 pmc docs update 3
417
418 /*
419
420 =back
421
422 =head1 SEE ALSO
423
424 F<docs/pdds/pdd03_calling_conventions.pod>.
425
426 =head1 HISTORY
427
428 Initial revision by sean 2002/08/04.
429
430 =cut
431
432 */
433
0eb3eb34 »
2004-02-22 added formatting footer and detabbed
434 /*
435 * Local variables:
72575ae0 »
2006-10-09 #40481: [PATCH] C-code coda in pmc files
436 * c-file-style: "parrot"
0eb3eb34 »
2004-02-22 added formatting footer and detabbed
437 * End:
438 * vim: expandtab shiftwidth=4:
72575ae0 »
2006-10-09 #40481: [PATCH] C-code coda in pmc files
439 */
Something went wrong with that request. Please try again.