From fdbcb97d634a639bc9f3f83aee71632df1e01ff9 Mon Sep 17 00:00:00 2001
From: Sami Vaarala
Date: Wed, 16 Aug 2017 00:03:22 +0300
Subject: [PATCH 1/4] Add an unused flags field to duk_push_proxy()
---
src-input/duk_api_stack.c | 6 ++++--
src-input/duk_bi_proxy.c | 2 +-
src-input/duktape.h.in | 2 +-
3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/src-input/duk_api_stack.c b/src-input/duk_api_stack.c
index dfe7ceb5e0..dfc277c1b8 100644
--- a/src-input/duk_api_stack.c
+++ b/src-input/duk_api_stack.c
@@ -5224,7 +5224,7 @@ DUK_INTERNAL void *duk_push_fixed_buffer_zero(duk_hthread *thr, duk_size_t len)
}
#if defined(DUK_USE_ES6_PROXY)
-DUK_EXTERNAL duk_idx_t duk_push_proxy(duk_hthread *thr) {
+DUK_EXTERNAL duk_idx_t duk_push_proxy(duk_hthread *thr, duk_uint_t proxy_flags) {
duk_hobject *h_target;
duk_hobject *h_handler;
duk_hproxy *h_proxy;
@@ -5232,6 +5232,7 @@ DUK_EXTERNAL duk_idx_t duk_push_proxy(duk_hthread *thr) {
duk_uint_t flags;
DUK_ASSERT_API_ENTRY(thr);
+ DUK_UNREF(proxy_flags);
/* DUK__CHECK_SPACE() unnecessary because the Proxy is written to
* value stack in-place.
@@ -5316,8 +5317,9 @@ DUK_EXTERNAL duk_idx_t duk_push_proxy(duk_hthread *thr) {
DUK_ERROR_TYPE_INVALID_ARGS(thr);
}
#else /* DUK_USE_ES6_PROXY */
-DUK_EXTERNAL duk_idx_t duk_push_proxy(duk_hthread *thr) {
+DUK_EXTERNAL duk_idx_t duk_push_proxy(duk_hthread *thr, duk_uint_t proxy_flags) {
DUK_ASSERT_API_ENTRY(thr);
+ DUK_UNREF(proxy_flags);
DUK_ERROR_UNSUPPORTED(thr);
}
#endif /* DUK_USE_ES6_PROXY */
diff --git a/src-input/duk_bi_proxy.c b/src-input/duk_bi_proxy.c
index 4c7d93100d..b80bb4b943 100644
--- a/src-input/duk_bi_proxy.c
+++ b/src-input/duk_bi_proxy.c
@@ -89,7 +89,7 @@ DUK_INTERNAL duk_ret_t duk_bi_proxy_constructor(duk_hthread *thr) {
DUK_ASSERT_TOP(thr, 2); /* [ target handler ] */
duk_require_constructor_call(thr);
- duk_push_proxy(thr); /* [ target handler ] -> [ proxy ] */
+ duk_push_proxy(thr, 0 /*flags*/); /* [ target handler ] -> [ proxy ] */
return 1; /* replacement */
}
#endif /* DUK_USE_ES6_PROXY */
diff --git a/src-input/duktape.h.in b/src-input/duktape.h.in
index 63e05153d9..dbfeff239e 100644
--- a/src-input/duktape.h.in
+++ b/src-input/duktape.h.in
@@ -536,7 +536,7 @@ DUK_EXTERNAL_DECL duk_idx_t duk_push_array(duk_context *ctx);
DUK_EXTERNAL_DECL duk_idx_t duk_push_c_function(duk_context *ctx, duk_c_function func, duk_idx_t nargs);
DUK_EXTERNAL_DECL duk_idx_t duk_push_c_lightfunc(duk_context *ctx, duk_c_function func, duk_idx_t nargs, duk_idx_t length, duk_int_t magic);
DUK_EXTERNAL_DECL duk_idx_t duk_push_thread_raw(duk_context *ctx, duk_uint_t flags);
-DUK_EXTERNAL_DECL duk_idx_t duk_push_proxy(duk_context *ctx);
+DUK_EXTERNAL_DECL duk_idx_t duk_push_proxy(duk_context *ctx, duk_uint_t proxy_flags);
#define duk_push_thread(ctx) \
duk_push_thread_raw((ctx), 0 /*flags*/)
From 3c48feb00828b77d913f7e32c92bc61b38c393da Mon Sep 17 00:00:00 2001
From: Sami Vaarala
Date: Wed, 16 Aug 2017 00:03:32 +0300
Subject: [PATCH 2/4] API test fixes for duk_push_proxy() flags
---
tests/api/test-all-public-symbols.c | 1 +
tests/api/test-proxy-apply.c | 4 ++--
tests/api/test-proxy-construct.c | 4 ++--
tests/api/test-push-proxy.c | 2 +-
4 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/tests/api/test-all-public-symbols.c b/tests/api/test-all-public-symbols.c
index c6dc3f207c..8301585fdb 100644
--- a/tests/api/test-all-public-symbols.c
+++ b/tests/api/test-all-public-symbols.c
@@ -239,6 +239,7 @@ static duk_ret_t test_func(duk_context *ctx, void *udata) {
(void) duk_push_number(ctx, 0.0);
(void) duk_push_object(ctx);
(void) duk_push_pointer(ctx, NULL);
+ (void) duk_push_proxy(ctx, 0);
(void) duk_push_sprintf(ctx, "dummy");
(void) duk_push_string(ctx, "dummy");
(void) duk_push_this(ctx);
diff --git a/tests/api/test-proxy-apply.c b/tests/api/test-proxy-apply.c
index 4ac8c1bf64..3db61cb744 100644
--- a/tests/api/test-proxy-apply.c
+++ b/tests/api/test-proxy-apply.c
@@ -31,7 +31,7 @@ static duk_ret_t test_passthrough(duk_context *ctx, void *udata) {
duk_push_c_function(ctx, my_function, 1 /*nargs*/); /* target */
duk_push_object(ctx); /* handler */
- duk_push_proxy(ctx);
+ duk_push_proxy(ctx, 0);
duk_push_uint(ctx, 123);
duk_call(ctx, 1);
@@ -53,7 +53,7 @@ static duk_ret_t test_trap(duk_context *ctx, void *udata) {
duk_push_c_function(ctx, my_apply_trap, 3 /*nargs*/);
duk_put_prop_string(ctx, -2, "apply");
- duk_push_proxy(ctx);
+ duk_push_proxy(ctx, 0);
duk_push_uint(ctx, 123);
duk_call(ctx, 1);
diff --git a/tests/api/test-proxy-construct.c b/tests/api/test-proxy-construct.c
index 1fc34efca2..295b6ea520 100644
--- a/tests/api/test-proxy-construct.c
+++ b/tests/api/test-proxy-construct.c
@@ -31,7 +31,7 @@ static duk_ret_t test_passthrough(duk_context *ctx, void *udata) {
duk_push_c_function(ctx, my_constructor, 1 /*nargs*/); /* target */
duk_push_object(ctx); /* handler */
- duk_push_proxy(ctx);
+ duk_push_proxy(ctx, 0);
duk_push_uint(ctx, 123);
duk_new(ctx, 1 /*nargs*/);
@@ -54,7 +54,7 @@ static duk_ret_t test_trap(duk_context *ctx, void *udata) {
duk_push_c_function(ctx, my_construct_trap, 3 /*nargs*/);
duk_put_prop_string(ctx, -2, "construct");
- duk_push_proxy(ctx);
+ duk_push_proxy(ctx, 0);
duk_push_uint(ctx, 123);
duk_new(ctx, 1 /*nargs*/);
diff --git a/tests/api/test-push-proxy.c b/tests/api/test-push-proxy.c
index 5bd2e37ad4..849c14269b 100644
--- a/tests/api/test-push-proxy.c
+++ b/tests/api/test-push-proxy.c
@@ -26,7 +26,7 @@ static duk_ret_t test_basic(duk_context *ctx, void *udata) {
duk_eval_string(ctx, "({ foo: 123 })");
duk_eval_string(ctx, "({ get: function myget() { return 321; } })");
printf("top before: %ld\n", (long) duk_get_top(ctx));
- ret = duk_push_proxy(ctx);
+ ret = duk_push_proxy(ctx, 0);
printf("top after: %ld\n", (long) duk_get_top(ctx));
printf("duk_push_proxy() returned %ld\n", (long) ret);
From a2d520d7508dfdec271a7c69e618eb2c1dd0685f Mon Sep 17 00:00:00 2001
From: Sami Vaarala
Date: Wed, 16 Aug 2017 00:03:43 +0300
Subject: [PATCH 3/4] API doc fix for duk_push_proxy() flags
---
website/api/duk_push_proxy.yaml | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/website/api/duk_push_proxy.yaml b/website/api/duk_push_proxy.yaml
index 9f1fc5650d..54db095871 100644
--- a/website/api/duk_push_proxy.yaml
+++ b/website/api/duk_push_proxy.yaml
@@ -1,14 +1,16 @@
name: duk_push_proxy
proto: |
- duk_idx_t duk_push_proxy(duk_context *ctx);
+ duk_idx_t duk_push_proxy(duk_context *ctx, duk_uint_t proxy_flags);
stack: |
[ ... target! handler! ] -> [ ... proxy! ]
summary: |
Push a new Proxy object for target and handler table given on the value
- stack, equivalent to new Proxy(target, handler)
.
+ stack, equivalent to new Proxy(target, handler)
. The
+ proxy_flags
argument is currently (Duktape 2.2) unused, calling
+ code must pass in a zero.
example: |
duk_idx_t proxy_idx;
@@ -17,7 +19,7 @@ example: |
duk_push_object(ctx); /* handler */
duk_push_c_function(ctx, my_get, 3); /* 'get' trap */
duk_put_prop_string(ctx, -2, "get");
- proxy_idx = duk_push_proxy(ctx); /* [ target handler ] -> [ proxy ] */
+ proxy_idx = duk_push_proxy(ctx, 0); /* [ target handler ] -> [ proxy ] */
tags:
- stack
From a14d99e7ad67e9b96e786530069ce00cce92b7d0 Mon Sep 17 00:00:00 2001
From: Sami Vaarala
Date: Wed, 16 Aug 2017 00:05:25 +0300
Subject: [PATCH 4/4] Releases: duk_push_proxy() flags
---
RELEASES.rst | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/RELEASES.rst b/RELEASES.rst
index 89c30894c6..0a4f81c1e5 100644
--- a/RELEASES.rst
+++ b/RELEASES.rst
@@ -2945,7 +2945,7 @@ Planned
* Add duk_is_constructable() API call (GH-1523)
* Add duk_push_proxy() API call which allows a Proxy to be created from C
- code (GH-1500, GH-837)
+ code (GH-1500, GH-837, GH-1680)
* Add DUK_HIDDEN_SYMBOL(), DUK_GLOBAL_SYMBOL(), DUK_LOCAL_SYMBOL(), and
DUK_WELLKNOWN_SYMBOL() macros for creating symbol literals (GH-1673)