Skip to content
This repository
Newer
Older
100644 370 lines (254 sloc) 8.912 kb
c64e58f7 » Michael Scott
2004-02-17 pmc docs update 3
1 /*
c1411da5 » rurban
2012-12-10 [cage] mark and document unused parameters as such
2 Copyright (C) 2001-2012, Parrot Foundation.
c64e58f7 » Michael Scott
2004-02-17 pmc docs update 3
3
4 =head1 NAME
5
f474cd7f » bschmalhofer
2006-01-18 [perl #38235] Rename (dyn)?classes to (dyn)?pmc
6 src/pmc/nci.pmc - Native Call Interface
c64e58f7 » Michael Scott
2004-02-17 pmc docs update 3
7
8 =head1 DESCRIPTION
9
10 The vtable functions for the native C call functions.
11
12 =head2 Methods
13
14 =over 4
15
16 =cut
17
18 */
2a2c19b1 » Dan Sugalski
2002-11-21 Added in code to properly do native calls to library routines loaded via
19
6bdd5f99 » petdance
2010-03-28 headerizer now runs on PMC files
20 /* HEADERIZER HFILE: none */
21 /* HEADERIZER BEGIN: static */
e69d2a4f » petdance
2010-03-30 Made pcc_params be static. Removed unused arg from build_func. Header…
22 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
23
1e5a8ee6 » plobsing
2010-11-01 eliminate use of libffi-specific nci.pmc
24 PARROT_IGNORABLE_RESULT
25 static nci_thunk_t /*@alt void@*/
26 build_func(PARROT_INTERP,
b75e23a1 » bacek
2011-02-03 Write barriering NCI in build_func.
27 ARGIN(PMC *obj),
a90f6d72 » plobsing
2010-10-30 switch ffi nci.pmc over to standard signature parser
28 ARGMOD(Parrot_NCI_attributes *nci))
f631eb3d » plobsing
2010-10-27 remove private2 (raw) flag from nci-ffi.pmc
29 __attribute__nonnull__(1)
30 __attribute__nonnull__(2)
b75e23a1 » bacek
2011-02-03 Write barriering NCI in build_func.
31 __attribute__nonnull__(3)
a90f6d72 » plobsing
2010-10-30 switch ffi nci.pmc over to standard signature parser
32 FUNC_MODIFIES(*nci);
33
1e5a8ee6 » plobsing
2010-11-01 eliminate use of libffi-specific nci.pmc
34 #define ASSERT_ARGS_build_func __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
f631eb3d » plobsing
2010-10-27 remove private2 (raw) flag from nci-ffi.pmc
35 PARROT_ASSERT_ARG(interp) \
b75e23a1 » bacek
2011-02-03 Write barriering NCI in build_func.
36 , PARROT_ASSERT_ARG(obj) \
a90f6d72 » plobsing
2010-10-30 switch ffi nci.pmc over to standard signature parser
37 , PARROT_ASSERT_ARG(nci))
e69d2a4f » petdance
2010-03-30 Made pcc_params be static. Removed unused arg from build_func. Header…
38 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
6bdd5f99 » petdance
2010-03-28 headerizer now runs on PMC files
39 /* HEADERIZER END: static */
40
75d67e7e » plobsing
2010-10-31 avoid rebuilding the pcc cif every call
41 /*
42
b75e23a1 » bacek
2011-02-03 Write barriering NCI in build_func.
43 =item C<static nci_thunk_t build_func(PARROT_INTERP, PMC *obj,
44 Parrot_NCI_attributes *nci)>
75d67e7e » plobsing
2010-10-31 avoid rebuilding the pcc cif every call
45
1e5a8ee6 » plobsing
2010-11-01 eliminate use of libffi-specific nci.pmc
46 Actually build the NCI thunk.
75d67e7e » plobsing
2010-10-31 avoid rebuilding the pcc cif every call
47
48 =cut
49
50 */
51
1e5a8ee6 » plobsing
2010-11-01 eliminate use of libffi-specific nci.pmc
52 PARROT_IGNORABLE_RESULT
53 static nci_thunk_t
b75e23a1 » bacek
2011-02-03 Write barriering NCI in build_func.
54 build_func(PARROT_INTERP, ARGIN(PMC *obj), ARGMOD(Parrot_NCI_attributes *nci))
f631eb3d » plobsing
2010-10-27 remove private2 (raw) flag from nci-ffi.pmc
55 {
1e5a8ee6 » plobsing
2010-11-01 eliminate use of libffi-specific nci.pmc
56 ASSERT_ARGS(build_func)
f631eb3d » plobsing
2010-10-27 remove private2 (raw) flag from nci-ffi.pmc
57
a90f6d72 » plobsing
2010-10-30 switch ffi nci.pmc over to standard signature parser
58 Parrot_nci_sig_to_pcc(interp, nci->signature,
59 &nci->pcc_params_signature,
60 &nci->pcc_return_signature);
f631eb3d » plobsing
2010-10-27 remove private2 (raw) flag from nci-ffi.pmc
61
a90f6d72 » plobsing
2010-10-30 switch ffi nci.pmc over to standard signature parser
62 /* Arity is length of the signature minus one (the return type). */
63 nci->arity = VTABLE_elements(interp, nci->signature) - 1;
f631eb3d » plobsing
2010-10-27 remove private2 (raw) flag from nci-ffi.pmc
64
1e5a8ee6 » plobsing
2010-11-01 eliminate use of libffi-specific nci.pmc
65 /* Build call function. */
c74300b7 » plobsing
2011-03-04 make nci thunk lookup work with signature arrays, not strings
66 nci->fb_info = build_call_func(interp, nci->signature);
1e5a8ee6 » plobsing
2010-11-01 eliminate use of libffi-specific nci.pmc
67 nci->func = F2DPTR(VTABLE_get_pointer(interp, nci->fb_info));
176db42d » bacek
2011-02-16 Move WB after we changed NCI guts.
68 PARROT_GC_WRITE_BARRIER(interp, obj);
1e5a8ee6 » plobsing
2010-11-01 eliminate use of libffi-specific nci.pmc
69
70 return (nci_thunk_t)nci->func;
f631eb3d » plobsing
2010-10-27 remove private2 (raw) flag from nci-ffi.pmc
71 }
72
1e5a8ee6 » plobsing
2010-11-01 eliminate use of libffi-specific nci.pmc
73
336b07ce » bacek
2010-05-16 Add 'does invokable' to all PMCs with VTABLE_invoke (except Object). …
74 pmclass NCI auto_attrs provides invokable {
9d723e0d » plobsing
2010-05-14 update NCI signature parsing to emit new (half year old) PCC param an…
75 /* NCI thunk handling attributes */
1e5a8ee6 » plobsing
2010-11-01 eliminate use of libffi-specific nci.pmc
76 ATTR PMC *signature; /* parsed signature */
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 */
0c5f9c3f » John Harrison
2010-08-17 GSoC: The majority of my NCI changes in 1 commit.
80
9d723e0d » plobsing
2010-05-14 update NCI signature parsing to emit new (half year old) PCC param an…
81 /* Parrot Sub-ish attributes */
82 ATTR STRING *pcc_params_signature;
83 ATTR STRING *pcc_return_signature;
2d5eeb8c » plobsing
2010-10-30 eliminate some unnecessary attributes
84 ATTR INTVAL arity;
9d723e0d » plobsing
2010-05-14 update NCI signature parsing to emit new (half year old) PCC param an…
85
86 /* MMD fields */
1e5a8ee6 » plobsing
2010-11-01 eliminate use of libffi-specific nci.pmc
87 ATTR STRING *long_signature;
88 ATTR PMC *multi_sig;
2a2c19b1 » Dan Sugalski
2002-11-21 Added in code to properly do native calls to library routines loaded via
89
c64e58f7 » Michael Scott
2004-02-17 pmc docs update 3
90 /*
91
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
92 =item C<METHOD get_multisig()>
1415cdab » Leopold Toetsch
2006-03-21 add introspection method get_multisig
93
1e5a8ee6 » plobsing
2010-11-01 eliminate use of libffi-specific nci.pmc
94 Return the MMD signature PMC, if any or C<PMCNULL>.
1415cdab » Leopold Toetsch
2006-03-21 add introspection method get_multisig
95
96 =cut
97
98 */
99
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
100 METHOD get_multisig() {
26f7d7ba » cotto
2009-02-19 [PMC] replace PMC_pmc_val with an ATTR in the NCI PMC
101 PMC *sig;
102 GET_ATTR_multi_sig(INTERP, SELF, sig);
83dd9f26 » NotFound
2009-05-18 [core] partial fix for TT #667, examples/namespace/namespace_dump.pir…
103 if (PMC_IS_NULL(sig))
26f7d7ba » cotto
2009-02-19 [PMC] replace PMC_pmc_val with an ATTR in the NCI PMC
104 sig = PMCNULL;
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
105 RETURN(PMC *sig);
1415cdab » Leopold Toetsch
2006-03-21 add introspection method get_multisig
106 }
107
108 /*
109
c64e58f7 » Michael Scott
2004-02-17 pmc docs update 3
110 =item C<void init()>
111
112 Initializes the NCI with a C<NULL> function pointer.
113
114 =cut
115
116 */
117
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
118 VTABLE void init() {
c1411da5 » rurban
2012-12-10 [cage] mark and document unused parameters as such
119 UNUSED(INTERP)
26469515 » tewk
2008-08-22 [gsoc_nci] gsoc_nci_001 merge
120 PObj_custom_mark_SET(SELF);
f7fc86b0 » Leopold Toetsch
2003-01-21 nci
121 }
122
1e5a8ee6 » plobsing
2010-11-01 eliminate use of libffi-specific nci.pmc
123 VTABLE void *get_pointer() {
c1411da5 » rurban
2012-12-10 [cage] mark and document unused parameters as such
124 UNUSED(INTERP)
1e5a8ee6 » plobsing
2010-11-01 eliminate use of libffi-specific nci.pmc
125 return PARROT_NCI(SELF)->orig_func;
126 }
127
c64e58f7 » Michael Scott
2004-02-17 pmc docs update 3
128 /*
129
73ef4d04 » plobsing
2011-04-25 add interface to allow creation of NCI objects from Ptr objects from HLL
130 =item C<void set_pmc_keyed(PMC *key, PMC *p)>
131
132 =item C<void set_pmc_keyed_str(STRING *key, PMC *p)>
133
134 Call the equivalent C<set_pointer*> function.
135
136 =cut
137
138 */
139
140 VTABLE void set_pmc_keyed(PMC *key, PMC *p) {
141 STATICSELF.set_pointer_keyed(key, VTABLE_get_pointer(INTERP, p));
142 }
143
144 VTABLE void set_pmc_keyed_str(STRING *key, PMC *p) {
145 STATICSELF.set_pointer_keyed_str(key, VTABLE_get_pointer(INTERP, p));
146 }
147
148 /*
149
c5334d6f » plobsing
2011-03-04 eliminate handling of string signatures within NCI objects
150 =item C<void set_pointer_keyed(PMC *key, void *func)>
c64e58f7 » Michael Scott
2004-02-17 pmc docs update 3
151
380c0ba5 » Leopold Toetsch
2004-05-07 fix NCI related DOD problem
152 Sets the specified function pointer and signature (C<*key>).
c64e58f7 » Michael Scott
2004-02-17 pmc docs update 3
153
c5334d6f » plobsing
2011-03-04 eliminate handling of string signatures within NCI objects
154 =item C<void set_pointer_keyed_str(STRING *key, void *func)>
155
156 Sets the specified function pointer and siganture as described in the string C<key>.
157
c64e58f7 » Michael Scott
2004-02-17 pmc docs update 3
158 =cut
159
160 */
161
c5334d6f » plobsing
2011-03-04 eliminate handling of string signatures within NCI objects
162 VTABLE void set_pointer_keyed(PMC *key, void *func) {
62e30495 » petdance
2007-12-17 consting, and fixed embedded tabs
163 /* Store the original function and signature. */
1e5a8ee6 » plobsing
2010-11-01 eliminate use of libffi-specific nci.pmc
164 SET_ATTR_orig_func(INTERP, SELF, func);
c5334d6f » plobsing
2011-03-04 eliminate handling of string signatures within NCI objects
165 SET_ATTR_signature(INTERP, SELF, key);
166 }
c4cd2815 » chromatic
2009-05-14 [PMC] Avoided an unnecessary STRING copying and creation in NCI's
167
c5334d6f » plobsing
2011-03-04 eliminate handling of string signatures within NCI objects
168 VTABLE void set_pointer_keyed_str(STRING *key, void *func) {
169 SELF.set_pointer_keyed(Parrot_nci_parse_signature(INTERP, key), func);
26469515 » tewk
2008-08-22 [gsoc_nci] gsoc_nci_001 merge
170 }
03918bc6 » chromatic
2008-11-09 [PMC] Fixed a read of unitialized memory in NCI PMC reported by Valgr…
171
26469515 » tewk
2008-08-22 [gsoc_nci] gsoc_nci_001 merge
172 /*
173
174 =item C<void mark()>
175
176 Mark any referenced strings and PMCs.
177
178 =cut
179
180 */
181 VTABLE void mark() {
1e5a8ee6 » plobsing
2010-11-01 eliminate use of libffi-specific nci.pmc
182 if (PARROT_NCI(SELF)) {
183 Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
f631eb3d » plobsing
2010-10-27 remove private2 (raw) flag from nci-ffi.pmc
184
1e5a8ee6 » plobsing
2010-11-01 eliminate use of libffi-specific nci.pmc
185 Parrot_gc_mark_PMC_alive(interp, nci_info->signature);
186 Parrot_gc_mark_PMC_alive(interp, nci_info->fb_info);
187 Parrot_gc_mark_PMC_alive(interp, nci_info->multi_sig);
f631eb3d » plobsing
2010-10-27 remove private2 (raw) flag from nci-ffi.pmc
188
1e5a8ee6 » plobsing
2010-11-01 eliminate use of libffi-specific nci.pmc
189 Parrot_gc_mark_STRING_alive(interp, nci_info->long_signature);
190 Parrot_gc_mark_STRING_alive(interp, nci_info->pcc_params_signature);
191 Parrot_gc_mark_STRING_alive(interp, nci_info->pcc_return_signature);
f631eb3d » plobsing
2010-10-27 remove private2 (raw) flag from nci-ffi.pmc
192 }
193 }
194
195 /*
196
c64e58f7 » Michael Scott
2004-02-17 pmc docs update 3
197 =item C<PMC *clone()>
198
199 Creates and returns a clone of the NCI.
200
201 =cut
202
203 */
204
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
205 VTABLE PMC *clone() {
971e9977 » NotFound
2008-09-08 rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
206 Parrot_NCI_attributes * const nci_info_self = PARROT_NCI(SELF);
62e30495 » petdance
2007-12-17 consting, and fixed embedded tabs
207
083213a2 » Whiteknight
2010-02-16 start rename of pmc_new to Parrot_pmc_new
208 PMC * const ret = Parrot_pmc_new(INTERP, SELF->vtable->base_type);
f1c9ca5c » petdance
2011-02-27 consting pointers and localizing temp vars
209 Parrot_NCI_attributes * const nci_info_ret = PARROT_NCI(ret);
82c7cf65 » chromatic
2007-08-30 [PMC] Minor cleanups and tidyings.
210
c64e58f7 » Michael Scott
2004-02-17 pmc docs update 3
211 /* FIXME if data is malloced (JIT/i386!) then we need
212 * the length of data here, to memcpy it
213 * ManagedStruct or Buffer?
214 */
26469515 » tewk
2008-08-22 [gsoc_nci] gsoc_nci_001 merge
215 nci_info_ret->func = nci_info_self->func;
3b094c73 » plobsing
2010-03-23 add NCI.fb_info for frame buffer info
216 nci_info_ret->fb_info = nci_info_self->fb_info;
811a7df5 » cotto
2009-02-21 [PMC] make NCI PMCs use ATTRs, with one temporary workaround for i386…
217 nci_info_ret->orig_func = nci_info_self->orig_func;
1e5a8ee6 » plobsing
2010-11-01 eliminate use of libffi-specific nci.pmc
218 nci_info_ret->signature = nci_info_self->signature;
26469515 » tewk
2008-08-22 [gsoc_nci] gsoc_nci_001 merge
219 nci_info_ret->pcc_params_signature = nci_info_self->pcc_params_signature;
9d723e0d » plobsing
2010-05-14 update NCI signature parsing to emit new (half year old) PCC param an…
220 nci_info_ret->pcc_return_signature = nci_info_self->pcc_params_signature;
26469515 » tewk
2008-08-22 [gsoc_nci] gsoc_nci_001 merge
221 nci_info_ret->arity = nci_info_self->arity;
1e5a8ee6 » plobsing
2010-11-01 eliminate use of libffi-specific nci.pmc
222 PObj_get_FLAGS(ret) = PObj_get_FLAGS(SELF);
82c7cf65 » chromatic
2007-08-30 [PMC] Minor cleanups and tidyings.
223
c64e58f7 » Michael Scott
2004-02-17 pmc docs update 3
224 return ret;
2a2c19b1 » Dan Sugalski
2002-11-21 Added in code to properly do native calls to library routines loaded via
225 }
226
c64e58f7 » Michael Scott
2004-02-17 pmc docs update 3
227 /*
228
229 =item C<INTVAL defined()>
230
231 Returns whether the NCI is defined.
232
233 =cut
234
235 */
236
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
237 VTABLE INTVAL defined() {
c1411da5 » rurban
2012-12-10 [cage] mark and document unused parameters as such
238 UNUSED(INTERP)
776e9da5 » petdance
2011-03-06 consting and removing unused var
239 const Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
8832378c » chromatic
2009-08-20 [PMC] Delayed NCI thunk initialization until absolutely necessary. This
240 return nci_info->orig_func != NULL;
2a2c19b1 » Dan Sugalski
2002-11-21 Added in code to properly do native calls to library routines loaded via
241 }
242
c64e58f7 » Michael Scott
2004-02-17 pmc docs update 3
243 /*
244
0ae5d554 » paultcochrane
2007-03-30 Patch courtesy of Steve Peters <steve at fisharerojo dot org>, his co…
245 =item C<opcode_t *invoke(void *next)>
c64e58f7 » Michael Scott
2004-02-17 pmc docs update 3
246
8832378c » chromatic
2009-08-20 [PMC] Delayed NCI thunk initialization until absolutely necessary. This
247 Calls the associated C function, returning C<*next>. If the invocant is a
248 class, the PMC arguments are shifted down.
c64e58f7 » Michael Scott
2004-02-17 pmc docs update 3
249
250 =cut
251
252 */
253
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
254 VTABLE opcode_t *invoke(void *next) {
1e5a8ee6 » plobsing
2010-11-01 eliminate use of libffi-specific nci.pmc
255 Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
256 nci_thunk_t func;
257 PMC *fb_info;
811a7df5 » cotto
2009-02-21 [PMC] make NCI PMCs use ATTRs, with one temporary workaround for i386…
258 PMC *cont;
1e5a8ee6 » plobsing
2010-11-01 eliminate use of libffi-specific nci.pmc
259
260 func = (nci_thunk_t)D2FPTR(nci_info->func);
261
262 if (!func) {
c64fa8d3 » plobsing
2010-10-27 split NCI signature parser out from nci.pmc
263 /* build the thunk only when necessary */
b75e23a1 » bacek
2011-02-03 Write barriering NCI in build_func.
264 func = build_func(interp, SELF, nci_info);
82c7cf65 » chromatic
2007-08-30 [PMC] Minor cleanups and tidyings.
265
1e5a8ee6 » plobsing
2010-11-01 eliminate use of libffi-specific nci.pmc
266 if (!func)
c64fa8d3 » plobsing
2010-10-27 split NCI signature parser out from nci.pmc
267 Parrot_ex_throw_from_c_args(INTERP, NULL,
268 EXCEPTION_INVALID_OPERATION,
269 "attempt to call NULL function");
8832378c » chromatic
2009-08-20 [PMC] Delayed NCI thunk initialization until absolutely necessary. This
270 }
26469515 » tewk
2008-08-22 [gsoc_nci] gsoc_nci_001 merge
271
1e5a8ee6 » plobsing
2010-11-01 eliminate use of libffi-specific nci.pmc
272 GET_ATTR_fb_info(INTERP, SELF, fb_info);
f631eb3d » plobsing
2010-10-27 remove private2 (raw) flag from nci-ffi.pmc
273
92c390d5 » Leopold Toetsch
2006-03-14 Fix tailcalls to NCI, #38724
274 cont = INTERP->current_cont;
8b188dbb » Whiteknight
2011-01-05 Fix for TT #1029. The return continuation was being mangled in the PI…
275 func(INTERP, SELF, fb_info);
276
8838c7fb » Leopold Toetsch
2005-03-19 builtins 1 - first shot
277 /*
92c390d5 » Leopold Toetsch
2006-03-14 Fix tailcalls to NCI, #38724
278 * If the NCI function was tailcalled, the return result
279 * is already passed back to the caller of this frame
280 * - see Parrot_init_ret_nci(). We therefore invoke the
281 * return continuation here, which gets rid of this frame
282 * and returns the real return address
8838c7fb » Leopold Toetsch
2005-03-19 builtins 1 - first shot
283 */
2caf6ce7 » bacek
2012-02-21 Kill NEED_CONTINUATION ugly hack.
284 if (!PMC_IS_NULL(cont)
8832378c » chromatic
2009-08-20 [PMC] Delayed NCI thunk initialization until absolutely necessary. This
285 && (PObj_get_FLAGS(cont) & SUB_FLAG_TAILCALL)) {
540d4c31 » bacek
2009-09-03 Merge context_pmc3 branch into trunk.
286 cont = Parrot_pcc_get_continuation(interp, CURRENT_CONTEXT(interp));
92c390d5 » Leopold Toetsch
2006-03-14 Fix tailcalls to NCI, #38724
287 next = VTABLE_invoke(INTERP, cont, next);
288 }
82c7cf65 » chromatic
2007-08-30 [PMC] Minor cleanups and tidyings.
289
e063e497 » chromatic
2007-04-26 Continuing Parrot/C++ cleanups (Steve Peters, RT #42746).
290 return (opcode_t *)next;
2a2c19b1 » Dan Sugalski
2002-11-21 Added in code to properly do native calls to library routines loaded via
291 }
380c0ba5 » Leopold Toetsch
2004-05-07 fix NCI related DOD problem
292
c64e58f7 » Michael Scott
2004-02-17 pmc docs update 3
293 /*
294
295 =item C<INTVAL get_integer()>
296
297 Returns the function pointer as an integer.
298
299 =cut
300
301 */
302
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
303 VTABLE INTVAL get_integer() {
1e5a8ee6 » plobsing
2010-11-01 eliminate use of libffi-specific nci.pmc
304 Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
305 if (!nci_info->func)
b75e23a1 » bacek
2011-02-03 Write barriering NCI in build_func.
306 build_func(INTERP, SELF, nci_info);
1e5a8ee6 » plobsing
2010-11-01 eliminate use of libffi-specific nci.pmc
307 return (INTVAL)nci_info->func;
3168931a » Dan Sugalski
2003-10-24 Forth can now generate code for words on the fly and execute them.
308 }
309
f35b03c9 » rubys
2004-12-20 Initial support for sort
310 /*
311
312 =item C<INTVAL get_bool()>
313
314 Returns the boolean value of the pointer.
315
316 =cut
317
318 */
319
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
320 VTABLE INTVAL get_bool() {
c1411da5 » rurban
2012-12-10 [cage] mark and document unused parameters as such
321 UNUSED(INTERP)
776e9da5 » petdance
2011-03-06 consting and removing unused var
322 const Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
1e5a8ee6 » plobsing
2010-11-01 eliminate use of libffi-specific nci.pmc
323 return (0 != (INTVAL)nci_info->orig_func);
f35b03c9 » rubys
2004-12-20 Initial support for sort
324 }
325
6586a2ca » jnthn
2007-12-15 Implement arity method on NCI PMCs, plus a test for it.
326 /*
327
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
328 =item C<METHOD arity()>
6586a2ca » jnthn
2007-12-15 Implement arity method on NCI PMCs, plus a test for it.
329
01e804c8 » Util
2009-03-13 [pmc] Typo corrections
330 Return the arity of the NCI (the number of arguments).
6586a2ca » jnthn
2007-12-15 Implement arity method on NCI PMCs, plus a test for it.
331
332 =cut
333
334 */
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
335 METHOD arity() {
971e9977 » NotFound
2008-09-08 rename pmc attributes struct from Parrot_<type> to Parrot_<type>_attr…
336 Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
337
8832378c » chromatic
2009-08-20 [PMC] Delayed NCI thunk initialization until absolutely necessary. This
338 if (nci_info) {
1e5a8ee6 » plobsing
2010-11-01 eliminate use of libffi-specific nci.pmc
339 if (!nci_info->func)
b75e23a1 » bacek
2011-02-03 Write barriering NCI in build_func.
340 build_func(INTERP, SELF, nci_info);
1e5a8ee6 » plobsing
2010-11-01 eliminate use of libffi-specific nci.pmc
341 if (nci_info->func) {
f1c9ca5c » petdance
2011-02-27 consting pointers and localizing temp vars
342 const INTVAL arity = nci_info->arity;
c64fa8d3 » plobsing
2010-10-27 split NCI signature parser out from nci.pmc
343 RETURN(INTVAL arity);
8832378c » chromatic
2009-08-20 [PMC] Delayed NCI thunk initialization until absolutely necessary. This
344 }
345 }
6586a2ca » jnthn
2007-12-15 Implement arity method on NCI PMCs, plus a test for it.
346
8832378c » chromatic
2009-08-20 [PMC] Delayed NCI thunk initialization until absolutely necessary. This
347 Parrot_ex_throw_from_c_args(INTERP, NULL,
348 EXCEPTION_INVALID_OPERATION,
349 "You cannot get the arity of an undefined NCI.");
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
350 }
2a2c19b1 » Dan Sugalski
2002-11-21 Added in code to properly do native calls to library routines loaded via
351 }
c64e58f7 » Michael Scott
2004-02-17 pmc docs update 3
352
353 /*
354
355 =back
356
357 =head1 SEE ALSO
358
1e5a8ee6 » plobsing
2010-11-01 eliminate use of libffi-specific nci.pmc
359 F<docs/pdds/pdd03_calling_conventions.pod>.
f631eb3d » plobsing
2010-10-27 remove private2 (raw) flag from nci-ffi.pmc
360
c64e58f7 » Michael Scott
2004-02-17 pmc docs update 3
361 =cut
362
363 */
364
0eb3eb34 » Michael Scott
2004-02-22 added formatting footer and detabbed
365 /*
366 * Local variables:
72575ae0 » bschmalhofer
2006-10-09 #40481: [PATCH] C-code coda in pmc files
367 * c-file-style: "parrot"
0eb3eb34 » Michael Scott
2004-02-22 added formatting footer and detabbed
368 * End:
1d7dded8 » plobsing
2010-11-29 update C file vim modelines
369 * vim: expandtab shiftwidth=4 cinoptions='\:2=2' :
72575ae0 » bschmalhofer
2006-10-09 #40481: [PATCH] C-code coda in pmc files
370 */
Something went wrong with that request. Please try again.