jscript: Implement the String.big() method.

This commit is contained in:
Andrew Nguyen 2008-11-30 06:40:01 -06:00 committed by Alexandre Julliard
parent 8c8d58f829
commit dd23e5b19c
2 changed files with 38 additions and 2 deletions

View File

@ -123,6 +123,33 @@ static HRESULT String_valueOf(DispatchEx *dispex, LCID lcid, WORD flags, DISPPAR
return String_toString(dispex, lcid, flags, dp, retv, ei, sp);
}
static HRESULT do_attributeless_tag_format(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp, const WCHAR *tagname)
{
static const WCHAR tagfmt[] = {'<','%','s','>','%','s','<','/','%','s','>',0};
StringInstance *string;
BSTR ret;
if(!is_class(dispex, JSCLASS_STRING)) {
WARN("this is not a string object\n");
return E_NOTIMPL;
}
string = (StringInstance*)dispex;
if(retv) {
ret = SysAllocStringLen(NULL, string->length + 2*strlenW(tagname) + 5);
if(!ret)
return E_OUTOFMEMORY;
sprintfW(ret, tagfmt, tagname, string->str, tagname);
V_VT(retv) = VT_BSTR;
V_BSTR(retv) = ret;
}
return S_OK;
}
static HRESULT String_anchor(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
@ -133,8 +160,8 @@ static HRESULT String_anchor(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARA
static HRESULT String_big(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
FIXME("\n");
return E_NOTIMPL;
static const WCHAR bigtagW[] = {'B','I','G',0};
return do_attributeless_tag_format(dispex, lcid, flags, dp, retv, ei, sp, bigtagW);
}
static HRESULT String_blink(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,

View File

@ -269,6 +269,15 @@ ok(tmp === "TEST", "''.toUpperCase() = " + tmp);
tmp = "tEsT".toUpperCase(3);
ok(tmp === "TEST", "''.toUpperCase(3) = " + tmp);
tmp = "".big();
ok(tmp === "<BIG></BIG>", "''.big() = " + tmp);
tmp = "".big(3);
ok(tmp === "<BIG></BIG>", "''.big(3) = " + tmp);
tmp = "test".big();
ok(tmp === "<BIG>test</BIG>", "'test'.big() = " + tmp);
tmp = "test".big(3);
ok(tmp === "<BIG>test</BIG>", "'test'.big(3) = " + tmp);
var arr = new Array();
ok(typeof(arr) === "object", "arr () is not object");
ok((arr.length === 0), "arr.length is not 0");