jscript: Add Map 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
d5aa637737
commit
6dda7096bf
|
@ -483,6 +483,11 @@ static void decrease_state(JScript *This, SCRIPTSTATE state)
|
|||
This->ctx->site = NULL;
|
||||
}
|
||||
|
||||
if(This->ctx->map_prototype) {
|
||||
jsdisp_release(This->ctx->map_prototype);
|
||||
This->ctx->map_prototype = NULL;
|
||||
}
|
||||
|
||||
if(This->ctx->set_prototype) {
|
||||
jsdisp_release(This->ctx->set_prototype);
|
||||
This->ctx->set_prototype = NULL;
|
||||
|
|
|
@ -131,6 +131,7 @@ typedef enum {
|
|||
JSCLASS_ARGUMENTS,
|
||||
JSCLASS_VBARRAY,
|
||||
JSCLASS_JSON,
|
||||
JSCLASS_MAP,
|
||||
JSCLASS_SET,
|
||||
} jsclass_t;
|
||||
|
||||
|
@ -467,6 +468,7 @@ struct _script_ctx_t {
|
|||
jsdisp_t *regexp_constr;
|
||||
jsdisp_t *string_constr;
|
||||
jsdisp_t *vbarray_constr;
|
||||
jsdisp_t *map_prototype;
|
||||
jsdisp_t *set_prototype;
|
||||
};
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@ static HRESULT Object_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u
|
|||
L"[object Object]",
|
||||
L"[object Object]",
|
||||
L"[object Object]",
|
||||
L"[object Object]",
|
||||
L"[object Object]"
|
||||
};
|
||||
|
||||
|
|
|
@ -26,6 +26,10 @@ typedef struct {
|
|||
jsdisp_t dispex;
|
||||
} SetInstance;
|
||||
|
||||
typedef struct {
|
||||
jsdisp_t dispex;
|
||||
} MapInstance;
|
||||
|
||||
static HRESULT Set_add(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
|
||||
jsval_t *r)
|
||||
{
|
||||
|
@ -119,6 +123,107 @@ static HRESULT Set_constructor(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u
|
|||
}
|
||||
}
|
||||
|
||||
static HRESULT Map_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 Map_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 Map_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 Map_get(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 Map_set(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 Map_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 Map_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 Map_prototype_props[] = {
|
||||
{L"clear", Map_clear, PROPF_METHOD},
|
||||
{L"delete" , Map_delete, PROPF_METHOD|1},
|
||||
{L"forEach", Map_forEach, PROPF_METHOD|1},
|
||||
{L"get", Map_get, PROPF_METHOD|1},
|
||||
{L"has", Map_has, PROPF_METHOD|1},
|
||||
{L"set", Map_set, PROPF_METHOD|2},
|
||||
};
|
||||
|
||||
static const builtin_info_t Map_prototype_info = {
|
||||
JSCLASS_OBJECT,
|
||||
{NULL, Map_value, 0},
|
||||
ARRAY_SIZE(Map_prototype_props),
|
||||
Map_prototype_props,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
static const builtin_info_t Map_info = {
|
||||
JSCLASS_MAP,
|
||||
{NULL, Map_value, 0},
|
||||
0, NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
static HRESULT Map_constructor(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
|
||||
jsval_t *r)
|
||||
{
|
||||
MapInstance *map;
|
||||
HRESULT hres;
|
||||
|
||||
switch(flags) {
|
||||
case DISPATCH_CONSTRUCT:
|
||||
TRACE("\n");
|
||||
|
||||
if(!(map = heap_alloc_zero(sizeof(*map))))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
hres = init_dispex(&map->dispex, ctx, &Map_info, ctx->map_prototype);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
*r = jsval_obj(&map->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;
|
||||
|
@ -139,5 +244,20 @@ HRESULT init_set_constructor(script_ctx_t *ctx)
|
|||
hres = jsdisp_define_data_property(ctx->global, L"Set", PROPF_WRITABLE,
|
||||
jsval_obj(constructor));
|
||||
jsdisp_release(constructor);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
hres = create_dispex(ctx, &Map_prototype_info, ctx->object_prototype, &ctx->map_prototype);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
hres = create_builtin_constructor(ctx, Map_constructor, L"Map", NULL,
|
||||
PROPF_CONSTR, ctx->map_prototype, &constructor);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
hres = jsdisp_define_data_property(ctx->global, L"Map", PROPF_WRITABLE,
|
||||
jsval_obj(constructor));
|
||||
jsdisp_release(constructor);
|
||||
return hres;
|
||||
}
|
||||
|
|
|
@ -117,6 +117,7 @@ sync_test("window_props", function() {
|
|||
test_exposed("onfocusout", v >= 9);
|
||||
test_exposed("getComputedStyle", v >= 9);
|
||||
test_exposed("requestAnimationFrame", v >= 10);
|
||||
test_exposed("Map", v >= 11);
|
||||
test_exposed("Set", v >= 11);
|
||||
if(v >= 9) /* FIXME: native exposes it in all compat modes */
|
||||
test_exposed("performance", true);
|
||||
|
@ -623,6 +624,29 @@ sync_test("set_obj", function() {
|
|||
ok(r === "[object Object]", "toString returned " + r);
|
||||
});
|
||||
|
||||
sync_test("map_obj", function() {
|
||||
if(!("Map" in window)) return;
|
||||
|
||||
var s = new Map, r;
|
||||
ok(Object.getPrototypeOf(s) === Map.prototype, "unexpected Map prototype");
|
||||
|
||||
function test_length(name, len) {
|
||||
ok(Map.prototype[name].length === len, "Map.prototype." + name + " = " + Map.prototype[name].length);
|
||||
}
|
||||
test_length("clear", 0);
|
||||
test_length("delete", 1);
|
||||
test_length("forEach", 1);
|
||||
test_length("get", 1);
|
||||
test_length("has", 1);
|
||||
test_length("set", 2);
|
||||
ok(!("entries" in s), "entries are in Map");
|
||||
ok(!("keys" in s), "keys are in Map");
|
||||
ok(!("values" in s), "values are in Map");
|
||||
|
||||
r = Object.prototype.toString.call(s);
|
||||
ok(r === "[object Object]", "toString returned " + r);
|
||||
});
|
||||
|
||||
sync_test("elem_attr", function() {
|
||||
var v = document.documentMode;
|
||||
var elem = document.createElement("div"), r;
|
||||
|
|
Loading…
Reference in New Issue