Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
duk_bi_proxy.c File Reference
#include "duk_internal.h"

Go to the source code of this file.

Functions

DUK_INTERNAL duk_ret_t duk_bi_proxy_constructor (duk_context *ctx)
 

Function Documentation

◆ duk_bi_proxy_constructor()

DUK_INTERNAL duk_ret_t duk_bi_proxy_constructor ( duk_context * ctx)

Definition at line 8 of file duktape-1.5.2/src-separate/duk_bi_proxy.c.

8 {
9 duk_hobject *h_target;
10 duk_hobject *h_handler;
11
12 if (!duk_is_constructor_call(ctx)) {
13 return DUK_RET_TYPE_ERROR;
14 }
15
16 /* Reject a proxy object as the target because it would need
17 * special handler in property lookups. (ES6 has no such restriction)
18 */
19 h_target = duk_require_hobject_or_lfunc_coerce(ctx, 0);
20 DUK_ASSERT(h_target != NULL);
21 if (DUK_HOBJECT_HAS_EXOTIC_PROXYOBJ(h_target)) {
22 return DUK_RET_TYPE_ERROR;
23 }
24
25 /* Reject a proxy object as the handler because it would cause
26 * potentially unbounded recursion. (ES6 has no such restriction)
27 */
28 h_handler = duk_require_hobject_or_lfunc_coerce(ctx, 1);
29 DUK_ASSERT(h_handler != NULL);
30 if (DUK_HOBJECT_HAS_EXOTIC_PROXYOBJ(h_handler)) {
31 return DUK_RET_TYPE_ERROR;
32 }
33
34 /* XXX: the returned value is exotic in ES6, but we use a
35 * simple object here with no prototype. Without a prototype,
36 * [[DefaultValue]] coercion fails which is abit confusing.
37 * No callable check/handling in the current Proxy subset.
38 */
43 NULL);
44 DUK_ASSERT_TOP(ctx, 3);
45
46 /* Make _Target and _Handler non-configurable and non-writable.
47 * They can still be forcibly changed by C code (both user and
48 * Duktape internal), but not by Ecmascript code.
49 */
50
51 /* Proxy target */
52 duk_dup(ctx, 0);
54
55 /* Proxy handler */
56 duk_dup(ctx, 1);
58
59 return 1; /* replacement handler */
60}
DUK_INTERNAL_DECL duk_idx_t duk_push_object_helper_proto(duk_context *ctx, duk_uint_t hobject_flags_and_class, duk_hobject *proto)
#define DUK_STRIDX_INT_HANDLER
#define DUK_HOBJECT_CLASS_OBJECT
#define DUK_PROPDESC_FLAGS_NONE
#define DUK_HOBJECT_CLASS_AS_FLAGS(v)
DUK_INTERNAL_DECL duk_hobject * duk_require_hobject_or_lfunc_coerce(duk_context *ctx, duk_idx_t index)
DUK_EXTERNAL void duk_dup(duk_context *ctx, duk_idx_t from_index)
DUK_EXTERNAL duk_bool_t duk_is_constructor_call(duk_context *ctx)
#define DUK_STRIDX_INT_TARGET
#define DUK_HOBJECT_HAS_EXOTIC_PROXYOBJ(h)
#define DUK_HOBJECT_FLAG_EXOTIC_PROXYOBJ
#define DUK_ASSERT_TOP(ctx, n)
#define DUK_HOBJECT_FLAG_EXTENSIBLE
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)
#define NULL
Definition gmacros.h:924

References DUK_ASSERT, DUK_ASSERT_TOP, duk_dup(), DUK_HOBJECT_CLASS_AS_FLAGS, DUK_HOBJECT_CLASS_OBJECT, DUK_HOBJECT_FLAG_EXOTIC_PROXYOBJ, DUK_HOBJECT_FLAG_EXTENSIBLE, DUK_HOBJECT_HAS_EXOTIC_PROXYOBJ, duk_is_constructor_call(), DUK_PROPDESC_FLAGS_NONE, duk_push_object_helper_proto(), duk_require_hobject_or_lfunc_coerce(), DUK_RET_TYPE_ERROR, DUK_STRIDX_INT_HANDLER, DUK_STRIDX_INT_TARGET, duk_xdef_prop_stridx(), and NULL.