]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /* |
2 | * Heap native function representation. | |
3 | */ | |
4 | ||
5 | #ifndef DUK_HNATIVEFUNCTION_H_INCLUDED | |
6 | #define DUK_HNATIVEFUNCTION_H_INCLUDED | |
7 | ||
8 | #define DUK_HNATIVEFUNCTION_NARGS_VARARGS ((duk_int16_t) -1) | |
9 | #define DUK_HNATIVEFUNCTION_NARGS_MAX ((duk_int16_t) 0x7fff) | |
10 | ||
11 | struct duk_hnativefunction { | |
12 | /* shared object part */ | |
13 | duk_hobject obj; | |
14 | ||
15 | duk_c_function func; | |
16 | duk_int16_t nargs; | |
17 | duk_int16_t magic; | |
18 | ||
19 | /* The 'magic' field allows an opaque 16-bit field to be accessed by the | |
20 | * Duktape/C function. This allows, for instance, the same native function | |
21 | * to be used for a set of very similar functions, with the 'magic' field | |
22 | * providing the necessary non-argument flags / values to guide the behavior | |
23 | * of the native function. The value is signed on purpose: it is easier to | |
24 | * convert a signed value to unsigned (simply AND with 0xffff) than vice | |
25 | * versa. | |
26 | * | |
27 | * Note: cannot place nargs/magic into the heaphdr flags, because | |
28 | * duk_hobject takes almost all flags already (and needs the spare). | |
29 | */ | |
30 | }; | |
31 | ||
32 | #endif /* DUK_HNATIVEFUNCTION_H_INCLUDED */ |