Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -48695,23 +48695,19 @@ static const JSClassExoticMethods js_proxy_exotic_methods = {
.set_property = js_proxy_set,
};

static JSValue js_proxy_constructor(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv)
JSValue JS_NewProxy(JSContext *ctx, JSValueConst target, JSValueConst handler)
{
JSValueConst target, handler;
JSValue obj;
JSProxyData *s;
JSValue obj;

target = argv[0];
handler = argv[1];
if (JS_VALUE_GET_TAG(target) != JS_TAG_OBJECT ||
JS_VALUE_GET_TAG(handler) != JS_TAG_OBJECT)
JS_VALUE_GET_TAG(handler) != JS_TAG_OBJECT) {
return JS_ThrowTypeErrorNotAnObject(ctx);

}
obj = JS_NewObjectProtoClass(ctx, JS_NULL, JS_CLASS_PROXY);
if (JS_IsException(obj))
return obj;
s = js_malloc(ctx, sizeof(JSProxyData));
s = js_malloc(ctx, sizeof(*s));
if (!s) {
JS_FreeValue(ctx, obj);
return JS_EXCEPTION;
Expand All @@ -48725,6 +48721,12 @@ static JSValue js_proxy_constructor(JSContext *ctx, JSValueConst this_val,
return obj;
}

static JSValue js_proxy_constructor(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv)
{
return JS_NewProxy(ctx, argv[0], argv[1]);
}

static JSValue js_proxy_revoke(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv, int magic,
JSValueConst *func_data)
Expand Down
2 changes: 2 additions & 0 deletions quickjs.h
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,8 @@ JS_EXTERN bool JS_IsArray(JSValueConst val);
JS_EXTERN bool JS_IsProxy(JSValueConst val);
JS_EXTERN JSValue JS_GetProxyTarget(JSContext *ctx, JSValueConst proxy);
JS_EXTERN JSValue JS_GetProxyHandler(JSContext *ctx, JSValueConst proxy);
JS_EXTERN JSValue JS_NewProxy(JSContext *ctx, JSValueConst target,
JSValueConst handler);

JS_EXTERN JSValue JS_NewDate(JSContext *ctx, double epoch_ms);
JS_EXTERN bool JS_IsDate(JSValueConst v);
Expand Down