Jacek Caban : jscript: Added String.length implementation.
Alexandre Julliard
julliard at winehq.org
Thu Sep 18 07:55:53 CDT 2008
Module: wine
Branch: master
Commit: b48489be3c884aecca8b5f3dd8f9eb21d4baa989
URL: http://source.winehq.org/git/wine.git/?a=commit;h=b48489be3c884aecca8b5f3dd8f9eb21d4baa989
Author: Jacek Caban <jacek at codeweavers.com>
Date: Wed Sep 17 23:35:12 2008 +0200
jscript: Added String.length implementation.
---
dlls/jscript/string.c | 18 ++++++++++++++++--
dlls/jscript/tests/api.js | 5 +++++
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/dlls/jscript/string.c b/dlls/jscript/string.c
index b310cab..0831532 100644
--- a/dlls/jscript/string.c
+++ b/dlls/jscript/string.c
@@ -70,8 +70,22 @@ static const WCHAR isPrototypeOfW[] = {'i','s','P','r','o','t','o','t','y','p','
static HRESULT String_length(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
- FIXME("\n");
- return E_NOTIMPL;
+ TRACE("%p\n", dispex);
+
+ switch(flags) {
+ case DISPATCH_PROPERTYGET: {
+ StringInstance *jsthis = (StringInstance*)dispex;
+
+ V_VT(retv) = VT_I4;
+ V_I4(retv) = jsthis->length;
+ break;
+ }
+ default:
+ FIXME("unimplemented flags %x\n", flags);
+ return E_NOTIMPL;
+ }
+
+ return S_OK;
}
static HRESULT String_toString(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js
index eed48dc..d6893e0 100644
--- a/dlls/jscript/tests/api.js
+++ b/dlls/jscript/tests/api.js
@@ -16,6 +16,11 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+ok("".length === 0, "\"\".length = " + "".length);
+ok(getVT("".length) == "VT_I4", "\"\".length = " + "".length);
+ok("abc".length === 3, "\"abc\".length = " + "abc".length);
+ok(String.prototype.length === 0, "String.prototype.length = " + String.prototype.length);
+
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