sync jscript with wine 1.1.28

svn path=/trunk/; revision=42849
This commit is contained in:
Christoph von Wittich 2009-08-22 15:25:26 +00:00
parent 3fd2c631b4
commit d125c45fff
15 changed files with 283 additions and 404 deletions

View file

@ -43,10 +43,6 @@ static const WCHAR spliceW[] = {'s','p','l','i','c','e',0};
static const WCHAR toStringW[] = {'t','o','S','t','r','i','n','g',0};
static const WCHAR toLocaleStringW[] = {'t','o','L','o','c','a','l','e','S','t','r','i','n','g',0};
static const WCHAR unshiftW[] = {'u','n','s','h','i','f','t',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 const WCHAR default_separatorW[] = {',',0};
@ -743,27 +739,6 @@ static HRESULT Array_unshift(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARA
return E_NOTIMPL;
}
static HRESULT Array_hasOwnProperty(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT Array_propertyIsEnumerable(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT Array_isPrototypeOf(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT Array_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
@ -809,22 +784,19 @@ static void Array_on_put(DispatchEx *dispex, const WCHAR *name)
}
static const builtin_prop_t Array_props[] = {
{concatW, Array_concat, PROPF_METHOD},
{hasOwnPropertyW, Array_hasOwnProperty, PROPF_METHOD},
{isPrototypeOfW, Array_isPrototypeOf, PROPF_METHOD},
{joinW, Array_join, PROPF_METHOD},
{concatW, Array_concat, PROPF_METHOD|1},
{joinW, Array_join, PROPF_METHOD|1},
{lengthW, Array_length, 0},
{popW, Array_pop, PROPF_METHOD},
{propertyIsEnumerableW, Array_propertyIsEnumerable, PROPF_METHOD},
{pushW, Array_push, PROPF_METHOD},
{pushW, Array_push, PROPF_METHOD|1},
{reverseW, Array_reverse, PROPF_METHOD},
{shiftW, Array_shift, PROPF_METHOD},
{sliceW, Array_slice, PROPF_METHOD},
{sortW, Array_sort, PROPF_METHOD},
{spliceW, Array_splice, PROPF_METHOD},
{sliceW, Array_slice, PROPF_METHOD|2},
{sortW, Array_sort, PROPF_METHOD|1},
{spliceW, Array_splice, PROPF_METHOD|2},
{toLocaleStringW, Array_toLocaleString, PROPF_METHOD},
{toStringW, Array_toString, PROPF_METHOD},
{unshiftW, Array_unshift, PROPF_METHOD},
{unshiftW, Array_unshift, PROPF_METHOD|1},
};
static const builtin_info_t Array_info = {
@ -888,7 +860,7 @@ static HRESULT ArrayConstr_value(DispatchEx *dispex, LCID lcid, WORD flags, DISP
return S_OK;
}
static HRESULT alloc_array(script_ctx_t *ctx, BOOL use_constr, ArrayInstance **ret)
static HRESULT alloc_array(script_ctx_t *ctx, DispatchEx *object_prototype, ArrayInstance **ret)
{
ArrayInstance *array;
HRESULT hres;
@ -897,8 +869,8 @@ static HRESULT alloc_array(script_ctx_t *ctx, BOOL use_constr, ArrayInstance **r
if(!array)
return E_OUTOFMEMORY;
if(use_constr)
hres = init_dispex_from_constr(&array->dispex, ctx, &Array_info, ctx->array_constr);
if(object_prototype)
hres = init_dispex(&array->dispex, ctx, &Array_info, object_prototype);
else
hres = init_dispex_from_constr(&array->dispex, ctx, &Array_info, ctx->object_constr);
@ -911,12 +883,12 @@ static HRESULT alloc_array(script_ctx_t *ctx, BOOL use_constr, ArrayInstance **r
return S_OK;
}
HRESULT create_array_constr(script_ctx_t *ctx, DispatchEx **ret)
HRESULT create_array_constr(script_ctx_t *ctx, DispatchEx *object_prototype, DispatchEx **ret)
{
ArrayInstance *array;
HRESULT hres;
hres = alloc_array(ctx, FALSE, &array);
hres = alloc_array(ctx, object_prototype, &array);
if(FAILED(hres))
return hres;
@ -931,7 +903,7 @@ HRESULT create_array(script_ctx_t *ctx, DWORD length, DispatchEx **ret)
ArrayInstance *array;
HRESULT hres;
hres = alloc_array(ctx, TRUE, &array);
hres = alloc_array(ctx, NULL, &array);
if(FAILED(hres))
return hres;

View file

@ -30,12 +30,7 @@ typedef struct {
} BoolInstance;
static const WCHAR toStringW[] = {'t','o','S','t','r','i','n','g',0};
static const WCHAR toLocaleStringW[] = {'t','o','L','o','c','a','l','e','S','t','r','i','n','g',0};
static const WCHAR valueOfW[] = {'v','a','l','u','e','O','f',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};
/* ECMA-262 3rd Edition 15.6.4.2 */
static HRESULT Bool_toString(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
@ -66,13 +61,6 @@ static HRESULT Bool_toString(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARA
return S_OK;
}
static HRESULT Bool_toLocaleString(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
TRACE("\n");
return Bool_toString(dispex, lcid, flags, dp, retv, ei, sp);
}
/* ECMA-262 3rd Edition 15.6.4.3 */
static HRESULT Bool_valueOf(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
@ -92,27 +80,6 @@ static HRESULT Bool_valueOf(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAM
return S_OK;
}
static HRESULT Bool_hasOwnProperty(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT Bool_propertyIsEnumerable(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT Bool_isPrototypeOf(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT Bool_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
@ -131,10 +98,6 @@ static HRESULT Bool_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS
}
static const builtin_prop_t Bool_props[] = {
{hasOwnPropertyW, Bool_hasOwnProperty, PROPF_METHOD},
{isPrototypeOfW, Bool_isPrototypeOf, PROPF_METHOD},
{propertyIsEnumerableW, Bool_propertyIsEnumerable, PROPF_METHOD},
{toLocaleStringW, Bool_toLocaleString, PROPF_METHOD},
{toStringW, Bool_toString, PROPF_METHOD},
{valueOfW, Bool_valueOf, PROPF_METHOD}
};
@ -188,7 +151,7 @@ static HRESULT BoolConstr_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPP
return S_OK;
}
static HRESULT alloc_bool(script_ctx_t *ctx, BOOL use_constr, BoolInstance **ret)
static HRESULT alloc_bool(script_ctx_t *ctx, DispatchEx *object_prototype, BoolInstance **ret)
{
BoolInstance *bool;
HRESULT hres;
@ -197,10 +160,10 @@ static HRESULT alloc_bool(script_ctx_t *ctx, BOOL use_constr, BoolInstance **ret
if(!bool)
return E_OUTOFMEMORY;
if(use_constr)
hres = init_dispex_from_constr(&bool->dispex, ctx, &Bool_info, ctx->bool_constr);
if(object_prototype)
hres = init_dispex(&bool->dispex, ctx, &Bool_info, object_prototype);
else
hres = init_dispex(&bool->dispex, ctx, &Bool_info, NULL);
hres = init_dispex_from_constr(&bool->dispex, ctx, &Bool_info, ctx->bool_constr);
if(FAILED(hres)) {
heap_free(bool);
@ -211,12 +174,12 @@ static HRESULT alloc_bool(script_ctx_t *ctx, BOOL use_constr, BoolInstance **ret
return S_OK;
}
HRESULT create_bool_constr(script_ctx_t *ctx, DispatchEx **ret)
HRESULT create_bool_constr(script_ctx_t *ctx, DispatchEx *object_prototype, DispatchEx **ret)
{
BoolInstance *bool;
HRESULT hres;
hres = alloc_bool(ctx, FALSE, &bool);
hres = alloc_bool(ctx, object_prototype, &bool);
if(FAILED(hres))
return hres;
@ -231,7 +194,7 @@ HRESULT create_bool(script_ctx_t *ctx, VARIANT_BOOL b, DispatchEx **ret)
BoolInstance *bool;
HRESULT hres;
hres = alloc_bool(ctx, TRUE, &bool);
hres = alloc_bool(ctx, NULL, &bool);
if(FAILED(hres))
return hres;

View file

@ -17,6 +17,9 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#include <limits.h>
#include <math.h>
@ -44,7 +47,6 @@ typedef struct {
static const WCHAR toStringW[] = {'t','o','S','t','r','i','n','g',0};
static const WCHAR toLocaleStringW[] = {'t','o','L','o','c','a','l','e','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};
@ -649,27 +651,6 @@ static HRESULT Date_toLocaleString(DispatchEx *dispex, LCID lcid, WORD flags, DI
return S_OK;
}
static HRESULT Date_hasOwnProperty(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT Date_propertyIsEnumerable(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT Date_isPrototypeOf(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT Date_valueOf(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller)
{
@ -2073,24 +2054,21 @@ static const builtin_prop_t Date_props[] = {
{getUTCMonthW, Date_getUTCMonth, PROPF_METHOD},
{getUTCSecondsW, Date_getUTCSeconds, PROPF_METHOD},
{getYearW, Date_getYear, PROPF_METHOD},
{hasOwnPropertyW, Date_hasOwnProperty, PROPF_METHOD},
{isPrototypeOfW, Date_isPrototypeOf, PROPF_METHOD},
{propertyIsEnumerableW, Date_propertyIsEnumerable, PROPF_METHOD},
{setDateW, Date_setDate, PROPF_METHOD},
{setFullYearW, Date_setFullYear, PROPF_METHOD},
{setHoursW, Date_setHours, PROPF_METHOD},
{setMillisecondsW, Date_setMilliseconds, PROPF_METHOD},
{setMinutesW, Date_setMinutes, PROPF_METHOD},
{setMonthW, Date_setMonth, PROPF_METHOD},
{setSecondsW, Date_setSeconds, PROPF_METHOD},
{setTimeW, Date_setTime, PROPF_METHOD},
{setUTCDateW, Date_setUTCDate, PROPF_METHOD},
{setUTCFullYearW, Date_setUTCFullYear, PROPF_METHOD},
{setUTCHoursW, Date_setUTCHours, PROPF_METHOD},
{setUTCMillisecondsW, Date_setUTCMilliseconds, PROPF_METHOD},
{setUTCMinutesW, Date_setUTCMinutes, PROPF_METHOD},
{setUTCMonthW, Date_setUTCMonth, PROPF_METHOD},
{setUTCSecondsW, Date_setUTCSeconds, PROPF_METHOD},
{setDateW, Date_setDate, PROPF_METHOD|1},
{setFullYearW, Date_setFullYear, PROPF_METHOD|3},
{setHoursW, Date_setHours, PROPF_METHOD|4},
{setMillisecondsW, Date_setMilliseconds, PROPF_METHOD|1},
{setMinutesW, Date_setMinutes, PROPF_METHOD|3},
{setMonthW, Date_setMonth, PROPF_METHOD|2},
{setSecondsW, Date_setSeconds, PROPF_METHOD|2},
{setTimeW, Date_setTime, PROPF_METHOD|1},
{setUTCDateW, Date_setUTCDate, PROPF_METHOD|1},
{setUTCFullYearW, Date_setUTCFullYear, PROPF_METHOD|3},
{setUTCHoursW, Date_setUTCHours, PROPF_METHOD|4},
{setUTCMillisecondsW, Date_setUTCMilliseconds, PROPF_METHOD|1},
{setUTCMinutesW, Date_setUTCMinutes, PROPF_METHOD|3},
{setUTCMonthW, Date_setUTCMonth, PROPF_METHOD|2},
{setUTCSecondsW, Date_setUTCSeconds, PROPF_METHOD|2},
{toDateStringW, Date_toDateString, PROPF_METHOD},
{toLocaleDateStringW, Date_toLocaleDateString, PROPF_METHOD},
{toLocaleStringW, Date_toLocaleString, PROPF_METHOD},
@ -2110,7 +2088,7 @@ static const builtin_info_t Date_info = {
NULL
};
static HRESULT create_date(script_ctx_t *ctx, BOOL use_constr, DOUBLE time, DispatchEx **ret)
static HRESULT create_date(script_ctx_t *ctx, DispatchEx *object_prototype, DOUBLE time, DispatchEx **ret)
{
DateInstance *date;
HRESULT hres;
@ -2122,10 +2100,10 @@ static HRESULT create_date(script_ctx_t *ctx, BOOL use_constr, DOUBLE time, Disp
if(!date)
return E_OUTOFMEMORY;
if(use_constr)
hres = init_dispex_from_constr(&date->dispex, ctx, &Date_info, ctx->date_constr);
if(object_prototype)
hres = init_dispex(&date->dispex, ctx, &Date_info, object_prototype);
else
hres = init_dispex(&date->dispex, ctx, &Date_info, NULL);
hres = init_dispex_from_constr(&date->dispex, ctx, &Date_info, ctx->date_constr);
if(FAILED(hres)) {
heap_free(date);
return hres;
@ -2537,7 +2515,7 @@ static HRESULT DateConstr_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPP
lltime = ((LONGLONG)time.dwHighDateTime<<32)
+ time.dwLowDateTime;
hres = create_date(dispex->ctx, TRUE, lltime/10000-TIME_EPOCH, &date);
hres = create_date(dispex->ctx, NULL, lltime/10000-TIME_EPOCH, &date);
if(FAILED(hres))
return hres;
break;
@ -2560,7 +2538,7 @@ static HRESULT DateConstr_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPP
if(FAILED(hres))
return hres;
hres = create_date(dispex->ctx, TRUE, time_clip(num_val(&num)), &date);
hres = create_date(dispex->ctx, NULL, time_clip(num_val(&num)), &date);
if(FAILED(hres))
return hres;
break;
@ -2573,7 +2551,7 @@ static HRESULT DateConstr_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPP
DateConstr_UTC(dispex, lcid, flags, dp, &ret_date, ei, sp);
hres = create_date(dispex->ctx, TRUE, num_val(&ret_date), &date);
hres = create_date(dispex->ctx, NULL, num_val(&ret_date), &date);
if(FAILED(hres))
return hres;
@ -2620,12 +2598,12 @@ static const builtin_info_t DateConstr_info = {
NULL
};
HRESULT create_date_constr(script_ctx_t *ctx, DispatchEx **ret)
HRESULT create_date_constr(script_ctx_t *ctx, DispatchEx *object_prototype, DispatchEx **ret)
{
DispatchEx *date;
HRESULT hres;
hres = create_date(ctx, FALSE, 0.0, &date);
hres = create_date(ctx, object_prototype, 0.0, &date);
if(FAILED(hres))
return hres;

View file

@ -844,6 +844,23 @@ HRESULT jsdisp_call(DispatchEx *disp, DISPID id, LCID lcid, WORD flags, DISPPARA
return invoke_prop_func(disp, disp, prop, lcid, flags, dp, retv, ei, caller);
}
HRESULT jsdisp_call_name(DispatchEx *disp, const WCHAR *name, LCID lcid, WORD flags, DISPPARAMS *dp, VARIANT *retv,
jsexcept_t *ei, IServiceProvider *caller)
{
dispex_prop_t *prop;
HRESULT hres;
hres = find_prop_name_prot(disp, name, TRUE, &prop);
if(FAILED(hres))
return hres;
memset(ei, 0, sizeof(*ei));
if(retv)
V_VT(retv) = VT_EMPTY;
return invoke_prop_func(disp, disp, prop, lcid, flags, dp, retv, ei, caller);
}
HRESULT disp_call(IDispatch *disp, DISPID id, LCID lcid, WORD flags, DISPPARAMS *dp, VARIANT *retv,
jsexcept_t *ei, IServiceProvider *caller)
{

View file

@ -356,6 +356,26 @@ static HRESULT literal_to_var(literal_t *literal, VARIANT *v)
return S_OK;
}
static BOOL lookup_global_members(script_ctx_t *ctx, BSTR identifier, exprval_t *ret)
{
named_item_t *item;
DISPID id;
HRESULT hres;
for(item = ctx->named_items; item; item = item->next) {
if(item->flags & SCRIPTITEM_GLOBALMEMBERS) {
hres = disp_get_id(item->disp, identifier, 0, &id);
if(SUCCEEDED(hres)) {
if(ret)
exprval_set_idref(ret, item->disp, id);
return TRUE;
}
}
}
return FALSE;
}
HRESULT exec_source(exec_ctx_t *ctx, parser_ctx_t *parser, source_elements_t *source, jsexcept_t *ei, VARIANT *retv)
{
script_ctx_t *script = parser->script;
@ -387,8 +407,15 @@ HRESULT exec_source(exec_ctx_t *ctx, parser_ctx_t *parser, source_elements_t *so
for(var = source->variables; var; var = var->next) {
DISPID id = 0;
BSTR name;
hres = jsdisp_get_id(ctx->var_disp, var->identifier, fdexNameEnsure, &id);
name = SysAllocString(var->identifier);
if(!name)
return E_OUTOFMEMORY;
if(!lookup_global_members(parser->script, name, NULL))
hres = jsdisp_get_id(ctx->var_disp, var->identifier, fdexNameEnsure, &id);
SysFreeString(name);
if(FAILED(hres))
return hres;
}
@ -493,25 +520,15 @@ static HRESULT identifier_eval(exec_ctx_t *ctx, BSTR identifier, DWORD flags, js
}
}
for(item = ctx->parser->script->named_items; item; item = item->next) {
if(item->flags & SCRIPTITEM_GLOBALMEMBERS) {
hres = disp_get_id(item->disp, identifier, 0, &id);
if(SUCCEEDED(hres))
break;
}
}
if(item) {
exprval_set_idref(ret, item->disp, id);
return S_OK;
}
hres = jsdisp_get_id(ctx->parser->script->script_disp, identifier, 0, &id);
if(SUCCEEDED(hres)) {
exprval_set_idref(ret, (IDispatch*)_IDispatchEx_(ctx->parser->script->script_disp), id);
return S_OK;
}
if(lookup_global_members(ctx->parser->script, identifier, ret))
return S_OK;
if(flags & EXPR_NEWREF) {
hres = jsdisp_get_id(ctx->var_disp, identifier, fdexNameEnsure, &id);
if(FAILED(hres))

View file

@ -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;

View file

@ -40,12 +40,8 @@ static const WCHAR prototypeW[] = {'p','r','o','t','o','t', 'y', 'p','e',0};
static const WCHAR lengthW[] = {'l','e','n','g','t','h',0};
static const WCHAR toStringW[] = {'t','o','S','t','r','i','n','g',0};
static const WCHAR toLocaleStringW[] = {'t','o','L','o','c','a','l','e','S','t','r','i','n','g',0};
static const WCHAR applyW[] = {'a','p','p','l','y',0};
static const WCHAR callW[] = {'c','a','l','l',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 IDispatch *get_this(DISPPARAMS *dp)
{
@ -290,13 +286,6 @@ static HRESULT Function_toString(DispatchEx *dispex, LCID lcid, WORD flags, DISP
return S_OK;
}
static HRESULT Function_toLocaleString(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT Function_apply(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
@ -311,27 +300,6 @@ static HRESULT Function_call(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARA
return E_NOTIMPL;
}
static HRESULT Function_hasOwnProperty(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT Function_propertyIsEnumerable(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT Function_isPrototypeOf(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
FIXME("\n");
return E_NOTIMPL;
}
HRESULT Function_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller)
{
@ -394,11 +362,7 @@ static void Function_destructor(DispatchEx *dispex)
static const builtin_prop_t Function_props[] = {
{applyW, Function_apply, PROPF_METHOD},
{callW, Function_call, PROPF_METHOD},
{hasOwnPropertyW, Function_hasOwnProperty, PROPF_METHOD},
{isPrototypeOfW, Function_isPrototypeOf, PROPF_METHOD},
{lengthW, Function_length, 0},
{propertyIsEnumerableW, Function_propertyIsEnumerable, PROPF_METHOD},
{toLocaleStringW, Function_toLocaleString, PROPF_METHOD},
{toStringW, Function_toString, PROPF_METHOD}
};

View file

@ -754,31 +754,31 @@ static HRESULT init_constructors(script_ctx_t *ctx, DispatchEx *object_prototype
if(FAILED(hres))
return hres;
hres = create_array_constr(ctx, &ctx->array_constr);
hres = create_array_constr(ctx, object_prototype, &ctx->array_constr);
if(FAILED(hres))
return hres;
hres = create_bool_constr(ctx, &ctx->bool_constr);
hres = create_bool_constr(ctx, object_prototype, &ctx->bool_constr);
if(FAILED(hres))
return hres;
hres = create_date_constr(ctx, &ctx->date_constr);
hres = create_date_constr(ctx, object_prototype, &ctx->date_constr);
if(FAILED(hres))
return hres;
hres = init_error_constr(ctx);
hres = init_error_constr(ctx, object_prototype);
if(FAILED(hres))
return hres;
hres = create_number_constr(ctx, &ctx->number_constr);
hres = create_number_constr(ctx, object_prototype, &ctx->number_constr);
if(FAILED(hres))
return hres;
hres = create_regexp_constr(ctx, &ctx->regexp_constr);
hres = create_regexp_constr(ctx, object_prototype, &ctx->regexp_constr);
if(FAILED(hres))
return hres;
hres = create_string_constr(ctx, &ctx->string_constr);
hres = create_string_constr(ctx, object_prototype, &ctx->string_constr);
if(FAILED(hres))
return hres;

View file

@ -131,6 +131,7 @@ DispatchEx *iface_to_jsdisp(IUnknown*);
HRESULT disp_call(IDispatch*,DISPID,LCID,WORD,DISPPARAMS*,VARIANT*,jsexcept_t*,IServiceProvider*);
HRESULT jsdisp_call_value(DispatchEx*,LCID,WORD,DISPPARAMS*,VARIANT*,jsexcept_t*,IServiceProvider*);
HRESULT jsdisp_call(DispatchEx*,DISPID,LCID,WORD,DISPPARAMS*,VARIANT*,jsexcept_t*,IServiceProvider*);
HRESULT jsdisp_call_name(DispatchEx*,const WCHAR*,LCID,WORD,DISPPARAMS*,VARIANT*,jsexcept_t*,IServiceProvider*);
HRESULT disp_propget(IDispatch*,DISPID,LCID,VARIANT*,jsexcept_t*,IServiceProvider*);
HRESULT disp_propput(IDispatch*,DISPID,LCID,VARIANT*,jsexcept_t*,IServiceProvider*);
HRESULT jsdisp_propget(DispatchEx*,DISPID,LCID,VARIANT*,jsexcept_t*,IServiceProvider*);
@ -225,14 +226,14 @@ HRESULT init_global(script_ctx_t*);
HRESULT init_function_constr(script_ctx_t*,DispatchEx*);
HRESULT create_object_prototype(script_ctx_t*,DispatchEx**);
HRESULT create_array_constr(script_ctx_t*,DispatchEx**);
HRESULT create_bool_constr(script_ctx_t*,DispatchEx**);
HRESULT create_date_constr(script_ctx_t*,DispatchEx**);
HRESULT init_error_constr(script_ctx_t*);
HRESULT create_number_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**);
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**);
HRESULT create_string_constr(script_ctx_t*,DispatchEx**);
HRESULT create_regexp_constr(script_ctx_t*,DispatchEx*,DispatchEx**);
HRESULT create_string_constr(script_ctx_t*,DispatchEx*,DispatchEx**);
typedef struct {
const WCHAR *str;

View file

@ -30,6 +30,7 @@ STRINGTABLE DISCARDABLE
IDS_SEMICOLON "';' verwacht"
IDS_LBRACKET "'(' verwacht"
IDS_RBRACKET "')' verwacht"
IDS_UNTERMINATED_STR "Onafgesloten tekenreeksconstante"
IDS_NOT_FUNC "Functie verwacht"
IDS_NOT_DATE "'[object]' is geen datum object"
IDS_NOT_NUM "Getal verwacht"

View file

@ -571,24 +571,24 @@ static const builtin_prop_t Math_props[] = {
{PIW, Math_PI, 0},
{SQRT1_2W, Math_SQRT1_2, 0},
{SQRT2W, Math_SQRT2, 0},
{absW, Math_abs, PROPF_METHOD},
{acosW, Math_acos, PROPF_METHOD},
{asinW, Math_asin, PROPF_METHOD},
{atanW, Math_atan, PROPF_METHOD},
{atan2W, Math_atan2, PROPF_METHOD},
{ceilW, Math_ceil, PROPF_METHOD},
{cosW, Math_cos, PROPF_METHOD},
{expW, Math_exp, PROPF_METHOD},
{floorW, Math_floor, PROPF_METHOD},
{logW, Math_log, PROPF_METHOD},
{maxW, Math_max, PROPF_METHOD},
{minW, Math_min, PROPF_METHOD},
{powW, Math_pow, PROPF_METHOD},
{absW, Math_abs, PROPF_METHOD|1},
{acosW, Math_acos, PROPF_METHOD|1},
{asinW, Math_asin, PROPF_METHOD|1},
{atanW, Math_atan, PROPF_METHOD|1},
{atan2W, Math_atan2, PROPF_METHOD|2},
{ceilW, Math_ceil, PROPF_METHOD|1},
{cosW, Math_cos, PROPF_METHOD|1},
{expW, Math_exp, PROPF_METHOD|1},
{floorW, Math_floor, PROPF_METHOD|1},
{logW, Math_log, PROPF_METHOD|1},
{maxW, Math_max, PROPF_METHOD|2},
{minW, Math_min, PROPF_METHOD|2},
{powW, Math_pow, PROPF_METHOD|2},
{randomW, Math_random, PROPF_METHOD},
{roundW, Math_round, PROPF_METHOD},
{sinW, Math_sin, PROPF_METHOD},
{sqrtW, Math_sqrt, PROPF_METHOD},
{tanW, Math_tan, PROPF_METHOD}
{roundW, Math_round, PROPF_METHOD|1},
{sinW, Math_sin, PROPF_METHOD|1},
{sqrtW, Math_sqrt, PROPF_METHOD|1},
{tanW, Math_tan, PROPF_METHOD|1}
};
static const builtin_info_t Math_info = {
@ -602,5 +602,19 @@ static const builtin_info_t Math_info = {
HRESULT create_math(script_ctx_t *ctx, DispatchEx **ret)
{
return create_dispex(ctx, &Math_info, NULL, ret);
DispatchEx *math;
HRESULT hres;
math = heap_alloc_zero(sizeof(DispatchEx));
if(!math)
return E_OUTOFMEMORY;
hres = init_dispex_from_constr(math, ctx, &Math_info, ctx->object_constr);
if(FAILED(hres)) {
heap_free(math);
return hres;
}
*ret = math;
return S_OK;
}

View file

@ -16,6 +16,9 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#include <math.h>
#include "jscript.h"
@ -36,10 +39,6 @@ static const WCHAR toFixedW[] = {'t','o','F','i','x','e','d',0};
static const WCHAR toExponentialW[] = {'t','o','E','x','p','o','n','e','n','t','i','a','l',0};
static const WCHAR toPrecisionW[] = {'t','o','P','r','e','c','i','s','i','o','n',0};
static const WCHAR valueOfW[] = {'v','a','l','u','e','O','f',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};
#define NUMBER_TOSTRING_BUF_SIZE 64
/* ECMA-262 3rd Edition 15.7.4.2 */
@ -214,27 +213,6 @@ static HRESULT Number_valueOf(DispatchEx *dispex, LCID lcid, WORD flags, DISPPAR
return S_OK;
}
static HRESULT Number_hasOwnProperty(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT Number_propertyIsEnumerable(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT Number_isPrototypeOf(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT Number_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
@ -256,14 +234,11 @@ static HRESULT Number_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAM
}
static const builtin_prop_t Number_props[] = {
{hasOwnPropertyW, Number_hasOwnProperty, PROPF_METHOD},
{isPrototypeOfW, Number_isPrototypeOf, PROPF_METHOD},
{propertyIsEnumerableW, Number_propertyIsEnumerable, PROPF_METHOD},
{toExponentialW, Number_toExponential, PROPF_METHOD},
{toExponentialW, Number_toExponential, PROPF_METHOD|1},
{toFixedW, Number_toFixed, PROPF_METHOD},
{toLocaleStringW, Number_toLocaleString, PROPF_METHOD},
{toPrecisionW, Number_toPrecision, PROPF_METHOD},
{toStringW, Number_toString, PROPF_METHOD},
{toPrecisionW, Number_toPrecision, PROPF_METHOD|1},
{toStringW, Number_toString, PROPF_METHOD|1},
{valueOfW, Number_valueOf, PROPF_METHOD}
};
@ -330,7 +305,7 @@ static HRESULT NumberConstr_value(DispatchEx *dispex, LCID lcid, WORD flags, DIS
return S_OK;
}
static HRESULT alloc_number(script_ctx_t *ctx, BOOL use_constr, NumberInstance **ret)
static HRESULT alloc_number(script_ctx_t *ctx, DispatchEx *object_prototype, NumberInstance **ret)
{
NumberInstance *number;
HRESULT hres;
@ -339,10 +314,10 @@ static HRESULT alloc_number(script_ctx_t *ctx, BOOL use_constr, NumberInstance *
if(!number)
return E_OUTOFMEMORY;
if(use_constr)
hres = init_dispex_from_constr(&number->dispex, ctx, &Number_info, ctx->number_constr);
if(object_prototype)
hres = init_dispex(&number->dispex, ctx, &Number_info, object_prototype);
else
hres = init_dispex(&number->dispex, ctx, &Number_info, NULL);
hres = init_dispex_from_constr(&number->dispex, ctx, &Number_info, ctx->number_constr);
if(FAILED(hres))
return hres;
@ -350,12 +325,12 @@ static HRESULT alloc_number(script_ctx_t *ctx, BOOL use_constr, NumberInstance *
return S_OK;
}
HRESULT create_number_constr(script_ctx_t *ctx, DispatchEx **ret)
HRESULT create_number_constr(script_ctx_t *ctx, DispatchEx *object_prototype, DispatchEx **ret)
{
NumberInstance *number;
HRESULT hres;
hres = alloc_number(ctx, FALSE, &number);
hres = alloc_number(ctx, object_prototype, &number);
if(FAILED(hres))
return hres;
@ -371,7 +346,7 @@ HRESULT create_number(script_ctx_t *ctx, VARIANT *num, DispatchEx **ret)
NumberInstance *number;
HRESULT hres;
hres = alloc_number(ctx, TRUE, &number);
hres = alloc_number(ctx, NULL, &number);
if(FAILED(hres))
return hres;

View file

@ -74,8 +74,11 @@ static HRESULT Object_toString(DispatchEx *dispex, LCID lcid, WORD flags, DISPPA
static HRESULT Object_toLocaleString(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
DISPPARAMS params = {NULL, NULL, 0, 0};
TRACE("\n");
return Object_toString(dispex, lcid, flags, dp, retv, ei, sp);
return jsdisp_call_name(dispex, toStringW, lcid, DISPATCH_METHOD, &params, retv, ei, sp);
}
static HRESULT Object_valueOf(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
@ -142,9 +145,9 @@ static void Object_destructor(DispatchEx *dispex)
}
static const builtin_prop_t Object_props[] = {
{hasOwnPropertyW, Object_hasOwnProperty, PROPF_METHOD},
{isPrototypeOfW, Object_isPrototypeOf, PROPF_METHOD},
{propertyIsEnumerableW, Object_propertyIsEnumerable, PROPF_METHOD},
{hasOwnPropertyW, Object_hasOwnProperty, PROPF_METHOD|1},
{isPrototypeOfW, Object_isPrototypeOf, PROPF_METHOD|1},
{propertyIsEnumerableW, Object_propertyIsEnumerable, PROPF_METHOD|1},
{toLocaleStringW, Object_toLocaleString, PROPF_METHOD},
{toStringW, Object_toString, PROPF_METHOD},
{valueOfW, Object_valueOf, PROPF_METHOD}

View file

@ -90,11 +90,6 @@ static const WCHAR ignoreCaseW[] = {'i','g','n','o','r','e','C','a','s','e',0};
static const WCHAR multilineW[] = {'m','u','l','t','i','l','i','n','e',0};
static const WCHAR lastIndexW[] = {'l','a','s','t','I','n','d','e','x',0};
static const WCHAR toStringW[] = {'t','o','S','t','r','i','n','g',0};
static const WCHAR toLocaleStringW[] = {'t','o','L','o','c','a','l','e','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 const WCHAR execW[] = {'e','x','e','c',0};
static const WCHAR testW[] = {'t','e','s','t',0};
@ -3432,8 +3427,24 @@ HRESULT regexp_match(DispatchEx *dispex, const WCHAR *str, DWORD len, BOOL gflag
static HRESULT RegExp_source(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
FIXME("\n");
return E_NOTIMPL;
TRACE("\n");
switch(flags) {
case DISPATCH_PROPERTYGET: {
RegExpInstance *This = (RegExpInstance*)dispex;
V_VT(retv) = VT_BSTR;
V_BSTR(retv) = SysAllocString(This->str);
if(!V_BSTR(retv))
return E_OUTOFMEMORY;
break;
}
default:
FIXME("Unimplemnted flags %x\n", flags);
return E_NOTIMPL;
}
return S_OK;
}
static HRESULT RegExp_global(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
@ -3471,34 +3482,6 @@ static HRESULT RegExp_toString(DispatchEx *dispex, LCID lcid, WORD flags, DISPPA
return E_NOTIMPL;
}
static HRESULT RegExp_toLocaleString(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT RegExp_hasOwnProperty(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT RegExp_propertyIsEnumerable(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT RegExp_isPrototypeOf(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT RegExp_exec(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
@ -3540,17 +3523,13 @@ static void RegExp_destructor(DispatchEx *dispex)
}
static const builtin_prop_t RegExp_props[] = {
{execW, RegExp_exec, PROPF_METHOD},
{execW, RegExp_exec, PROPF_METHOD|1},
{globalW, RegExp_global, 0},
{hasOwnPropertyW, RegExp_hasOwnProperty, PROPF_METHOD},
{ignoreCaseW, RegExp_ignoreCase, 0},
{isPrototypeOfW, RegExp_isPrototypeOf, PROPF_METHOD},
{lastIndexW, RegExp_lastIndex, 0},
{multilineW, RegExp_multiline, 0},
{propertyIsEnumerableW, RegExp_propertyIsEnumerable, PROPF_METHOD},
{sourceW, RegExp_source, 0},
{testW, RegExp_test, PROPF_METHOD},
{toLocaleStringW, RegExp_toLocaleString, PROPF_METHOD},
{testW, RegExp_test, PROPF_METHOD|1},
{toStringW, RegExp_toString, PROPF_METHOD}
};
@ -3563,7 +3542,7 @@ static const builtin_info_t RegExp_info = {
NULL
};
static HRESULT alloc_regexp(script_ctx_t *ctx, BOOL use_constr, RegExpInstance **ret)
static HRESULT alloc_regexp(script_ctx_t *ctx, DispatchEx *object_prototype, RegExpInstance **ret)
{
RegExpInstance *regexp;
HRESULT hres;
@ -3572,10 +3551,10 @@ static HRESULT alloc_regexp(script_ctx_t *ctx, BOOL use_constr, RegExpInstance *
if(!regexp)
return E_OUTOFMEMORY;
if(use_constr)
hres = init_dispex_from_constr(&regexp->dispex, ctx, &RegExp_info, ctx->regexp_constr);
if(object_prototype)
hres = init_dispex(&regexp->dispex, ctx, &RegExp_info, object_prototype);
else
hres = init_dispex(&regexp->dispex, ctx, &RegExp_info, NULL);
hres = init_dispex_from_constr(&regexp->dispex, ctx, &RegExp_info, ctx->regexp_constr);
if(FAILED(hres)) {
heap_free(regexp);
@ -3593,7 +3572,7 @@ static HRESULT create_regexp(script_ctx_t *ctx, const WCHAR *exp, int len, DWORD
TRACE("%s %x\n", debugstr_w(exp), flags);
hres = alloc_regexp(ctx, TRUE, &regexp);
hres = alloc_regexp(ctx, NULL, &regexp);
if(FAILED(hres))
return hres;
@ -3694,12 +3673,12 @@ static HRESULT RegExpConstr_value(DispatchEx *dispex, LCID lcid, WORD flags, DIS
return S_OK;
}
HRESULT create_regexp_constr(script_ctx_t *ctx, DispatchEx **ret)
HRESULT create_regexp_constr(script_ctx_t *ctx, DispatchEx *object_prototype, DispatchEx **ret)
{
RegExpInstance *regexp;
HRESULT hres;
hres = alloc_regexp(ctx, FALSE, &regexp);
hres = alloc_regexp(ctx, object_prototype, &regexp);
if(FAILED(hres))
return hres;

View file

@ -62,10 +62,6 @@ static const WCHAR toUpperCaseW[] = {'t','o','U','p','p','e','r','C','a','s','e'
static const WCHAR toLocaleLowerCaseW[] = {'t','o','L','o','c','a','l','e','L','o','w','e','r','C','a','s','e',0};
static const WCHAR toLocaleUpperCaseW[] = {'t','o','L','o','c','a','l','e','U','p','p','e','r','C','a','s','e',0};
static const WCHAR localeCompareW[] = {'l','o','c','a','l','e','C','o','m','p','a','r','e',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 const WCHAR fromCharCodeW[] = {'f','r','o','m','C','h','a','r','C','o','d','e',0};
static HRESULT String_length(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
@ -802,7 +798,7 @@ static HRESULT String_replace(DispatchEx *dispex, LCID lcid, WORD flags, DISPPAR
DWORD parens_cnt = 0, parens_size=0, rep_len=0, length;
BSTR rep_str = NULL, match_str = NULL, ret_str, val_str = NULL;
DispatchEx *rep_func = NULL, *regexp = NULL;
match_result_t *parens = NULL, match;
match_result_t *parens = NULL, match, **parens_ptr = &parens;
strbuf_t ret = {NULL,0,0};
BOOL gcheck = FALSE;
VARIANT *arg_var;
@ -884,12 +880,9 @@ static HRESULT String_replace(DispatchEx *dispex, LCID lcid, WORD flags, DISPPAR
if(FAILED(hres))
break;
if(strchrW(rep_str, '$')) {
FIXME("unsupported $ in replace string\n");
hres = E_NOTIMPL;
}
rep_len = SysStringLen(rep_str);
if(!strchrW(rep_str, '$'))
parens_ptr = NULL;
}
}
@ -900,7 +893,7 @@ static HRESULT String_replace(DispatchEx *dispex, LCID lcid, WORD flags, DISPPAR
while(1) {
if(regexp) {
hres = regexp_match_next(regexp, gcheck, str, length, &cp, rep_func ? &parens : NULL,
hres = regexp_match_next(regexp, gcheck, str, length, &cp, parens_ptr,
&parens_size, &parens_cnt, &match);
gcheck = TRUE;
@ -934,6 +927,64 @@ static HRESULT String_replace(DispatchEx *dispex, LCID lcid, WORD flags, DISPPAR
SysFreeString(cstr);
if(FAILED(hres))
break;
}else if(rep_str && regexp) {
const WCHAR *ptr = rep_str, *ptr2;
while((ptr2 = strchrW(ptr, '$'))) {
hres = strbuf_append(&ret, ptr, ptr2-ptr);
if(FAILED(hres))
break;
switch(ptr2[1]) {
case '$':
hres = strbuf_append(&ret, ptr2, 1);
ptr = ptr2+2;
break;
case '&':
hres = strbuf_append(&ret, match.str, match.len);
ptr = ptr2+2;
break;
case '`':
hres = strbuf_append(&ret, str, match.str-str);
ptr = ptr2+2;
break;
case '\'':
hres = strbuf_append(&ret, ecp, (str+length)-ecp);
ptr = ptr2+2;
break;
default: {
DWORD idx;
if(!isdigitW(ptr2[1])) {
hres = strbuf_append(&ret, ptr2, 1);
ptr = ptr2+1;
break;
}
idx = ptr2[1] - '0';
if(isdigitW(ptr[3]) && idx*10 + (ptr[2]-'0') <= parens_cnt) {
idx = idx*10 + (ptr[2]-'0');
ptr = ptr2+3;
}else if(idx && idx <= parens_cnt) {
ptr = ptr2+2;
}else {
hres = strbuf_append(&ret, ptr2, 1);
ptr = ptr2+1;
break;
}
hres = strbuf_append(&ret, parens[idx-1].str, parens[idx-1].len);
}
}
if(FAILED(hres))
break;
}
if(SUCCEEDED(hres))
hres = strbuf_append(&ret, ptr, (rep_str+rep_len)-ptr);
if(FAILED(hres))
break;
}else if(rep_str) {
hres = strbuf_append(&ret, rep_str, rep_len);
if(FAILED(hres))
@ -1456,27 +1507,6 @@ static HRESULT String_localeCompare(DispatchEx *dispex, LCID lcid, WORD flags, D
return E_NOTIMPL;
}
static HRESULT String_hasOwnProperty(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT String_propertyIsEnumerable(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT String_isPrototypeOf(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT String_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
@ -1513,35 +1543,32 @@ static void String_destructor(DispatchEx *dispex)
}
static const builtin_prop_t String_props[] = {
{anchorW, String_anchor, PROPF_METHOD},
{anchorW, String_anchor, PROPF_METHOD|1},
{bigW, String_big, PROPF_METHOD},
{blinkW, String_blink, PROPF_METHOD},
{boldW, String_bold, PROPF_METHOD},
{charAtW, String_charAt, PROPF_METHOD},
{charCodeAtW, String_charCodeAt, PROPF_METHOD},
{concatW, String_concat, PROPF_METHOD},
{charAtW, String_charAt, PROPF_METHOD|1},
{charCodeAtW, String_charCodeAt, PROPF_METHOD|1},
{concatW, String_concat, PROPF_METHOD|1},
{fixedW, String_fixed, PROPF_METHOD},
{fontcolorW, String_fontcolor, PROPF_METHOD},
{fontsizeW, String_fontsize, PROPF_METHOD},
{hasOwnPropertyW, String_hasOwnProperty, PROPF_METHOD},
{indexOfW, String_indexOf, PROPF_METHOD},
{isPrototypeOfW, String_isPrototypeOf, PROPF_METHOD},
{fontcolorW, String_fontcolor, PROPF_METHOD|1},
{fontsizeW, String_fontsize, PROPF_METHOD|1},
{indexOfW, String_indexOf, PROPF_METHOD|2},
{italicsW, String_italics, PROPF_METHOD},
{lastIndexOfW, String_lastIndexOf, PROPF_METHOD},
{lastIndexOfW, String_lastIndexOf, PROPF_METHOD|2},
{lengthW, String_length, 0},
{linkW, String_link, PROPF_METHOD},
{localeCompareW, String_localeCompare, PROPF_METHOD},
{matchW, String_match, PROPF_METHOD},
{propertyIsEnumerableW, String_propertyIsEnumerable, PROPF_METHOD},
{replaceW, String_replace, PROPF_METHOD},
{linkW, String_link, PROPF_METHOD|1},
{localeCompareW, String_localeCompare, PROPF_METHOD|1},
{matchW, String_match, PROPF_METHOD|1},
{replaceW, String_replace, PROPF_METHOD|1},
{searchW, String_search, PROPF_METHOD},
{sliceW, String_slice, PROPF_METHOD},
{smallW, String_small, PROPF_METHOD},
{splitW, String_split, PROPF_METHOD},
{splitW, String_split, PROPF_METHOD|2},
{strikeW, String_strike, PROPF_METHOD},
{subW, String_sub, PROPF_METHOD},
{substrW, String_substr, PROPF_METHOD},
{substringW, String_substring, PROPF_METHOD},
{substrW, String_substr, PROPF_METHOD|2},
{substringW, String_substring, PROPF_METHOD|2},
{supW, String_sup, PROPF_METHOD},
{toLocaleLowerCaseW, String_toLocaleLowerCase, PROPF_METHOD},
{toLocaleUpperCaseW, String_toLocaleUpperCase, PROPF_METHOD},
@ -1648,7 +1675,7 @@ static HRESULT StringConstr_value(DispatchEx *dispex, LCID lcid, WORD flags, DIS
return S_OK;
}
static HRESULT string_alloc(script_ctx_t *ctx, BOOL use_constr, StringInstance **ret)
static HRESULT string_alloc(script_ctx_t *ctx, DispatchEx *object_prototype, StringInstance **ret)
{
StringInstance *string;
HRESULT hres;
@ -1657,10 +1684,10 @@ static HRESULT string_alloc(script_ctx_t *ctx, BOOL use_constr, StringInstance *
if(!string)
return E_OUTOFMEMORY;
if(use_constr)
hres = init_dispex_from_constr(&string->dispex, ctx, &String_info, ctx->string_constr);
if(object_prototype)
hres = init_dispex(&string->dispex, ctx, &String_info, object_prototype);
else
hres = init_dispex(&string->dispex, ctx, &String_info, NULL);
hres = init_dispex_from_constr(&string->dispex, ctx, &String_info, ctx->string_constr);
if(FAILED(hres)) {
heap_free(string);
return hres;
@ -1683,12 +1710,12 @@ static const builtin_info_t StringConstr_info = {
NULL
};
HRESULT create_string_constr(script_ctx_t *ctx, DispatchEx **ret)
HRESULT create_string_constr(script_ctx_t *ctx, DispatchEx *object_prototype, DispatchEx **ret)
{
StringInstance *string;
HRESULT hres;
hres = string_alloc(ctx, FALSE, &string);
hres = string_alloc(ctx, object_prototype, &string);
if(FAILED(hres))
return hres;
@ -1703,7 +1730,7 @@ HRESULT create_string(script_ctx_t *ctx, const WCHAR *str, DWORD len, DispatchEx
StringInstance *string;
HRESULT hres;
hres = string_alloc(ctx, TRUE, &string);
hres = string_alloc(ctx, NULL, &string);
if(FAILED(hres))
return hres;