jscript: Inherit some String functions from Object.
This commit is contained in:
parent
1dfd55ff9a
commit
79f45c5374
|
@ -778,7 +778,7 @@ static HRESULT init_constructors(script_ctx_t *ctx, DispatchEx *object_prototype
|
|||
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;
|
||||
|
||||
|
|
|
@ -232,7 +232,7 @@ HRESULT init_error_constr(script_ctx_t*);
|
|||
HRESULT create_number_constr(script_ctx_t*,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_string_constr(script_ctx_t*,DispatchEx*,DispatchEx**);
|
||||
|
||||
typedef struct {
|
||||
const WCHAR *str;
|
||||
|
|
|
@ -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,
|
||||
|
@ -1511,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)
|
||||
{
|
||||
|
@ -1578,16 +1553,13 @@ static const builtin_prop_t String_props[] = {
|
|||
{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},
|
||||
{italicsW, String_italics, PROPF_METHOD},
|
||||
{lastIndexOfW, String_lastIndexOf, PROPF_METHOD},
|
||||
{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},
|
||||
{searchW, String_search, PROPF_METHOD},
|
||||
{sliceW, String_slice, PROPF_METHOD},
|
||||
|
@ -1703,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;
|
||||
|
@ -1712,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;
|
||||
|
@ -1738,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;
|
||||
|
||||
|
@ -1758,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;
|
||||
|
||||
|
|
|
@ -1345,4 +1345,39 @@ exception_test(function() {eval("while(")}, "SyntaxError", -2146827286);
|
|||
exception_test(function() {eval("if(")}, "SyntaxError", -2146827286);
|
||||
exception_test(function() {eval("'unterminated")}, "SyntaxError", -2146827273);
|
||||
|
||||
function testObjectInherit(obj, ts, tls, vo) {
|
||||
ok(obj.hasOwnProperty === Object.prototype.hasOwnProperty,
|
||||
"obj.hasOwnProperty !== Object.prototype.hasOwnProprty");
|
||||
ok(obj.isPrototypeOf === Object.prototype.isPrototypeOf,
|
||||
"obj.isPrototypeOf !== Object.prototype.isPrototypeOf");
|
||||
ok(obj.propertyIsEnumerable === Object.prototype.propertyIsEnumerable,
|
||||
"obj.propertyIsEnumerable !== Object.prototype.propertyIsEnumerable");
|
||||
|
||||
if(ts)
|
||||
ok(obj.toString === Object.prototype.toString,
|
||||
"obj.toString !== Object.prototype.toString");
|
||||
else
|
||||
ok(obj.toString != Object.prototype.toString,
|
||||
"obj.toString == Object.prototype.toString");
|
||||
|
||||
if(tls)
|
||||
ok(obj.toLocaleString === Object.prototype.toLocaleString,
|
||||
"obj.toLocaleString !== Object.prototype.toLocaleString");
|
||||
else
|
||||
ok(obj.toLocaleString != Object.prototype.toLocaleString,
|
||||
"obj.toLocaleString == Object.prototype.toLocaleString");
|
||||
|
||||
if(vo)
|
||||
ok(obj.valueOf === Object.prototype.valueOf,
|
||||
"obj.valueOf !== Object.prototype.valueOf");
|
||||
else
|
||||
ok(obj.valueOf != Object.prototype.valueOf,
|
||||
"obj.valueOf == Object.prototype.valueOf");
|
||||
|
||||
ok(obj.test === "test", "obj.test = " + obj.test);
|
||||
}
|
||||
|
||||
Object.prototype.test = "test";
|
||||
testObjectInherit(new String("test"), false, true, false);
|
||||
|
||||
reportSuccess();
|
||||
|
|
Loading…
Reference in New Issue