jscript: Inherit some Number functions from Object.

This commit is contained in:
Piotr Caban 2009-08-12 12:48:34 +02:00 committed by Alexandre Julliard
parent 5d41205654
commit 9f0969fbcb
4 changed files with 10 additions and 37 deletions

View File

@ -770,7 +770,7 @@ static HRESULT init_constructors(script_ctx_t *ctx, DispatchEx *object_prototype
if(FAILED(hres))
return hres;
hres = create_number_constr(ctx, &ctx->number_constr);
hres = create_number_constr(ctx, object_prototype, &ctx->number_constr);
if(FAILED(hres))
return hres;

View File

@ -229,7 +229,7 @@ HRESULT create_array_constr(script_ctx_t*,DispatchEx**);
HRESULT create_bool_constr(script_ctx_t*,DispatchEx**);
HRESULT create_date_constr(script_ctx_t*,DispatchEx**);
HRESULT init_error_constr(script_ctx_t*);
HRESULT create_number_constr(script_ctx_t*,DispatchEx**);
HRESULT create_number_constr(script_ctx_t*,DispatchEx*,DispatchEx**);
HRESULT create_object_constr(script_ctx_t*,DispatchEx*,DispatchEx**);
HRESULT create_regexp_constr(script_ctx_t*,DispatchEx*,DispatchEx**);
HRESULT create_string_constr(script_ctx_t*,DispatchEx*,DispatchEx**);

View File

@ -36,10 +36,6 @@ static const WCHAR toFixedW[] = {'t','o','F','i','x','e','d',0};
static const WCHAR toExponentialW[] = {'t','o','E','x','p','o','n','e','n','t','i','a','l',0};
static const WCHAR toPrecisionW[] = {'t','o','P','r','e','c','i','s','i','o','n',0};
static const WCHAR valueOfW[] = {'v','a','l','u','e','O','f',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};
#define NUMBER_TOSTRING_BUF_SIZE 64
/* ECMA-262 3rd Edition 15.7.4.2 */
@ -214,27 +210,6 @@ static HRESULT Number_valueOf(DispatchEx *dispex, LCID lcid, WORD flags, DISPPAR
return S_OK;
}
static HRESULT Number_hasOwnProperty(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT Number_propertyIsEnumerable(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT Number_isPrototypeOf(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT Number_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
@ -256,9 +231,6 @@ static HRESULT Number_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAM
}
static const builtin_prop_t Number_props[] = {
{hasOwnPropertyW, Number_hasOwnProperty, PROPF_METHOD},
{isPrototypeOfW, Number_isPrototypeOf, PROPF_METHOD},
{propertyIsEnumerableW, Number_propertyIsEnumerable, PROPF_METHOD},
{toExponentialW, Number_toExponential, PROPF_METHOD},
{toFixedW, Number_toFixed, PROPF_METHOD},
{toLocaleStringW, Number_toLocaleString, PROPF_METHOD},
@ -330,7 +302,7 @@ static HRESULT NumberConstr_value(DispatchEx *dispex, LCID lcid, WORD flags, DIS
return S_OK;
}
static HRESULT alloc_number(script_ctx_t *ctx, BOOL use_constr, NumberInstance **ret)
static HRESULT alloc_number(script_ctx_t *ctx, DispatchEx *object_prototype, NumberInstance **ret)
{
NumberInstance *number;
HRESULT hres;
@ -339,10 +311,10 @@ static HRESULT alloc_number(script_ctx_t *ctx, BOOL use_constr, NumberInstance *
if(!number)
return E_OUTOFMEMORY;
if(use_constr)
hres = init_dispex_from_constr(&number->dispex, ctx, &Number_info, ctx->number_constr);
if(object_prototype)
hres = init_dispex(&number->dispex, ctx, &Number_info, object_prototype);
else
hres = init_dispex(&number->dispex, ctx, &Number_info, NULL);
hres = init_dispex_from_constr(&number->dispex, ctx, &Number_info, ctx->number_constr);
if(FAILED(hres))
return hres;
@ -350,12 +322,12 @@ static HRESULT alloc_number(script_ctx_t *ctx, BOOL use_constr, NumberInstance *
return S_OK;
}
HRESULT create_number_constr(script_ctx_t *ctx, DispatchEx **ret)
HRESULT create_number_constr(script_ctx_t *ctx, DispatchEx *object_prototype, DispatchEx **ret)
{
NumberInstance *number;
HRESULT hres;
hres = alloc_number(ctx, FALSE, &number);
hres = alloc_number(ctx, object_prototype, &number);
if(FAILED(hres))
return hres;
@ -371,7 +343,7 @@ HRESULT create_number(script_ctx_t *ctx, VARIANT *num, DispatchEx **ret)
NumberInstance *number;
HRESULT hres;
hres = alloc_number(ctx, TRUE, &number);
hres = alloc_number(ctx, NULL, &number);
if(FAILED(hres))
return hres;

View File

@ -1380,5 +1380,6 @@ function testObjectInherit(obj, ts, tls, vo) {
Object.prototype._test = "test";
testObjectInherit(new String("test"), false, true, false);
testObjectInherit(/test/g, false, true, true);
testObjectInherit(new Number(1), false, false, false);
reportSuccess();