Return-Path: X-Original-To: archive-asf-public@eu.ponee.io Delivered-To: archive-asf-public@eu.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by mx-eu-01.ponee.io (Postfix) with ESMTP id CEE02180784 for ; Tue, 2 Jan 2018 19:28:05 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id BF134160C3F; Tue, 2 Jan 2018 18:28:05 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 1FB2A160C52 for ; Tue, 2 Jan 2018 19:28:00 +0100 (CET) Received: (qmail 8502 invoked by uid 500); 2 Jan 2018 18:28:00 -0000 Mailing-List: contact commits-help@nifi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@nifi.apache.org Delivered-To: mailing list commits@nifi.apache.org Received: (qmail 7738 invoked by uid 99); 2 Jan 2018 18:27:59 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Jan 2018 18:27:59 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id C6C4BF2DF6; Tue, 2 Jan 2018 18:27:57 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: phrocker@apache.org To: commits@nifi.apache.org Date: Tue, 02 Jan 2018 18:28:28 -0000 Message-Id: In-Reply-To: <393125fe9d4f4240ad0d4ebb59d982bb@git.apache.org> References: <393125fe9d4f4240ad0d4ebb59d982bb@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [33/51] [partial] nifi-minifi-cpp git commit: MINIFICPP-351: Remove Civetweb third party directory archived-at: Tue, 02 Jan 2018 18:28:07 -0000 http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/ede68a10/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_api_compile.c ---------------------------------------------------------------------- diff --git a/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_api_compile.c b/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_api_compile.c deleted file mode 100644 index 38677ba..0000000 --- a/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_api_compile.c +++ /dev/null @@ -1,194 +0,0 @@ -/* - * Compilation and evaluation - */ - -#include "duk_internal.h" - -typedef struct duk__compile_raw_args duk__compile_raw_args; -struct duk__compile_raw_args { - duk_size_t src_length; /* should be first on 64-bit platforms */ - const duk_uint8_t *src_buffer; - duk_uint_t flags; -}; - -/* Eval is just a wrapper now. */ -DUK_EXTERNAL duk_int_t duk_eval_raw(duk_context *ctx, const char *src_buffer, duk_size_t src_length, duk_uint_t flags) { - duk_uint_t comp_flags; - duk_int_t rc; - - DUK_ASSERT_CTX_VALID(ctx); - - /* Note: strictness is *not* inherited from the current Duktape/C. - * This would be confusing because the current strictness state - * depends on whether we're running inside a Duktape/C activation - * (= strict mode) or outside of any activation (= non-strict mode). - * See tests/api/test-eval-strictness.c for more discussion. - */ - - /* [ ... source? filename? ] (depends on flags) */ - - comp_flags = flags; - comp_flags |= DUK_COMPILE_EVAL; - rc = duk_compile_raw(ctx, src_buffer, src_length, comp_flags); /* may be safe, or non-safe depending on flags */ - - /* [ ... closure/error ] */ - - if (rc != DUK_EXEC_SUCCESS) { - rc = DUK_EXEC_ERROR; - goto got_rc; - } - - duk_push_global_object(ctx); /* explicit 'this' binding, see GH-164 */ - - if (flags & DUK_COMPILE_SAFE) { - rc = duk_pcall_method(ctx, 0); - } else { - duk_call_method(ctx, 0); - rc = DUK_EXEC_SUCCESS; - } - - /* [ ... result/error ] */ - - got_rc: - if (flags & DUK_COMPILE_NORESULT) { - duk_pop(ctx); - } - - return rc; -} - -/* Helper which can be called both directly and with duk_safe_call(). */ -DUK_LOCAL duk_ret_t duk__do_compile(duk_context *ctx) { - duk_hthread *thr = (duk_hthread *) ctx; - duk__compile_raw_args *comp_args; - duk_uint_t flags; - duk_small_uint_t comp_flags; - duk_hcompiledfunction *h_templ; - - DUK_ASSERT_CTX_VALID(ctx); - - /* Note: strictness is not inherited from the current Duktape/C - * context. Otherwise it would not be possible to compile - * non-strict code inside a Duktape/C activation (which is - * always strict now). See tests/api/test-eval-strictness.c - * for discussion. - */ - - /* [ ... source? filename? &comp_args ] (depends on flags) */ - - comp_args = (duk__compile_raw_args *) duk_require_pointer(ctx, -1); - flags = comp_args->flags; - duk_pop(ctx); - - /* [ ... source? filename? ] */ - - if (flags & DUK_COMPILE_NOFILENAME) { - /* Automatic filename: 'eval' or 'input'. */ - duk_push_hstring_stridx(ctx, (flags & DUK_COMPILE_EVAL) ? DUK_STRIDX_EVAL : DUK_STRIDX_INPUT); - } - - /* [ ... source? filename ] */ - - if (!comp_args->src_buffer) { - duk_hstring *h_sourcecode; - - h_sourcecode = duk_get_hstring(ctx, -2); - if ((flags & DUK_COMPILE_NOSOURCE) || /* args incorrect */ - (h_sourcecode == NULL)) { /* e.g. duk_push_string_file_raw() pushed undefined */ - /* XXX: when this error is caused by a nonexistent - * file given to duk_peval_file() or similar, the - * error message is not the best possible. - */ - DUK_ERROR_API(thr, DUK_STR_NO_SOURCECODE); - } - DUK_ASSERT(h_sourcecode != NULL); - comp_args->src_buffer = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h_sourcecode); - comp_args->src_length = (duk_size_t) DUK_HSTRING_GET_BYTELEN(h_sourcecode); - } - DUK_ASSERT(comp_args->src_buffer != NULL); - - /* XXX: unnecessary translation of flags */ - comp_flags = 0; - if (flags & DUK_COMPILE_EVAL) { - comp_flags |= DUK_JS_COMPILE_FLAG_EVAL; - } - if (flags & DUK_COMPILE_FUNCTION) { - comp_flags |= DUK_JS_COMPILE_FLAG_EVAL | - DUK_JS_COMPILE_FLAG_FUNCEXPR; - } - if (flags & DUK_COMPILE_STRICT) { - comp_flags |= DUK_JS_COMPILE_FLAG_STRICT; - } - - /* [ ... source? filename ] */ - - duk_js_compile(thr, comp_args->src_buffer, comp_args->src_length, comp_flags); - - /* [ ... source? func_template ] */ - - if (flags & DUK_COMPILE_NOSOURCE) { - ; - } else { - duk_remove(ctx, -2); - } - - /* [ ... func_template ] */ - - h_templ = (duk_hcompiledfunction *) duk_get_hobject(ctx, -1); - DUK_ASSERT(h_templ != NULL); - duk_js_push_closure(thr, - h_templ, - thr->builtins[DUK_BIDX_GLOBAL_ENV], - thr->builtins[DUK_BIDX_GLOBAL_ENV], - 1 /*add_auto_proto*/); - duk_remove(ctx, -2); /* -> [ ... closure ] */ - - /* [ ... closure ] */ - - return 1; -} - -DUK_EXTERNAL duk_int_t duk_compile_raw(duk_context *ctx, const char *src_buffer, duk_size_t src_length, duk_uint_t flags) { - duk__compile_raw_args comp_args_alloc; - duk__compile_raw_args *comp_args = &comp_args_alloc; - - DUK_ASSERT_CTX_VALID(ctx); - - if ((flags & DUK_COMPILE_STRLEN) && (src_buffer != NULL)) { - /* String length is computed here to avoid multiple evaluation - * of a macro argument in the calling side. - */ - src_length = DUK_STRLEN(src_buffer); - } - - comp_args->src_buffer = (const duk_uint8_t *) src_buffer; - comp_args->src_length = src_length; - comp_args->flags = flags; - duk_push_pointer(ctx, (void *) comp_args); - - /* [ ... source? filename? &comp_args ] (depends on flags) */ - - if (flags & DUK_COMPILE_SAFE) { - duk_int_t rc; - duk_int_t nargs; - duk_int_t nrets = 1; - - /* Arguments can be: [ source? filename? &comp_args] so that - * nargs is 1 to 3. Call site encodes the correct nargs count - * directly into flags. - */ - nargs = flags & 0x07; - DUK_ASSERT(nargs == (1 + - ((flags & DUK_COMPILE_NOSOURCE) ? 0 : 1) + - ((flags & DUK_COMPILE_NOFILENAME) ? 0 : 1))); - rc = duk_safe_call(ctx, duk__do_compile, nargs, nrets); - - /* [ ... closure ] */ - return rc; - } - - (void) duk__do_compile(ctx); - - /* [ ... closure ] */ - return DUK_EXEC_SUCCESS; -} http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/ede68a10/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_api_debug.c ---------------------------------------------------------------------- diff --git a/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_api_debug.c b/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_api_debug.c deleted file mode 100644 index 9698b82..0000000 --- a/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_api_debug.c +++ /dev/null @@ -1,263 +0,0 @@ -/* - * Debugging related API calls - */ - -#include "duk_internal.h" - -DUK_EXTERNAL void duk_push_context_dump(duk_context *ctx) { - duk_idx_t idx; - duk_idx_t top; - - DUK_ASSERT_CTX_VALID(ctx); - - /* We don't duk_require_stack() here now, but rely on the caller having - * enough space. - */ - - top = duk_get_top(ctx); - duk_push_array(ctx); - for (idx = 0; idx < top; idx++) { - duk_dup(ctx, idx); - duk_put_prop_index(ctx, -2, idx); - } - - /* XXX: conversion errors should not propagate outwards. - * Perhaps values need to be coerced individually? - */ - duk_bi_json_stringify_helper(ctx, - duk_get_top_index(ctx), /*idx_value*/ - DUK_INVALID_INDEX, /*idx_replacer*/ - DUK_INVALID_INDEX, /*idx_space*/ - DUK_JSON_FLAG_EXT_CUSTOM | - DUK_JSON_FLAG_ASCII_ONLY | - DUK_JSON_FLAG_AVOID_KEY_QUOTES /*flags*/); - - duk_push_sprintf(ctx, "ctx: top=%ld, stack=%s", (long) top, (const char *) duk_safe_to_string(ctx, -1)); - duk_replace(ctx, -3); /* [ ... arr jsonx(arr) res ] -> [ ... res jsonx(arr) ] */ - duk_pop(ctx); - DUK_ASSERT(duk_is_string(ctx, -1)); -} - -#if defined(DUK_USE_DEBUGGER_SUPPORT) - -DUK_EXTERNAL void duk_debugger_attach_custom(duk_context *ctx, - duk_debug_read_function read_cb, - duk_debug_write_function write_cb, - duk_debug_peek_function peek_cb, - duk_debug_read_flush_function read_flush_cb, - duk_debug_write_flush_function write_flush_cb, - duk_debug_request_function request_cb, - duk_debug_detached_function detached_cb, - void *udata) { - duk_hthread *thr = (duk_hthread *) ctx; - duk_heap *heap; - const char *str; - duk_size_t len; - - /* XXX: should there be an error or an automatic detach if - * already attached? - */ - - DUK_D(DUK_DPRINT("application called duk_debugger_attach()")); - - DUK_ASSERT_CTX_VALID(ctx); - DUK_ASSERT(read_cb != NULL); - DUK_ASSERT(write_cb != NULL); - /* Other callbacks are optional. */ - - heap = thr->heap; - heap->dbg_read_cb = read_cb; - heap->dbg_write_cb = write_cb; - heap->dbg_peek_cb = peek_cb; - heap->dbg_read_flush_cb = read_flush_cb; - heap->dbg_write_flush_cb = write_flush_cb; - heap->dbg_request_cb = request_cb; - heap->dbg_detached_cb = detached_cb; - heap->dbg_udata = udata; - heap->dbg_have_next_byte = 0; - - /* Start in paused state. */ - heap->dbg_processing = 0; - heap->dbg_paused = 1; - heap->dbg_state_dirty = 1; - heap->dbg_force_restart = 0; - heap->dbg_step_type = 0; - heap->dbg_step_thread = NULL; - heap->dbg_step_csindex = 0; - heap->dbg_step_startline = 0; - heap->dbg_exec_counter = 0; - heap->dbg_last_counter = 0; - heap->dbg_last_time = 0.0; - - /* Send version identification and flush right afterwards. Note that - * we must write raw, unframed bytes here. - */ - duk_push_sprintf(ctx, "%ld %ld %s %s\n", - (long) DUK_DEBUG_PROTOCOL_VERSION, - (long) DUK_VERSION, - (const char *) DUK_GIT_DESCRIBE, - (const char *) DUK_USE_TARGET_INFO); - str = duk_get_lstring(ctx, -1, &len); - DUK_ASSERT(str != NULL); - duk_debug_write_bytes(thr, (const duk_uint8_t *) str, len); - duk_debug_write_flush(thr); - duk_pop(ctx); -} - -DUK_EXTERNAL void duk_debugger_detach(duk_context *ctx) { - duk_hthread *thr; - - DUK_D(DUK_DPRINT("application called duk_debugger_detach()")); - - DUK_ASSERT_CTX_VALID(ctx); - thr = (duk_hthread *) ctx; - DUK_ASSERT(thr != NULL); - DUK_ASSERT(thr->heap != NULL); - - /* Can be called multiple times with no harm. */ - duk_debug_do_detach(thr->heap); -} - -DUK_EXTERNAL void duk_debugger_cooperate(duk_context *ctx) { - duk_hthread *thr; - duk_bool_t processed_messages; - - DUK_ASSERT_CTX_VALID(ctx); - thr = (duk_hthread *) ctx; - DUK_ASSERT(thr != NULL); - DUK_ASSERT(thr->heap != NULL); - - if (!DUK_HEAP_IS_DEBUGGER_ATTACHED(thr->heap)) { - return; - } - if (thr->callstack_top > 0 || thr->heap->dbg_processing) { - /* Calling duk_debugger_cooperate() while Duktape is being - * called into is not supported. This is not a 100% check - * but prevents any damage in most cases. - */ - return; - } - - processed_messages = duk_debug_process_messages(thr, 1 /*no_block*/); - DUK_UNREF(processed_messages); -} - -DUK_EXTERNAL duk_bool_t duk_debugger_notify(duk_context *ctx, duk_idx_t nvalues) { - duk_hthread *thr; - duk_idx_t top; - duk_idx_t idx; - duk_bool_t ret = 0; - - DUK_ASSERT_CTX_VALID(ctx); - thr = (duk_hthread *) ctx; - DUK_ASSERT(thr != NULL); - DUK_ASSERT(thr->heap != NULL); - - DUK_D(DUK_DPRINT("application called duk_debugger_notify() with nvalues=%ld", (long) nvalues)); - - top = duk_get_top(ctx); - if (top < nvalues) { - DUK_ERROR_API(thr, "not enough stack values for notify"); - return ret; /* unreachable */ - } - if (DUK_HEAP_IS_DEBUGGER_ATTACHED(thr->heap)) { - duk_debug_write_notify(thr, DUK_DBG_CMD_APPNOTIFY); - for (idx = top - nvalues; idx < top; idx++) { - duk_tval *tv = DUK_GET_TVAL_POSIDX(ctx, idx); - duk_debug_write_tval(thr, tv); - } - duk_debug_write_eom(thr); - - /* Return non-zero (true) if we have a good reason to believe - * the notify was delivered; if we're still attached at least - * a transport error was not indicated by the transport write - * callback. This is not a 100% guarantee of course. - */ - if (DUK_HEAP_IS_DEBUGGER_ATTACHED(thr->heap)) { - ret = 1; - } - } - duk_pop_n(ctx, nvalues); - return ret; -} - -DUK_EXTERNAL void duk_debugger_pause(duk_context *ctx) { - duk_hthread *thr; - - DUK_ASSERT_CTX_VALID(ctx); - thr = (duk_hthread *) ctx; - DUK_ASSERT(thr != NULL); - DUK_ASSERT(thr->heap != NULL); - - DUK_D(DUK_DPRINT("application called duk_debugger_pause()")); - - /* Treat like a debugger statement: ignore when not attached. */ - if (DUK_HEAP_IS_DEBUGGER_ATTACHED(thr->heap)) { - DUK_HEAP_SET_PAUSED(thr->heap); - - /* Pause on the next opcode executed. This is always safe to do even - * inside the debugger message loop: the interrupt counter will be reset - * to its proper value when the message loop exits. - */ - thr->interrupt_init = 1; - thr->interrupt_counter = 0; - } -} - -#else /* DUK_USE_DEBUGGER_SUPPORT */ - -DUK_EXTERNAL void duk_debugger_attach_custom(duk_context *ctx, - duk_debug_read_function read_cb, - duk_debug_write_function write_cb, - duk_debug_peek_function peek_cb, - duk_debug_read_flush_function read_flush_cb, - duk_debug_write_flush_function write_flush_cb, - duk_debug_request_function request_cb, - duk_debug_detached_function detached_cb, - void *udata) { - DUK_ASSERT_CTX_VALID(ctx); - DUK_UNREF(read_cb); - DUK_UNREF(write_cb); - DUK_UNREF(peek_cb); - DUK_UNREF(read_flush_cb); - DUK_UNREF(write_flush_cb); - DUK_UNREF(request_cb); - DUK_UNREF(detached_cb); - DUK_UNREF(udata); - DUK_ERROR_API((duk_hthread *) ctx, "no debugger support"); -} - -DUK_EXTERNAL void duk_debugger_detach(duk_context *ctx) { - DUK_ASSERT_CTX_VALID(ctx); - DUK_ERROR_API((duk_hthread *) ctx, "no debugger support"); -} - -DUK_EXTERNAL void duk_debugger_cooperate(duk_context *ctx) { - /* nop */ - DUK_ASSERT_CTX_VALID(ctx); - DUK_UNREF(ctx); -} - -DUK_EXTERNAL duk_bool_t duk_debugger_notify(duk_context *ctx, duk_idx_t nvalues) { - duk_idx_t top; - - DUK_ASSERT_CTX_VALID(ctx); - - top = duk_get_top(ctx); - if (top < nvalues) { - DUK_ERROR_API((duk_hthread *) ctx, "not enough stack values for notify"); - return 0; /* unreachable */ - } - - /* No debugger support, just pop values. */ - duk_pop_n(ctx, nvalues); - return 0; -} - -DUK_EXTERNAL void duk_debugger_pause(duk_context *ctx) { - /* Treat like debugger statement: nop */ - DUK_ASSERT_CTX_VALID(ctx); - DUK_UNREF(ctx); -} - -#endif /* DUK_USE_DEBUGGER_SUPPORT */ http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/ede68a10/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_api_heap.c ---------------------------------------------------------------------- diff --git a/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_api_heap.c b/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_api_heap.c deleted file mode 100644 index 6cb1837..0000000 --- a/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_api_heap.c +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Heap creation and destruction - */ - -#include "duk_internal.h" - -DUK_EXTERNAL -duk_context *duk_create_heap(duk_alloc_function alloc_func, - duk_realloc_function realloc_func, - duk_free_function free_func, - void *heap_udata, - duk_fatal_function fatal_handler) { - duk_heap *heap = NULL; - duk_context *ctx; - - /* Assume that either all memory funcs are NULL or non-NULL, mixed - * cases will now be unsafe. - */ - - /* XXX: just assert non-NULL values here and make caller arguments - * do the defaulting to the default implementations (smaller code)? - */ - - if (!alloc_func) { - DUK_ASSERT(realloc_func == NULL); - DUK_ASSERT(free_func == NULL); -#if defined(DUK_USE_PROVIDE_DEFAULT_ALLOC_FUNCTIONS) - alloc_func = duk_default_alloc_function; - realloc_func = duk_default_realloc_function; - free_func = duk_default_free_function; -#else - DUK_D(DUK_DPRINT("no allocation functions given and no default providers")); - return NULL; -#endif - } else { - DUK_ASSERT(realloc_func != NULL); - DUK_ASSERT(free_func != NULL); - } - - if (!fatal_handler) { - fatal_handler = duk_default_fatal_handler; - } - - DUK_ASSERT(alloc_func != NULL); - DUK_ASSERT(realloc_func != NULL); - DUK_ASSERT(free_func != NULL); - DUK_ASSERT(fatal_handler != NULL); - - heap = duk_heap_alloc(alloc_func, realloc_func, free_func, heap_udata, fatal_handler); - if (!heap) { - return NULL; - } - ctx = (duk_context *) heap->heap_thread; - DUK_ASSERT(ctx != NULL); - DUK_ASSERT(((duk_hthread *) ctx)->heap != NULL); - return ctx; -} - -DUK_EXTERNAL void duk_destroy_heap(duk_context *ctx) { - duk_hthread *thr = (duk_hthread *) ctx; - duk_heap *heap; - - if (!ctx) { - return; - } - heap = thr->heap; - DUK_ASSERT(heap != NULL); - - duk_heap_free(heap); -} - -/* XXX: better place for this */ -DUK_EXTERNAL void duk_set_global_object(duk_context *ctx) { - duk_hthread *thr = (duk_hthread *) ctx; - duk_hobject *h_glob; - duk_hobject *h_prev_glob; - duk_hobject *h_env; - duk_hobject *h_prev_env; - - DUK_D(DUK_DPRINT("replace global object with: %!T", duk_get_tval(ctx, -1))); - - h_glob = duk_require_hobject(ctx, -1); - DUK_ASSERT(h_glob != NULL); - - /* - * Replace global object. - */ - - h_prev_glob = thr->builtins[DUK_BIDX_GLOBAL]; - DUK_UNREF(h_prev_glob); - thr->builtins[DUK_BIDX_GLOBAL] = h_glob; - DUK_HOBJECT_INCREF(thr, h_glob); - DUK_HOBJECT_DECREF_ALLOWNULL(thr, h_prev_glob); /* side effects, in theory (referenced by global env) */ - - /* - * Replace lexical environment for global scope - * - * Create a new object environment for the global lexical scope. - * We can't just reset the _Target property of the current one, - * because the lexical scope is shared by other threads with the - * same (initial) built-ins. - */ - - (void) duk_push_object_helper(ctx, - DUK_HOBJECT_FLAG_EXTENSIBLE | - DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_OBJENV), - -1); /* no prototype, updated below */ - - duk_dup(ctx, -2); - duk_dup(ctx, -3); - - /* [ ... new_glob new_env new_glob new_glob ] */ - - duk_xdef_prop_stridx(thr, -3, DUK_STRIDX_INT_TARGET, DUK_PROPDESC_FLAGS_NONE); - duk_xdef_prop_stridx(thr, -2, DUK_STRIDX_INT_THIS, DUK_PROPDESC_FLAGS_NONE); - - /* [ ... new_glob new_env ] */ - - h_env = duk_get_hobject(ctx, -1); - DUK_ASSERT(h_env != NULL); - - h_prev_env = thr->builtins[DUK_BIDX_GLOBAL_ENV]; - thr->builtins[DUK_BIDX_GLOBAL_ENV] = h_env; - DUK_HOBJECT_INCREF(thr, h_env); - DUK_HOBJECT_DECREF_ALLOWNULL(thr, h_prev_env); /* side effects */ - DUK_UNREF(h_env); /* without refcounts */ - DUK_UNREF(h_prev_env); - - /* [ ... new_glob new_env ] */ - - duk_pop_2(ctx); - - /* [ ... ] */ -} http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/ede68a10/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_api_internal.h ---------------------------------------------------------------------- diff --git a/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_api_internal.h b/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_api_internal.h deleted file mode 100644 index 3e7aea6..0000000 --- a/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_api_internal.h +++ /dev/null @@ -1,194 +0,0 @@ -/* - * Internal API calls which have (stack and other) semantics similar - * to the public API. - */ - -#ifndef DUK_API_INTERNAL_H_INCLUDED -#define DUK_API_INTERNAL_H_INCLUDED - -/* duk_push_sprintf constants */ -#define DUK_PUSH_SPRINTF_INITIAL_SIZE 256L -#define DUK_PUSH_SPRINTF_SANITY_LIMIT (1L * 1024L * 1024L * 1024L) - -/* Flag ORed to err_code to indicate __FILE__ / __LINE__ is not - * blamed as source of error for error fileName / lineNumber. - */ -#define DUK_ERRCODE_FLAG_NOBLAME_FILELINE (1L << 24) - -/* Valstack resize flags */ -#define DUK_VSRESIZE_FLAG_SHRINK (1 << 0) -#define DUK_VSRESIZE_FLAG_COMPACT (1 << 1) -#define DUK_VSRESIZE_FLAG_THROW (1 << 2) - -/* Current convention is to use duk_size_t for value stack sizes and global indices, - * and duk_idx_t for local frame indices. - */ -DUK_INTERNAL_DECL -duk_bool_t duk_valstack_resize_raw(duk_context *ctx, - duk_size_t min_new_size, - duk_small_uint_t flags); - -#if defined(DUK_USE_VERBOSE_ERRORS) && defined(DUK_USE_PARANOID_ERRORS) -DUK_INTERNAL_DECL const char *duk_get_type_name(duk_context *ctx, duk_idx_t index); -#endif - -DUK_INTERNAL_DECL duk_tval *duk_get_tval(duk_context *ctx, duk_idx_t index); -DUK_INTERNAL_DECL duk_tval *duk_require_tval(duk_context *ctx, duk_idx_t index); -DUK_INTERNAL_DECL void duk_push_tval(duk_context *ctx, duk_tval *tv); - -/* Push the current 'this' binding; throw TypeError if binding is not object - * coercible (CheckObjectCoercible). - */ -DUK_INTERNAL_DECL void duk_push_this_check_object_coercible(duk_context *ctx); - -/* duk_push_this() + CheckObjectCoercible() + duk_to_object() */ -DUK_INTERNAL_DECL duk_hobject *duk_push_this_coercible_to_object(duk_context *ctx); - -/* duk_push_this() + CheckObjectCoercible() + duk_to_string() */ -DUK_INTERNAL_DECL duk_hstring *duk_push_this_coercible_to_string(duk_context *ctx); - -/* Get a borrowed duk_tval pointer to the current 'this' binding. Caller must - * make sure there's an active callstack entry. Note that the returned pointer - * is unstable with regards to side effects. - */ -DUK_INTERNAL_DECL duk_tval *duk_get_borrowed_this_tval(duk_context *ctx); - -/* XXX: add fastint support? */ -#define duk_push_u64(ctx,val) \ - duk_push_number((ctx), (duk_double_t) (val)) -#define duk_push_i64(ctx,val) \ - duk_push_number((ctx), (duk_double_t) (val)) - -/* duk_push_(u)int() is guaranteed to support at least (un)signed 32-bit range */ -#define duk_push_u32(ctx,val) \ - duk_push_uint((ctx), (duk_uint_t) (val)) -#define duk_push_i32(ctx,val) \ - duk_push_int((ctx), (duk_int_t) (val)) - -/* sometimes stack and array indices need to go on the stack */ -#define duk_push_idx(ctx,val) \ - duk_push_int((ctx), (duk_int_t) (val)) -#define duk_push_uarridx(ctx,val) \ - duk_push_uint((ctx), (duk_uint_t) (val)) -#define duk_push_size_t(ctx,val) \ - duk_push_uint((ctx), (duk_uint_t) (val)) /* XXX: assumed to fit for now */ - -DUK_INTERNAL_DECL duk_hstring *duk_get_hstring(duk_context *ctx, duk_idx_t index); -DUK_INTERNAL_DECL duk_hobject *duk_get_hobject(duk_context *ctx, duk_idx_t index); -DUK_INTERNAL_DECL duk_hbuffer *duk_get_hbuffer(duk_context *ctx, duk_idx_t index); -DUK_INTERNAL_DECL duk_hthread *duk_get_hthread(duk_context *ctx, duk_idx_t index); -DUK_INTERNAL_DECL duk_hcompiledfunction *duk_get_hcompiledfunction(duk_context *ctx, duk_idx_t index); -DUK_INTERNAL_DECL duk_hnativefunction *duk_get_hnativefunction(duk_context *ctx, duk_idx_t index); - -DUK_INTERNAL_DECL duk_hobject *duk_get_hobject_with_class(duk_context *ctx, duk_idx_t index, duk_small_uint_t classnum); - -#if 0 /* This would be pointless: unexpected type and lightfunc would both return NULL */ -DUK_INTERNAL_DECL duk_hobject *duk_get_hobject_or_lfunc(duk_context *ctx, duk_idx_t index); -#endif -DUK_INTERNAL_DECL duk_hobject *duk_get_hobject_or_lfunc_coerce(duk_context *ctx, duk_idx_t index); - -#if 0 /*unused*/ -DUK_INTERNAL_DECL void *duk_get_voidptr(duk_context *ctx, duk_idx_t index); -#endif - -DUK_INTERNAL_DECL duk_hstring *duk_to_hstring(duk_context *ctx, duk_idx_t index); -#if defined(DUK_USE_DEBUGGER_SUPPORT) /* only needed by debugger for now */ -DUK_INTERNAL_DECL duk_hstring *duk_safe_to_hstring(duk_context *ctx, duk_idx_t index); -#endif -DUK_INTERNAL_DECL void duk_to_object_class_string_top(duk_context *ctx); -#if !defined(DUK_USE_PARANOID_ERRORS) -DUK_INTERNAL_DECL void duk_push_hobject_class_string(duk_context *ctx, duk_hobject *h); -#endif - -DUK_INTERNAL_DECL duk_int_t duk_to_int_clamped_raw(duk_context *ctx, duk_idx_t index, duk_int_t minval, duk_int_t maxval, duk_bool_t *out_clamped); /* out_clamped=NULL, RangeError if outside range */ -DUK_INTERNAL_DECL duk_int_t duk_to_int_clamped(duk_context *ctx, duk_idx_t index, duk_int_t minval, duk_int_t maxval); -DUK_INTERNAL_DECL duk_int_t duk_to_int_check_range(duk_context *ctx, duk_idx_t index, duk_int_t minval, duk_int_t maxval); -#if defined(DUK_USE_BUFFEROBJECT_SUPPORT) -DUK_INTERNAL_DECL duk_uint8_t duk_to_uint8clamped(duk_context *ctx, duk_idx_t index); -#endif - -DUK_INTERNAL_DECL duk_hstring *duk_require_hstring(duk_context *ctx, duk_idx_t index); -DUK_INTERNAL_DECL duk_hobject *duk_require_hobject(duk_context *ctx, duk_idx_t index); -DUK_INTERNAL_DECL duk_hbuffer *duk_require_hbuffer(duk_context *ctx, duk_idx_t index); -DUK_INTERNAL_DECL duk_hthread *duk_require_hthread(duk_context *ctx, duk_idx_t index); -DUK_INTERNAL_DECL duk_hcompiledfunction *duk_require_hcompiledfunction(duk_context *ctx, duk_idx_t index); -DUK_INTERNAL_DECL duk_hnativefunction *duk_require_hnativefunction(duk_context *ctx, duk_idx_t index); - -DUK_INTERNAL_DECL duk_hobject *duk_require_hobject_with_class(duk_context *ctx, duk_idx_t index, duk_small_uint_t classnum); - -DUK_INTERNAL_DECL duk_hobject *duk_require_hobject_or_lfunc(duk_context *ctx, duk_idx_t index); -DUK_INTERNAL_DECL duk_hobject *duk_require_hobject_or_lfunc_coerce(duk_context *ctx, duk_idx_t index); - -DUK_INTERNAL_DECL void duk_push_hstring(duk_context *ctx, duk_hstring *h); -DUK_INTERNAL_DECL void duk_push_hstring_stridx(duk_context *ctx, duk_small_int_t stridx); -DUK_INTERNAL_DECL void duk_push_hobject(duk_context *ctx, duk_hobject *h); -DUK_INTERNAL_DECL void duk_push_hbuffer(duk_context *ctx, duk_hbuffer *h); -#define duk_push_hthread(ctx,h) \ - duk_push_hobject((ctx), (duk_hobject *) (h)) -#define duk_push_hcompiledfunction(ctx,h) \ - duk_push_hobject((ctx), (duk_hobject *) (h)) -#define duk_push_hnativefunction(ctx,h) \ - duk_push_hobject((ctx), (duk_hobject *) (h)) -DUK_INTERNAL_DECL void duk_push_hobject_bidx(duk_context *ctx, duk_small_int_t builtin_idx); -DUK_INTERNAL_DECL duk_idx_t duk_push_object_helper(duk_context *ctx, duk_uint_t hobject_flags_and_class, duk_small_int_t prototype_bidx); -DUK_INTERNAL_DECL duk_idx_t duk_push_object_helper_proto(duk_context *ctx, duk_uint_t hobject_flags_and_class, duk_hobject *proto); -DUK_INTERNAL_DECL duk_idx_t duk_push_object_internal(duk_context *ctx); -DUK_INTERNAL_DECL duk_idx_t duk_push_compiledfunction(duk_context *ctx); -DUK_INTERNAL_DECL void duk_push_c_function_noexotic(duk_context *ctx, duk_c_function func, duk_int_t nargs); -DUK_INTERNAL_DECL void duk_push_c_function_noconstruct_noexotic(duk_context *ctx, duk_c_function func, duk_int_t nargs); - -DUK_INTERNAL_DECL void duk_push_string_funcptr(duk_context *ctx, duk_uint8_t *ptr, duk_size_t sz); -DUK_INTERNAL_DECL void duk_push_lightfunc_name(duk_context *ctx, duk_tval *tv); -DUK_INTERNAL_DECL void duk_push_lightfunc_tostring(duk_context *ctx, duk_tval *tv); -DUK_INTERNAL_DECL duk_hbufferobject *duk_push_bufferobject_raw(duk_context *ctx, duk_uint_t hobject_flags_and_class, duk_small_int_t prototype_bidx); - -#if !defined(DUK_USE_PARANOID_ERRORS) -DUK_INTERNAL_DECL const char *duk_push_string_readable(duk_context *ctx, duk_idx_t index); -DUK_INTERNAL_DECL const char *duk_push_string_tval_readable(duk_context *ctx, duk_tval *tv); -#endif - -DUK_INTERNAL_DECL duk_bool_t duk_get_prop_stridx(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx); /* [] -> [val] */ -DUK_INTERNAL_DECL duk_bool_t duk_put_prop_stridx(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx); /* [val] -> [] */ -DUK_INTERNAL_DECL duk_bool_t duk_del_prop_stridx(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx); /* [] -> [] */ -DUK_INTERNAL_DECL duk_bool_t duk_has_prop_stridx(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx); /* [] -> [] */ - -DUK_INTERNAL_DECL duk_bool_t duk_get_prop_stridx_boolean(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx, duk_bool_t *out_has_prop); /* [] -> [] */ - -DUK_INTERNAL_DECL void duk_xdef_prop(duk_context *ctx, duk_idx_t obj_index, duk_small_uint_t desc_flags); /* [key val] -> [] */ -DUK_INTERNAL_DECL void duk_xdef_prop_index(duk_context *ctx, duk_idx_t obj_index, duk_uarridx_t arr_index, duk_small_uint_t desc_flags); /* [val] -> [] */ -DUK_INTERNAL_DECL void duk_xdef_prop_stridx(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx, duk_small_uint_t desc_flags); /* [val] -> [] */ -DUK_INTERNAL_DECL void duk_xdef_prop_stridx_builtin(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx, duk_small_int_t builtin_idx, duk_small_uint_t desc_flags); /* [] -> [] */ -DUK_INTERNAL_DECL void duk_xdef_prop_stridx_thrower(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx, duk_small_uint_t desc_flags); /* [] -> [] */ - -/* These are macros for now, but could be separate functions to reduce code - * footprint (check call site count before refactoring). - */ -#define duk_xdef_prop_wec(ctx,obj_index) \ - duk_xdef_prop((ctx), (obj_index), DUK_PROPDESC_FLAGS_WEC) -#define duk_xdef_prop_index_wec(ctx,obj_index,arr_index) \ - duk_xdef_prop_index((ctx), (obj_index), (arr_index), DUK_PROPDESC_FLAGS_WEC) -#define duk_xdef_prop_stridx_wec(ctx,obj_index,stridx) \ - duk_xdef_prop_stridx((ctx), (obj_index), (stridx), DUK_PROPDESC_FLAGS_WEC) - -/* Set object 'length'. */ -DUK_INTERNAL_DECL void duk_set_length(duk_context *ctx, duk_idx_t index, duk_size_t length); - -/* Raw internal valstack access macros: access is unsafe so call site - * must have a guarantee that the index is valid. When that is the case, - * using these macro results in faster and smaller code than duk_get_tval(). - * Both 'ctx' and 'idx' are evaluted multiple times, but only for asserts. - */ -#define DUK_ASSERT_VALID_NEGIDX(ctx,idx) \ - (DUK_ASSERT_EXPR((idx) < 0), DUK_ASSERT_EXPR(duk_is_valid_index((ctx), (idx)))) -#define DUK_ASSERT_VALID_POSIDX(ctx,idx) \ - (DUK_ASSERT_EXPR((idx) >= 0), DUK_ASSERT_EXPR(duk_is_valid_index((ctx), (idx)))) -#define DUK_GET_TVAL_NEGIDX(ctx,idx) \ - (DUK_ASSERT_VALID_NEGIDX((ctx),(idx)), ((duk_hthread *) (ctx))->valstack_top + (idx)) -#define DUK_GET_TVAL_POSIDX(ctx,idx) \ - (DUK_ASSERT_VALID_POSIDX((ctx),(idx)), ((duk_hthread *) (ctx))->valstack_bottom + (idx)) -#define DUK_GET_HOBJECT_NEGIDX(ctx,idx) \ - (DUK_ASSERT_VALID_NEGIDX((ctx),(idx)), DUK_TVAL_GET_OBJECT(((duk_hthread *) (ctx))->valstack_top + (idx))) -#define DUK_GET_HOBJECT_POSIDX(ctx,idx) \ - (DUK_ASSERT_VALID_POSIDX((ctx),(idx)), DUK_TVAL_GET_OBJECT(((duk_hthread *) (ctx))->valstack_bottom + (idx))) - -#endif /* DUK_API_INTERNAL_H_INCLUDED */ http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/ede68a10/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_api_logging.c ---------------------------------------------------------------------- diff --git a/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_api_logging.c b/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_api_logging.c deleted file mode 100644 index aa9784f..0000000 --- a/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_api_logging.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Logging - * - * Current logging primitive is a sprintf-style log which is convenient - * for most C code. Another useful primitive would be to log N arguments - * from value stack (like the Ecmascript binding does). - */ - -#include "duk_internal.h" - -DUK_EXTERNAL void duk_log_va(duk_context *ctx, duk_int_t level, const char *fmt, va_list ap) { - /* stridx_logfunc[] must be static to allow initializer with old compilers like BCC */ - static const duk_uint16_t stridx_logfunc[6] = { - DUK_STRIDX_LC_TRACE, DUK_STRIDX_LC_DEBUG, DUK_STRIDX_LC_INFO, - DUK_STRIDX_LC_WARN, DUK_STRIDX_LC_ERROR, DUK_STRIDX_LC_FATAL - }; - - DUK_ASSERT_CTX_VALID(ctx); - - if (level < 0) { - level = 0; - } else if (level > (int) (sizeof(stridx_logfunc) / sizeof(duk_uint16_t)) - 1) { - level = (int) (sizeof(stridx_logfunc) / sizeof(duk_uint16_t)) - 1; - } - - duk_push_hobject_bidx(ctx, DUK_BIDX_LOGGER_CONSTRUCTOR); - duk_get_prop_stridx(ctx, -1, DUK_STRIDX_CLOG); - duk_get_prop_stridx(ctx, -1, stridx_logfunc[level]); - duk_dup(ctx, -2); - - /* [ ... Logger clog logfunc clog ] */ - - duk_push_vsprintf(ctx, fmt, ap); - - /* [ ... Logger clog logfunc clog(=this) msg ] */ - - duk_call_method(ctx, 1 /*nargs*/); - - /* [ ... Logger clog res ] */ - - duk_pop_3(ctx); -} - -DUK_EXTERNAL void duk_log(duk_context *ctx, duk_int_t level, const char *fmt, ...) { - va_list ap; - - DUK_ASSERT_CTX_VALID(ctx); - - va_start(ap, fmt); - duk_log_va(ctx, level, fmt, ap); - va_end(ap); -} http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/ede68a10/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_api_memory.c ---------------------------------------------------------------------- diff --git a/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_api_memory.c b/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_api_memory.c deleted file mode 100644 index f3e5b8e..0000000 --- a/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_api_memory.c +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Memory calls. - */ - -#include "duk_internal.h" - -DUK_EXTERNAL void *duk_alloc_raw(duk_context *ctx, duk_size_t size) { - duk_hthread *thr = (duk_hthread *) ctx; - - DUK_ASSERT_CTX_VALID(ctx); - - return DUK_ALLOC_RAW(thr->heap, size); -} - -DUK_EXTERNAL void duk_free_raw(duk_context *ctx, void *ptr) { - duk_hthread *thr = (duk_hthread *) ctx; - - DUK_ASSERT_CTX_VALID(ctx); - - DUK_FREE_RAW(thr->heap, ptr); -} - -DUK_EXTERNAL void *duk_realloc_raw(duk_context *ctx, void *ptr, duk_size_t size) { - duk_hthread *thr = (duk_hthread *) ctx; - - DUK_ASSERT_CTX_VALID(ctx); - - return DUK_REALLOC_RAW(thr->heap, ptr, size); -} - -DUK_EXTERNAL void *duk_alloc(duk_context *ctx, duk_size_t size) { - duk_hthread *thr = (duk_hthread *) ctx; - - DUK_ASSERT_CTX_VALID(ctx); - - return DUK_ALLOC(thr->heap, size); -} - -DUK_EXTERNAL void duk_free(duk_context *ctx, void *ptr) { - duk_hthread *thr = (duk_hthread *) ctx; - - DUK_ASSERT_CTX_VALID(ctx); - - DUK_FREE(thr->heap, ptr); -} - -DUK_EXTERNAL void *duk_realloc(duk_context *ctx, void *ptr, duk_size_t size) { - duk_hthread *thr = (duk_hthread *) ctx; - - DUK_ASSERT_CTX_VALID(ctx); - - /* - * Note: since this is an exposed API call, there should be - * no way a mark-and-sweep could have a side effect on the - * memory allocation behind 'ptr'; the pointer should never - * be something that Duktape wants to change. - * - * Thus, no need to use DUK_REALLOC_INDIRECT (and we don't - * have the storage location here anyway). - */ - - return DUK_REALLOC(thr->heap, ptr, size); -} - -DUK_EXTERNAL void duk_get_memory_functions(duk_context *ctx, duk_memory_functions *out_funcs) { - duk_hthread *thr = (duk_hthread *) ctx; - duk_heap *heap; - - DUK_ASSERT_CTX_VALID(ctx); - DUK_ASSERT(out_funcs != NULL); - DUK_ASSERT(thr != NULL); - DUK_ASSERT(thr->heap != NULL); - - heap = thr->heap; - out_funcs->alloc_func = heap->alloc_func; - out_funcs->realloc_func = heap->realloc_func; - out_funcs->free_func = heap->free_func; - out_funcs->udata = heap->heap_udata; -} - -DUK_EXTERNAL void duk_gc(duk_context *ctx, duk_uint_t flags) { -#ifdef DUK_USE_MARK_AND_SWEEP - duk_hthread *thr = (duk_hthread *) ctx; - duk_heap *heap; - - DUK_UNREF(flags); - - /* NULL accepted */ - if (!ctx) { - return; - } - DUK_ASSERT_CTX_VALID(ctx); - heap = thr->heap; - DUK_ASSERT(heap != NULL); - - DUK_D(DUK_DPRINT("mark-and-sweep requested by application")); - duk_heap_mark_and_sweep(heap, 0); -#else - DUK_D(DUK_DPRINT("mark-and-sweep requested by application but mark-and-sweep not enabled, ignoring")); - DUK_UNREF(ctx); - DUK_UNREF(flags); -#endif -} http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/ede68a10/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_api_object.c ---------------------------------------------------------------------- diff --git a/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_api_object.c b/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_api_object.c deleted file mode 100644 index 46634c5..0000000 --- a/thirdparty/civetweb-1.10/src/third_party/duktape-1.5.2/src-separate/duk_api_object.c +++ /dev/null @@ -1,610 +0,0 @@ -/* - * Object handling: property access and other support functions. - */ - -#include "duk_internal.h" - -/* - * Property handling - * - * The API exposes only the most common property handling functions. - * The caller can invoke Ecmascript built-ins for full control (e.g. - * defineProperty, getOwnPropertyDescriptor). - */ - -DUK_EXTERNAL duk_bool_t duk_get_prop(duk_context *ctx, duk_idx_t obj_index) { - duk_hthread *thr = (duk_hthread *) ctx; - duk_tval *tv_obj; - duk_tval *tv_key; - duk_bool_t rc; - - DUK_ASSERT_CTX_VALID(ctx); - - /* Note: copying tv_obj and tv_key to locals to shield against a valstack - * resize is not necessary for a property get right now. - */ - - tv_obj = duk_require_tval(ctx, obj_index); - tv_key = duk_require_tval(ctx, -1); - - rc = duk_hobject_getprop(thr, tv_obj, tv_key); - DUK_ASSERT(rc == 0 || rc == 1); - /* a value is left on stack regardless of rc */ - - duk_remove(ctx, -2); /* remove key */ - return rc; /* 1 if property found, 0 otherwise */ -} - -DUK_EXTERNAL duk_bool_t duk_get_prop_string(duk_context *ctx, duk_idx_t obj_index, const char *key) { - DUK_ASSERT_CTX_VALID(ctx); - DUK_ASSERT(key != NULL); - - obj_index = duk_require_normalize_index(ctx, obj_index); - duk_push_string(ctx, key); - return duk_get_prop(ctx, obj_index); -} - -DUK_EXTERNAL duk_bool_t duk_get_prop_index(duk_context *ctx, duk_idx_t obj_index, duk_uarridx_t arr_index) { - DUK_ASSERT_CTX_VALID(ctx); - - obj_index = duk_require_normalize_index(ctx, obj_index); - duk_push_uarridx(ctx, arr_index); - return duk_get_prop(ctx, obj_index); -} - -DUK_INTERNAL duk_bool_t duk_get_prop_stridx(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx) { - duk_hthread *thr = (duk_hthread *) ctx; - - DUK_ASSERT_CTX_VALID(ctx); - DUK_ASSERT_DISABLE(stridx >= 0); - DUK_ASSERT(stridx < DUK_HEAP_NUM_STRINGS); - DUK_UNREF(thr); - - obj_index = duk_require_normalize_index(ctx, obj_index); - duk_push_hstring(ctx, DUK_HTHREAD_GET_STRING(thr, stridx)); - return duk_get_prop(ctx, obj_index); -} - -DUK_INTERNAL duk_bool_t duk_get_prop_stridx_boolean(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx, duk_bool_t *out_has_prop) { - duk_bool_t rc; - - DUK_ASSERT_CTX_VALID(ctx); - DUK_ASSERT_DISABLE(stridx >= 0); - DUK_ASSERT(stridx < DUK_HEAP_NUM_STRINGS); - - rc = duk_get_prop_stridx(ctx, obj_index, stridx); - if (out_has_prop) { - *out_has_prop = rc; - } - rc = duk_to_boolean(ctx, -1); - DUK_ASSERT(rc == 0 || rc == 1); - duk_pop(ctx); - return rc; -} - -DUK_LOCAL duk_bool_t duk__put_prop_shared(duk_context *ctx, duk_idx_t obj_idx, duk_idx_t idx_key) { - duk_hthread *thr = (duk_hthread *) ctx; - duk_tval *tv_obj; - duk_tval *tv_key; - duk_tval *tv_val; - duk_small_int_t throw_flag; - duk_bool_t rc; - - /* Note: copying tv_obj and tv_key to locals to shield against a valstack - * resize is not necessary for a property put right now (putprop protects - * against it internally). - */ - - /* Key and value indices are either (-2, -1) or (-1, -2). Given idx_key, - * idx_val is always (idx_key ^ 0x01). - */ - DUK_ASSERT((idx_key == -2 && (idx_key ^ 1) == -1) || - (idx_key == -1 && (idx_key ^ 1) == -2)); - tv_obj = duk_require_tval(ctx, obj_idx); - tv_key = duk_require_tval(ctx, idx_key); - tv_val = duk_require_tval(ctx, idx_key ^ 1); - throw_flag = duk_is_strict_call(ctx); - - rc = duk_hobject_putprop(thr, tv_obj, tv_key, tv_val, throw_flag); - DUK_ASSERT(rc == 0 || rc == 1); - - duk_pop_2(ctx); /* remove key and value */ - return rc; /* 1 if property found, 0 otherwise */ -} - -DUK_EXTERNAL duk_bool_t duk_put_prop(duk_context *ctx, duk_idx_t obj_idx) { - DUK_ASSERT_CTX_VALID(ctx); - return duk__put_prop_shared(ctx, obj_idx, -2); -} - -DUK_EXTERNAL duk_bool_t duk_put_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key) { - DUK_ASSERT_CTX_VALID(ctx); - DUK_ASSERT(key != NULL); - - /* Careful here and with other duk_put_prop_xxx() helpers: the - * target object and the property value may be in the same value - * stack slot (unusual, but still conceptually clear). - */ - obj_idx = duk_normalize_index(ctx, obj_idx); - (void) duk_push_string(ctx, key); - return duk__put_prop_shared(ctx, obj_idx, -1); -} - -DUK_EXTERNAL duk_bool_t duk_put_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx) { - DUK_ASSERT_CTX_VALID(ctx); - - obj_idx = duk_require_normalize_index(ctx, obj_idx); - duk_push_uarridx(ctx, arr_idx); - return duk__put_prop_shared(ctx, obj_idx, -1); -} - -DUK_INTERNAL duk_bool_t duk_put_prop_stridx(duk_context *ctx, duk_idx_t obj_idx, duk_small_int_t stridx) { - duk_hthread *thr = (duk_hthread *) ctx; - - DUK_ASSERT_CTX_VALID(ctx); - DUK_ASSERT_DISABLE(stridx >= 0); - DUK_ASSERT(stridx < DUK_HEAP_NUM_STRINGS); - DUK_UNREF(thr); - - obj_idx = duk_require_normalize_index(ctx, obj_idx); - duk_push_hstring(ctx, DUK_HTHREAD_GET_STRING(thr, stridx)); - return duk__put_prop_shared(ctx, obj_idx, -1); -} - -DUK_EXTERNAL duk_bool_t duk_del_prop(duk_context *ctx, duk_idx_t obj_index) { - duk_hthread *thr = (duk_hthread *) ctx; - duk_tval *tv_obj; - duk_tval *tv_key; - duk_small_int_t throw_flag; - duk_bool_t rc; - - DUK_ASSERT_CTX_VALID(ctx); - - /* Note: copying tv_obj and tv_key to locals to shield against a valstack - * resize is not necessary for a property delete right now. - */ - - tv_obj = duk_require_tval(ctx, obj_index); - tv_key = duk_require_tval(ctx, -1); - throw_flag = duk_is_strict_call(ctx); - - rc = duk_hobject_delprop(thr, tv_obj, tv_key, throw_flag); - DUK_ASSERT(rc == 0 || rc == 1); - - duk_pop(ctx); /* remove key */ - return rc; -} - -DUK_EXTERNAL duk_bool_t duk_del_prop_string(duk_context *ctx, duk_idx_t obj_index, const char *key) { - DUK_ASSERT_CTX_VALID(ctx); - DUK_ASSERT(key != NULL); - - obj_index = duk_require_normalize_index(ctx, obj_index); - duk_push_string(ctx, key); - return duk_del_prop(ctx, obj_index); -} - -DUK_EXTERNAL duk_bool_t duk_del_prop_index(duk_context *ctx, duk_idx_t obj_index, duk_uarridx_t arr_index) { - DUK_ASSERT_CTX_VALID(ctx); - - obj_index = duk_require_normalize_index(ctx, obj_index); - duk_push_uarridx(ctx, arr_index); - return duk_del_prop(ctx, obj_index); -} - -DUK_INTERNAL duk_bool_t duk_del_prop_stridx(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx) { - duk_hthread *thr = (duk_hthread *) ctx; - - DUK_ASSERT_CTX_VALID(ctx); - DUK_ASSERT_DISABLE(stridx >= 0); - DUK_ASSERT(stridx < DUK_HEAP_NUM_STRINGS); - DUK_UNREF(thr); - - obj_index = duk_require_normalize_index(ctx, obj_index); - duk_push_hstring(ctx, DUK_HTHREAD_GET_STRING(thr, stridx)); - return duk_del_prop(ctx, obj_index); -} - -DUK_EXTERNAL duk_bool_t duk_has_prop(duk_context *ctx, duk_idx_t obj_index) { - duk_hthread *thr = (duk_hthread *) ctx; - duk_tval *tv_obj; - duk_tval *tv_key; - duk_bool_t rc; - - DUK_ASSERT_CTX_VALID(ctx); - - /* Note: copying tv_obj and tv_key to locals to shield against a valstack - * resize is not necessary for a property existence check right now. - */ - - tv_obj = duk_require_tval(ctx, obj_index); - tv_key = duk_require_tval(ctx, -1); - - rc = duk_hobject_hasprop(thr, tv_obj, tv_key); - DUK_ASSERT(rc == 0 || rc == 1); - - duk_pop(ctx); /* remove key */ - return rc; /* 1 if property found, 0 otherwise */ -} - -DUK_EXTERNAL duk_bool_t duk_has_prop_string(duk_context *ctx, duk_idx_t obj_index, const char *key) { - DUK_ASSERT_CTX_VALID(ctx); - DUK_ASSERT(key != NULL); - - obj_index = duk_require_normalize_index(ctx, obj_index); - duk_push_string(ctx, key); - return duk_has_prop(ctx, obj_index); -} - -DUK_EXTERNAL duk_bool_t duk_has_prop_index(duk_context *ctx, duk_idx_t obj_index, duk_uarridx_t arr_index) { - DUK_ASSERT_CTX_VALID(ctx); - - obj_index = duk_require_normalize_index(ctx, obj_index); - duk_push_uarridx(ctx, arr_index); - return duk_has_prop(ctx, obj_index); -} - -DUK_INTERNAL duk_bool_t duk_has_prop_stridx(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx) { - duk_hthread *thr = (duk_hthread *) ctx; - - DUK_ASSERT_CTX_VALID(ctx); - DUK_ASSERT_DISABLE(stridx >= 0); - DUK_ASSERT(stridx < DUK_HEAP_NUM_STRINGS); - DUK_UNREF(thr); - - obj_index = duk_require_normalize_index(ctx, obj_index); - duk_push_hstring(ctx, DUK_HTHREAD_GET_STRING(thr, stridx)); - return duk_has_prop(ctx, obj_index); -} - -/* Define own property without inheritance looks and such. This differs from - * [[DefineOwnProperty]] because special behaviors (like Array 'length') are - * not invoked by this method. The caller must be careful to invoke any such - * behaviors if necessary. - */ -DUK_INTERNAL void duk_xdef_prop(duk_context *ctx, duk_idx_t obj_index, duk_small_uint_t desc_flags) { - duk_hthread *thr = (duk_hthread *) ctx; - duk_hobject *obj; - duk_hstring *key; - - DUK_ASSERT_CTX_VALID(ctx); - - obj = duk_require_hobject(ctx, obj_index); - DUK_ASSERT(obj != NULL); - key = duk_to_hstring(ctx, -2); - DUK_ASSERT(key != NULL); - DUK_ASSERT(duk_require_tval(ctx, -1) != NULL); - - duk_hobject_define_property_internal(thr, obj, key, desc_flags); - - duk_pop(ctx); /* pop key */ -} - -DUK_INTERNAL void duk_xdef_prop_index(duk_context *ctx, duk_idx_t obj_index, duk_uarridx_t arr_index, duk_small_uint_t desc_flags) { - duk_hthread *thr = (duk_hthread *) ctx; - duk_hobject *obj; - - DUK_ASSERT_CTX_VALID(ctx); - - obj = duk_require_hobject(ctx, obj_index); - DUK_ASSERT(obj != NULL); - - duk_hobject_define_property_internal_arridx(thr, obj, arr_index, desc_flags); - /* value popped by call */ -} - -DUK_INTERNAL void duk_xdef_prop_stridx(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx, duk_small_uint_t desc_flags) { - duk_hthread *thr = (duk_hthread *) ctx; - duk_hobject *obj; - duk_hstring *key; - - DUK_ASSERT_CTX_VALID(ctx); - DUK_ASSERT_DISABLE(stridx >= 0); - DUK_ASSERT(stridx < DUK_HEAP_NUM_STRINGS); - - obj = duk_require_hobject(ctx, obj_index); - DUK_ASSERT(obj != NULL); - key = DUK_HTHREAD_GET_STRING(thr, stridx); - DUK_ASSERT(key != NULL); - DUK_ASSERT(duk_require_tval(ctx, -1) != NULL); - - duk_hobject_define_property_internal(thr, obj, key, desc_flags); - /* value popped by call */ -} - -DUK_INTERNAL void duk_xdef_prop_stridx_builtin(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx, duk_small_int_t builtin_idx, duk_small_uint_t desc_flags) { - duk_hthread *thr = (duk_hthread *) ctx; - duk_hobject *obj; - duk_hstring *key; - - DUK_ASSERT_CTX_VALID(ctx); - DUK_ASSERT_DISABLE(stridx >= 0); - DUK_ASSERT(stridx < DUK_HEAP_NUM_STRINGS); - DUK_ASSERT_DISABLE(builtin_idx >= 0); - DUK_ASSERT(builtin_idx < DUK_NUM_BUILTINS); - - obj = duk_require_hobject(ctx, obj_index); - DUK_ASSERT(obj != NULL); - key = DUK_HTHREAD_GET_STRING(thr, stridx); - DUK_ASSERT(key != NULL); - - duk_push_hobject(ctx, thr->builtins[builtin_idx]); - duk_hobject_define_property_internal(thr, obj, key, desc_flags); - /* value popped by call */ -} - -/* This is a rare property helper; it sets the global thrower (E5 Section 13.2.3) - * setter/getter into an object property. This is needed by the 'arguments' - * object creation code, function instance creation code, and Function.prototype.bind(). - */ - -DUK_INTERNAL void duk_xdef_prop_stridx_thrower(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx, duk_small_uint_t desc_flags) { - duk_hthread *thr = (duk_hthread *) ctx; - duk_hobject *obj = duk_require_hobject(ctx, obj_index); - duk_hobject *thrower = thr->builtins[DUK_BIDX_TYPE_ERROR_THROWER]; - duk_hobject_define_accessor_internal(thr, obj, DUK_HTHREAD_GET_STRING(thr, stridx), thrower, thrower, desc_flags); -} - -/* Object.defineProperty() equivalent C binding. */ -DUK_EXTERNAL void duk_def_prop(duk_context *ctx, duk_idx_t obj_index, duk_uint_t flags) { - duk_hthread *thr = (duk_hthread *) ctx; - duk_idx_t idx_base; - duk_hobject *obj; - duk_hstring *key; - duk_idx_t idx_value; - duk_hobject *get; - duk_hobject *set; - duk_uint_t is_data_desc; - duk_uint_t is_acc_desc; - - DUK_ASSERT_CTX_VALID(ctx); - - obj = duk_require_hobject(ctx, obj_index); - - is_data_desc = flags & (DUK_DEFPROP_HAVE_VALUE | DUK_DEFPROP_HAVE_WRITABLE); - is_acc_desc = flags & (DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER); - if (is_data_desc && is_acc_desc) { - /* "Have" flags must not be conflicting so that they would - * apply to both a plain property and an accessor at the same - * time. - */ - goto fail_invalid_desc; - } - - idx_base = duk_get_top_index(ctx); - if (flags & DUK_DEFPROP_HAVE_SETTER) { - duk_require_type_mask(ctx, idx_base, DUK_TYPE_MASK_UNDEFINED | - DUK_TYPE_MASK_OBJECT | - DUK_TYPE_MASK_LIGHTFUNC); - set = duk_get_hobject_or_lfunc_coerce(ctx, idx_base); - if (set != NULL && !DUK_HOBJECT_IS_CALLABLE(set)) { - goto fail_not_callable; - } - idx_base--; - } else { - set = NULL; - } - if (flags & DUK_DEFPROP_HAVE_GETTER) { - duk_require_type_mask(ctx, idx_base, DUK_TYPE_MASK_UNDEFINED | - DUK_TYPE_MASK_OBJECT | - DUK_TYPE_MASK_LIGHTFUNC); - get = duk_get_hobject_or_lfunc_coerce(ctx, idx_base); - if (get != NULL && !DUK_HOBJECT_IS_CALLABLE(get)) { - goto fail_not_callable; - } - idx_base--; - } else { - get = NULL; - } - if (flags & DUK_DEFPROP_HAVE_VALUE) { - idx_value = idx_base; - idx_base--; - } else { - idx_value = (duk_idx_t) -1; - } - key = duk_require_hstring(ctx, idx_base); - - duk_require_valid_index(ctx, idx_base); - - duk_hobject_define_property_helper(ctx, - flags /*defprop_flags*/, - obj, - key, - idx_value, - get, - set); - - /* Clean up stack */ - - duk_set_top(ctx, idx_base); - - /* [ ... obj ... ] */ - - return; - - fail_invalid_desc: - DUK_ERROR_TYPE(thr, DUK_STR_INVALID_DESCRIPTOR); - return; - - fail_not_callable: - DUK_ERROR_TYPE(thr, DUK_STR_NOT_CALLABLE); - return; -} - -/* - * Object related - * - * Note: seal() and freeze() are accessible through Ecmascript bindings, - * and are not exposed through the API. - */ - -DUK_EXTERNAL void duk_compact(duk_context *ctx, duk_idx_t obj_index) { - duk_hthread *thr = (duk_hthread *) ctx; - duk_hobject *obj; - - DUK_ASSERT_CTX_VALID(ctx); - - obj = duk_get_hobject(ctx, obj_index); - if (obj) { - /* Note: this may fail, caller should protect the call if necessary */ - duk_hobject_compact_props(thr, obj); - } -} - -/* XXX: the duk_hobject_enum.c stack APIs should be reworked */ - -DUK_EXTERNAL void duk_enum(duk_context *ctx, duk_idx_t obj_index, duk_uint_t enum_flags) { - DUK_ASSERT_CTX_VALID(ctx); - - duk_dup(ctx, obj_index); - duk_require_hobject_or_lfunc_coerce(ctx, -1); - duk_hobject_enumerator_create(ctx, enum_flags); /* [target] -> [enum] */ -} - -DUK_EXTERNAL duk_bool_t duk_next(duk_context *ctx, duk_idx_t enum_index, duk_bool_t get_value) { - DUK_ASSERT_CTX_VALID(ctx); - - duk_require_hobject(ctx, enum_index); - duk_dup(ctx, enum_index); - return duk_hobject_enumerator_next(ctx, get_value); -} - -/* - * Helpers for writing multiple properties - */ - -DUK_EXTERNAL void duk_put_function_list(duk_context *ctx, duk_idx_t obj_index, const duk_function_list_entry *funcs) { - const duk_function_list_entry *ent = funcs; - - DUK_ASSERT_CTX_VALID(ctx); - - obj_index = duk_require_normalize_index(ctx, obj_index); - if (ent != NULL) { - while (ent->key != NULL) { - duk_push_c_function(ctx, ent->value, ent->nargs); - duk_put_prop_string(ctx, obj_index, ent->key); - ent++; - } - } -} - -DUK_EXTERNAL void duk_put_number_list(duk_context *ctx, duk_idx_t obj_index, const duk_number_list_entry *numbers) { - const duk_number_list_entry *ent = numbers; - - DUK_ASSERT_CTX_VALID(ctx); - - obj_index = duk_require_normalize_index(ctx, obj_index); - if (ent != NULL) { - while (ent->key != NULL) { - duk_push_number(ctx, ent->value); - duk_put_prop_string(ctx, obj_index, ent->key); - ent++; - } - } -} - -/* - * Shortcut for accessing global object properties - */ - -DUK_EXTERNAL duk_bool_t duk_get_global_string(duk_context *ctx, const char *key) { - duk_hthread *thr = (duk_hthread *) ctx; - duk_bool_t ret; - - DUK_ASSERT_CTX_VALID(ctx); - DUK_ASSERT(thr->builtins[DUK_BIDX_GLOBAL] != NULL); - - /* XXX: direct implementation */ - - duk_push_hobject(ctx, thr->builtins[DUK_BIDX_GLOBAL]); - ret = duk_get_prop_string(ctx, -1, key); - duk_remove(ctx, -2); - return ret; -} - -DUK_EXTERNAL duk_bool_t duk_put_global_string(duk_context *ctx, const char *key) { - duk_hthread *thr = (duk_hthread *) ctx; - duk_bool_t ret; - - DUK_ASSERT_CTX_VALID(ctx); - DUK_ASSERT(thr->builtins[DUK_BIDX_GLOBAL] != NULL); - - /* XXX: direct implementation */ - - duk_push_hobject(ctx, thr->builtins[DUK_BIDX_GLOBAL]); - duk_insert(ctx, -2); - ret = duk_put_prop_string(ctx, -2, key); /* [ ... global val ] -> [ ... global ] */ - duk_pop(ctx); - return ret; -} - -/* - * Object prototype - */ - -DUK_EXTERNAL void duk_get_prototype(duk_context *ctx, duk_idx_t index) { - duk_hthread *thr = (duk_hthread *) ctx; - duk_hobject *obj; - duk_hobject *proto; - - DUK_ASSERT_CTX_VALID(ctx); - DUK_UNREF(thr); - - obj = duk_require_hobject(ctx, index); - DUK_ASSERT(obj != NULL); - - /* XXX: shared helper for duk_push_hobject_or_undefined()? */ - proto = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, obj); - if (proto) { - duk_push_hobject(ctx, proto); - } else { - duk_push_undefined(ctx); - } -} - -DUK_EXTERNAL void duk_set_prototype(duk_context *ctx, duk_idx_t index) { - duk_hthread *thr = (duk_hthread *) ctx; - duk_hobject *obj; - duk_hobject *proto; - - DUK_ASSERT_CTX_VALID(ctx); - - obj = duk_require_hobject(ctx, index); - DUK_ASSERT(obj != NULL); - duk_require_type_mask(ctx, -1, DUK_TYPE_MASK_UNDEFINED | - DUK_TYPE_MASK_OBJECT); - proto = duk_get_hobject(ctx, -1); - /* proto can also be NULL here (allowed explicitly) */ - -#if defined(DUK_USE_ROM_OBJECTS) - if (DUK_HEAPHDR_HAS_READONLY((duk_heaphdr *) obj)) { - DUK_ERROR_TYPE(thr, DUK_STR_NOT_CONFIGURABLE); /* XXX: "read only object"? */ - return; - } -#endif - - DUK_HOBJECT_SET_PROTOTYPE_UPDREF(thr, obj, proto); - - duk_pop(ctx); -} - -/* - * Object finalizer - */ - -/* XXX: these could be implemented as macros calling an internal function - * directly. - * XXX: same issue as with Duktape.fin: there's no way to delete the property - * now (just set it to undefined). - */ -DUK_EXTERNAL void duk_get_finalizer(duk_context *ctx, duk_idx_t index) { - DUK_ASSERT_CTX_VALID(ctx); - - duk_get_prop_stridx(ctx, index, DUK_STRIDX_INT_FINALIZER); -} - -DUK_EXTERNAL void duk_set_finalizer(duk_context *ctx, duk_idx_t index) { - DUK_ASSERT_CTX_VALID(ctx); - - duk_put_prop_stridx(ctx, index, DUK_STRIDX_INT_FINALIZER); -}