jscript: Added to_object(number) implementation.

This commit is contained in:
Jacek Caban 2008-09-16 20:45:45 +02:00 committed by Alexandre Julliard
parent 7fa373e364
commit 1a97632a4e
4 changed files with 30 additions and 0 deletions

View File

@ -135,6 +135,7 @@ HRESULT create_array(script_ctx_t*,DWORD,DispatchEx**);
HRESULT create_regexp_str(script_ctx_t*,const WCHAR*,DWORD,const WCHAR*,DWORD,DispatchEx**);
HRESULT create_string(script_ctx_t*,const WCHAR*,DWORD,DispatchEx**);
HRESULT create_bool(script_ctx_t*,VARIANT_BOOL,DispatchEx**);
HRESULT create_number(script_ctx_t*,VARIANT*,DispatchEx**);
HRESULT to_primitive(script_ctx_t*,VARIANT*,jsexcept_t*,VARIANT*);
HRESULT to_boolean(VARIANT*,VARIANT_BOOL*);

View File

@ -258,6 +258,14 @@ HRESULT to_object(exec_ctx_t *ctx, VARIANT *v, IDispatch **disp)
if(FAILED(hres))
return hres;
*disp = (IDispatch*)_IDispatchEx_(dispex);
break;
case VT_I4:
case VT_R8:
hres = create_number(ctx->parser->script, v, &dispex);
if(FAILED(hres))
return hres;
*disp = (IDispatch*)_IDispatchEx_(dispex);
break;
case VT_DISPATCH:

View File

@ -24,6 +24,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(jscript);
typedef struct {
DispatchEx dispex;
VARIANT num;
} NumberInstance;
static const WCHAR toStringW[] = {'t','o','S','t','r','i','n','g',0};
@ -165,3 +167,18 @@ HRESULT create_number_constr(script_ctx_t *ctx, DispatchEx **ret)
jsdisp_release(&number->dispex);
return hres;
}
HRESULT create_number(script_ctx_t *ctx, VARIANT *num, DispatchEx **ret)
{
NumberInstance *number;
HRESULT hres;
hres = alloc_number(ctx, TRUE, &number);
if(FAILED(hres))
return hres;
number->num = *num;
*ret = &number->dispex;
return S_OK;
}

View File

@ -239,6 +239,10 @@ ok("".test === true, "\"\".test is not true");
Boolean.prototype.test = true;
ok(true.test === true, "true.test is not true");
Number.prototype.test = true;
ok((0).test === true, "(0).test is not true");
ok((0.5).test === true, "(0.5).test is not true");
var state = "";
try {
ok(state === "", "try: state = " + state);