From 41e297af1120e5f0007f46a42cd0b49021506c88 Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Fri, 3 Jul 2009 02:45:12 +0200 Subject: [PATCH] jscript: Added stub implementation of Date constructor properties. --- dlls/jscript/array.c | 2 +- dlls/jscript/bool.c | 2 +- dlls/jscript/date.c | 33 ++++++++++++++++++++++++++++++++- dlls/jscript/dispex.c | 2 +- dlls/jscript/function.c | 19 +++++++++++-------- dlls/jscript/jscript.h | 5 ++++- dlls/jscript/number.c | 2 +- dlls/jscript/object.c | 2 +- dlls/jscript/regexp.c | 2 +- dlls/jscript/string.c | 2 +- 10 files changed, 54 insertions(+), 17 deletions(-) diff --git a/dlls/jscript/array.c b/dlls/jscript/array.c index 8f0802e8e93..cd40e432517 100644 --- a/dlls/jscript/array.c +++ b/dlls/jscript/array.c @@ -829,7 +829,7 @@ HRESULT create_array_constr(script_ctx_t *ctx, DispatchEx **ret) if(FAILED(hres)) return hres; - hres = create_builtin_function(ctx, ArrayConstr_value, PROPF_CONSTR, &array->dispex, ret); + hres = create_builtin_function(ctx, ArrayConstr_value, NULL, PROPF_CONSTR, &array->dispex, ret); IDispatchEx_Release(_IDispatchEx_(&array->dispex)); return hres; diff --git a/dlls/jscript/bool.c b/dlls/jscript/bool.c index 1add8efb768..7e3bf7ac738 100644 --- a/dlls/jscript/bool.c +++ b/dlls/jscript/bool.c @@ -142,7 +142,7 @@ HRESULT create_bool_constr(script_ctx_t *ctx, DispatchEx **ret) if(FAILED(hres)) return hres; - hres = create_builtin_function(ctx, BoolConstr_value, PROPF_CONSTR, &bool->dispex, ret); + hres = create_builtin_function(ctx, BoolConstr_value, NULL, PROPF_CONSTR, &bool->dispex, ret); jsdisp_release(&bool->dispex); return hres; diff --git a/dlls/jscript/date.c b/dlls/jscript/date.c index 2fd53020997..7888a1c5f9d 100644 --- a/dlls/jscript/date.c +++ b/dlls/jscript/date.c @@ -87,6 +87,9 @@ static const WCHAR setUTCMonthW[] = {'s','e','t','U','T','C','M','o','n','t','h' static const WCHAR setFullYearW[] = {'s','e','t','F','u','l','l','Y','e','a','r',0}; static const WCHAR setUTCFullYearW[] = {'s','e','t','U','T','C','F','u','l','l','Y','e','a','r',0}; +static const WCHAR UTCW[] = {'U','T','C',0}; +static const WCHAR parseW[] = {'p','a','r','s','e',0}; + /*ECMA-262 3rd Edition 15.9.1.2 */ #define MS_PER_DAY 86400000 #define MS_PER_HOUR 3600000 @@ -2197,6 +2200,20 @@ static HRESULT create_date(script_ctx_t *ctx, BOOL use_constr, DOUBLE time, Disp return S_OK; } +static HRESULT DateConstr_parse(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp, + VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) +{ + FIXME("\n"); + return E_NOTIMPL; +} + +static HRESULT DateConstr_UTC(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp, + VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) +{ + FIXME("\n"); + return E_NOTIMPL; +} + static HRESULT DateConstr_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) { @@ -2339,6 +2356,20 @@ static HRESULT DateConstr_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPP return S_OK; } +static const builtin_prop_t DateConstr_props[] = { + {UTCW, DateConstr_UTC, PROPF_METHOD}, + {parseW, DateConstr_parse, PROPF_METHOD} +}; + +static const builtin_info_t DateConstr_info = { + JSCLASS_FUNCTION, + {NULL, Function_value, 0}, + sizeof(DateConstr_props)/sizeof(*DateConstr_props), + DateConstr_props, + NULL, + NULL +}; + HRESULT create_date_constr(script_ctx_t *ctx, DispatchEx **ret) { DispatchEx *date; @@ -2348,7 +2379,7 @@ HRESULT create_date_constr(script_ctx_t *ctx, DispatchEx **ret) if(FAILED(hres)) return hres; - hres = create_builtin_function(ctx, DateConstr_value, PROPF_CONSTR, date, ret); + hres = create_builtin_function(ctx, DateConstr_value, &DateConstr_info, PROPF_CONSTR, date, ret); jsdisp_release(date); return hres; diff --git a/dlls/jscript/dispex.c b/dlls/jscript/dispex.c index 86410af4ec7..a387ecdbff6 100644 --- a/dlls/jscript/dispex.c +++ b/dlls/jscript/dispex.c @@ -293,7 +293,7 @@ static HRESULT prop_get(DispatchEx *This, dispex_prop_t *prop, LCID lcid, DISPPA case PROP_BUILTIN: if(prop->u.p->flags & PROPF_METHOD) { DispatchEx *obj; - hres = create_builtin_function(This->ctx, prop->u.p->invoke, prop->u.p->flags, NULL, &obj); + hres = create_builtin_function(This->ctx, prop->u.p->invoke, NULL, prop->u.p->flags, NULL, &obj); if(FAILED(hres)) break; diff --git a/dlls/jscript/function.c b/dlls/jscript/function.c index 314d58558e8..d780aeebde1 100644 --- a/dlls/jscript/function.c +++ b/dlls/jscript/function.c @@ -341,7 +341,7 @@ static HRESULT Function_isPrototypeOf(DispatchEx *dispex, LCID lcid, WORD flags, return E_NOTIMPL; } -static HRESULT Function_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp, +HRESULT Function_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller) { FunctionInstance *function; @@ -435,7 +435,8 @@ static HRESULT FunctionProt_value(DispatchEx *dispex, LCID lcid, WORD flags, DIS return E_NOTIMPL; } -static HRESULT create_function(script_ctx_t *ctx, DWORD flags, BOOL funcprot, DispatchEx *prototype, FunctionInstance **ret) +static HRESULT create_function(script_ctx_t *ctx, const builtin_info_t *builtin_info, DWORD flags, + BOOL funcprot, DispatchEx *prototype, FunctionInstance **ret) { FunctionInstance *function; HRESULT hres; @@ -446,6 +447,8 @@ static HRESULT create_function(script_ctx_t *ctx, DWORD flags, BOOL funcprot, Di if(funcprot) hres = init_dispex(&function->dispex, ctx, &Function_info, prototype); + else if(builtin_info) + hres = init_dispex_from_constr(&function->dispex, ctx, builtin_info, ctx->function_constr); else hres = init_dispex_from_constr(&function->dispex, ctx, &Function_info, ctx->function_constr); if(FAILED(hres)) @@ -473,13 +476,13 @@ static HRESULT create_function(script_ctx_t *ctx, DWORD flags, BOOL funcprot, Di return S_OK; } -HRESULT create_builtin_function(script_ctx_t *ctx, builtin_invoke_t value_proc, DWORD flags, - DispatchEx *prototype, DispatchEx **ret) +HRESULT create_builtin_function(script_ctx_t *ctx, builtin_invoke_t value_proc, + const builtin_info_t *builtin_info, DWORD flags, DispatchEx *prototype, DispatchEx **ret) { FunctionInstance *function; HRESULT hres; - hres = create_function(ctx, flags, FALSE, prototype, &function); + hres = create_function(ctx, builtin_info, flags, FALSE, prototype, &function); if(FAILED(hres)) return hres; @@ -502,7 +505,7 @@ HRESULT create_source_function(parser_ctx_t *ctx, parameter_t *parameters, sourc if(FAILED(hres)) return hres; - hres = create_function(ctx->script, PROPF_CONSTR, FALSE, prototype, &function); + hres = create_function(ctx->script, NULL, PROPF_CONSTR, FALSE, prototype, &function); jsdisp_release(prototype); if(FAILED(hres)) return hres; @@ -534,13 +537,13 @@ HRESULT init_function_constr(script_ctx_t *ctx) FunctionInstance *prot, *constr; HRESULT hres; - hres = create_function(ctx, PROPF_CONSTR, TRUE, NULL, &prot); + hres = create_function(ctx, NULL, PROPF_CONSTR, TRUE, NULL, &prot); if(FAILED(hres)) return hres; prot->value_proc = FunctionProt_value; - hres = create_function(ctx, PROPF_CONSTR, TRUE, &prot->dispex, &constr); + hres = create_function(ctx, NULL, PROPF_CONSTR, TRUE, &prot->dispex, &constr); jsdisp_release(&prot->dispex); if(FAILED(hres)) return hres; diff --git a/dlls/jscript/jscript.h b/dlls/jscript/jscript.h index 6cf3535c92f..7a4158c631f 100644 --- a/dlls/jscript/jscript.h +++ b/dlls/jscript/jscript.h @@ -132,7 +132,10 @@ HRESULT jsdisp_propget_name(DispatchEx*,LPCWSTR,LCID,VARIANT*,jsexcept_t*,IServi HRESULT jsdisp_propget_idx(DispatchEx*,DWORD,LCID,VARIANT*,jsexcept_t*,IServiceProvider*); HRESULT jsdisp_get_id(DispatchEx*,const WCHAR*,DWORD,DISPID*); -HRESULT create_builtin_function(script_ctx_t*,builtin_invoke_t,DWORD,DispatchEx*,DispatchEx**); +HRESULT create_builtin_function(script_ctx_t*,builtin_invoke_t,const builtin_info_t*,DWORD, + DispatchEx*,DispatchEx**); +HRESULT Function_value(DispatchEx*,LCID,WORD,DISPPARAMS*,VARIANT*,jsexcept_t*,IServiceProvider*); + HRESULT create_object(script_ctx_t*,DispatchEx*,DispatchEx**); HRESULT create_math(script_ctx_t*,DispatchEx**); diff --git a/dlls/jscript/number.c b/dlls/jscript/number.c index d909cdb851a..d6591d06317 100644 --- a/dlls/jscript/number.c +++ b/dlls/jscript/number.c @@ -263,7 +263,7 @@ HRESULT create_number_constr(script_ctx_t *ctx, DispatchEx **ret) return hres; V_VT(&number->num) = VT_I4; - hres = create_builtin_function(ctx, NumberConstr_value, PROPF_CONSTR, &number->dispex, ret); + hres = create_builtin_function(ctx, NumberConstr_value, NULL, PROPF_CONSTR, &number->dispex, ret); jsdisp_release(&number->dispex); return hres; diff --git a/dlls/jscript/object.c b/dlls/jscript/object.c index 02d80de02fd..9474bc4f8bc 100644 --- a/dlls/jscript/object.c +++ b/dlls/jscript/object.c @@ -154,7 +154,7 @@ HRESULT create_object_constr(script_ctx_t *ctx, DispatchEx **ret) if(FAILED(hres)) return hres; - hres = create_builtin_function(ctx, ObjectConstr_value, PROPF_CONSTR, object, ret); + hres = create_builtin_function(ctx, ObjectConstr_value, NULL, PROPF_CONSTR, object, ret); jsdisp_release(object); return hres; diff --git a/dlls/jscript/regexp.c b/dlls/jscript/regexp.c index fe552b10778..0acc47815c8 100644 --- a/dlls/jscript/regexp.c +++ b/dlls/jscript/regexp.c @@ -3685,7 +3685,7 @@ HRESULT create_regexp_constr(script_ctx_t *ctx, DispatchEx **ret) if(FAILED(hres)) return hres; - hres = create_builtin_function(ctx, RegExpConstr_value, PROPF_CONSTR, ®exp->dispex, ret); + hres = create_builtin_function(ctx, RegExpConstr_value, NULL, PROPF_CONSTR, ®exp->dispex, ret); jsdisp_release(®exp->dispex); return hres; diff --git a/dlls/jscript/string.c b/dlls/jscript/string.c index 82c1043490e..9f2ab9b2f3a 100644 --- a/dlls/jscript/string.c +++ b/dlls/jscript/string.c @@ -1370,7 +1370,7 @@ HRESULT create_string_constr(script_ctx_t *ctx, DispatchEx **ret) if(FAILED(hres)) return hres; - hres = create_builtin_function(ctx, StringConstr_value, PROPF_CONSTR, &string->dispex, ret); + hres = create_builtin_function(ctx, StringConstr_value, NULL, PROPF_CONSTR, &string->dispex, ret); jsdisp_release(&string->dispex); return hres;