Piotr Caban : jscript: Throw 'undefined object' error.
Alexandre Julliard
julliard at winehq.org
Wed Jul 22 09:34:57 CDT 2009
Module: wine
Branch: master
Commit: d8e841ca505ac53ace3374a59204c73d04b8419c
URL: http://source.winehq.org/git/wine.git/?a=commit;h=d8e841ca505ac53ace3374a59204c73d04b8419c
Author: Piotr Caban <piotr.caban at gmail.com>
Date: Wed Jul 22 13:01:59 2009 +0200
jscript: Throw 'undefined object' error.
---
dlls/jscript/engine.c | 9 ++++-----
dlls/jscript/error.c | 6 +++---
dlls/jscript/jscript_En.rc | 1 +
dlls/jscript/resource.h | 1 +
dlls/jscript/tests/api.js | 1 +
5 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c
index 10004a7..c79c48f 100644
--- a/dlls/jscript/engine.c
+++ b/dlls/jscript/engine.c
@@ -433,7 +433,7 @@ HRESULT exec_source(exec_ctx_t *ctx, parser_ctx_t *parser, source_elements_t *so
}
/* ECMA-262 3rd Edition 10.1.4 */
-static HRESULT identifier_eval(exec_ctx_t *ctx, BSTR identifier, DWORD flags, exprval_t *ret)
+static HRESULT identifier_eval(exec_ctx_t *ctx, BSTR identifier, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
scope_chain_t *scope;
named_item_t *item;
@@ -518,8 +518,7 @@ static HRESULT identifier_eval(exec_ctx_t *ctx, BSTR identifier, DWORD flags, ex
return S_OK;
}
- WARN("Could not find identifier %s\n", debugstr_w(identifier));
- return E_FAIL;
+ return throw_type_error(ctx->var_disp->ctx, ei, IDS_UNDEFINED, identifier);
}
/* ECMA-262 3rd Edition 12.1 */
@@ -855,7 +854,7 @@ HRESULT forin_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t
TRACE("iter %s\n", debugstr_w(str));
if(stat->variable)
- hres = identifier_eval(ctx, identifier, 0, &exprval);
+ hres = identifier_eval(ctx, identifier, 0, NULL, &exprval);
else
hres = expr_eval(ctx, stat->expr, EXPR_NEWREF, &rt->ei, &exprval);
if(SUCCEEDED(hres)) {
@@ -1596,7 +1595,7 @@ HRESULT identifier_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD f
if(!identifier)
return E_OUTOFMEMORY;
- hres = identifier_eval(ctx, identifier, flags, ret);
+ hres = identifier_eval(ctx, identifier, flags, ei, ret);
SysFreeString(identifier);
return hres;
diff --git a/dlls/jscript/error.c b/dlls/jscript/error.c
index d160dd6..49bdb07 100644
--- a/dlls/jscript/error.c
+++ b/dlls/jscript/error.c
@@ -415,17 +415,17 @@ static HRESULT throw_error(script_ctx_t *ctx, jsexcept_t *ei, UINT id, const WCH
DispatchEx *err;
HRESULT hres;
- TRACE("\n");
-
LoadStringW(jscript_hinstance, id, buf, sizeof(buf)/sizeof(WCHAR));
if(str) pos = strchrW(buf, '|');
if(pos) {
int len = strlenW(str);
- memmove(pos+len, pos+1, strlenW(pos+1)*sizeof(WCHAR));
+ memmove(pos+len, pos+1, (strlenW(pos+1)+1)*sizeof(WCHAR));
memcpy(pos, str, len*sizeof(WCHAR));
}
+ WARN("%s\n", debugstr_w(buf));
+
id |= 0x800A0000;
hres = create_error(ctx, constr, &id, buf, &err);
if(FAILED(hres))
diff --git a/dlls/jscript/jscript_En.rc b/dlls/jscript/jscript_En.rc
index 8a0a9a9..e0825e9 100644
--- a/dlls/jscript/jscript_En.rc
+++ b/dlls/jscript/jscript_En.rc
@@ -27,6 +27,7 @@ STRINGTABLE DISCARDABLE
IDS_ARG_NOT_OPT "Argument not optional"
IDS_NOT_DATE "'[object]' is not a date object"
IDS_NOT_NUM "Number expected"
+ IDS_UNDEFINED "'|' is undefined"
IDS_NOT_BOOL "Boolean object expected"
IDS_INVALID_LENGTH "Array length must be a finite positive integer"
}
diff --git a/dlls/jscript/resource.h b/dlls/jscript/resource.h
index 8caff6a..3aa014e 100644
--- a/dlls/jscript/resource.h
+++ b/dlls/jscript/resource.h
@@ -23,5 +23,6 @@
#define IDS_ARG_NOT_OPT 0x01c1
#define IDS_NOT_DATE 0x138E
#define IDS_NOT_NUM 0x1389
+#define IDS_UNDEFINED 0x1391
#define IDS_NOT_BOOL 0x1392
#define IDS_INVALID_LENGTH 0x13A5
diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js
index c20cd8b..b663dad 100644
--- a/dlls/jscript/tests/api.js
+++ b/dlls/jscript/tests/api.js
@@ -1313,5 +1313,6 @@ exception_test(function() {date.setTime();}, "TypeError", -2146827839);
exception_test(function() {arr.test();}, "TypeError", -2146827850);
exception_test(function() {arr.toString = Number.prototype.toString; arr.toString();}, "TypeError", -2146823287);
exception_test(function() {(new Number(3)).toString(1);}, "TypeError", -2146828283);
+exception_test(function() {not_existing_variable.something();}, "TypeError", -2146823279);
reportSuccess();
More information about the wine-cvs
mailing list