Commit 1a97632a authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Added to_object(number) implementation.

parent 7fa373e3
......@@ -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*);
......
......@@ -260,6 +260,14 @@ HRESULT to_object(exec_ctx_t *ctx, VARIANT *v, IDispatch **disp)
*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:
IDispatch_AddRef(V_DISPATCH(v));
*disp = V_DISPATCH(v);
......
......@@ -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;
}
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment