http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/a9485aeb/thirdparty/civetweb-1.9.1/src/third_party/duktape-1.5.2/src-separate/duk_bi_logger.c ---------------------------------------------------------------------- diff --git a/thirdparty/civetweb-1.9.1/src/third_party/duktape-1.5.2/src-separate/duk_bi_logger.c b/thirdparty/civetweb-1.9.1/src/third_party/duktape-1.5.2/src-separate/duk_bi_logger.c new file mode 100644 index 0000000..d2b89e5 --- /dev/null +++ b/thirdparty/civetweb-1.9.1/src/third_party/duktape-1.5.2/src-separate/duk_bi_logger.c @@ -0,0 +1,300 @@ +/* + * Logging support + */ + +#include "duk_internal.h" + +/* 3-letter log level strings */ +DUK_LOCAL const duk_uint8_t duk__log_level_strings[] = { + (duk_uint8_t) DUK_ASC_UC_T, (duk_uint8_t) DUK_ASC_UC_R, (duk_uint8_t) DUK_ASC_UC_C, + (duk_uint8_t) DUK_ASC_UC_D, (duk_uint8_t) DUK_ASC_UC_B, (duk_uint8_t) DUK_ASC_UC_G, + (duk_uint8_t) DUK_ASC_UC_I, (duk_uint8_t) DUK_ASC_UC_N, (duk_uint8_t) DUK_ASC_UC_F, + (duk_uint8_t) DUK_ASC_UC_W, (duk_uint8_t) DUK_ASC_UC_R, (duk_uint8_t) DUK_ASC_UC_N, + (duk_uint8_t) DUK_ASC_UC_E, (duk_uint8_t) DUK_ASC_UC_R, (duk_uint8_t) DUK_ASC_UC_R, + (duk_uint8_t) DUK_ASC_UC_F, (duk_uint8_t) DUK_ASC_UC_T, (duk_uint8_t) DUK_ASC_UC_L +}; + +/* Constructor */ +DUK_INTERNAL duk_ret_t duk_bi_logger_constructor(duk_context *ctx) { + duk_hthread *thr = (duk_hthread *) ctx; + duk_idx_t nargs; + + /* Calling as a non-constructor is not meaningful. */ + if (!duk_is_constructor_call(ctx)) { + return DUK_RET_TYPE_ERROR; + } + + nargs = duk_get_top(ctx); + duk_set_top(ctx, 1); + + duk_push_this(ctx); + + /* [ name this ] */ + + if (nargs == 0) { + /* Automatic defaulting of logger name from caller. This would + * work poorly with tail calls, but constructor calls are currently + * never tail calls, so tail calls are not an issue now. + */ + + if (thr->callstack_top >= 2) { + duk_activation *act_caller = thr->callstack + thr->callstack_top - 2; + duk_hobject *func_caller; + + func_caller = DUK_ACT_GET_FUNC(act_caller); + if (func_caller) { + /* Stripping the filename might be a good idea + * ("/foo/bar/quux.js" -> logger name "quux"), + * but now used verbatim. + */ + duk_push_hobject(ctx, func_caller); + duk_get_prop_stridx(ctx, -1, DUK_STRIDX_FILE_NAME); + duk_replace(ctx, 0); + } + } + } + /* the stack is unbalanced here on purpose; we only rely on the + * initial two values: [ name this ]. + */ + + if (duk_is_string(ctx, 0)) { + duk_dup(ctx, 0); + duk_put_prop_stridx(ctx, 1, DUK_STRIDX_LC_N); + } else { + /* don't set 'n' at all, inherited value is used as name */ + } + + duk_compact(ctx, 1); + + return 0; /* keep default instance */ +} + +/* Default function to format objects. Tries to use toLogString() but falls + * back to toString(). Any errors are propagated out without catching. + */ +DUK_INTERNAL duk_ret_t duk_bi_logger_prototype_fmt(duk_context *ctx) { + if (duk_get_prop_stridx(ctx, 0, DUK_STRIDX_TO_LOG_STRING)) { + /* [ arg toLogString ] */ + + duk_dup(ctx, 0); + duk_call_method(ctx, 0); + + /* [ arg result ] */ + return 1; + } + + /* [ arg undefined ] */ + duk_pop(ctx); + duk_to_string(ctx, 0); + return 1; +} + +/* Default function to write a formatted log line. Writes to stderr, + * appending a newline to the log line. + * + * The argument is a buffer whose visible size contains the log message. + * This function should avoid coercing the buffer to a string to avoid + * string table traffic. + */ +DUK_INTERNAL duk_ret_t duk_bi_logger_prototype_raw(duk_context *ctx) { + const char *data; + duk_size_t data_len; + + DUK_UNREF(ctx); + DUK_UNREF(data); + DUK_UNREF(data_len); + +#ifdef DUK_USE_FILE_IO + data = (const char *) duk_require_buffer(ctx, 0, &data_len); + DUK_FWRITE((const void *) data, 1, data_len, DUK_STDERR); + DUK_FPUTC((int) '\n', DUK_STDERR); + DUK_FFLUSH(DUK_STDERR); +#else + /* nop */ +#endif + return 0; +} + +/* Log frontend shared helper, magic value indicates log level. Provides + * frontend functions: trace(), debug(), info(), warn(), error(), fatal(). + * This needs to have small footprint, reasonable performance, minimal + * memory churn, etc. + */ +DUK_INTERNAL duk_ret_t duk_bi_logger_prototype_log_shared(duk_context *ctx) { + duk_hthread *thr = (duk_hthread *) ctx; + duk_double_t now; + duk_small_int_t entry_lev = duk_get_current_magic(ctx); + duk_small_int_t logger_lev; + duk_int_t nargs; + duk_int_t i; + duk_size_t tot_len; + const duk_uint8_t *arg_str; + duk_size_t arg_len; + duk_uint8_t *buf, *p; + const duk_uint8_t *q; + duk_uint8_t date_buf[DUK_BI_DATE_ISO8601_BUFSIZE]; + duk_size_t date_len; + duk_small_int_t rc; + + DUK_ASSERT(entry_lev >= 0 && entry_lev <= 5); + DUK_UNREF(thr); + + /* XXX: sanitize to printable (and maybe ASCII) */ + /* XXX: better multiline */ + + /* + * Logger arguments are: + * + * magic: log level (0-5) + * this: logger + * stack: plain log args + * + * We want to minimize memory churn so a two-pass approach + * is used: first pass formats arguments and computes final + * string length, second pass copies strings either into a + * pre-allocated and reused buffer (short messages) or into a + * newly allocated fixed buffer. If the backend function plays + * nice, it won't coerce the buffer to a string (and thus + * intern it). + */ + + nargs = duk_get_top(ctx); + + /* [ arg1 ... argN this ] */ + + /* + * Log level check + */ + + duk_push_this(ctx); + + duk_get_prop_stridx(ctx, -1, DUK_STRIDX_LC_L); + logger_lev = (duk_small_int_t) duk_get_int(ctx, -1); + if (entry_lev < logger_lev) { + return 0; + } + /* log level could be popped but that's not necessary */ + + now = DUK_USE_DATE_GET_NOW(ctx); + duk_bi_date_format_timeval(now, date_buf); + date_len = DUK_STRLEN((const char *) date_buf); + + duk_get_prop_stridx(ctx, -2, DUK_STRIDX_LC_N); + duk_to_string(ctx, -1); + DUK_ASSERT(duk_is_string(ctx, -1)); + + /* [ arg1 ... argN this loggerLevel loggerName ] */ + + /* + * Pass 1 + */ + + /* Line format: <time> <entryLev> <loggerName>: <msg> */ + + tot_len = 0; + tot_len += 3 + /* separators: space, space, colon */ + 3 + /* level string */ + date_len + /* time */ + duk_get_length(ctx, -1); /* loggerName */ + + for (i = 0; i < nargs; i++) { + /* When formatting an argument to a string, errors may happen from multiple + * causes. In general we want to catch obvious errors like a toLogString() + * throwing an error, but we don't currently try to catch every possible + * error. In particular, internal errors (like out of memory or stack) are + * not caught. Also, we expect Error toString() to not throw an error. + */ + if (duk_is_object(ctx, i)) { + /* duk_pcall_prop() may itself throw an error, but we're content + * in catching the obvious errors (like toLogString() throwing an + * error). + */ + duk_push_hstring_stridx(ctx, DUK_STRIDX_FMT); + duk_dup(ctx, i); + /* [ arg1 ... argN this loggerLevel loggerName 'fmt' arg ] */ + /* call: this.fmt(arg) */ + rc = duk_pcall_prop(ctx, -5 /*obj_index*/, 1 /*nargs*/); + if (rc) { + /* Keep the error as the result (coercing it might fail below, + * but we don't catch that now). + */ + ; + } + duk_replace(ctx, i); + } + (void) duk_to_lstring(ctx, i, &arg_len); + tot_len++; /* sep (even before first one) */ + tot_len += arg_len; + } + + /* + * Pass 2 + */ + + /* XXX: There used to be a shared log buffer here, but it was removed + * when dynamic buffer spare was removed. The problem with using + * bufwriter is that, without the spare, the buffer gets passed on + * as an argument to the raw() call so it'd need to be resized + * (reallocated) anyway. If raw() call convention is changed, this + * could be made more efficient. + */ + + buf = (duk_uint8_t *) duk_push_fixed_buffer(ctx, tot_len); + DUK_ASSERT(buf != NULL); + p = buf; + + DUK_MEMCPY((void *) p, (const void *) date_buf, (size_t) date_len); + p += date_len; + *p++ = (duk_uint8_t) DUK_ASC_SPACE; + + q = duk__log_level_strings + (entry_lev * 3); + DUK_MEMCPY((void *) p, (const void *) q, (size_t) 3); + p += 3; + + *p++ = (duk_uint8_t) DUK_ASC_SPACE; + + arg_str = (const duk_uint8_t *) duk_get_lstring(ctx, -2, &arg_len); + DUK_MEMCPY((void *) p, (const void *) arg_str, (size_t) arg_len); + p += arg_len; + + *p++ = (duk_uint8_t) DUK_ASC_COLON; + + for (i = 0; i < nargs; i++) { + *p++ = (duk_uint8_t) DUK_ASC_SPACE; + + arg_str = (const duk_uint8_t *) duk_get_lstring(ctx, i, &arg_len); + DUK_ASSERT(arg_str != NULL); + DUK_MEMCPY((void *) p, (const void *) arg_str, (size_t) arg_len); + p += arg_len; + } + DUK_ASSERT(buf + tot_len == p); + + /* [ arg1 ... argN this loggerLevel loggerName buffer ] */ + +#if defined(DUK_USE_DEBUGGER_SUPPORT) && defined(DUK_USE_DEBUGGER_FWD_LOGGING) + /* Do debugger forwarding before raw() because the raw() function + * doesn't get the log level right now. + */ + if (DUK_HEAP_IS_DEBUGGER_ATTACHED(thr->heap)) { + const char *log_buf; + duk_size_t sz_buf; + log_buf = (const char *) duk_get_buffer(ctx, -1, &sz_buf); + DUK_ASSERT(log_buf != NULL); + duk_debug_write_notify(thr, DUK_DBG_CMD_LOG); + duk_debug_write_int(thr, (duk_int32_t) entry_lev); + duk_debug_write_string(thr, (const char *) log_buf, sz_buf); + duk_debug_write_eom(thr); + } +#endif + + /* Call this.raw(msg); look up through the instance allows user to override + * the raw() function in the instance or in the prototype for maximum + * flexibility. + */ + duk_push_hstring_stridx(ctx, DUK_STRIDX_RAW); + duk_dup(ctx, -2); + /* [ arg1 ... argN this loggerLevel loggerName buffer 'raw' buffer ] */ + duk_call_prop(ctx, -6, 1); /* this.raw(buffer) */ + + return 0; +}
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/a9485aeb/thirdparty/civetweb-1.9.1/src/third_party/duktape-1.5.2/src-separate/duk_bi_math.c ---------------------------------------------------------------------- diff --git a/thirdparty/civetweb-1.9.1/src/third_party/duktape-1.5.2/src-separate/duk_bi_math.c b/thirdparty/civetweb-1.9.1/src/third_party/duktape-1.5.2/src-separate/duk_bi_math.c new file mode 100644 index 0000000..62c9341 --- /dev/null +++ b/thirdparty/civetweb-1.9.1/src/third_party/duktape-1.5.2/src-separate/duk_bi_math.c @@ -0,0 +1,348 @@ +/* + * Math built-ins + */ + +#include "duk_internal.h" + +#if defined(DUK_USE_MATH_BUILTIN) + +/* + * Use static helpers which can work with math.h functions matching + * the following signatures. This is not portable if any of these math + * functions is actually a macro. + * + * Typing here is intentionally 'double' wherever values interact with + * the standard library APIs. + */ + +typedef double (*duk__one_arg_func)(double); +typedef double (*duk__two_arg_func)(double, double); + +DUK_LOCAL duk_ret_t duk__math_minmax(duk_context *ctx, duk_double_t initial, duk__two_arg_func min_max) { + duk_idx_t n = duk_get_top(ctx); + duk_idx_t i; + duk_double_t res = initial; + duk_double_t t; + + /* + * Note: fmax() does not match the E5 semantics. E5 requires + * that if -any- input to Math.max() is a NaN, the result is a + * NaN. fmax() will return a NaN only if -both- inputs are NaN. + * Same applies to fmin(). + * + * Note: every input value must be coerced with ToNumber(), even + * if we know the result will be a NaN anyway: ToNumber() may have + * side effects for which even order of evaluation matters. + */ + + for (i = 0; i < n; i++) { + t = duk_to_number(ctx, i); + if (DUK_FPCLASSIFY(t) == DUK_FP_NAN || DUK_FPCLASSIFY(res) == DUK_FP_NAN) { + /* Note: not normalized, but duk_push_number() will normalize */ + res = (duk_double_t) DUK_DOUBLE_NAN; + } else { + res = (duk_double_t) min_max(res, (double) t); + } + } + + duk_push_number(ctx, res); + return 1; +} + +DUK_LOCAL double duk__fmin_fixed(double x, double y) { + /* fmin() with args -0 and +0 is not guaranteed to return + * -0 as Ecmascript requires. + */ + if (x == 0 && y == 0) { + /* XXX: what's the safest way of creating a negative zero? */ + if (DUK_SIGNBIT(x) != 0 || DUK_SIGNBIT(y) != 0) { + return -0.0; + } else { + return +0.0; + } + } +#ifdef DUK_USE_MATH_FMIN + return DUK_FMIN(x, y); +#else + return (x < y ? x : y); +#endif +} + +DUK_LOCAL double duk__fmax_fixed(double x, double y) { + /* fmax() with args -0 and +0 is not guaranteed to return + * +0 as Ecmascript requires. + */ + if (x == 0 && y == 0) { + if (DUK_SIGNBIT(x) == 0 || DUK_SIGNBIT(y) == 0) { + return +0.0; + } else { + return -0.0; + } + } +#ifdef DUK_USE_MATH_FMAX + return DUK_FMAX(x, y); +#else + return (x > y ? x : y); +#endif +} + +DUK_LOCAL double duk__round_fixed(double x) { + /* Numbers half-way between integers must be rounded towards +Infinity, + * e.g. -3.5 must be rounded to -3 (not -4). When rounded to zero, zero + * sign must be set appropriately. E5.1 Section 15.8.2.15. + * + * Note that ANSI C round() is "round to nearest integer, away from zero", + * which is incorrect for negative values. Here we make do with floor(). + */ + + duk_small_int_t c = (duk_small_int_t) DUK_FPCLASSIFY(x); + if (c == DUK_FP_NAN || c == DUK_FP_INFINITE || c == DUK_FP_ZERO) { + return x; + } + + /* + * x is finite and non-zero + * + * -1.6 -> floor(-1.1) -> -2 + * -1.5 -> floor(-1.0) -> -1 (towards +Inf) + * -1.4 -> floor(-0.9) -> -1 + * -0.5 -> -0.0 (special case) + * -0.1 -> -0.0 (special case) + * +0.1 -> +0.0 (special case) + * +0.5 -> floor(+1.0) -> 1 (towards +Inf) + * +1.4 -> floor(+1.9) -> 1 + * +1.5 -> floor(+2.0) -> 2 (towards +Inf) + * +1.6 -> floor(+2.1) -> 2 + */ + + if (x >= -0.5 && x < 0.5) { + /* +0.5 is handled by floor, this is on purpose */ + if (x < 0.0) { + return -0.0; + } else { + return +0.0; + } + } + + return DUK_FLOOR(x + 0.5); +} + +DUK_LOCAL double duk__pow_fixed(double x, double y) { + /* The ANSI C pow() semantics differ from Ecmascript. + * + * E.g. when x==1 and y is +/- infinite, the Ecmascript required + * result is NaN, while at least Linux pow() returns 1. + */ + + duk_small_int_t cx, cy, sx; + + DUK_UNREF(cx); + DUK_UNREF(sx); + cy = (duk_small_int_t) DUK_FPCLASSIFY(y); + + if (cy == DUK_FP_NAN) { + goto ret_nan; + } + if (DUK_FABS(x) == 1.0 && cy == DUK_FP_INFINITE) { + goto ret_nan; + } +#if defined(DUK_USE_POW_NETBSD_WORKAROUND) + /* See test-bug-netbsd-math-pow.js: NetBSD 6.0 on x86 (at least) does not + * correctly handle some cases where x=+/-0. Specific fixes to these + * here. + */ + cx = (duk_small_int_t) DUK_FPCLASSIFY(x); + if (cx == DUK_FP_ZERO && y < 0.0) { + sx = (duk_small_int_t) DUK_SIGNBIT(x); + if (sx == 0) { + /* Math.pow(+0,y) should be Infinity when y<0. NetBSD pow() + * returns -Infinity instead when y is <0 and finite. The + * if-clause also catches y == -Infinity (which works even + * without the fix). + */ + return DUK_DOUBLE_INFINITY; + } else { + /* Math.pow(-0,y) where y<0 should be: + * - -Infinity if y<0 and an odd integer + * - Infinity otherwise + * NetBSD pow() returns -Infinity for all finite y<0. The + * if-clause also catches y == -Infinity (which works even + * without the fix). + */ + + /* fmod() return value has same sign as input (negative) so + * the result here will be in the range ]-2,0], 1 indicates + * odd. If x is -Infinity, NaN is returned and the odd check + * always concludes "not odd" which results in desired outcome. + */ + double tmp = DUK_FMOD(y, 2); + if (tmp == -1.0) { + return -DUK_DOUBLE_INFINITY; + } else { + /* Not odd, or y == -Infinity */ + return DUK_DOUBLE_INFINITY; + } + } + } +#endif + return DUK_POW(x, y); + + ret_nan: + return DUK_DOUBLE_NAN; +} + +/* Wrappers for calling standard math library methods. These may be required + * on platforms where one or more of the math built-ins are defined as macros + * or inline functions and are thus not suitable to be used as function pointers. + */ +#if defined(DUK_USE_AVOID_PLATFORM_FUNCPTRS) +DUK_LOCAL double duk__fabs(double x) { + return DUK_FABS(x); +} +DUK_LOCAL double duk__acos(double x) { + return DUK_ACOS(x); +} +DUK_LOCAL double duk__asin(double x) { + return DUK_ASIN(x); +} +DUK_LOCAL double duk__atan(double x) { + return DUK_ATAN(x); +} +DUK_LOCAL double duk__ceil(double x) { + return DUK_CEIL(x); +} +DUK_LOCAL double duk__cos(double x) { + return DUK_COS(x); +} +DUK_LOCAL double duk__exp(double x) { + return DUK_EXP(x); +} +DUK_LOCAL double duk__floor(double x) { + return DUK_FLOOR(x); +} +DUK_LOCAL double duk__log(double x) { + return DUK_LOG(x); +} +DUK_LOCAL double duk__sin(double x) { + return DUK_SIN(x); +} +DUK_LOCAL double duk__sqrt(double x) { + return DUK_SQRT(x); +} +DUK_LOCAL double duk__tan(double x) { + return DUK_TAN(x); +} +DUK_LOCAL double duk__atan2(double x, double y) { + return DUK_ATAN2(x, y); +} +#endif /* DUK_USE_AVOID_PLATFORM_FUNCPTRS */ + +/* order must match constants in genbuiltins.py */ +DUK_LOCAL const duk__one_arg_func duk__one_arg_funcs[] = { +#if defined(DUK_USE_AVOID_PLATFORM_FUNCPTRS) + duk__fabs, + duk__acos, + duk__asin, + duk__atan, + duk__ceil, + duk__cos, + duk__exp, + duk__floor, + duk__log, + duk__round_fixed, + duk__sin, + duk__sqrt, + duk__tan +#else + DUK_FABS, + DUK_ACOS, + DUK_ASIN, + DUK_ATAN, + DUK_CEIL, + DUK_COS, + DUK_EXP, + DUK_FLOOR, + DUK_LOG, + duk__round_fixed, + DUK_SIN, + DUK_SQRT, + DUK_TAN +#endif +}; + +/* order must match constants in genbuiltins.py */ +DUK_LOCAL const duk__two_arg_func duk__two_arg_funcs[] = { +#if defined(DUK_USE_AVOID_PLATFORM_FUNCPTRS) + duk__atan2, + duk__pow_fixed +#else + DUK_ATAN2, + duk__pow_fixed +#endif +}; + +DUK_INTERNAL duk_ret_t duk_bi_math_object_onearg_shared(duk_context *ctx) { + duk_small_int_t fun_idx = duk_get_current_magic(ctx); + duk__one_arg_func fun; + + DUK_ASSERT(fun_idx >= 0); + DUK_ASSERT(fun_idx < (duk_small_int_t) (sizeof(duk__one_arg_funcs) / sizeof(duk__one_arg_func))); + fun = duk__one_arg_funcs[fun_idx]; + duk_push_number(ctx, (duk_double_t) fun((double) duk_to_number(ctx, 0))); + return 1; +} + +DUK_INTERNAL duk_ret_t duk_bi_math_object_twoarg_shared(duk_context *ctx) { + duk_small_int_t fun_idx = duk_get_current_magic(ctx); + duk__two_arg_func fun; + + DUK_ASSERT(fun_idx >= 0); + DUK_ASSERT(fun_idx < (duk_small_int_t) (sizeof(duk__two_arg_funcs) / sizeof(duk__two_arg_func))); + fun = duk__two_arg_funcs[fun_idx]; + duk_push_number(ctx, (duk_double_t) fun((double) duk_to_number(ctx, 0), (double) duk_to_number(ctx, 1))); + return 1; +} + +DUK_INTERNAL duk_ret_t duk_bi_math_object_max(duk_context *ctx) { + return duk__math_minmax(ctx, -DUK_DOUBLE_INFINITY, duk__fmax_fixed); +} + +DUK_INTERNAL duk_ret_t duk_bi_math_object_min(duk_context *ctx) { + return duk__math_minmax(ctx, DUK_DOUBLE_INFINITY, duk__fmin_fixed); +} + +DUK_INTERNAL duk_ret_t duk_bi_math_object_random(duk_context *ctx) { + duk_push_number(ctx, (duk_double_t) duk_util_tinyrandom_get_double((duk_hthread *) ctx)); + return 1; +} + +#else /* DUK_USE_MATH_BUILTIN */ + +/* A stubbed built-in is useful for e.g. compilation torture testing with BCC. */ + +DUK_INTERNAL duk_ret_t duk_bi_math_object_onearg_shared(duk_context *ctx) { + DUK_UNREF(ctx); + return DUK_RET_UNIMPLEMENTED_ERROR; +} + +DUK_INTERNAL duk_ret_t duk_bi_math_object_twoarg_shared(duk_context *ctx) { + DUK_UNREF(ctx); + return DUK_RET_UNIMPLEMENTED_ERROR; +} + +DUK_INTERNAL duk_ret_t duk_bi_math_object_max(duk_context *ctx) { + DUK_UNREF(ctx); + return DUK_RET_UNIMPLEMENTED_ERROR; +} + +DUK_INTERNAL duk_ret_t duk_bi_math_object_min(duk_context *ctx) { + DUK_UNREF(ctx); + return DUK_RET_UNIMPLEMENTED_ERROR; +} + +DUK_INTERNAL duk_ret_t duk_bi_math_object_random(duk_context *ctx) { + DUK_UNREF(ctx); + return DUK_RET_UNIMPLEMENTED_ERROR; +} + +#endif /* DUK_USE_MATH_BUILTIN */ http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/a9485aeb/thirdparty/civetweb-1.9.1/src/third_party/duktape-1.5.2/src-separate/duk_bi_number.c ---------------------------------------------------------------------- diff --git a/thirdparty/civetweb-1.9.1/src/third_party/duktape-1.5.2/src-separate/duk_bi_number.c b/thirdparty/civetweb-1.9.1/src/third_party/duktape-1.5.2/src-separate/duk_bi_number.c new file mode 100644 index 0000000..4b7abf5 --- /dev/null +++ b/thirdparty/civetweb-1.9.1/src/third_party/duktape-1.5.2/src-separate/duk_bi_number.c @@ -0,0 +1,240 @@ +/* + * Number built-ins + */ + +#include "duk_internal.h" + +DUK_LOCAL duk_double_t duk__push_this_number_plain(duk_context *ctx) { + duk_hobject *h; + + /* Number built-in accepts a plain number or a Number object (whose + * internal value is operated on). Other types cause TypeError. + */ + + duk_push_this(ctx); + if (duk_is_number(ctx, -1)) { + DUK_DDD(DUK_DDDPRINT("plain number value: %!T", (duk_tval *) duk_get_tval(ctx, -1))); + goto done; + } + h = duk_get_hobject(ctx, -1); + if (!h || + (DUK_HOBJECT_GET_CLASS_NUMBER(h) != DUK_HOBJECT_CLASS_NUMBER)) { + DUK_DDD(DUK_DDDPRINT("unacceptable this value: %!T", (duk_tval *) duk_get_tval(ctx, -1))); + DUK_ERROR_TYPE((duk_hthread *) ctx, "number expected"); + } + duk_get_prop_stridx(ctx, -1, DUK_STRIDX_INT_VALUE); + DUK_ASSERT(duk_is_number(ctx, -1)); + DUK_DDD(DUK_DDDPRINT("number object: %!T, internal value: %!T", + (duk_tval *) duk_get_tval(ctx, -2), (duk_tval *) duk_get_tval(ctx, -1))); + duk_remove(ctx, -2); + + done: + return duk_get_number(ctx, -1); +} + +DUK_INTERNAL duk_ret_t duk_bi_number_constructor(duk_context *ctx) { + duk_hthread *thr = (duk_hthread *) ctx; + duk_idx_t nargs; + duk_hobject *h_this; + + DUK_UNREF(thr); + + /* + * The Number constructor uses ToNumber(arg) for number coercion + * (coercing an undefined argument to NaN). However, if the + * argument is not given at all, +0 must be used instead. To do + * this, a vararg function is used. + */ + + nargs = duk_get_top(ctx); + if (nargs == 0) { + duk_push_int(ctx, 0); + } + duk_to_number(ctx, 0); + duk_set_top(ctx, 1); + DUK_ASSERT_TOP(ctx, 1); + + if (!duk_is_constructor_call(ctx)) { + return 1; + } + + /* + * E5 Section 15.7.2.1 requires that the constructed object + * must have the original Number.prototype as its internal + * prototype. However, since Number.prototype is non-writable + * and non-configurable, this doesn't have to be enforced here: + * The default object (bound to 'this') is OK, though we have + * to change its class. + * + * Internal value set to ToNumber(arg) or +0; if no arg given, + * ToNumber(undefined) = NaN, so special treatment is needed + * (above). String internal value is immutable. + */ + + /* XXX: helper */ + duk_push_this(ctx); + h_this = duk_get_hobject(ctx, -1); + DUK_ASSERT(h_this != NULL); + DUK_HOBJECT_SET_CLASS_NUMBER(h_this, DUK_HOBJECT_CLASS_NUMBER); + + DUK_ASSERT(DUK_HOBJECT_GET_PROTOTYPE(thr->heap, h_this) == thr->builtins[DUK_BIDX_NUMBER_PROTOTYPE]); + DUK_ASSERT(DUK_HOBJECT_GET_CLASS_NUMBER(h_this) == DUK_HOBJECT_CLASS_NUMBER); + DUK_ASSERT(DUK_HOBJECT_HAS_EXTENSIBLE(h_this)); + + duk_dup(ctx, 0); /* -> [ val obj val ] */ + duk_xdef_prop_stridx(ctx, -2, DUK_STRIDX_INT_VALUE, DUK_PROPDESC_FLAGS_NONE); + return 0; /* no return value -> don't replace created value */ +} + +DUK_INTERNAL duk_ret_t duk_bi_number_prototype_value_of(duk_context *ctx) { + (void) duk__push_this_number_plain(ctx); + return 1; +} + +DUK_INTERNAL duk_ret_t duk_bi_number_prototype_to_string(duk_context *ctx) { + duk_small_int_t radix; + duk_small_uint_t n2s_flags; + + (void) duk__push_this_number_plain(ctx); + if (duk_is_undefined(ctx, 0)) { + radix = 10; + } else { + radix = (duk_small_int_t) duk_to_int_check_range(ctx, 0, 2, 36); + } + DUK_DDD(DUK_DDDPRINT("radix=%ld", (long) radix)); + + n2s_flags = 0; + + duk_numconv_stringify(ctx, + radix /*radix*/, + 0 /*digits*/, + n2s_flags /*flags*/); + return 1; +} + +DUK_INTERNAL duk_ret_t duk_bi_number_prototype_to_locale_string(duk_context *ctx) { + /* XXX: just use toString() for now; permitted although not recommended. + * nargs==1, so radix is passed to toString(). + */ + return duk_bi_number_prototype_to_string(ctx); +} + +/* + * toFixed(), toExponential(), toPrecision() + */ + +/* XXX: shared helper for toFixed(), toExponential(), toPrecision()? */ + +DUK_INTERNAL duk_ret_t duk_bi_number_prototype_to_fixed(duk_context *ctx) { + duk_small_int_t frac_digits; + duk_double_t d; + duk_small_int_t c; + duk_small_uint_t n2s_flags; + + frac_digits = (duk_small_int_t) duk_to_int_check_range(ctx, 0, 0, 20); + d = duk__push_this_number_plain(ctx); + + c = (duk_small_int_t) DUK_FPCLASSIFY(d); + if (c == DUK_FP_NAN || c == DUK_FP_INFINITE) { + goto use_to_string; + } + + if (d >= 1.0e21 || d <= -1.0e21) { + goto use_to_string; + } + + n2s_flags = DUK_N2S_FLAG_FIXED_FORMAT | + DUK_N2S_FLAG_FRACTION_DIGITS; + + duk_numconv_stringify(ctx, + 10 /*radix*/, + frac_digits /*digits*/, + n2s_flags /*flags*/); + return 1; + + use_to_string: + DUK_ASSERT_TOP(ctx, 2); + duk_to_string(ctx, -1); + return 1; +} + +DUK_INTERNAL duk_ret_t duk_bi_number_prototype_to_exponential(duk_context *ctx) { + duk_bool_t frac_undefined; + duk_small_int_t frac_digits; + duk_double_t d; + duk_small_int_t c; + duk_small_uint_t n2s_flags; + + d = duk__push_this_number_plain(ctx); + + frac_undefined = duk_is_undefined(ctx, 0); + duk_to_int(ctx, 0); /* for side effects */ + + c = (duk_small_int_t) DUK_FPCLASSIFY(d); + if (c == DUK_FP_NAN || c == DUK_FP_INFINITE) { + goto use_to_string; + } + + frac_digits = (duk_small_int_t) duk_to_int_check_range(ctx, 0, 0, 20); + + n2s_flags = DUK_N2S_FLAG_FORCE_EXP | + (frac_undefined ? 0 : DUK_N2S_FLAG_FIXED_FORMAT); + + duk_numconv_stringify(ctx, + 10 /*radix*/, + frac_digits + 1 /*leading digit + fractions*/, + n2s_flags /*flags*/); + return 1; + + use_to_string: + DUK_ASSERT_TOP(ctx, 2); + duk_to_string(ctx, -1); + return 1; +} + +DUK_INTERNAL duk_ret_t duk_bi_number_prototype_to_precision(duk_context *ctx) { + /* The specification has quite awkward order of coercion and + * checks for toPrecision(). The operations below are a bit + * reordered, within constraints of observable side effects. + */ + + duk_double_t d; + duk_small_int_t prec; + duk_small_int_t c; + duk_small_uint_t n2s_flags; + + DUK_ASSERT_TOP(ctx, 1); + + d = duk__push_this_number_plain(ctx); + if (duk_is_undefined(ctx, 0)) { + goto use_to_string; + } + DUK_ASSERT_TOP(ctx, 2); + + duk_to_int(ctx, 0); /* for side effects */ + + c = (duk_small_int_t) DUK_FPCLASSIFY(d); + if (c == DUK_FP_NAN || c == DUK_FP_INFINITE) { + goto use_to_string; + } + + prec = (duk_small_int_t) duk_to_int_check_range(ctx, 0, 1, 21); + + n2s_flags = DUK_N2S_FLAG_FIXED_FORMAT | + DUK_N2S_FLAG_NO_ZERO_PAD; + + duk_numconv_stringify(ctx, + 10 /*radix*/, + prec /*digits*/, + n2s_flags /*flags*/); + return 1; + + use_to_string: + /* Used when precision is undefined; also used for NaN (-> "NaN"), + * and +/- infinity (-> "Infinity", "-Infinity"). + */ + + DUK_ASSERT_TOP(ctx, 2); + duk_to_string(ctx, -1); + return 1; +} http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/a9485aeb/thirdparty/civetweb-1.9.1/src/third_party/duktape-1.5.2/src-separate/duk_bi_object.c ---------------------------------------------------------------------- diff --git a/thirdparty/civetweb-1.9.1/src/third_party/duktape-1.5.2/src-separate/duk_bi_object.c b/thirdparty/civetweb-1.9.1/src/third_party/duktape-1.5.2/src-separate/duk_bi_object.c new file mode 100644 index 0000000..28509ab --- /dev/null +++ b/thirdparty/civetweb-1.9.1/src/third_party/duktape-1.5.2/src-separate/duk_bi_object.c @@ -0,0 +1,577 @@ +/* + * Object built-ins + */ + +#include "duk_internal.h" + +DUK_INTERNAL duk_ret_t duk_bi_object_constructor(duk_context *ctx) { + if (!duk_is_constructor_call(ctx) && + !duk_is_null_or_undefined(ctx, 0)) { + duk_to_object(ctx, 0); + return 1; + } + + if (duk_is_object(ctx, 0)) { + return 1; + } + + /* Pointer and buffer primitive values are treated like other + * primitives values which have a fully fledged object counterpart: + * promote to an object value. Lightfuncs are coerced with + * ToObject() even they could also be returned as is. + */ + if (duk_check_type_mask(ctx, 0, DUK_TYPE_MASK_STRING | + DUK_TYPE_MASK_BOOLEAN | + DUK_TYPE_MASK_NUMBER | + DUK_TYPE_MASK_POINTER | + DUK_TYPE_MASK_BUFFER | + DUK_TYPE_MASK_LIGHTFUNC)) { + duk_to_object(ctx, 0); + return 1; + } + + duk_push_object_helper(ctx, + DUK_HOBJECT_FLAG_EXTENSIBLE | + DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_OBJECT), + DUK_BIDX_OBJECT_PROTOTYPE); + return 1; +} + +/* Shared helper to implement Object.getPrototypeOf and the ES6 + * Object.prototype.__proto__ getter. + * + * http://www.ecma-international.org/ecma-262/6.0/index.html#sec-get-object.prototype.__proto__ + */ +DUK_INTERNAL duk_ret_t duk_bi_object_getprototype_shared(duk_context *ctx) { + duk_hthread *thr = (duk_hthread *) ctx; + duk_hobject *h; + duk_hobject *proto; + + DUK_UNREF(thr); + + /* magic: 0=getter call, 1=Object.getPrototypeOf */ + if (duk_get_current_magic(ctx) == 0) { + duk_push_this_coercible_to_object(ctx); + duk_insert(ctx, 0); + } + + h = duk_require_hobject_or_lfunc(ctx, 0); + /* h is NULL for lightfunc */ + + /* XXX: should the API call handle this directly, i.e. attempt + * to duk_push_hobject(ctx, null) would push a null instead? + * (On the other hand 'undefined' would be just as logical, but + * not wanted here.) + */ + + if (h == NULL) { + duk_push_hobject_bidx(ctx, DUK_BIDX_FUNCTION_PROTOTYPE); + } else { + proto = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, h); + if (proto) { + duk_push_hobject(ctx, proto); + } else { + duk_push_null(ctx); + } + } + return 1; +} + +/* Shared helper to implement ES6 Object.setPrototypeOf and + * Object.prototype.__proto__ setter. + * + * http://www.ecma-international.org/ecma-262/6.0/index.html#sec-get-object.prototype.__proto__ + * http://www.ecma-international.org/ecma-262/6.0/index.html#sec-object.setprototypeof + */ +DUK_INTERNAL duk_ret_t duk_bi_object_setprototype_shared(duk_context *ctx) { + duk_hthread *thr = (duk_hthread *) ctx; + duk_hobject *h_obj; + duk_hobject *h_new_proto; + duk_hobject *h_curr; + duk_ret_t ret_success = 1; /* retval for success path */ + + /* Preliminaries for __proto__ and setPrototypeOf (E6 19.1.2.18 steps 1-4); + * magic: 0=setter call, 1=Object.setPrototypeOf + */ + if (duk_get_current_magic(ctx) == 0) { + duk_push_this_check_object_coercible(ctx); + duk_insert(ctx, 0); + if (!duk_check_type_mask(ctx, 1, DUK_TYPE_MASK_NULL | DUK_TYPE_MASK_OBJECT)) { + return 0; + } + + /* __proto__ setter returns 'undefined' on success unlike the + * setPrototypeOf() call which returns the target object. + */ + ret_success = 0; + } else { + duk_require_object_coercible(ctx, 0); + duk_require_type_mask(ctx, 1, DUK_TYPE_MASK_NULL | DUK_TYPE_MASK_OBJECT); + } + + h_new_proto = duk_get_hobject(ctx, 1); + /* h_new_proto may be NULL */ + if (duk_is_lightfunc(ctx, 0)) { + if (h_new_proto == thr->builtins[DUK_BIDX_FUNCTION_PROTOTYPE]) { + goto skip; + } + goto fail_nonextensible; + } + h_obj = duk_get_hobject(ctx, 0); + if (!h_obj) { + goto skip; + } + DUK_ASSERT(h_obj != NULL); + + /* [[SetPrototypeOf]] standard behavior, E6 9.1.2 */ + /* TODO: implement Proxy object support here */ + + if (h_new_proto == DUK_HOBJECT_GET_PROTOTYPE(thr->heap, h_obj)) { + goto skip; + } + if (!DUK_HOBJECT_HAS_EXTENSIBLE(h_obj)) { + goto fail_nonextensible; + } + for (h_curr = h_new_proto; h_curr != NULL; h_curr = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, h_curr)) { + /* Loop prevention */ + if (h_curr == h_obj) { + goto fail_loop; + } + } + DUK_HOBJECT_SET_PROTOTYPE_UPDREF(thr, h_obj, h_new_proto); + /* fall thru */ + + skip: + duk_set_top(ctx, 1); + return ret_success; + + fail_nonextensible: + fail_loop: + return DUK_RET_TYPE_ERROR; +} + +DUK_INTERNAL duk_ret_t duk_bi_object_constructor_get_own_property_descriptor(duk_context *ctx) { + /* XXX: no need for indirect call */ + return duk_hobject_object_get_own_property_descriptor(ctx); +} + +DUK_INTERNAL duk_ret_t duk_bi_object_constructor_create(duk_context *ctx) { + duk_tval *tv; + duk_hobject *proto = NULL; + + DUK_ASSERT_TOP(ctx, 2); + + tv = duk_get_tval(ctx, 0); + DUK_ASSERT(tv != NULL); + if (DUK_TVAL_IS_NULL(tv)) { + ; + } else if (DUK_TVAL_IS_OBJECT(tv)) { + proto = DUK_TVAL_GET_OBJECT(tv); + DUK_ASSERT(proto != NULL); + } else { + return DUK_RET_TYPE_ERROR; + } + + (void) duk_push_object_helper_proto(ctx, + DUK_HOBJECT_FLAG_EXTENSIBLE | + DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_OBJECT), + proto); + + if (!duk_is_undefined(ctx, 1)) { + /* [ O Properties obj ] */ + + duk_replace(ctx, 0); + + /* [ obj Properties ] */ + + /* Just call the "original" Object.defineProperties() to + * finish up. + */ + + return duk_bi_object_constructor_define_properties(ctx); + } + + /* [ O Properties obj ] */ + + return 1; +} + +DUK_INTERNAL duk_ret_t duk_bi_object_constructor_define_property(duk_context *ctx) { + duk_hobject *obj; + duk_hstring *key; + duk_hobject *get; + duk_hobject *set; + duk_idx_t idx_value; + duk_uint_t defprop_flags; + + DUK_ASSERT(ctx != NULL); + + DUK_DDD(DUK_DDDPRINT("Object.defineProperty(): ctx=%p obj=%!T key=%!T desc=%!T", + (void *) ctx, + (duk_tval *) duk_get_tval(ctx, 0), + (duk_tval *) duk_get_tval(ctx, 1), + (duk_tval *) duk_get_tval(ctx, 2))); + + /* [ obj key desc ] */ + + /* Lightfuncs are currently supported by coercing to a temporary + * Function object; changes will be allowed (the coerced value is + * extensible) but will be lost. + */ + obj = duk_require_hobject_or_lfunc_coerce(ctx, 0); + (void) duk_to_string(ctx, 1); + key = duk_require_hstring(ctx, 1); + (void) duk_require_hobject(ctx, 2); + + DUK_ASSERT(obj != NULL); + DUK_ASSERT(key != NULL); + DUK_ASSERT(duk_get_hobject(ctx, 2) != NULL); + + /* + * Validate and convert argument property descriptor (an Ecmascript + * object) into a set of defprop_flags and possibly property value, + * getter, and/or setter values on the value stack. + * + * Lightfunc set/get values are coerced to full Functions. + */ + + duk_hobject_prepare_property_descriptor(ctx, + 2 /*idx_desc*/, + &defprop_flags, + &idx_value, + &get, + &set); + + /* + * Use Object.defineProperty() helper for the actual operation. + */ + + duk_hobject_define_property_helper(ctx, + defprop_flags, + obj, + key, + idx_value, + get, + set); + + /* Ignore the normalize/validate helper outputs on the value stack, + * they're popped automatically. + */ + + /* + * Return target object. + */ + + duk_push_hobject(ctx, obj); + return 1; +} + +DUK_INTERNAL duk_ret_t duk_bi_object_constructor_define_properties(duk_context *ctx) { + duk_small_uint_t pass; + duk_uint_t defprop_flags; + duk_hobject *obj; + duk_idx_t idx_value; + duk_hobject *get; + duk_hobject *set; + + /* Lightfunc handling by ToObject() coercion. */ + obj = duk_require_hobject_or_lfunc_coerce(ctx, 0); /* target */ + DUK_ASSERT(obj != NULL); + + duk_to_object(ctx, 1); /* properties object */ + + DUK_DDD(DUK_DDDPRINT("target=%!iT, properties=%!iT", + (duk_tval *) duk_get_tval(ctx, 0), + (duk_tval *) duk_get_tval(ctx, 1))); + + /* + * Two pass approach to processing the property descriptors. + * On first pass validate and normalize all descriptors before + * any changes are made to the target object. On second pass + * make the actual modifications to the target object. + * + * Right now we'll just use the same normalize/validate helper + * on both passes, ignoring its outputs on the first pass. + */ + + for (pass = 0; pass < 2; pass++) { + duk_set_top(ctx, 2); /* -> [ hobject props ] */ + duk_enum(ctx, 1, DUK_ENUM_OWN_PROPERTIES_ONLY /*enum_flags*/); + + for (;;) { + duk_hstring *key; + + /* [ hobject props enum(props) ] */ + + duk_set_top(ctx, 3); + + if (!duk_next(ctx, 2, 1 /*get_value*/)) { + break; + } + + DUK_DDD(DUK_DDDPRINT("-> key=%!iT, desc=%!iT", + (duk_tval *) duk_get_tval(ctx, -2), + (duk_tval *) duk_get_tval(ctx, -1))); + + /* [ hobject props enum(props) key desc ] */ + + duk_hobject_prepare_property_descriptor(ctx, + 4 /*idx_desc*/, + &defprop_flags, + &idx_value, + &get, + &set); + + /* [ hobject props enum(props) key desc value? getter? setter? ] */ + + if (pass == 0) { + continue; + } + + key = duk_get_hstring(ctx, 3); + DUK_ASSERT(key != NULL); + + duk_hobject_define_property_helper(ctx, + defprop_flags, + obj, + key, + idx_value, + get, + set); + } + } + + /* + * Return target object + */ + + duk_dup(ctx, 0); + return 1; +} + +DUK_INTERNAL duk_ret_t duk_bi_object_constructor_seal_freeze_shared(duk_context *ctx) { + duk_hthread *thr = (duk_hthread *) ctx; + duk_hobject *h; + duk_bool_t is_freeze; + + h = duk_require_hobject_or_lfunc(ctx, 0); + if (!h) { + /* Lightfunc, always success. */ + return 1; + } + + is_freeze = (duk_bool_t) duk_get_current_magic(ctx); + duk_hobject_object_seal_freeze_helper(thr, h, is_freeze); + + /* Sealed and frozen objects cannot gain any more properties, + * so this is a good time to compact them. + */ + duk_hobject_compact_props(thr, h); + + return 1; +} + +DUK_INTERNAL duk_ret_t duk_bi_object_constructor_prevent_extensions(duk_context *ctx) { + duk_hthread *thr = (duk_hthread *) ctx; + duk_hobject *h; + + h = duk_require_hobject_or_lfunc(ctx, 0); + if (!h) { + /* Lightfunc, always success. */ + return 1; + } + DUK_ASSERT(h != NULL); + + DUK_HOBJECT_CLEAR_EXTENSIBLE(h); + + /* A non-extensible object cannot gain any more properties, + * so this is a good time to compact. + */ + duk_hobject_compact_props(thr, h); + + return 1; +} + +DUK_INTERNAL duk_ret_t duk_bi_object_constructor_is_sealed_frozen_shared(duk_context *ctx) { + duk_hobject *h; + duk_bool_t is_frozen; + duk_bool_t rc; + + h = duk_require_hobject_or_lfunc(ctx, 0); + if (!h) { + duk_push_true(ctx); /* frozen and sealed */ + } else { + is_frozen = duk_get_current_magic(ctx); + rc = duk_hobject_object_is_sealed_frozen_helper((duk_hthread *) ctx, h, is_frozen /*is_frozen*/); + duk_push_boolean(ctx, rc); + } + return 1; +} + +DUK_INTERNAL duk_ret_t duk_bi_object_constructor_is_extensible(duk_context *ctx) { + duk_hobject *h; + + h = duk_require_hobject_or_lfunc(ctx, 0); + if (!h) { + duk_push_false(ctx); + } else { + duk_push_boolean(ctx, DUK_HOBJECT_HAS_EXTENSIBLE(h)); + } + return 1; +} + +/* Shared helper for Object.getOwnPropertyNames() and Object.keys(). + * Magic: 0=getOwnPropertyNames, 1=Object.keys. + */ +DUK_INTERNAL duk_ret_t duk_bi_object_constructor_keys_shared(duk_context *ctx) { + duk_hthread *thr = (duk_hthread *) ctx; + duk_hobject *obj; +#if defined(DUK_USE_ES6_PROXY) + duk_hobject *h_proxy_target; + duk_hobject *h_proxy_handler; + duk_hobject *h_trap_result; + duk_uarridx_t i, len, idx; +#endif + duk_small_uint_t enum_flags; + + DUK_ASSERT_TOP(ctx, 1); + DUK_UNREF(thr); + + obj = duk_require_hobject_or_lfunc_coerce(ctx, 0); + DUK_ASSERT(obj != NULL); + DUK_UNREF(obj); + +#if defined(DUK_USE_ES6_PROXY) + if (DUK_LIKELY(!duk_hobject_proxy_check(thr, + obj, + &h_proxy_target, + &h_proxy_handler))) { + goto skip_proxy; + } + + duk_push_hobject(ctx, h_proxy_handler); + if (!duk_get_prop_stridx(ctx, -1, DUK_STRIDX_OWN_KEYS)) { + /* Careful with reachability here: don't pop 'obj' before pushing + * proxy target. + */ + DUK_DDD(DUK_DDDPRINT("no ownKeys trap, get keys of target instead")); + duk_pop_2(ctx); + duk_push_hobject(ctx, h_proxy_target); + duk_replace(ctx, 0); + DUK_ASSERT_TOP(ctx, 1); + goto skip_proxy; + } + + /* [ obj handler trap ] */ + duk_insert(ctx, -2); + duk_push_hobject(ctx, h_proxy_target); /* -> [ obj trap handler target ] */ + duk_call_method(ctx, 1 /*nargs*/); /* -> [ obj trap_result ] */ + h_trap_result = duk_require_hobject(ctx, -1); + DUK_UNREF(h_trap_result); + + len = (duk_uarridx_t) duk_get_length(ctx, -1); + idx = 0; + duk_push_array(ctx); + for (i = 0; i < len; i++) { + /* [ obj trap_result res_arr ] */ + if (duk_get_prop_index(ctx, -2, i) && duk_is_string(ctx, -1)) { + /* XXX: for Object.keys() we should check enumerability of key */ + /* [ obj trap_result res_arr propname ] */ + duk_put_prop_index(ctx, -2, idx); + idx++; + } else { + duk_pop(ctx); + } + } + + /* XXX: missing trap result validation for non-configurable target keys + * (must be present), for non-extensible target all target keys must be + * present and no extra keys can be present. + * http://www.ecma-international.org/ecma-262/6.0/#sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys + */ + + /* XXX: for Object.keys() the [[OwnPropertyKeys]] result (trap result) + * should be filtered so that only enumerable keys remain. Enumerability + * should be checked with [[GetOwnProperty]] on the original object + * (i.e., the proxy in this case). If the proxy has a getOwnPropertyDescriptor + * trap, it should be triggered for every property. If the proxy doesn't have + * the trap, enumerability should be checked against the target object instead. + * We don't do any of this now, so Object.keys() and Object.getOwnPropertyNames() + * return the same result now for proxy traps. We still do clean up the trap + * result, so that Object.keys() and Object.getOwnPropertyNames() will return a + * clean array of strings without gaps. + */ + return 1; + + skip_proxy: +#endif /* DUK_USE_ES6_PROXY */ + + DUK_ASSERT_TOP(ctx, 1); + + if (duk_get_current_magic(ctx)) { + /* Object.keys */ + enum_flags = DUK_ENUM_OWN_PROPERTIES_ONLY | + DUK_ENUM_NO_PROXY_BEHAVIOR; + } else { + /* Object.getOwnPropertyNames */ + enum_flags = DUK_ENUM_INCLUDE_NONENUMERABLE | + DUK_ENUM_OWN_PROPERTIES_ONLY | + DUK_ENUM_NO_PROXY_BEHAVIOR; + } + + return duk_hobject_get_enumerated_keys(ctx, enum_flags); +} + +DUK_INTERNAL duk_ret_t duk_bi_object_prototype_to_string(duk_context *ctx) { + duk_push_this(ctx); + duk_to_object_class_string_top(ctx); + return 1; +} + +DUK_INTERNAL duk_ret_t duk_bi_object_prototype_to_locale_string(duk_context *ctx) { + DUK_ASSERT_TOP(ctx, 0); + (void) duk_push_this_coercible_to_object(ctx); + duk_get_prop_stridx(ctx, 0, DUK_STRIDX_TO_STRING); + if (!duk_is_callable(ctx, 1)) { + return DUK_RET_TYPE_ERROR; + } + duk_dup(ctx, 0); /* -> [ O toString O ] */ + duk_call_method(ctx, 0); /* XXX: call method tail call? */ + return 1; +} + +DUK_INTERNAL duk_ret_t duk_bi_object_prototype_value_of(duk_context *ctx) { + (void) duk_push_this_coercible_to_object(ctx); + return 1; +} + +DUK_INTERNAL duk_ret_t duk_bi_object_prototype_is_prototype_of(duk_context *ctx) { + duk_hthread *thr = (duk_hthread *) ctx; + duk_hobject *h_v; + duk_hobject *h_obj; + + DUK_ASSERT_TOP(ctx, 1); + + h_v = duk_get_hobject(ctx, 0); + if (!h_v) { + duk_push_false(ctx); /* XXX: tail call: return duk_push_false(ctx) */ + return 1; + } + + h_obj = duk_push_this_coercible_to_object(ctx); + DUK_ASSERT(h_obj != NULL); + + /* E5.1 Section 15.2.4.6, step 3.a, lookup proto once before compare. + * Prototype loops should cause an error to be thrown. + */ + duk_push_boolean(ctx, duk_hobject_prototype_chain_contains(thr, DUK_HOBJECT_GET_PROTOTYPE(thr->heap, h_v), h_obj, 0 /*ignore_loop*/)); + return 1; +} + +DUK_INTERNAL duk_ret_t duk_bi_object_prototype_has_own_property(duk_context *ctx) { + return duk_hobject_object_ownprop_helper(ctx, 0 /*required_desc_flags*/); +} + +DUK_INTERNAL duk_ret_t duk_bi_object_prototype_property_is_enumerable(duk_context *ctx) { + return duk_hobject_object_ownprop_helper(ctx, DUK_PROPDESC_FLAG_ENUMERABLE /*required_desc_flags*/); +} http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/a9485aeb/thirdparty/civetweb-1.9.1/src/third_party/duktape-1.5.2/src-separate/duk_bi_pointer.c ---------------------------------------------------------------------- diff --git a/thirdparty/civetweb-1.9.1/src/third_party/duktape-1.5.2/src-separate/duk_bi_pointer.c b/thirdparty/civetweb-1.9.1/src/third_party/duktape-1.5.2/src-separate/duk_bi_pointer.c new file mode 100644 index 0000000..340fbae --- /dev/null +++ b/thirdparty/civetweb-1.9.1/src/third_party/duktape-1.5.2/src-separate/duk_bi_pointer.c @@ -0,0 +1,74 @@ +/* + * Pointer built-ins + */ + +#include "duk_internal.h" + +/* + * Constructor + */ + +DUK_INTERNAL duk_ret_t duk_bi_pointer_constructor(duk_context *ctx) { + /* XXX: this behavior is quite useless now; it would be nice to be able + * to create pointer values from e.g. numbers or strings. Numbers are + * problematic on 64-bit platforms though. Hex encoded strings? + */ + if (duk_get_top(ctx) == 0) { + duk_push_pointer(ctx, NULL); + } else { + duk_to_pointer(ctx, 0); + } + DUK_ASSERT(duk_is_pointer(ctx, 0)); + duk_set_top(ctx, 1); + + if (duk_is_constructor_call(ctx)) { + duk_push_object_helper(ctx, + DUK_HOBJECT_FLAG_EXTENSIBLE | + DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_POINTER), + DUK_BIDX_POINTER_PROTOTYPE); + + /* Pointer object internal value is immutable */ + duk_dup(ctx, 0); + duk_xdef_prop_stridx(ctx, -2, DUK_STRIDX_INT_VALUE, DUK_PROPDESC_FLAGS_NONE); + } + /* Note: unbalanced stack on purpose */ + + return 1; +} + +/* + * toString(), valueOf() + */ + +DUK_INTERNAL duk_ret_t duk_bi_pointer_prototype_tostring_shared(duk_context *ctx) { + duk_tval *tv; + duk_small_int_t to_string = duk_get_current_magic(ctx); + + duk_push_this(ctx); + tv = duk_require_tval(ctx, -1); + DUK_ASSERT(tv != NULL); + + if (DUK_TVAL_IS_POINTER(tv)) { + /* nop */ + } else if (DUK_TVAL_IS_OBJECT(tv)) { + duk_hobject *h = DUK_TVAL_GET_OBJECT(tv); + DUK_ASSERT(h != NULL); + + /* Must be a "pointer object", i.e. class "Pointer" */ + if (DUK_HOBJECT_GET_CLASS_NUMBER(h) != DUK_HOBJECT_CLASS_POINTER) { + goto type_error; + } + + duk_get_prop_stridx(ctx, -1, DUK_STRIDX_INT_VALUE); + } else { + goto type_error; + } + + if (to_string) { + duk_to_string(ctx, -1); + } + return 1; + + type_error: + return DUK_RET_TYPE_ERROR; +} http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/a9485aeb/thirdparty/civetweb-1.9.1/src/third_party/duktape-1.5.2/src-separate/duk_bi_protos.h ---------------------------------------------------------------------- diff --git a/thirdparty/civetweb-1.9.1/src/third_party/duktape-1.5.2/src-separate/duk_bi_protos.h b/thirdparty/civetweb-1.9.1/src/third_party/duktape-1.5.2/src-separate/duk_bi_protos.h new file mode 100644 index 0000000..f9b42bc --- /dev/null +++ b/thirdparty/civetweb-1.9.1/src/third_party/duktape-1.5.2/src-separate/duk_bi_protos.h @@ -0,0 +1,69 @@ +/* + * Prototypes for built-in functions not automatically covered by the + * header declarations emitted by genbuiltins.py. + */ + +#ifndef DUK_BUILTIN_PROTOS_H_INCLUDED +#define DUK_BUILTIN_PROTOS_H_INCLUDED + +/* Buffer size needed for duk_bi_date_format_timeval(). + * Accurate value is 32 + 1 for NUL termination: + * >>> len('+123456-01-23T12:34:56.123+12:34') + * 32 + * Include additional space to be safe. + */ +#define DUK_BI_DATE_ISO8601_BUFSIZE 48 + +/* Maximum length of CommonJS module identifier to resolve. Length includes + * both current module ID, requested (possibly relative) module ID, and a + * slash in between. + */ +#define DUK_BI_COMMONJS_MODULE_ID_LIMIT 256 + +/* Helpers exposed for internal use */ +DUK_INTERNAL_DECL void duk_bi_date_timeval_to_parts(duk_double_t d, duk_int_t *parts, duk_double_t *dparts, duk_small_uint_t flags); +DUK_INTERNAL_DECL duk_double_t duk_bi_date_get_timeval_from_dparts(duk_double_t *dparts, duk_small_uint_t flags); +DUK_INTERNAL_DECL void duk_bi_date_format_timeval(duk_double_t timeval, duk_uint8_t *out_buf); +DUK_INTERNAL_DECL duk_bool_t duk_bi_date_is_leap_year(duk_int_t year); +DUK_INTERNAL_DECL duk_bool_t duk_bi_date_timeval_in_valid_range(duk_double_t x); +DUK_INTERNAL_DECL duk_bool_t duk_bi_date_year_in_valid_range(duk_double_t year); +DUK_INTERNAL_DECL duk_bool_t duk_bi_date_timeval_in_leeway_range(duk_double_t x); +/* Built-in providers */ +#if defined(DUK_USE_DATE_NOW_GETTIMEOFDAY) +DUK_INTERNAL_DECL duk_double_t duk_bi_date_get_now_gettimeofday(duk_context *ctx); +#endif +#if defined(DUK_USE_DATE_NOW_TIME) +DUK_INTERNAL_DECL duk_double_t duk_bi_date_get_now_time(duk_context *ctx); +#endif +#if defined(DUK_USE_DATE_NOW_WINDOWS) +DUK_INTERNAL_DECL duk_double_t duk_bi_date_get_now_windows(duk_context *ctx); +#endif +#if defined(DUK_USE_DATE_TZO_GMTIME_R) || defined(DUK_USE_DATE_TZO_GMTIME) +DUK_INTERNAL_DECL duk_int_t duk_bi_date_get_local_tzoffset_gmtime(duk_double_t d); +#endif +#if defined(DUK_USE_DATE_TZO_WINDOWS) +DUK_INTERNAL_DECL duk_int_t duk_bi_date_get_local_tzoffset_windows(duk_double_t d); +#endif +#if defined(DUK_USE_DATE_PRS_STRPTIME) +DUK_INTERNAL_DECL duk_bool_t duk_bi_date_parse_string_strptime(duk_context *ctx, const char *str); +#endif +#if defined(DUK_USE_DATE_PRS_GETDATE) +DUK_INTERNAL_DECL duk_bool_t duk_bi_date_parse_string_getdate(duk_context *ctx, const char *str); +#endif +#if defined(DUK_USE_DATE_FMT_STRFTIME) +DUK_INTERNAL_DECL duk_bool_t duk_bi_date_format_parts_strftime(duk_context *ctx, duk_int_t *parts, duk_int_t tzoffset, duk_small_uint_t flags); +#endif + +DUK_INTERNAL_DECL +void duk_bi_json_parse_helper(duk_context *ctx, + duk_idx_t idx_value, + duk_idx_t idx_reviver, + duk_small_uint_t flags); +DUK_INTERNAL_DECL +void duk_bi_json_stringify_helper(duk_context *ctx, + duk_idx_t idx_value, + duk_idx_t idx_replacer, + duk_idx_t idx_space, + duk_small_uint_t flags); + +#endif /* DUK_BUILTIN_PROTOS_H_INCLUDED */ http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/a9485aeb/thirdparty/civetweb-1.9.1/src/third_party/duktape-1.5.2/src-separate/duk_bi_proxy.c ---------------------------------------------------------------------- diff --git a/thirdparty/civetweb-1.9.1/src/third_party/duktape-1.5.2/src-separate/duk_bi_proxy.c b/thirdparty/civetweb-1.9.1/src/third_party/duktape-1.5.2/src-separate/duk_bi_proxy.c new file mode 100644 index 0000000..9787ec4 --- /dev/null +++ b/thirdparty/civetweb-1.9.1/src/third_party/duktape-1.5.2/src-separate/duk_bi_proxy.c @@ -0,0 +1,66 @@ +/* + * Proxy built-in (ES6) + */ + +#include "duk_internal.h" + +#if defined(DUK_USE_ES6_PROXY) +DUK_INTERNAL duk_ret_t duk_bi_proxy_constructor(duk_context *ctx) { + duk_hobject *h_target; + duk_hobject *h_handler; + + if (!duk_is_constructor_call(ctx)) { + return DUK_RET_TYPE_ERROR; + } + + /* Reject a proxy object as the target because it would need + * special handler in property lookups. (ES6 has no such restriction) + */ + h_target = duk_require_hobject_or_lfunc_coerce(ctx, 0); + DUK_ASSERT(h_target != NULL); + if (DUK_HOBJECT_HAS_EXOTIC_PROXYOBJ(h_target)) { + return DUK_RET_TYPE_ERROR; + } + + /* Reject a proxy object as the handler because it would cause + * potentially unbounded recursion. (ES6 has no such restriction) + */ + h_handler = duk_require_hobject_or_lfunc_coerce(ctx, 1); + DUK_ASSERT(h_handler != NULL); + if (DUK_HOBJECT_HAS_EXOTIC_PROXYOBJ(h_handler)) { + return DUK_RET_TYPE_ERROR; + } + + /* XXX: the returned value is exotic in ES6, but we use a + * simple object here with no prototype. Without a prototype, + * [[DefaultValue]] coercion fails which is abit confusing. + * No callable check/handling in the current Proxy subset. + */ + (void) duk_push_object_helper_proto(ctx, + DUK_HOBJECT_FLAG_EXTENSIBLE | + DUK_HOBJECT_FLAG_EXOTIC_PROXYOBJ | + DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_OBJECT), + NULL); + DUK_ASSERT_TOP(ctx, 3); + + /* Make _Target and _Handler non-configurable and non-writable. + * They can still be forcibly changed by C code (both user and + * Duktape internal), but not by Ecmascript code. + */ + + /* Proxy target */ + duk_dup(ctx, 0); + duk_xdef_prop_stridx(ctx, -2, DUK_STRIDX_INT_TARGET, DUK_PROPDESC_FLAGS_NONE); + + /* Proxy handler */ + duk_dup(ctx, 1); + duk_xdef_prop_stridx(ctx, -2, DUK_STRIDX_INT_HANDLER, DUK_PROPDESC_FLAGS_NONE); + + return 1; /* replacement handler */ +} +#else /* DUK_USE_ES6_PROXY */ +DUK_INTERNAL duk_ret_t duk_bi_proxy_constructor(duk_context *ctx) { + DUK_UNREF(ctx); + return DUK_RET_UNSUPPORTED_ERROR; +} +#endif /* DUK_USE_ES6_PROXY */ http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/a9485aeb/thirdparty/civetweb-1.9.1/src/third_party/duktape-1.5.2/src-separate/duk_bi_regexp.c ---------------------------------------------------------------------- diff --git a/thirdparty/civetweb-1.9.1/src/third_party/duktape-1.5.2/src-separate/duk_bi_regexp.c b/thirdparty/civetweb-1.9.1/src/third_party/duktape-1.5.2/src-separate/duk_bi_regexp.c new file mode 100644 index 0000000..2259c77 --- /dev/null +++ b/thirdparty/civetweb-1.9.1/src/third_party/duktape-1.5.2/src-separate/duk_bi_regexp.c @@ -0,0 +1,209 @@ +/* + * RegExp built-ins + */ + +#include "duk_internal.h" + +#ifdef DUK_USE_REGEXP_SUPPORT + +DUK_LOCAL void duk__get_this_regexp(duk_context *ctx) { + duk_hobject *h; + + duk_push_this(ctx); + h = duk_require_hobject_with_class(ctx, -1, DUK_HOBJECT_CLASS_REGEXP); + DUK_ASSERT(h != NULL); + DUK_UNREF(h); + duk_insert(ctx, 0); /* prepend regexp to valstack 0 index */ +} + +/* XXX: much to improve (code size) */ +DUK_INTERNAL duk_ret_t duk_bi_regexp_constructor(duk_context *ctx) { + duk_hthread *thr = (duk_hthread *) ctx; + duk_hobject *h_pattern; + + DUK_ASSERT_TOP(ctx, 2); + h_pattern = duk_get_hobject(ctx, 0); + + if (!duk_is_constructor_call(ctx) && + h_pattern != NULL && + DUK_HOBJECT_GET_CLASS_NUMBER(h_pattern) == DUK_HOBJECT_CLASS_REGEXP && + duk_is_undefined(ctx, 1)) { + /* Called as a function, pattern has [[Class]] "RegExp" and + * flags is undefined -> return object as is. + */ + duk_dup(ctx, 0); + return 1; + } + + /* Else functionality is identical for function call and constructor + * call. + */ + + if (h_pattern != NULL && + DUK_HOBJECT_GET_CLASS_NUMBER(h_pattern) == DUK_HOBJECT_CLASS_REGEXP) { + if (duk_is_undefined(ctx, 1)) { + duk_bool_t flag_g, flag_i, flag_m; + duk_get_prop_stridx(ctx, 0, DUK_STRIDX_SOURCE); + flag_g = duk_get_prop_stridx_boolean(ctx, 0, DUK_STRIDX_GLOBAL, NULL); + flag_i = duk_get_prop_stridx_boolean(ctx, 0, DUK_STRIDX_IGNORE_CASE, NULL); + flag_m = duk_get_prop_stridx_boolean(ctx, 0, DUK_STRIDX_MULTILINE, NULL); + + duk_push_sprintf(ctx, "%s%s%s", + (const char *) (flag_g ? "g" : ""), + (const char *) (flag_i ? "i" : ""), + (const char *) (flag_m ? "m" : "")); + + /* [ ... pattern flags ] */ + } else { + return DUK_RET_TYPE_ERROR; + } + } else { + if (duk_is_undefined(ctx, 0)) { + duk_push_string(ctx, ""); + } else { + duk_dup(ctx, 0); + duk_to_string(ctx, -1); + } + if (duk_is_undefined(ctx, 1)) { + duk_push_string(ctx, ""); + } else { + duk_dup(ctx, 1); + duk_to_string(ctx, -1); + } + + /* [ ... pattern flags ] */ + } + + DUK_DDD(DUK_DDDPRINT("RegExp constructor/function call, pattern=%!T, flags=%!T", + (duk_tval *) duk_get_tval(ctx, -2), (duk_tval *) duk_get_tval(ctx, -1))); + + /* [ ... pattern flags ] */ + + duk_regexp_compile(thr); + + /* [ ... bytecode escaped_source ] */ + + duk_regexp_create_instance(thr); + + /* [ ... RegExp ] */ + + return 1; +} + +DUK_INTERNAL duk_ret_t duk_bi_regexp_prototype_exec(duk_context *ctx) { + duk__get_this_regexp(ctx); + + /* [ regexp input ] */ + + duk_regexp_match((duk_hthread *) ctx); + + /* [ result ] */ + + return 1; +} + +DUK_INTERNAL duk_ret_t duk_bi_regexp_prototype_test(duk_context *ctx) { + duk__get_this_regexp(ctx); + + /* [ regexp input ] */ + + /* result object is created and discarded; wasteful but saves code space */ + duk_regexp_match((duk_hthread *) ctx); + + /* [ result ] */ + + duk_push_boolean(ctx, (duk_is_null(ctx, -1) ? 0 : 1)); + + return 1; +} + +DUK_INTERNAL duk_ret_t duk_bi_regexp_prototype_to_string(duk_context *ctx) { + duk_hstring *h_bc; + duk_small_int_t re_flags; + +#if 0 + /* A little tricky string approach to provide the flags string. + * This depends on the specific flag values in duk_regexp.h, + * which needs to be asserted for. In practice this doesn't + * produce more compact code than the easier approach in use. + */ + + const char *flag_strings = "gim\0gi\0gm\0g\0"; + duk_uint8_t flag_offsets[8] = { + (duk_uint8_t) 3, /* flags: "" */ + (duk_uint8_t) 10, /* flags: "g" */ + (duk_uint8_t) 5, /* flags: "i" */ + (duk_uint8_t) 4, /* flags: "gi" */ + (duk_uint8_t) 2, /* flags: "m" */ + (duk_uint8_t) 7, /* flags: "gm" */ + (duk_uint8_t) 1, /* flags: "im" */ + (duk_uint8_t) 0, /* flags: "gim" */ + }; + DUK_ASSERT(DUK_RE_FLAG_GLOBAL == 1); + DUK_ASSERT(DUK_RE_FLAG_IGNORE_CASE == 2); + DUK_ASSERT(DUK_RE_FLAG_MULTILINE == 4); +#endif + + duk__get_this_regexp(ctx); + + /* [ regexp ] */ + + duk_get_prop_stridx(ctx, 0, DUK_STRIDX_SOURCE); + duk_get_prop_stridx(ctx, 0, DUK_STRIDX_INT_BYTECODE); + h_bc = duk_get_hstring(ctx, -1); + DUK_ASSERT(h_bc != NULL); + DUK_ASSERT(DUK_HSTRING_GET_BYTELEN(h_bc) >= 1); + DUK_ASSERT(DUK_HSTRING_GET_CHARLEN(h_bc) >= 1); + DUK_ASSERT(DUK_HSTRING_GET_DATA(h_bc)[0] < 0x80); + re_flags = (duk_small_int_t) DUK_HSTRING_GET_DATA(h_bc)[0]; + + /* [ regexp source bytecode ] */ + +#if 1 + /* This is a cleaner approach and also produces smaller code than + * the other alternative. Use duk_require_string() for format + * safety (although the source property should always exist). + */ + duk_push_sprintf(ctx, "/%s/%s%s%s", + (const char *) duk_require_string(ctx, -2), /* require to be safe */ + (re_flags & DUK_RE_FLAG_GLOBAL) ? "g" : "", + (re_flags & DUK_RE_FLAG_IGNORE_CASE) ? "i" : "", + (re_flags & DUK_RE_FLAG_MULTILINE) ? "m" : ""); +#else + /* This should not be necessary because no-one should tamper with the + * regexp bytecode, but is prudent to avoid potential segfaults if that + * were to happen for some reason. + */ + re_flags &= 0x07; + DUK_ASSERT(re_flags >= 0 && re_flags <= 7); /* three flags */ + duk_push_sprintf(ctx, "/%s/%s", + (const char *) duk_require_string(ctx, -2), + (const char *) (flag_strings + flag_offsets[re_flags])); +#endif + + return 1; +} + +#else /* DUK_USE_REGEXP_SUPPORT */ + +DUK_INTERNAL duk_ret_t duk_bi_regexp_constructor(duk_context *ctx) { + DUK_UNREF(ctx); + return DUK_RET_UNSUPPORTED_ERROR; +} + +DUK_INTERNAL duk_ret_t duk_bi_regexp_prototype_exec(duk_context *ctx) { + DUK_UNREF(ctx); + return DUK_RET_UNSUPPORTED_ERROR; +} + +DUK_INTERNAL duk_ret_t duk_bi_regexp_prototype_test(duk_context *ctx) { + DUK_UNREF(ctx); + return DUK_RET_UNSUPPORTED_ERROR; +} + +DUK_INTERNAL duk_ret_t duk_bi_regexp_prototype_to_string(duk_context *ctx) { + DUK_UNREF(ctx); + return DUK_RET_UNSUPPORTED_ERROR; +} + +#endif /* DUK_USE_REGEXP_SUPPORT */
