jscript: Make String_toUpperCase generic.

This commit is contained in:
Piotr Caban 2009-07-12 19:52:10 +02:00 committed by Alexandre Julliard
parent ab8168141b
commit df8195668d
1 changed files with 27 additions and 14 deletions

View File

@ -1388,33 +1388,46 @@ static HRESULT String_toLowerCase(DispatchEx *dispex, LCID lcid, WORD flags, DIS
static HRESULT String_toUpperCase(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp, static HRESULT String_toUpperCase(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{ {
StringInstance *string;
const WCHAR* str; const WCHAR* str;
DWORD length; DWORD length;
BSTR bstr; BSTR val_str = NULL;
HRESULT hres;
TRACE("\n"); TRACE("\n");
if(is_class(dispex, JSCLASS_STRING)) { if(!is_class(dispex, JSCLASS_STRING)) {
string = (StringInstance*)dispex; VARIANT this;
length = string->length; V_VT(&this) = VT_DISPATCH;
str = string->str; V_DISPATCH(&this) = (IDispatch*)_IDispatchEx_(dispex);
}else {
FIXME("not string this not supported\n"); hres = to_string(dispex->ctx, &this, ei, &val_str);
return E_NOTIMPL; if(FAILED(hres))
return hres;
str = val_str;
length = SysStringLen(val_str);
}
else {
StringInstance *this = (StringInstance*)dispex;
str = this->str;
length = this->length;
} }
if(retv) { if(retv) {
bstr = SysAllocStringLen(str, length); if(!val_str) {
if (!bstr) val_str = SysAllocStringLen(str, length);
return E_OUTOFMEMORY; if(!val_str)
return E_OUTOFMEMORY;
}
struprW(bstr); struprW(val_str);
V_VT(retv) = VT_BSTR; V_VT(retv) = VT_BSTR;
V_BSTR(retv) = bstr; V_BSTR(retv) = val_str;
} }
else SysFreeString(val_str);
return S_OK; return S_OK;
} }