Commit 7bb41e75 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Store value as double in NumberInstance object.

parent 0bf61fb6
...@@ -242,7 +242,7 @@ HRESULT create_regexp(script_ctx_t*,const WCHAR *,int,DWORD,jsdisp_t**) DECLSPEC ...@@ -242,7 +242,7 @@ HRESULT create_regexp(script_ctx_t*,const WCHAR *,int,DWORD,jsdisp_t**) DECLSPEC
HRESULT create_regexp_var(script_ctx_t*,VARIANT*,VARIANT*,jsdisp_t**) DECLSPEC_HIDDEN; HRESULT create_regexp_var(script_ctx_t*,VARIANT*,VARIANT*,jsdisp_t**) DECLSPEC_HIDDEN;
HRESULT create_string(script_ctx_t*,const WCHAR*,DWORD,jsdisp_t**) DECLSPEC_HIDDEN; HRESULT create_string(script_ctx_t*,const WCHAR*,DWORD,jsdisp_t**) DECLSPEC_HIDDEN;
HRESULT create_bool(script_ctx_t*,VARIANT_BOOL,jsdisp_t**) DECLSPEC_HIDDEN; HRESULT create_bool(script_ctx_t*,VARIANT_BOOL,jsdisp_t**) DECLSPEC_HIDDEN;
HRESULT create_number(script_ctx_t*,VARIANT*,jsdisp_t**) DECLSPEC_HIDDEN; HRESULT create_number(script_ctx_t*,double,jsdisp_t**) DECLSPEC_HIDDEN;
HRESULT create_vbarray(script_ctx_t*,SAFEARRAY*,jsdisp_t**) DECLSPEC_HIDDEN; HRESULT create_vbarray(script_ctx_t*,SAFEARRAY*,jsdisp_t**) DECLSPEC_HIDDEN;
typedef enum { typedef enum {
......
...@@ -623,7 +623,7 @@ HRESULT to_object(script_ctx_t *ctx, VARIANT *v, IDispatch **disp) ...@@ -623,7 +623,7 @@ HRESULT to_object(script_ctx_t *ctx, VARIANT *v, IDispatch **disp)
break; break;
case VT_I4: case VT_I4:
case VT_R8: case VT_R8:
hres = create_number(ctx, v, &dispex); hres = create_number(ctx, num_val(v), &dispex);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
......
...@@ -30,7 +30,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(jscript); ...@@ -30,7 +30,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(jscript);
typedef struct { typedef struct {
jsdisp_t dispex; jsdisp_t dispex;
VARIANT num; double value;
} NumberInstance; } NumberInstance;
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};
...@@ -76,17 +76,16 @@ static HRESULT Number_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, D ...@@ -76,17 +76,16 @@ static HRESULT Number_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, D
return throw_type_error(ctx, ei, JS_E_INVALIDARG, NULL); return throw_type_error(ctx, ei, JS_E_INVALIDARG, NULL);
} }
if(V_VT(&number->num) == VT_I4) val = number->value;
val = V_I4(&number->num);
else
val = V_R8(&number->num);
if(radix==10 || isnan(val) || isinf(val)) { if(radix==10 || isnan(val) || isinf(val)) {
hres = to_string(ctx, &number->num, ei, &str); VARIANT v;
num_set_val(&v, val);
hres = to_string(ctx, &v, ei, &str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
} }else {
else {
INT idx = 0; INT idx = 0;
DOUBLE integ, frac, log_radix = 0; DOUBLE integ, frac, log_radix = 0;
WCHAR buf[NUMBER_TOSTRING_BUF_SIZE+16]; WCHAR buf[NUMBER_TOSTRING_BUF_SIZE+16];
...@@ -218,7 +217,7 @@ static HRESULT Number_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI ...@@ -218,7 +217,7 @@ static HRESULT Number_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI
return throw_type_error(ctx, ei, JS_E_NUMBER_EXPECTED, NULL); return throw_type_error(ctx, ei, JS_E_NUMBER_EXPECTED, NULL);
if(retv) if(retv)
*retv = number->num; num_set_val(retv, number->value);
return S_OK; return S_OK;
} }
...@@ -231,7 +230,7 @@ static HRESULT Number_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP ...@@ -231,7 +230,7 @@ static HRESULT Number_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP
case INVOKE_FUNC: case INVOKE_FUNC:
return throw_type_error(ctx, ei, JS_E_FUNCTION_EXPECTED, NULL); return throw_type_error(ctx, ei, JS_E_FUNCTION_EXPECTED, NULL);
case DISPATCH_PROPERTYGET: case DISPATCH_PROPERTYGET:
*retv = number->num; num_set_val(retv, number->value);
break; break;
default: default:
...@@ -288,20 +287,16 @@ static HRESULT NumberConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags ...@@ -288,20 +287,16 @@ static HRESULT NumberConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
case DISPATCH_CONSTRUCT: { case DISPATCH_CONSTRUCT: {
jsdisp_t *obj; jsdisp_t *obj;
VARIANT v;
if(arg_cnt(dp)) { if(arg_cnt(dp)) {
hres = to_number(ctx, get_arg(dp, 0), ei, &n); hres = to_number(ctx, get_arg(dp, 0), ei, &n);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
num_set_val(&v, n);
}else { }else {
V_VT(&v) = VT_I4; n = 0;
V_I4(&v) = 0;
} }
hres = create_number(ctx, &v, &obj); hres = create_number(ctx, n, &obj);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
...@@ -347,7 +342,7 @@ HRESULT create_number_constr(script_ctx_t *ctx, jsdisp_t *object_prototype, jsdi ...@@ -347,7 +342,7 @@ HRESULT create_number_constr(script_ctx_t *ctx, jsdisp_t *object_prototype, jsdi
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
V_VT(&number->num) = VT_I4; number->value = 0;
hres = create_builtin_function(ctx, NumberConstr_value, NumberW, NULL, hres = create_builtin_function(ctx, NumberConstr_value, NumberW, NULL,
PROPF_CONSTR|1, &number->dispex, ret); PROPF_CONSTR|1, &number->dispex, ret);
...@@ -355,7 +350,7 @@ HRESULT create_number_constr(script_ctx_t *ctx, jsdisp_t *object_prototype, jsdi ...@@ -355,7 +350,7 @@ HRESULT create_number_constr(script_ctx_t *ctx, jsdisp_t *object_prototype, jsdi
return hres; return hres;
} }
HRESULT create_number(script_ctx_t *ctx, VARIANT *num, jsdisp_t **ret) HRESULT create_number(script_ctx_t *ctx, double value, jsdisp_t **ret)
{ {
NumberInstance *number; NumberInstance *number;
HRESULT hres; HRESULT hres;
...@@ -364,7 +359,7 @@ HRESULT create_number(script_ctx_t *ctx, VARIANT *num, jsdisp_t **ret) ...@@ -364,7 +359,7 @@ HRESULT create_number(script_ctx_t *ctx, VARIANT *num, jsdisp_t **ret)
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
number->num = *num; number->value = value;
*ret = &number->dispex; *ret = &number->dispex;
return S_OK; return S_OK;
......
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