]> git.proxmox.com Git - ceph.git/blame - ceph/src/civetweb/src/third_party/duktape-1.8.0/polyfills/duktape-isfastint.js
buildsys: switch source download to quincy
[ceph.git] / ceph / src / civetweb / src / third_party / duktape-1.8.0 / polyfills / duktape-isfastint.js
CommitLineData
7c673cae
FG
1/*
2 * Helper to check if a number is internally represented as a fastint:
3 *
4 * if (Duktape.isFastint(x)) {
5 * print('fastint');
6 * } else {
7 * print('not a fastint (or not a number)');
8 * }
9 *
10 * NOTE: This helper depends on the internal tag numbering (defined in
11 * duk_tval.h) which is both version specific and depends on whether
12 * duk_tval is packed or not.
13 */
14
15if (typeof Duktape === 'object') {
16 if (typeof Duktape.fastintTag === 'undefined') {
17 Object.defineProperty(Duktape, 'fastintTag', {
18 /* Tag number depends on duk_tval packing. */
11fdf7f2 19 value: (Duktape.info(true)[1] >= 0xfff0) ?
7c673cae
FG
20 0xfff1 /* tag for packed duk_tval */ :
21 1 /* tag for unpacked duk_tval */,
22 writable: false,
23 enumerable: false,
24 configurable: true
25 });
26 }
27 if (typeof Duktape.isFastint === 'undefined') {
28 Object.defineProperty(Duktape, 'isFastint', {
29 value: function (v) {
30 return Duktape.info(v)[0] === 4 && /* public type is DUK_TYPE_NUMBER */
31 Duktape.info(v)[1] === Duktape.fastintTag; /* internal tag is fastint */
32 },
33 writable: false,
34 enumerable: false,
35 configurable: true
36 });
37 }
38}