Jacek Caban : jscript: Store builtin constructor' s length in instance object.
Alexandre Julliard
julliard at winehq.org
Thu May 27 10:46:39 CDT 2010
Module: wine
Branch: master
Commit: 0cbe1574fe3a522284ef57e22dabb12ef4177fd9
URL: http://source.winehq.org/git/wine.git/?a=commit;h=0cbe1574fe3a522284ef57e22dabb12ef4177fd9
Author: Jacek Caban <jacek at codeweavers.com>
Date: Wed May 26 19:17:21 2010 +0200
jscript: Store builtin constructor's length in instance object.
---
dlls/jscript/dispex.c | 15 +++++++++++++++
dlls/jscript/function.c | 11 ++++++++++-
dlls/jscript/jscript.h | 7 +++++--
dlls/jscript/tests/api.js | 7 +++++--
4 files changed, 35 insertions(+), 5 deletions(-)
diff --git a/dlls/jscript/dispex.c b/dlls/jscript/dispex.c
index 6894eae..07880bc 100644
--- a/dlls/jscript/dispex.c
+++ b/dlls/jscript/dispex.c
@@ -358,6 +358,9 @@ static HRESULT prop_put(DispatchEx *This, dispex_prop_t *prop, VARIANT *val,
{
HRESULT hres;
+ if(prop->flags & PROPF_CONST)
+ return S_OK;
+
switch(prop->type) {
case PROP_BUILTIN:
if(!(prop->flags & PROPF_METHOD)) {
@@ -974,6 +977,18 @@ HRESULT jsdisp_propput_name(DispatchEx *obj, const WCHAR *name, VARIANT *val, js
return prop_put(obj, prop, val, ei, caller);
}
+HRESULT jsdisp_propput_const(DispatchEx *obj, const WCHAR *name, VARIANT *val)
+{
+ dispex_prop_t *prop;
+ HRESULT hres;
+
+ hres = ensure_prop_name(obj, name, FALSE, PROPF_ENUM|PROPF_CONST, &prop);
+ if(FAILED(hres))
+ return hres;
+
+ return VariantCopy(&prop->u.var, val);
+}
+
HRESULT jsdisp_propput_idx(DispatchEx *obj, DWORD idx, VARIANT *val, jsexcept_t *ei, IServiceProvider *caller)
{
WCHAR buf[12];
diff --git a/dlls/jscript/function.c b/dlls/jscript/function.c
index c7494cf..df46f1d 100644
--- a/dlls/jscript/function.c
+++ b/dlls/jscript/function.c
@@ -606,7 +606,16 @@ HRESULT create_builtin_function(script_ctx_t *ctx, builtin_invoke_t value_proc,
if(FAILED(hres))
return hres;
- hres = set_prototype(ctx, &function->dispex, prototype);
+ if(builtin_info) {
+ VARIANT var;
+
+ V_VT(&var) = VT_I4;
+ V_I4(&var) = function->length;
+ hres = jsdisp_propput_const(&function->dispex, lengthW, &var);
+ }
+
+ if(SUCCEEDED(hres))
+ hres = set_prototype(ctx, &function->dispex, prototype);
if(FAILED(hres)) {
jsdisp_release(&function->dispex);
return hres;
diff --git a/dlls/jscript/jscript.h b/dlls/jscript/jscript.h
index c1c8e60..c58c05d 100644
--- a/dlls/jscript/jscript.h
+++ b/dlls/jscript/jscript.h
@@ -68,6 +68,7 @@ extern HINSTANCE jscript_hinstance;
#define PROPF_METHOD 0x0100
#define PROPF_ENUM 0x0200
#define PROPF_CONSTR 0x0400
+#define PROPF_CONST 0x0800
/* NOTE: Keep in sync with names in Object.toString implementation */
typedef enum {
@@ -203,6 +204,7 @@ HRESULT disp_propget(script_ctx_t*,IDispatch*,DISPID,VARIANT*,jsexcept_t*,IServi
HRESULT disp_propput(script_ctx_t*,IDispatch*,DISPID,VARIANT*,jsexcept_t*,IServiceProvider*);
HRESULT jsdisp_propget(DispatchEx*,DISPID,VARIANT*,jsexcept_t*,IServiceProvider*);
HRESULT jsdisp_propput_name(DispatchEx*,const WCHAR*,VARIANT*,jsexcept_t*,IServiceProvider*);
+HRESULT jsdisp_propput_const(DispatchEx*,const WCHAR*,VARIANT*);
HRESULT jsdisp_propput_idx(DispatchEx*,DWORD,VARIANT*,jsexcept_t*,IServiceProvider*);
HRESULT jsdisp_propget_name(DispatchEx*,LPCWSTR,VARIANT*,jsexcept_t*,IServiceProvider*);
HRESULT jsdisp_get_idx(DispatchEx*,DWORD,VARIANT*,jsexcept_t*,IServiceProvider*);
@@ -318,8 +320,9 @@ typedef struct {
DWORD len;
} match_result_t;
-#define REM_CHECK_GLOBAL 0x0001
-#define REM_RESET_INDEX 0x0002
+#define REM_CHECK_GLOBAL 0x0001
+#define REM_RESET_INDEX 0x0002
+#define REM_NO_CTX_UPDATE 0x0004
HRESULT regexp_match_next(script_ctx_t*,DispatchEx*,DWORD,const WCHAR*,DWORD,const WCHAR**,match_result_t**,
DWORD*,DWORD*,match_result_t*);
HRESULT regexp_match(script_ctx_t*,DispatchEx*,const WCHAR*,DWORD,BOOL,match_result_t**,DWORD*);
diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js
index 2fba252..2ccad3d 100644
--- a/dlls/jscript/tests/api.js
+++ b/dlls/jscript/tests/api.js
@@ -2129,7 +2129,7 @@ ok(ActiveXObject.length == 1, "ActiveXObject.length = " + ActiveXObject.length);
ok(Array.length == 1, "Array.length = " + Array.length);
ok(Boolean.length == 1, "Boolean.length = " + Boolean.length);
ok(CollectGarbage.length == 0, "CollectGarbage.length = " + CollectGarbage.length);
-//ok(Date.length == 7, "Date.length = " + Date.length);
+ok(Date.length == 7, "Date.length = " + Date.length);
ok(Enumerator.length == 7, "Enumerator.length = " + Enumerator.length);
ok(Error.length == 1, "Error.length = " + Error.length);
ok(EvalError.length == 1, "EvalError.length = " + EvalError.length);
@@ -2147,7 +2147,7 @@ ok(ScriptEngineMajorVersion.length == 0,
"ScriptEngineMajorVersion.length = " + ScriptEngineMajorVersion.length);
ok(ScriptEngineMinorVersion.length == 0,
"ScriptEngineMinorVersion.length = " + ScriptEngineMinorVersion.length);
-//ok(String.length == 1, "String.length = " + String.length);
+ok(String.length == 1, "String.length = " + String.length);
ok(SyntaxError.length == 1, "SyntaxError.length = " + SyntaxError.length);
ok(TypeError.length == 1, "TypeError.length = " + TypeError.length);
ok(URIError.length == 1, "URIError.length = " + URIError.length);
@@ -2164,4 +2164,7 @@ ok(parseFloat.length == 1, "parseFloat.length = " + parseFloat.length);
ok(parseInt.length == 2, "parseInt.length = " + parseInt.length);
ok(unescape.length == 1, "unescape.length = " + unescape.length);
+String.length = 3;
+ok(String.length == 1, "String.length = " + String.length);
+
reportSuccess();
More information about the wine-cvs
mailing list