Andrew Nguyen : jscript: Implement the String.big() method.
Alexandre Julliard
julliard at winehq.org
Tue Dec 2 11:02:10 CST 2008
Module: wine
Branch: master
Commit: dd23e5b19c00659f527f4840d4fbc3068a3a9308
URL: http://source.winehq.org/git/wine.git/?a=commit;h=dd23e5b19c00659f527f4840d4fbc3068a3a9308
Author: Andrew Nguyen <arethusa26 at gmail.com>
Date: Sun Nov 30 06:40:01 2008 -0600
jscript: Implement the String.big() method.
---
dlls/jscript/string.c | 31 +++++++++++++++++++++++++++++--
dlls/jscript/tests/api.js | 9 +++++++++
2 files changed, 38 insertions(+), 2 deletions(-)
diff --git a/dlls/jscript/string.c b/dlls/jscript/string.c
index 5c074e8..4cfc082 100644
--- a/dlls/jscript/string.c
+++ b/dlls/jscript/string.c
@@ -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,
diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js
index 4f843ec..e0d7025 100644
--- a/dlls/jscript/tests/api.js
+++ b/dlls/jscript/tests/api.js
@@ -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");
More information about the wine-cvs
mailing list