Commit 1532037b authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Use num_set_int where possible.

parent 7118e6fb
......@@ -2030,16 +2030,14 @@ static HRESULT equal_values(script_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jse
if(V_VT(rval) == VT_BOOL) {
VARIANT v;
V_VT(&v) = VT_I4;
V_I4(&v) = V_BOOL(rval) ? 1 : 0;
num_set_int(&v, V_BOOL(rval) ? 1 : 0);
return equal_values(ctx, lval, &v, ei, ret);
}
if(V_VT(lval) == VT_BOOL) {
VARIANT v;
V_VT(&v) = VT_I4;
V_I4(&v) = V_BOOL(lval) ? 1 : 0;
num_set_int(&v, V_BOOL(lval) ? 1 : 0);
return equal_values(ctx, &v, rval, ei, ret);
}
......
......@@ -199,8 +199,7 @@ static HRESULT create_error(script_ctx_t *ctx, jsdisp_t *constr,
if(FAILED(hres))
return hres;
V_VT(&v) = VT_I4;
V_I4(&v) = number;
num_set_int(&v, number);
hres = jsdisp_propput_name(err, numberW, &v, NULL/*FIXME*/);
if(FAILED(hres)) {
jsdisp_release(err);
......
......@@ -133,8 +133,7 @@ static HRESULT create_arguments(script_ctx_t *ctx, IDispatch *calee, DISPPARAMS
}
if(SUCCEEDED(hres)) {
V_VT(&var) = VT_I4;
V_I4(&var) = arg_cnt(dp);
num_set_int(&var, arg_cnt(dp));
hres = jsdisp_propput_name(args, lengthW, &var, ei);
if(SUCCEEDED(hres)) {
......@@ -315,8 +314,7 @@ static HRESULT Function_length(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, D
switch(flags) {
case DISPATCH_PROPERTYGET:
V_VT(retv) = VT_I4;
V_I4(retv) = This->length;
num_set_int(retv, This->length);
break;
default:
FIXME("unimplemented flags %x\n", flags);
......@@ -635,8 +633,7 @@ HRESULT create_builtin_function(script_ctx_t *ctx, builtin_invoke_t value_proc,
if(builtin_info) {
VARIANT var;
V_VT(&var) = VT_I4;
V_I4(&var) = function->length;
num_set_int(&var, function->length);
hres = jsdisp_propput_const(&function->dispex, lengthW, &var);
}
......
......@@ -745,10 +745,8 @@ static HRESULT JSGlobal_ScriptEngineMajorVersion(script_ctx_t *ctx, vdisp_t *jst
{
TRACE("\n");
if(retv) {
V_VT(retv) = VT_I4;
V_I4(retv) = JSCRIPT_MAJOR_VERSION;
}
if(retv)
num_set_int(retv, JSCRIPT_MAJOR_VERSION);
return S_OK;
}
......@@ -757,10 +755,8 @@ static HRESULT JSGlobal_ScriptEngineMinorVersion(script_ctx_t *ctx, vdisp_t *jst
{
TRACE("\n");
if(retv) {
V_VT(retv) = VT_I4;
V_I4(retv) = JSCRIPT_MINOR_VERSION;
}
if(retv)
num_set_int(retv, JSCRIPT_MINOR_VERSION);
return S_OK;
}
......@@ -769,10 +765,8 @@ static HRESULT JSGlobal_ScriptEngineBuildVersion(script_ctx_t *ctx, vdisp_t *jst
{
TRACE("\n");
if(retv) {
V_VT(retv) = VT_I4;
V_I4(retv) = JSCRIPT_BUILD_VERSION;
}
if(retv)
num_set_int(retv, JSCRIPT_BUILD_VERSION);
return S_OK;
}
......
......@@ -554,10 +554,8 @@ static HRESULT NumberConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
switch(flags) {
case INVOKE_FUNC:
if(!arg_cnt(dp)) {
if(retv) {
V_VT(retv) = VT_I4;
V_I4(retv) = 0;
}
if(retv)
num_set_int(retv, 0);
return S_OK;
}
......
......@@ -3606,13 +3606,12 @@ static HRESULT create_match_array(script_ctx_t *ctx, BSTR input, const match_res
}
while(SUCCEEDED(hres)) {
V_VT(&var) = VT_I4;
V_I4(&var) = result->str-input;
num_set_int(&var, result->str-input);
hres = jsdisp_propput_name(array, indexW, &var, ei);
if(FAILED(hres))
break;
V_I4(&var) = result->str-input+result->len;
num_set_int(&var, result->str-input+result->len);
hres = jsdisp_propput_name(array, lastIndexW, &var, ei);
if(FAILED(hres))
break;
......@@ -3862,8 +3861,7 @@ HRESULT create_regexp(script_ctx_t *ctx, const WCHAR *exp, int len, DWORD flags,
return E_FAIL;
}
V_VT(&regexp->last_index_var) = VT_I4;
V_I4(&regexp->last_index_var) = 0;
num_set_int(&regexp->last_index_var, 0);
*ret = &regexp->dispex;
return S_OK;
......@@ -3990,13 +3988,12 @@ HRESULT regexp_string_match(script_ctx_t *ctx, jsdisp_t *re, BSTR str,
}
while(SUCCEEDED(hres)) {
V_VT(&var) = VT_I4;
V_I4(&var) = match_result[match_cnt-1].str-str;
num_set_int(&var, match_result[match_cnt-1].str-str);
hres = jsdisp_propput_name(array, indexW, &var, ei);
if(FAILED(hres))
break;
V_I4(&var) = match_result[match_cnt-1].str-str+match_result[match_cnt-1].len;
num_set_int(&var, match_result[match_cnt-1].str-str+match_result[match_cnt-1].len);
hres = jsdisp_propput_name(array, lastIndexW, &var, ei);
if(FAILED(hres))
break;
......
......@@ -111,8 +111,7 @@ static HRESULT String_length(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DIS
case DISPATCH_PROPERTYGET: {
StringInstance *string = string_from_vdisp(jsthis);
V_VT(retv) = VT_I4;
V_I4(retv) = string->length;
num_set_int(retv, string->length);
break;
}
default:
......@@ -368,10 +367,8 @@ static HRESULT String_charCodeAt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
idx = d;
}
if(retv) {
V_VT(retv) = VT_I4;
V_I4(retv) = str[idx];
}
if(retv)
num_set_int(retv, str[idx]);
SysFreeString(val_str);
return S_OK;
......@@ -476,10 +473,8 @@ static HRESULT String_indexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI
return hres;
if(!arg_cnt(dp)) {
if(retv) {
V_VT(retv) = VT_I4;
V_I4(retv) = -1;
}
if(retv)
num_set_int(retv, -1);
SysFreeString(val_str);
return S_OK;
}
......@@ -513,10 +508,8 @@ static HRESULT String_indexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI
if(FAILED(hres))
return hres;
if(retv) {
V_VT(retv) = VT_I4;
V_I4(retv) = ret;
}
if(retv)
num_set_int(retv, ret);
return S_OK;
}
......@@ -544,10 +537,8 @@ static HRESULT String_lastIndexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
return hres;
if(!arg_cnt(dp)) {
if(retv) {
V_VT(retv) = VT_I4;
V_I4(retv) = -1;
}
if(retv)
num_set_int(retv, -1);
SysFreeString(val_str);
return S_OK;
}
......@@ -586,10 +577,8 @@ static HRESULT String_lastIndexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
if(FAILED(hres))
return hres;
if(retv) {
V_VT(retv) = VT_I4;
V_I4(retv) = ret;
}
if(retv)
num_set_int(retv, ret);
return S_OK;
}
......@@ -729,8 +718,7 @@ static HRESULT rep_call(script_ctx_t *ctx, jsdisp_t *func, const WCHAR *str, mat
if(SUCCEEDED(hres)) {
arg = get_arg(&dp,parens_cnt+1);
V_VT(arg) = VT_I4;
V_I4(arg) = match->str - str;
num_set_int(arg, match->str - str);
arg = get_arg(&dp,parens_cnt+2);
V_VT(arg) = VT_BSTR;
......@@ -1046,10 +1034,8 @@ static HRESULT String_search(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DIS
if(FAILED(hres))
return hres;
if(retv) {
V_VT(retv) = VT_I4;
V_I4(retv) = hres == S_OK ? match.str-str : -1;
}
if(retv)
num_set_int(retv, hres == S_OK ? match.str-str : -1);
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