Piotr Caban : jscript: Inherit some Error functions from Object.
Alexandre Julliard
julliard at winehq.org
Fri Aug 14 09:00:26 CDT 2009
Module: wine
Branch: master
Commit: 28734e3756761867d94eca0eb870a36a8f6da3b2
URL: http://source.winehq.org/git/wine.git/?a=commit;h=28734e3756761867d94eca0eb870a36a8f6da3b2
Author: Piotr Caban <piotr.caban at gmail.com>
Date: Fri Aug 14 11:58:10 2009 +0200
jscript: Inherit some Error functions from Object.
---
dlls/jscript/error.c | 50 ++++++++------------------------------------
dlls/jscript/global.c | 2 +-
dlls/jscript/jscript.h | 2 +-
dlls/jscript/tests/api.js | 1 +
4 files changed, 12 insertions(+), 43 deletions(-)
diff --git a/dlls/jscript/error.c b/dlls/jscript/error.c
index 25a3836..70fd008 100644
--- a/dlls/jscript/error.c
+++ b/dlls/jscript/error.c
@@ -38,10 +38,6 @@ static const WCHAR descriptionW[] = {'d','e','s','c','r','i','p','t','i','o','n'
static const WCHAR messageW[] = {'m','e','s','s','a','g','e',0};
static const WCHAR numberW[] = {'n','u','m','b','e','r',0};
static const WCHAR toStringW[] = {'t','o','S','t','r','i','n','g',0};
-static const WCHAR hasOwnPropertyW[] = {'h','a','s','O','w','n','P','r','o','p','e','r','t','y',0};
-static const WCHAR propertyIsEnumerableW[] =
- {'p','r','o','p','e','r','t','y','I','s','E','n','u','m','e','r','a','b','l','e',0};
-static const WCHAR isPrototypeOfW[] = {'i','s','P','r','o','t','o','t','y','p','e','O','f',0};
static HRESULT Error_number(DispatchEx *dispex, LCID lcid, WORD flags,
DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
@@ -116,28 +112,6 @@ static HRESULT Error_toString(DispatchEx *dispex, LCID lcid, WORD flags,
return S_OK;
}
-static HRESULT Error_hasOwnProperty(DispatchEx *dispex, LCID lcid, WORD flags,
- DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
-{
- FIXME("\n");
- return E_NOTIMPL;
-}
-
-static HRESULT Error_propertyIsEnumerable(DispatchEx *dispex, LCID lcid, WORD flags,
- DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
-{
- FIXME("\n");
- return E_NOTIMPL;
-}
-
-
-static HRESULT Error_isPrototypeOf(DispatchEx *dispex, LCID lcid, WORD flags,
- DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
-{
- FIXME("\n");
- return E_NOTIMPL;
-}
-
static HRESULT Error_value(DispatchEx *dispex, LCID lcid, WORD flags,
DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
@@ -166,11 +140,8 @@ static void Error_destructor(DispatchEx *dispex)
static const builtin_prop_t Error_props[] = {
{descriptionW, Error_description, 0},
- {hasOwnPropertyW, Error_hasOwnProperty, PROPF_METHOD},
- {isPrototypeOfW, Error_isPrototypeOf, PROPF_METHOD},
{messageW, Error_message, 0},
{numberW, Error_number, 0},
- {propertyIsEnumerableW, Error_propertyIsEnumerable, PROPF_METHOD},
{toStringW, Error_toString, PROPF_METHOD}
};
@@ -185,11 +156,8 @@ static const builtin_info_t Error_info = {
static const builtin_prop_t ErrorInst_props[] = {
{descriptionW, Error_description, 0},
- {hasOwnPropertyW, Error_hasOwnProperty, PROPF_METHOD},
- {isPrototypeOfW, Error_isPrototypeOf, PROPF_METHOD},
{messageW, Error_message, 0},
{numberW, Error_number, 0},
- {propertyIsEnumerableW, Error_propertyIsEnumerable, PROPF_METHOD}
};
static const builtin_info_t ErrorInst_info = {
@@ -201,21 +169,21 @@ static const builtin_info_t ErrorInst_info = {
NULL
};
-static HRESULT alloc_error(script_ctx_t *ctx, BOOL error_prototype,
+static HRESULT alloc_error(script_ctx_t *ctx, DispatchEx *prototype,
DispatchEx *constr, ErrorInstance **ret)
{
ErrorInstance *err;
- DispatchEx *inherit;
HRESULT hres;
err = heap_alloc_zero(sizeof(ErrorInstance));
if(!err)
return E_OUTOFMEMORY;
- inherit = error_prototype ? ctx->object_constr : ctx->error_constr;
- hres = init_dispex_from_constr(&err->dispex, ctx,
- error_prototype ? &Error_info : &ErrorInst_info,
- constr ? constr : inherit);
+ if(prototype)
+ hres = init_dispex(&err->dispex, ctx, &Error_info, prototype);
+ else
+ hres = init_dispex_from_constr(&err->dispex, ctx, &ErrorInst_info,
+ constr ? constr : ctx->error_constr);
if(FAILED(hres)) {
heap_free(err);
return hres;
@@ -231,7 +199,7 @@ static HRESULT create_error(script_ctx_t *ctx, DispatchEx *constr,
ErrorInstance *err;
HRESULT hres;
- hres = alloc_error(ctx, FALSE, constr, &err);
+ hres = alloc_error(ctx, NULL, constr, &err);
if(FAILED(hres))
return hres;
@@ -366,7 +334,7 @@ static HRESULT URIErrorConstr_value(DispatchEx *dispex, LCID lcid, WORD flags,
dispex->ctx->uri_error_constr);
}
-HRESULT init_error_constr(script_ctx_t *ctx)
+HRESULT init_error_constr(script_ctx_t *ctx, DispatchEx *object_prototype)
{
static const WCHAR nameW[] = {'n','a','m','e',0};
static const WCHAR ErrorW[] = {'E','r','r','o','r',0};
@@ -392,7 +360,7 @@ HRESULT init_error_constr(script_ctx_t *ctx)
HRESULT hres;
for(i=0; i<7; i++) {
- hres = alloc_error(ctx, i==0, NULL, &err);
+ hres = alloc_error(ctx, i==0 ? object_prototype : NULL, NULL, &err);
if(FAILED(hres))
return hres;
diff --git a/dlls/jscript/global.c b/dlls/jscript/global.c
index f0dadc3..e843fac 100644
--- a/dlls/jscript/global.c
+++ b/dlls/jscript/global.c
@@ -766,7 +766,7 @@ static HRESULT init_constructors(script_ctx_t *ctx, DispatchEx *object_prototype
if(FAILED(hres))
return hres;
- hres = init_error_constr(ctx);
+ hres = init_error_constr(ctx, object_prototype);
if(FAILED(hres))
return hres;
diff --git a/dlls/jscript/jscript.h b/dlls/jscript/jscript.h
index 2adcc86..807225a 100644
--- a/dlls/jscript/jscript.h
+++ b/dlls/jscript/jscript.h
@@ -229,7 +229,7 @@ HRESULT create_object_prototype(script_ctx_t*,DispatchEx**);
HRESULT create_array_constr(script_ctx_t*,DispatchEx*,DispatchEx**);
HRESULT create_bool_constr(script_ctx_t*,DispatchEx*,DispatchEx**);
HRESULT create_date_constr(script_ctx_t*,DispatchEx*,DispatchEx**);
-HRESULT init_error_constr(script_ctx_t*);
+HRESULT init_error_constr(script_ctx_t*,DispatchEx*);
HRESULT create_number_constr(script_ctx_t*,DispatchEx*,DispatchEx**);
HRESULT create_object_constr(script_ctx_t*,DispatchEx*,DispatchEx**);
HRESULT create_regexp_constr(script_ctx_t*,DispatchEx*,DispatchEx**);
diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js
index 05cb2b2..4c1e24f 100644
--- a/dlls/jscript/tests/api.js
+++ b/dlls/jscript/tests/api.js
@@ -1392,5 +1392,6 @@ testObjectInherit(new Number(1), false, false, false);
testObjectInherit(new Date(), false, false, false);
testObjectInherit(new Boolean(true), false, true, false);
testObjectInherit(new Array(), false, false, true);
+testObjectInherit(new Error(), false, true, true);
reportSuccess();
More information about the wine-cvs
mailing list