jscript: Use script LCID in *disp_propget* functions.

This commit is contained in:
Jacek Caban 2009-09-23 16:10:36 +02:00 committed by Alexandre Julliard
parent 1f565ac095
commit 8b338786aa
6 changed files with 37 additions and 39 deletions

View File

@ -51,7 +51,7 @@ static HRESULT get_jsdisp_length(DispatchEx *obj, LCID lcid, jsexcept_t *ei, DWO
VARIANT var; VARIANT var;
HRESULT hres; HRESULT hres;
hres = jsdisp_propget_name(obj, lengthW, lcid, &var, ei, NULL/*FIXME*/); hres = jsdisp_propget_name(obj, lengthW, &var, ei, NULL/*FIXME*/);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -136,7 +136,7 @@ static HRESULT concat_array(DispatchEx *array, ArrayInstance *obj, DWORD *len, L
HRESULT hres; HRESULT hres;
for(i=0; i < obj->length; i++) { for(i=0; i < obj->length; i++) {
hres = jsdisp_propget_idx(&obj->dispex, i, lcid, &var, ei, caller); hres = jsdisp_propget_idx(&obj->dispex, i, &var, ei, caller);
if(hres == DISP_E_UNKNOWNNAME) if(hres == DISP_E_UNKNOWNNAME)
continue; continue;
if(FAILED(hres)) if(FAILED(hres))
@ -237,7 +237,7 @@ static HRESULT array_join(DispatchEx *array, LCID lcid, DWORD length, const WCHA
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
for(i=0; i < length; i++) { for(i=0; i < length; i++) {
hres = jsdisp_propget_idx(array, i, lcid, &var, ei, caller); hres = jsdisp_propget_idx(array, i, &var, ei, caller);
if(FAILED(hres)) if(FAILED(hres))
break; break;
@ -374,7 +374,7 @@ static HRESULT Array_pop(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *
sprintfW(buf, formatW, --length); sprintfW(buf, formatW, --length);
hres = jsdisp_get_id(dispex, buf, 0, &id); hres = jsdisp_get_id(dispex, buf, 0, &id);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
hres = jsdisp_propget(dispex, id, lcid, &val, ei, caller); hres = jsdisp_propget(dispex, id, &val, ei, caller);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -476,14 +476,14 @@ static HRESULT Array_shift(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS
return S_OK; return S_OK;
} }
hres = jsdisp_propget_idx(dispex, 0, lcid, &ret, ei, caller); hres = jsdisp_propget_idx(dispex, 0, &ret, ei, caller);
if(hres == DISP_E_UNKNOWNNAME) { if(hres == DISP_E_UNKNOWNNAME) {
V_VT(&ret) = VT_EMPTY; V_VT(&ret) = VT_EMPTY;
hres = S_OK; hres = S_OK;
} }
for(i=1; SUCCEEDED(hres) && i<length; i++) { for(i=1; SUCCEEDED(hres) && i<length; i++) {
hres = jsdisp_propget_idx(dispex, i, lcid, &v, ei, caller); hres = jsdisp_propget_idx(dispex, i, &v, ei, caller);
if(hres == DISP_E_UNKNOWNNAME) if(hres == DISP_E_UNKNOWNNAME)
hres = jsdisp_delete_idx(dispex, i-1); hres = jsdisp_delete_idx(dispex, i-1);
else if(SUCCEEDED(hres)) else if(SUCCEEDED(hres))
@ -562,7 +562,7 @@ static HRESULT Array_slice(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS
return hres; return hres;
for(idx=start; idx<end; idx++) { for(idx=start; idx<end; idx++) {
hres = jsdisp_propget_idx(dispex, idx, lcid, &v, ei, sp); hres = jsdisp_propget_idx(dispex, idx, &v, ei, sp);
if(hres == DISP_E_UNKNOWNNAME) if(hres == DISP_E_UNKNOWNNAME)
continue; continue;
@ -696,7 +696,7 @@ static HRESULT Array_sort(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS
vtab = heap_alloc_zero(length * sizeof(VARIANT)); vtab = heap_alloc_zero(length * sizeof(VARIANT));
if(vtab) { if(vtab) {
for(i=0; i<length; i++) { for(i=0; i<length; i++) {
hres = jsdisp_propget_idx(dispex, i, lcid, vtab+i, ei, caller); hres = jsdisp_propget_idx(dispex, i, vtab+i, ei, caller);
if(FAILED(hres) && hres != DISP_E_UNKNOWNNAME) { if(FAILED(hres) && hres != DISP_E_UNKNOWNNAME) {
WARN("Could not get elem %d: %08x\n", i, hres); WARN("Could not get elem %d: %08x\n", i, hres);
break; break;
@ -853,7 +853,7 @@ static HRESULT Array_splice(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAM
return hres; return hres;
for(i=0; SUCCEEDED(hres) && i < delete_cnt; i++) { for(i=0; SUCCEEDED(hres) && i < delete_cnt; i++) {
hres = jsdisp_propget_idx(dispex, start+i, lcid, &v, ei, caller); hres = jsdisp_propget_idx(dispex, start+i, &v, ei, caller);
if(hres == DISP_E_UNKNOWNNAME) if(hres == DISP_E_UNKNOWNNAME)
hres = S_OK; hres = S_OK;
else if(SUCCEEDED(hres)) else if(SUCCEEDED(hres))
@ -870,7 +870,7 @@ static HRESULT Array_splice(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAM
if(add_args < delete_cnt) { if(add_args < delete_cnt) {
for(i = start; SUCCEEDED(hres) && i < length-delete_cnt; i++) { for(i = start; SUCCEEDED(hres) && i < length-delete_cnt; i++) {
hres = jsdisp_propget_idx(dispex, i+delete_cnt, lcid, &v, ei, caller); hres = jsdisp_propget_idx(dispex, i+delete_cnt, &v, ei, caller);
if(hres == DISP_E_UNKNOWNNAME) if(hres == DISP_E_UNKNOWNNAME)
hres = jsdisp_delete_idx(dispex, i+add_args); hres = jsdisp_delete_idx(dispex, i+add_args);
else if(SUCCEEDED(hres)) else if(SUCCEEDED(hres))
@ -881,7 +881,7 @@ static HRESULT Array_splice(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAM
hres = jsdisp_delete_idx(dispex, i-1); hres = jsdisp_delete_idx(dispex, i-1);
}else if(add_args > delete_cnt) { }else if(add_args > delete_cnt) {
for(i=length-delete_cnt; SUCCEEDED(hres) && i != start; i--) { for(i=length-delete_cnt; SUCCEEDED(hres) && i != start; i--) {
hres = jsdisp_propget_idx(dispex, i+delete_cnt-1, lcid, &v, ei, caller); hres = jsdisp_propget_idx(dispex, i+delete_cnt-1, &v, ei, caller);
if(hres == DISP_E_UNKNOWNNAME) if(hres == DISP_E_UNKNOWNNAME)
hres = jsdisp_delete_idx(dispex, i+add_args-1); hres = jsdisp_delete_idx(dispex, i+add_args-1);
else if(SUCCEEDED(hres)) else if(SUCCEEDED(hres))
@ -968,7 +968,7 @@ static HRESULT Array_unshift(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARA
hres = jsdisp_get_id(dispex, str, 0, &id); hres = jsdisp_get_id(dispex, str, 0, &id);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
hres = jsdisp_propget(dispex, id, lcid, &var, ei, caller); hres = jsdisp_propget(dispex, id, &var, ei, caller);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;

View File

@ -284,7 +284,7 @@ static HRESULT invoke_prop_func(DispatchEx *This, DispatchEx *jsthis, dispex_pro
return E_FAIL; return E_FAIL;
} }
static HRESULT prop_get(DispatchEx *This, dispex_prop_t *prop, LCID lcid, DISPPARAMS *dp, static HRESULT prop_get(DispatchEx *This, dispex_prop_t *prop, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller) VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller)
{ {
HRESULT hres; HRESULT hres;
@ -304,11 +304,11 @@ static HRESULT prop_get(DispatchEx *This, dispex_prop_t *prop, LCID lcid, DISPPA
hres = VariantCopy(retv, &prop->u.var); hres = VariantCopy(retv, &prop->u.var);
}else { }else {
hres = prop->u.p->invoke(This, lcid, DISPATCH_PROPERTYGET, dp, retv, ei, caller); hres = prop->u.p->invoke(This, This->ctx->lcid, DISPATCH_PROPERTYGET, dp, retv, ei, caller);
} }
break; break;
case PROP_PROTREF: case PROP_PROTREF:
hres = prop_get(This->prototype, This->prototype->props+prop->u.ref, lcid, dp, retv, ei, caller); hres = prop_get(This->prototype, This->prototype->props+prop->u.ref, dp, retv, ei, caller);
break; break;
case PROP_VARIANT: case PROP_VARIANT:
hres = VariantCopy(retv, &prop->u.var); hres = VariantCopy(retv, &prop->u.var);
@ -556,7 +556,7 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc
hres = invoke_prop_func(This, This, prop, wFlags, pdp, pvarRes, &jsexcept, pspCaller); hres = invoke_prop_func(This, This, prop, wFlags, pdp, pvarRes, &jsexcept, pspCaller);
break; break;
case DISPATCH_PROPERTYGET: case DISPATCH_PROPERTYGET:
hres = prop_get(This, prop, lcid, pdp, pvarRes, &jsexcept, pspCaller); hres = prop_get(This, prop, pdp, pvarRes, &jsexcept, pspCaller);
break; break;
case DISPATCH_PROPERTYPUT: case DISPATCH_PROPERTYPUT:
hres = prop_put(This, prop, lcid, pdp, &jsexcept, pspCaller); hres = prop_put(This, prop, lcid, pdp, &jsexcept, pspCaller);
@ -775,7 +775,7 @@ HRESULT init_dispex_from_constr(DispatchEx *dispex, script_ctx_t *ctx, const bui
V_VT(&var) = VT_EMPTY; V_VT(&var) = VT_EMPTY;
memset(&jsexcept, 0, sizeof(jsexcept)); memset(&jsexcept, 0, sizeof(jsexcept));
hres = prop_get(constr, prop, ctx->lcid, NULL, &var, &jsexcept, NULL/*FIXME*/); hres = prop_get(constr, prop, NULL, &var, &jsexcept, NULL/*FIXME*/);
if(FAILED(hres)) { if(FAILED(hres)) {
ERR("Could not get prototype\n"); ERR("Could not get prototype\n");
return hres; return hres;
@ -959,8 +959,7 @@ HRESULT disp_propput(IDispatch *disp, DISPID id, LCID lcid, VARIANT *val, jsexce
return hres; return hres;
} }
HRESULT jsdisp_propget_name(DispatchEx *obj, const WCHAR *name, LCID lcid, VARIANT *var, HRESULT jsdisp_propget_name(DispatchEx *obj, const WCHAR *name, VARIANT *var, jsexcept_t *ei, IServiceProvider *caller)
jsexcept_t *ei, IServiceProvider *caller)
{ {
DISPPARAMS dp = {NULL, NULL, 0, 0}; DISPPARAMS dp = {NULL, NULL, 0, 0};
dispex_prop_t *prop; dispex_prop_t *prop;
@ -974,21 +973,20 @@ HRESULT jsdisp_propget_name(DispatchEx *obj, const WCHAR *name, LCID lcid, VARIA
if(!prop) if(!prop)
return S_OK; return S_OK;
return prop_get(obj, prop, lcid, &dp, var, ei, caller); return prop_get(obj, prop, &dp, var, ei, caller);
} }
HRESULT jsdisp_propget_idx(DispatchEx *obj, DWORD idx, LCID lcid, VARIANT *var, jsexcept_t *ei, IServiceProvider *caller) HRESULT jsdisp_propget_idx(DispatchEx *obj, DWORD idx, VARIANT *var, jsexcept_t *ei, IServiceProvider *caller)
{ {
WCHAR buf[12]; WCHAR buf[12];
static const WCHAR formatW[] = {'%','d',0}; static const WCHAR formatW[] = {'%','d',0};
sprintfW(buf, formatW, idx); sprintfW(buf, formatW, idx);
return jsdisp_propget_name(obj, buf, lcid, var, ei, caller); return jsdisp_propget_name(obj, buf, var, ei, caller);
} }
HRESULT jsdisp_propget(DispatchEx *jsdisp, DISPID id, LCID lcid, VARIANT *val, jsexcept_t *ei, HRESULT jsdisp_propget(DispatchEx *jsdisp, DISPID id, VARIANT *val, jsexcept_t *ei, IServiceProvider *caller)
IServiceProvider *caller)
{ {
DISPPARAMS dp = {NULL,NULL,0,0}; DISPPARAMS dp = {NULL,NULL,0,0};
dispex_prop_t *prop; dispex_prop_t *prop;
@ -998,10 +996,10 @@ HRESULT jsdisp_propget(DispatchEx *jsdisp, DISPID id, LCID lcid, VARIANT *val, j
return DISP_E_MEMBERNOTFOUND; return DISP_E_MEMBERNOTFOUND;
V_VT(val) = VT_EMPTY; V_VT(val) = VT_EMPTY;
return prop_get(jsdisp, prop, lcid, &dp, val, ei, caller); return prop_get(jsdisp, prop, &dp, val, ei, caller);
} }
HRESULT disp_propget(IDispatch *disp, DISPID id, LCID lcid, VARIANT *val, jsexcept_t *ei, IServiceProvider *caller) HRESULT disp_propget(script_ctx_t *ctx, IDispatch *disp, DISPID id, VARIANT *val, jsexcept_t *ei, IServiceProvider *caller)
{ {
DISPPARAMS dp = {NULL,NULL,0,0}; DISPPARAMS dp = {NULL,NULL,0,0};
IDispatchEx *dispex; IDispatchEx *dispex;
@ -1010,7 +1008,7 @@ HRESULT disp_propget(IDispatch *disp, DISPID id, LCID lcid, VARIANT *val, jsexce
jsdisp = iface_to_jsdisp((IUnknown*)disp); jsdisp = iface_to_jsdisp((IUnknown*)disp);
if(jsdisp) { if(jsdisp) {
hres = jsdisp_propget(jsdisp, id, lcid, val, ei, caller); hres = jsdisp_propget(jsdisp, id, val, ei, caller);
jsdisp_release(jsdisp); jsdisp_release(jsdisp);
return hres; return hres;
} }
@ -1020,10 +1018,10 @@ HRESULT disp_propget(IDispatch *disp, DISPID id, LCID lcid, VARIANT *val, jsexce
ULONG err = 0; ULONG err = 0;
TRACE("using IDispatch\n"); TRACE("using IDispatch\n");
return IDispatch_Invoke(disp, id, &IID_NULL, lcid, INVOKE_PROPERTYGET, &dp, val, &ei->ei, &err); return IDispatch_Invoke(disp, id, &IID_NULL, ctx->lcid, INVOKE_PROPERTYGET, &dp, val, &ei->ei, &err);
} }
hres = IDispatchEx_InvokeEx(dispex, id, lcid, INVOKE_PROPERTYGET, &dp, val, &ei->ei, caller); hres = IDispatchEx_InvokeEx(dispex, id, ctx->lcid, INVOKE_PROPERTYGET, &dp, val, &ei->ei, caller);
IDispatchEx_Release(dispex); IDispatchEx_Release(dispex);
return hres; return hres;

View File

@ -77,7 +77,7 @@ static HRESULT exprval_value(script_ctx_t *ctx, exprval_t *val, jsexcept_t *ei,
return E_FAIL; return E_FAIL;
} }
return disp_propget(val->u.idref.disp, val->u.idref.id, ctx->lcid, ret, ei, NULL/*FIXME*/); return disp_propget(ctx, val->u.idref.disp, val->u.idref.id, ret, ei, NULL/*FIXME*/);
case EXPRVAL_NAMEREF: case EXPRVAL_NAMEREF:
break; break;
case EXPRVAL_INVALID: case EXPRVAL_INVALID:
@ -1326,7 +1326,7 @@ HRESULT function_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD fla
TRACE("\n"); TRACE("\n");
if(expr->identifier) { if(expr->identifier) {
hres = jsdisp_propget_name(ctx->var_disp, expr->identifier, ctx->parser->script->lcid, &var, ei, NULL/*FIXME*/); hres = jsdisp_propget_name(ctx->var_disp, expr->identifier, &var, ei, NULL/*FIXME*/);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
}else { }else {
@ -1989,7 +1989,7 @@ static HRESULT instanceof_eval(exec_ctx_t *ctx, VARIANT *inst, VARIANT *objv, js
} }
if(is_class(obj, JSCLASS_FUNCTION)) { if(is_class(obj, JSCLASS_FUNCTION)) {
hres = jsdisp_propget_name(obj, prototypeW, ctx->parser->script->lcid, &var, ei, NULL/*FIXME*/); hres = jsdisp_propget_name(obj, prototypeW, &var, ei, NULL/*FIXME*/);
}else { }else {
FIXME("throw TypeError\n"); FIXME("throw TypeError\n");
hres = E_FAIL; hres = E_FAIL;

View File

@ -374,7 +374,7 @@ static HRESULT array_to_args(DispatchEx *arg_array, LCID lcid, jsexcept_t *ei, I
DWORD length, i; DWORD length, i;
HRESULT hres; HRESULT hres;
hres = jsdisp_propget_name(arg_array, lengthW, lcid, &var, ei, NULL/*FIXME*/); hres = jsdisp_propget_name(arg_array, lengthW, &var, ei, NULL/*FIXME*/);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -388,7 +388,7 @@ static HRESULT array_to_args(DispatchEx *arg_array, LCID lcid, jsexcept_t *ei, I
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
for(i=0; i<length; i++) { for(i=0; i<length; i++) {
hres = jsdisp_propget_idx(arg_array, i, lcid, argv+i, ei, caller); hres = jsdisp_propget_idx(arg_array, i, argv+i, ei, caller);
if(FAILED(hres)) { if(FAILED(hres)) {
while(i--) while(i--)
VariantClear(argv+i); VariantClear(argv+i);

View File

@ -134,13 +134,13 @@ HRESULT disp_call(script_ctx_t*,IDispatch*,DISPID,WORD,DISPPARAMS*,VARIANT*,jsex
HRESULT jsdisp_call_value(DispatchEx*,WORD,DISPPARAMS*,VARIANT*,jsexcept_t*,IServiceProvider*); HRESULT jsdisp_call_value(DispatchEx*,WORD,DISPPARAMS*,VARIANT*,jsexcept_t*,IServiceProvider*);
HRESULT jsdisp_call(DispatchEx*,DISPID,WORD,DISPPARAMS*,VARIANT*,jsexcept_t*,IServiceProvider*); HRESULT jsdisp_call(DispatchEx*,DISPID,WORD,DISPPARAMS*,VARIANT*,jsexcept_t*,IServiceProvider*);
HRESULT jsdisp_call_name(DispatchEx*,const WCHAR*,WORD,DISPPARAMS*,VARIANT*,jsexcept_t*,IServiceProvider*); HRESULT jsdisp_call_name(DispatchEx*,const WCHAR*,WORD,DISPPARAMS*,VARIANT*,jsexcept_t*,IServiceProvider*);
HRESULT disp_propget(IDispatch*,DISPID,LCID,VARIANT*,jsexcept_t*,IServiceProvider*); HRESULT disp_propget(script_ctx_t*,IDispatch*,DISPID,VARIANT*,jsexcept_t*,IServiceProvider*);
HRESULT disp_propput(IDispatch*,DISPID,LCID,VARIANT*,jsexcept_t*,IServiceProvider*); HRESULT disp_propput(IDispatch*,DISPID,LCID,VARIANT*,jsexcept_t*,IServiceProvider*);
HRESULT jsdisp_propget(DispatchEx*,DISPID,LCID,VARIANT*,jsexcept_t*,IServiceProvider*); HRESULT jsdisp_propget(DispatchEx*,DISPID,VARIANT*,jsexcept_t*,IServiceProvider*);
HRESULT jsdisp_propput_name(DispatchEx*,const WCHAR*,LCID,VARIANT*,jsexcept_t*,IServiceProvider*); HRESULT jsdisp_propput_name(DispatchEx*,const WCHAR*,LCID,VARIANT*,jsexcept_t*,IServiceProvider*);
HRESULT jsdisp_propput_idx(DispatchEx*,DWORD,LCID,VARIANT*,jsexcept_t*,IServiceProvider*); HRESULT jsdisp_propput_idx(DispatchEx*,DWORD,LCID,VARIANT*,jsexcept_t*,IServiceProvider*);
HRESULT jsdisp_propget_name(DispatchEx*,LPCWSTR,LCID,VARIANT*,jsexcept_t*,IServiceProvider*); HRESULT jsdisp_propget_name(DispatchEx*,LPCWSTR,VARIANT*,jsexcept_t*,IServiceProvider*);
HRESULT jsdisp_propget_idx(DispatchEx*,DWORD,LCID,VARIANT*,jsexcept_t*,IServiceProvider*); HRESULT jsdisp_propget_idx(DispatchEx*,DWORD,VARIANT*,jsexcept_t*,IServiceProvider*);
HRESULT jsdisp_get_id(DispatchEx*,const WCHAR*,DWORD,DISPID*); HRESULT jsdisp_get_id(DispatchEx*,const WCHAR*,DWORD,DISPID*);
HRESULT jsdisp_delete_idx(DispatchEx*,DWORD); HRESULT jsdisp_delete_idx(DispatchEx*,DWORD);

View File

@ -209,7 +209,7 @@ HRESULT to_primitive(script_ctx_t *ctx, VARIANT *v, jsexcept_t *ei, VARIANT *ret
jsdisp = iface_to_jsdisp((IUnknown*)V_DISPATCH(v)); jsdisp = iface_to_jsdisp((IUnknown*)V_DISPATCH(v));
if(!jsdisp) { if(!jsdisp) {
V_VT(ret) = VT_EMPTY; V_VT(ret) = VT_EMPTY;
return disp_propget(V_DISPATCH(v), DISPID_VALUE, ctx->lcid, ret, ei, NULL /*FIXME*/); return disp_propget(ctx, V_DISPATCH(v), DISPID_VALUE, ret, ei, NULL /*FIXME*/);
} }
if(hint == NO_HINT) if(hint == NO_HINT)