mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-06 17:54:05 +00:00
jscript: Add Set object stub implementation.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
6e292a745f
commit
8dd582ebeb
|
@ -27,6 +27,7 @@ C_SRCS = \
|
|||
number.c \
|
||||
object.c \
|
||||
regexp.c \
|
||||
set.c \
|
||||
string.c \
|
||||
vbarray.c
|
||||
|
||||
|
|
|
@ -1114,5 +1114,8 @@ HRESULT init_global(script_ctx_t *ctx)
|
|||
return hres;
|
||||
|
||||
hres = jsdisp_define_data_property(ctx->global, L"Infinity", const_flags, jsval_number(INFINITY));
|
||||
return hres;
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
return init_set_constructor(ctx);
|
||||
}
|
||||
|
|
|
@ -483,6 +483,11 @@ static void decrease_state(JScript *This, SCRIPTSTATE state)
|
|||
This->ctx->site = NULL;
|
||||
}
|
||||
|
||||
if(This->ctx->set_prototype) {
|
||||
jsdisp_release(This->ctx->set_prototype);
|
||||
This->ctx->set_prototype = NULL;
|
||||
}
|
||||
|
||||
if(This->ctx->object_prototype) {
|
||||
jsdisp_release(This->ctx->object_prototype);
|
||||
This->ctx->object_prototype = NULL;
|
||||
|
|
|
@ -130,7 +130,8 @@ typedef enum {
|
|||
JSCLASS_STRING,
|
||||
JSCLASS_ARGUMENTS,
|
||||
JSCLASS_VBARRAY,
|
||||
JSCLASS_JSON
|
||||
JSCLASS_JSON,
|
||||
JSCLASS_SET,
|
||||
} jsclass_t;
|
||||
|
||||
jsdisp_t *iface_to_jsdisp(IDispatch*) DECLSPEC_HIDDEN;
|
||||
|
@ -466,6 +467,7 @@ struct _script_ctx_t {
|
|||
jsdisp_t *regexp_constr;
|
||||
jsdisp_t *string_constr;
|
||||
jsdisp_t *vbarray_constr;
|
||||
jsdisp_t *set_prototype;
|
||||
};
|
||||
|
||||
void script_release(script_ctx_t*) DECLSPEC_HIDDEN;
|
||||
|
@ -478,6 +480,7 @@ static inline void script_addref(script_ctx_t *ctx)
|
|||
HRESULT init_global(script_ctx_t*) DECLSPEC_HIDDEN;
|
||||
HRESULT init_function_constr(script_ctx_t*,jsdisp_t*) DECLSPEC_HIDDEN;
|
||||
HRESULT create_object_prototype(script_ctx_t*,jsdisp_t**) DECLSPEC_HIDDEN;
|
||||
HRESULT init_set_constructor(script_ctx_t*) DECLSPEC_HIDDEN;
|
||||
|
||||
HRESULT create_activex_constr(script_ctx_t*,jsdisp_t**) DECLSPEC_HIDDEN;
|
||||
HRESULT create_array_constr(script_ctx_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
|
||||
|
|
|
@ -47,6 +47,7 @@ static HRESULT Object_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u
|
|||
L"[object String]",
|
||||
L"[object Object]",
|
||||
L"[object Object]",
|
||||
L"[object Object]",
|
||||
L"[object Object]"
|
||||
};
|
||||
|
||||
|
|
143
dlls/jscript/set.c
Normal file
143
dlls/jscript/set.c
Normal file
|
@ -0,0 +1,143 @@
|
|||
/*
|
||||
* Copyright 2021 Jacek Caban for CodeWeavers
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include "jscript.h"
|
||||
|
||||
#include "wine/debug.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(jscript);
|
||||
|
||||
typedef struct {
|
||||
jsdisp_t dispex;
|
||||
} SetInstance;
|
||||
|
||||
static HRESULT Set_add(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
|
||||
jsval_t *r)
|
||||
{
|
||||
FIXME("%p\n", jsthis);
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT Set_clear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
|
||||
jsval_t *r)
|
||||
{
|
||||
FIXME("%p\n", jsthis);
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT Set_delete(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
|
||||
jsval_t *r)
|
||||
{
|
||||
FIXME("%p\n", jsthis);
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT Set_forEach(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
|
||||
jsval_t *r)
|
||||
{
|
||||
FIXME("%p\n", jsthis);
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT Set_has(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
|
||||
jsval_t *r)
|
||||
{
|
||||
FIXME("%p\n", jsthis);
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT Set_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
|
||||
jsval_t *r)
|
||||
{
|
||||
FIXME("\n");
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static const builtin_prop_t Set_props[] = {
|
||||
{L"add", Set_add, PROPF_METHOD|1},
|
||||
{L"clear", Set_clear, PROPF_METHOD},
|
||||
{L"delete" , Set_delete, PROPF_METHOD|1},
|
||||
{L"forEach", Set_forEach, PROPF_METHOD|1},
|
||||
{L"has", Set_has, PROPF_METHOD|1},
|
||||
};
|
||||
|
||||
static const builtin_info_t Set_prototype_info = {
|
||||
JSCLASS_SET,
|
||||
{NULL, Set_value, 0},
|
||||
ARRAY_SIZE(Set_props),
|
||||
Set_props,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
static const builtin_info_t Set_info = {
|
||||
JSCLASS_SET,
|
||||
{NULL, Set_value, 0},
|
||||
0, NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
static HRESULT Set_constructor(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
|
||||
jsval_t *r)
|
||||
{
|
||||
SetInstance *set;
|
||||
HRESULT hres;
|
||||
|
||||
switch(flags) {
|
||||
case DISPATCH_CONSTRUCT:
|
||||
TRACE("\n");
|
||||
|
||||
if(!(set = heap_alloc_zero(sizeof(*set))))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
hres = init_dispex(&set->dispex, ctx, &Set_info, ctx->set_prototype);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
*r = jsval_obj(&set->dispex);
|
||||
return S_OK;
|
||||
|
||||
default:
|
||||
FIXME("unimplemented flags %x\n", flags);
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT init_set_constructor(script_ctx_t *ctx)
|
||||
{
|
||||
jsdisp_t *constructor;
|
||||
HRESULT hres;
|
||||
|
||||
if(ctx->version < SCRIPTLANGUAGEVERSION_ES6)
|
||||
return S_OK;
|
||||
|
||||
hres = create_dispex(ctx, &Set_prototype_info, ctx->object_prototype, &ctx->set_prototype);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
hres = create_builtin_constructor(ctx, Set_constructor, L"Set", NULL,
|
||||
PROPF_CONSTR, ctx->set_prototype, &constructor);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
hres = jsdisp_define_data_property(ctx->global, L"Set", PROPF_WRITABLE,
|
||||
jsval_obj(constructor));
|
||||
jsdisp_release(constructor);
|
||||
return hres;
|
||||
}
|
|
@ -115,6 +115,7 @@ sync_test("window_props", function() {
|
|||
test_exposed("getSelection", v >= 9);
|
||||
test_exposed("onfocusout", v >= 9);
|
||||
test_exposed("getComputedStyle", v >= 9);
|
||||
test_exposed("Set", v >= 11);
|
||||
if(v >= 9) /* FIXME: native exposes it in all compat modes */
|
||||
test_exposed("performance", true);
|
||||
});
|
||||
|
@ -597,3 +598,25 @@ sync_test("func_scope", function() {
|
|||
}catch(e) {}
|
||||
})(o);
|
||||
});
|
||||
|
||||
sync_test("set_obj", function() {
|
||||
if(!("Set" in window)) return;
|
||||
|
||||
var s = new Set, r;
|
||||
ok(Object.getPrototypeOf(s) === Set.prototype, "unexpected Set prototype");
|
||||
|
||||
function test_length(name, len) {
|
||||
ok(Set.prototype[name].length === len, "Set.prototype." + name + " = " + Set.prototype[name].length);
|
||||
}
|
||||
test_length("add", 1);
|
||||
test_length("clear", 0);
|
||||
test_length("delete", 1);
|
||||
test_length("forEach", 1);
|
||||
test_length("has", 1);
|
||||
ok(!("entries" in s), "entries are in Set");
|
||||
ok(!("keys" in s), "keys are in Set");
|
||||
ok(!("values" in s), "values are in Set");
|
||||
|
||||
r = Object.prototype.toString.call(s);
|
||||
ok(r === "[object Object]", "toString returned " + r);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue