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