From 2ea23923a72a93642fdb8b4aebf564dc23e753bd Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Tue, 29 Sep 2009 00:10:50 +0200 Subject: [PATCH] jscript: Added ActiveXObject constructor stub implementation. --- dlls/jscript/Makefile.in | 1 + dlls/jscript/activex.c | 50 +++++++++++++++++++++++++++++++++++++++ dlls/jscript/global.c | 11 ++++++--- dlls/jscript/jscript.h | 2 ++ dlls/jscript/tests/api.js | 3 +++ 5 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 dlls/jscript/activex.c diff --git a/dlls/jscript/Makefile.in b/dlls/jscript/Makefile.in index 241ef4b4476..d9d490aff83 100644 --- a/dlls/jscript/Makefile.in +++ b/dlls/jscript/Makefile.in @@ -16,6 +16,7 @@ RC_SRCS = \ rsrc.rc C_SRCS = \ + activex.c \ array.c \ bool.c \ date.c \ diff --git a/dlls/jscript/activex.c b/dlls/jscript/activex.c new file mode 100644 index 00000000000..eada0c2e179 --- /dev/null +++ b/dlls/jscript/activex.c @@ -0,0 +1,50 @@ +/* + * Copyright 2009 Jacek Caban for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "config.h" +#include "wine/port.h" + +#include "jscript.h" + +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(jscript); + +static HRESULT ActiveXObject_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, + VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller) +{ + FIXME("\n"); + return E_NOTIMPL; +} + +HRESULT create_activex_constr(script_ctx_t *ctx, DispatchEx **ret) +{ + DispatchEx *prototype; + HRESULT hres; + + static const WCHAR ActiveXObjectW[] = {'A','c','t','i','v','e','X','O','b','j','e','c','t',0}; + + hres = create_object(ctx, NULL, &prototype); + if(FAILED(hres)) + return hres; + + hres = create_builtin_function(ctx, ActiveXObject_value, ActiveXObjectW, NULL, PROPF_CONSTR, prototype, ret); + + jsdisp_release(prototype); + return hres; +} diff --git a/dlls/jscript/global.c b/dlls/jscript/global.c index d9c54db1588..bc39940aeb9 100644 --- a/dlls/jscript/global.c +++ b/dlls/jscript/global.c @@ -274,8 +274,9 @@ static HRESULT JSGlobal_RegExp(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, D static HRESULT JSGlobal_ActiveXObject(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) { - FIXME("\n"); - return E_NOTIMPL; + TRACE("\n"); + + return constructor_call(ctx->activex_constr, flags, dp, retv, ei, sp); } static HRESULT JSGlobal_VBArray(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, @@ -770,7 +771,7 @@ static HRESULT JSGlobal_encodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags } static const builtin_prop_t JSGlobal_props[] = { - {ActiveXObjectW, JSGlobal_ActiveXObject, PROPF_METHOD}, + {ActiveXObjectW, JSGlobal_ActiveXObject, PROPF_CONSTR}, {ArrayW, JSGlobal_Array, PROPF_CONSTR}, {BooleanW, JSGlobal_Boolean, PROPF_CONSTR}, {CollectGarbageW, JSGlobal_CollectGarbage, PROPF_METHOD}, @@ -828,6 +829,10 @@ static HRESULT init_constructors(script_ctx_t *ctx, DispatchEx *object_prototype if(FAILED(hres)) return hres; + hres = create_activex_constr(ctx, &ctx->activex_constr); + if(FAILED(hres)) + return hres; + hres = create_array_constr(ctx, object_prototype, &ctx->array_constr); if(FAILED(hres)) return hres; diff --git a/dlls/jscript/jscript.h b/dlls/jscript/jscript.h index bbf929dd631..9190110d533 100644 --- a/dlls/jscript/jscript.h +++ b/dlls/jscript/jscript.h @@ -268,6 +268,7 @@ struct _script_ctx_t { DispatchEx *global; DispatchEx *function_constr; + DispatchEx *activex_constr; DispatchEx *array_constr; DispatchEx *bool_constr; DispatchEx *date_constr; @@ -296,6 +297,7 @@ HRESULT init_global(script_ctx_t*); HRESULT init_function_constr(script_ctx_t*,DispatchEx*); HRESULT create_object_prototype(script_ctx_t*,DispatchEx**); +HRESULT create_activex_constr(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**); diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js index 2e4b0aaebd1..ae118c264ae 100644 --- a/dlls/jscript/tests/api.js +++ b/dlls/jscript/tests/api.js @@ -1532,6 +1532,9 @@ ok(bool.toString() === "true", "bool.toString() = " + bool.toString()); ok(bool.valueOf() === Boolean(1), "bool.valueOf() = " + bool.valueOf()); ok(bool.toLocaleString() === bool.toString(), "bool.toLocaleString() = " + bool.toLocaleString()); +ok(ActiveXObject instanceof Function, "ActiveXObject is not instance of Function"); +ok(ActiveXObject.prototype instanceof Object, "ActiveXObject.prototype is not instance of Object"); + ok(Error.prototype !== TypeError.prototype, "Error.prototype === TypeError.prototype"); ok(RangeError.prototype !== TypeError.prototype, "RangeError.prototype === TypeError.prototype"); ok(Error.prototype.toLocaleString === Object.prototype.toLocaleString,