Commit 228aab23 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Always use jsval-based to_object implementation.

parent acfd2b98
......@@ -148,7 +148,7 @@ static HRESULT stack_pop_object(exec_ctx_t *ctx, IDispatch **r)
return S_OK;
}
hres = to_object_jsval(ctx->script, v, r);
hres = to_object(ctx->script, v, r);
jsval_release(v);
return hres;
}
......@@ -627,7 +627,7 @@ static HRESULT interp_push_scope(exec_ctx_t *ctx)
TRACE("\n");
v = stack_pop(ctx);
hres = to_object_jsval(ctx->script, v, &disp);
hres = to_object(ctx->script, v, &disp);
jsval_release(v);
if(FAILED(hres))
return hres;
......@@ -878,7 +878,7 @@ static HRESULT interp_memberid(exec_ctx_t *ctx)
namev = stack_pop(ctx);
objv = stack_pop(ctx);
hres = to_object_jsval(ctx->script, objv, &obj);
hres = to_object(ctx->script, objv, &obj);
jsval_release(objv);
if(SUCCEEDED(hres)) {
hres = to_string(ctx->script, namev, ctx->ei, &name);
......@@ -1578,7 +1578,7 @@ static HRESULT interp_delete(exec_ctx_t *ctx)
namev = stack_pop(ctx);
objv = stack_pop(ctx);
hres = to_object_jsval(ctx->script, objv, &obj);
hres = to_object(ctx->script, objv, &obj);
jsval_release(objv);
if(FAILED(hres)) {
jsval_release(namev);
......
......@@ -389,7 +389,7 @@ static HRESULT Function_apply(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un
if(argc) {
if(!is_undefined(argv[0]) && !is_null(argv[0])) {
hres = to_object_jsval(ctx, argv[0], &this_obj);
hres = to_object(ctx, argv[0], &this_obj);
if(FAILED(hres))
return hres;
}
......@@ -442,7 +442,7 @@ static HRESULT Function_call(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns
if(argc) {
if(!is_undefined(argv[0]) && !is_null(argv[0])) {
hres = to_object_jsval(ctx, argv[0], &this_obj);
hres = to_object(ctx, argv[0], &this_obj);
if(FAILED(hres))
return hres;
}
......
......@@ -261,8 +261,7 @@ HRESULT to_integer(script_ctx_t*,jsval_t,jsexcept_t*,double*) DECLSPEC_HIDDEN;
HRESULT to_int32(script_ctx_t*,jsval_t,jsexcept_t*,INT*) DECLSPEC_HIDDEN;
HRESULT to_uint32(script_ctx_t*,jsval_t,jsexcept_t*,DWORD*) DECLSPEC_HIDDEN;
HRESULT to_string(script_ctx_t*,jsval_t,jsexcept_t*,BSTR*) DECLSPEC_HIDDEN;
HRESULT to_object(script_ctx_t*,VARIANT*,IDispatch**) DECLSPEC_HIDDEN;
HRESULT to_object_jsval(script_ctx_t*,jsval_t,IDispatch**) DECLSPEC_HIDDEN;
HRESULT to_object(script_ctx_t*,jsval_t,IDispatch**) DECLSPEC_HIDDEN;
HRESULT variant_change_type(script_ctx_t*,VARIANT*,VARIANT*,VARTYPE) DECLSPEC_HIDDEN;
......
......@@ -760,31 +760,30 @@ HRESULT to_string(script_ctx_t *ctx, jsval_t val, jsexcept_t *ei, BSTR *str)
}
/* ECMA-262 3rd Edition 9.9 */
HRESULT to_object(script_ctx_t *ctx, VARIANT *v, IDispatch **disp)
HRESULT to_object(script_ctx_t *ctx, jsval_t val, IDispatch **disp)
{
jsdisp_t *dispex;
HRESULT hres;
switch(V_VT(v)) {
case VT_BSTR:
hres = create_string(ctx, V_BSTR(v), SysStringLen(V_BSTR(v)), &dispex);
switch(val.type) {
case JSV_STRING:
hres = create_string(ctx, get_string(val), SysStringLen(get_string(val)), &dispex);
if(FAILED(hres))
return hres;
*disp = to_disp(dispex);
break;
case VT_I4:
case VT_R8:
hres = create_number(ctx, num_val(v), &dispex);
case JSV_NUMBER:
hres = create_number(ctx, get_number(val), &dispex);
if(FAILED(hres))
return hres;
*disp = to_disp(dispex);
break;
case VT_DISPATCH:
if(V_DISPATCH(v)) {
IDispatch_AddRef(V_DISPATCH(v));
*disp = V_DISPATCH(v);
case JSV_OBJECT:
if(get_object(val)) {
*disp = get_object(val);
IDispatch_AddRef(*disp);
}else {
jsdisp_t *obj;
......@@ -795,47 +794,36 @@ HRESULT to_object(script_ctx_t *ctx, VARIANT *v, IDispatch **disp)
*disp = to_disp(obj);
}
break;
case VT_BOOL:
hres = create_bool(ctx, V_BOOL(v), &dispex);
case JSV_BOOL:
hres = create_bool(ctx, get_bool(val), &dispex);
if(FAILED(hres))
return hres;
*disp = to_disp(dispex);
break;
case VT_ARRAY|VT_VARIANT:
hres = create_vbarray(ctx, V_ARRAY(v), &dispex);
if(FAILED(hres))
return hres;
case JSV_VARIANT:
switch(V_VT(get_variant(val))) {
case VT_ARRAY|VT_VARIANT:
hres = create_vbarray(ctx, V_ARRAY(get_variant(val)), &dispex);
if(FAILED(hres))
return hres;
*disp = to_disp(dispex);
*disp = to_disp(dispex);
break;
default:
FIXME("Unsupported %s\n", debugstr_variant(get_variant(val)));
return E_NOTIMPL;
}
break;
default:
FIXME("unsupported vt %d\n", V_VT(v));
FIXME("unsupported %s\n", debugstr_jsval(val));
return E_NOTIMPL;
}
return S_OK;
}
/* ECMA-262 3rd Edition 9.9 */
HRESULT to_object_jsval(script_ctx_t *ctx, jsval_t v, IDispatch **disp)
{
VARIANT var;
HRESULT hres;
if(is_object_instance(v)) {
*disp = get_object(v);
IDispatch_AddRef(*disp);
return S_OK;
}
hres = jsval_to_variant(v, &var);
if(FAILED(hres))
return hres;
return to_object(ctx, &var, disp);
}
HRESULT variant_change_type(script_ctx_t *ctx, VARIANT *dst, VARIANT *src, VARTYPE vt)
{
jsexcept_t ei;
......
......@@ -228,7 +228,7 @@ static HRESULT ObjectConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
if(!is_undefined(argv[0]) && !is_null(argv[0]) && (!is_object_instance(argv[0]) || get_object(argv[0]))) {
IDispatch *disp;
hres = to_object_jsval(ctx, argv[0], &disp);
hres = to_object(ctx, argv[0], &disp);
if(FAILED(hres))
return hres;
......
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