Jacek Caban : jscript: Added ActiveXObject constructor stub implementation.

Alexandre Julliard julliard at winehq.org
Tue Sep 29 11:09:07 CDT 2009


Module: wine
Branch: master
Commit: 2ea23923a72a93642fdb8b4aebf564dc23e753bd
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=2ea23923a72a93642fdb8b4aebf564dc23e753bd

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Tue Sep 29 00:10:50 2009 +0200

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(-)

diff --git a/dlls/jscript/Makefile.in b/dlls/jscript/Makefile.in
index 241ef4b..d9d490a 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 0000000..eada0c2
--- /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 d9c54db..bc39940 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 bbf929d..9190110 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 2e4b0aa..ae118c2 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,




More information about the wine-cvs mailing list