jscript: Inherit some Array functions from Object.

This commit is contained in:
Piotr Caban 2009-08-14 11:55:15 +02:00 committed by Alexandre Julliard
parent da6398dccd
commit 4791cdb11f
4 changed files with 9 additions and 36 deletions

View File

@ -43,10 +43,6 @@ static const WCHAR spliceW[] = {'s','p','l','i','c','e',0};
static const WCHAR toStringW[] = {'t','o','S','t','r','i','n','g',0}; static const WCHAR toStringW[] = {'t','o','S','t','r','i','n','g',0};
static const WCHAR toLocaleStringW[] = {'t','o','L','o','c','a','l','e','S','t','r','i','n','g',0}; static const WCHAR toLocaleStringW[] = {'t','o','L','o','c','a','l','e','S','t','r','i','n','g',0};
static const WCHAR unshiftW[] = {'u','n','s','h','i','f','t',0}; static const WCHAR unshiftW[] = {'u','n','s','h','i','f','t',0};
static const WCHAR hasOwnPropertyW[] = {'h','a','s','O','w','n','P','r','o','p','e','r','t','y',0};
static const WCHAR propertyIsEnumerableW[] =
{'p','r','o','p','e','r','t','y','I','s','E','n','u','m','e','r','a','b','l','e',0};
static const WCHAR isPrototypeOfW[] = {'i','s','P','r','o','t','o','t','y','p','e','O','f',0};
static const WCHAR default_separatorW[] = {',',0}; static const WCHAR default_separatorW[] = {',',0};
@ -743,27 +739,6 @@ static HRESULT Array_unshift(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARA
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT Array_hasOwnProperty(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT Array_propertyIsEnumerable(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT Array_isPrototypeOf(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT Array_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp, static HRESULT Array_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{ {
@ -810,12 +785,9 @@ static void Array_on_put(DispatchEx *dispex, const WCHAR *name)
static const builtin_prop_t Array_props[] = { static const builtin_prop_t Array_props[] = {
{concatW, Array_concat, PROPF_METHOD}, {concatW, Array_concat, PROPF_METHOD},
{hasOwnPropertyW, Array_hasOwnProperty, PROPF_METHOD},
{isPrototypeOfW, Array_isPrototypeOf, PROPF_METHOD},
{joinW, Array_join, PROPF_METHOD}, {joinW, Array_join, PROPF_METHOD},
{lengthW, Array_length, 0}, {lengthW, Array_length, 0},
{popW, Array_pop, PROPF_METHOD}, {popW, Array_pop, PROPF_METHOD},
{propertyIsEnumerableW, Array_propertyIsEnumerable, PROPF_METHOD},
{pushW, Array_push, PROPF_METHOD}, {pushW, Array_push, PROPF_METHOD},
{reverseW, Array_reverse, PROPF_METHOD}, {reverseW, Array_reverse, PROPF_METHOD},
{shiftW, Array_shift, PROPF_METHOD}, {shiftW, Array_shift, PROPF_METHOD},
@ -888,7 +860,7 @@ static HRESULT ArrayConstr_value(DispatchEx *dispex, LCID lcid, WORD flags, DISP
return S_OK; return S_OK;
} }
static HRESULT alloc_array(script_ctx_t *ctx, BOOL use_constr, ArrayInstance **ret) static HRESULT alloc_array(script_ctx_t *ctx, DispatchEx *object_prototype, ArrayInstance **ret)
{ {
ArrayInstance *array; ArrayInstance *array;
HRESULT hres; HRESULT hres;
@ -897,8 +869,8 @@ static HRESULT alloc_array(script_ctx_t *ctx, BOOL use_constr, ArrayInstance **r
if(!array) if(!array)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
if(use_constr) if(object_prototype)
hres = init_dispex_from_constr(&array->dispex, ctx, &Array_info, ctx->array_constr); hres = init_dispex(&array->dispex, ctx, &Array_info, object_prototype);
else else
hres = init_dispex_from_constr(&array->dispex, ctx, &Array_info, ctx->object_constr); hres = init_dispex_from_constr(&array->dispex, ctx, &Array_info, ctx->object_constr);
@ -911,12 +883,12 @@ static HRESULT alloc_array(script_ctx_t *ctx, BOOL use_constr, ArrayInstance **r
return S_OK; return S_OK;
} }
HRESULT create_array_constr(script_ctx_t *ctx, DispatchEx **ret) HRESULT create_array_constr(script_ctx_t *ctx, DispatchEx *object_prototype, DispatchEx **ret)
{ {
ArrayInstance *array; ArrayInstance *array;
HRESULT hres; HRESULT hres;
hres = alloc_array(ctx, FALSE, &array); hres = alloc_array(ctx, object_prototype, &array);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -931,7 +903,7 @@ HRESULT create_array(script_ctx_t *ctx, DWORD length, DispatchEx **ret)
ArrayInstance *array; ArrayInstance *array;
HRESULT hres; HRESULT hres;
hres = alloc_array(ctx, TRUE, &array); hres = alloc_array(ctx, NULL, &array);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;

View File

@ -754,7 +754,7 @@ static HRESULT init_constructors(script_ctx_t *ctx, DispatchEx *object_prototype
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
hres = create_array_constr(ctx, &ctx->array_constr); hres = create_array_constr(ctx, object_prototype, &ctx->array_constr);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;

View File

@ -226,7 +226,7 @@ HRESULT init_global(script_ctx_t*);
HRESULT init_function_constr(script_ctx_t*,DispatchEx*); HRESULT init_function_constr(script_ctx_t*,DispatchEx*);
HRESULT create_object_prototype(script_ctx_t*,DispatchEx**); HRESULT create_object_prototype(script_ctx_t*,DispatchEx**);
HRESULT create_array_constr(script_ctx_t*,DispatchEx**); HRESULT create_array_constr(script_ctx_t*,DispatchEx*,DispatchEx**);
HRESULT create_bool_constr(script_ctx_t*,DispatchEx*,DispatchEx**); HRESULT create_bool_constr(script_ctx_t*,DispatchEx*,DispatchEx**);
HRESULT create_date_constr(script_ctx_t*,DispatchEx*,DispatchEx**); HRESULT create_date_constr(script_ctx_t*,DispatchEx*,DispatchEx**);
HRESULT init_error_constr(script_ctx_t*); HRESULT init_error_constr(script_ctx_t*);

View File

@ -1391,5 +1391,6 @@ testObjectInherit(/test/g, false, true, true);
testObjectInherit(new Number(1), false, false, false); testObjectInherit(new Number(1), false, false, false);
testObjectInherit(new Date(), false, false, false); testObjectInherit(new Date(), false, false, false);
testObjectInherit(new Boolean(true), false, true, false); testObjectInherit(new Boolean(true), false, true, false);
testObjectInherit(new Array(), false, false, true);
reportSuccess(); reportSuccess();