ReactOS 0.4.15-dev-7961-gdcf9eb0
object.c File Reference
#include <assert.h>
#include "jscript.h"
#include "wine/debug.h"
Include dependency graph for object.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (jscript)
 
static HRESULT Object_toString (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Object_toLocaleString (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Object_valueOf (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Object_hasOwnProperty (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Object_propertyIsEnumerable (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Object_isPrototypeOf (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Object_get_value (script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
 
static void Object_destructor (jsdisp_t *dispex)
 
static void release_property_descriptor (property_desc_t *desc)
 
static HRESULT to_property_descriptor (script_ctx_t *ctx, jsdisp_t *attr_obj, property_desc_t *desc)
 
static HRESULT jsdisp_define_properties (script_ctx_t *ctx, jsdisp_t *obj, jsval_t list_val)
 
static HRESULT Object_defineProperty (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Object_defineProperties (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Object_getOwnPropertyDescriptor (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Object_create (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Object_getPrototypeOf (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT ObjectConstr_value (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
HRESULT create_object_constr (script_ctx_t *ctx, jsdisp_t *object_prototype, jsdisp_t **ret)
 
HRESULT create_object_prototype (script_ctx_t *ctx, jsdisp_t **ret)
 
HRESULT create_object (script_ctx_t *ctx, jsdisp_t *constr, jsdisp_t **ret)
 

Variables

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 []
 
static const WCHAR isPrototypeOfW [] = {'i','s','P','r','o','t','o','t','y','p','e','O','f',0}
 
static const WCHAR createW [] = {'c','r','e','a','t','e',0}
 
static const WCHAR getOwnPropertyDescriptorW []
 
static const WCHAR getPrototypeOfW []
 
static const WCHAR definePropertyW [] = {'d','e','f','i','n','e','P','r','o','p','e','r','t','y',0}
 
static const WCHAR definePropertiesW [] = {'d','e','f','i','n','e','P','r','o','p','e','r','t','i','e','s',0}
 
static const WCHAR default_valueW [] = {'[','o','b','j','e','c','t',' ','O','b','j','e','c','t',']',0}
 
static const WCHAR configurableW [] = {'c','o','n','f','i','g','u','r','a','b','l','e',0}
 
static const WCHAR enumerableW [] = {'e','n','u','m','e','r','a','b','l','e',0}
 
static const WCHAR valueW [] = {'v','a','l','u','e',0}
 
static const WCHAR writableW [] = {'w','r','i','t','a','b','l','e',0}
 
static const WCHAR getW [] = {'g','e','t',0}
 
static const WCHAR setW [] = {'s','e','t',0}
 
static const builtin_prop_t Object_props []
 
static const builtin_info_t Object_info
 
static const builtin_info_t ObjectInst_info
 
static const builtin_prop_t ObjectConstr_props []
 
static const builtin_info_t ObjectConstr_info
 

Function Documentation

◆ create_object()

HRESULT create_object ( script_ctx_t ctx,
jsdisp_t constr,
jsdisp_t **  ret 
)

Definition at line 731 of file object.c.

732{
735
736 object = heap_alloc_zero(sizeof(jsdisp_t));
737 if(!object)
738 return E_OUTOFMEMORY;
739
740 hres = init_dispex_from_constr(object, ctx, &ObjectInst_info, constr ? constr : ctx->object_constr);
741 if(FAILED(hres)) {
742 heap_free(object);
743 return hres;
744 }
745
746 *ret = object;
747 return S_OK;
748}
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static const builtin_info_t ObjectInst_info
Definition: object.c:264
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
HRESULT init_dispex_from_constr(jsdisp_t *dispex, script_ctx_t *ctx, const builtin_info_t *builtin_info, jsdisp_t *constr)
Definition: dispex.c:1030
HRESULT hres
Definition: protocol.c:465
int ret

Referenced by create_activex_constr(), create_source_function(), d3drm3_CreateObject(), interp_new_obj(), InterpretedFunction_call(), Object_getOwnPropertyDescriptor(), ObjectConstr_value(), parse_json_value(), and to_object().

◆ create_object_constr()

HRESULT create_object_constr ( script_ctx_t ctx,
jsdisp_t object_prototype,
jsdisp_t **  ret 
)

Definition at line 718 of file object.c.

719{
720 static const WCHAR ObjectW[] = {'O','b','j','e','c','t',0};
721
723 object_prototype, ret);
724}
HRESULT create_builtin_constructor(script_ctx_t *ctx, builtin_invoke_t value_proc, const WCHAR *name, const builtin_info_t *builtin_info, DWORD flags, jsdisp_t *prototype, jsdisp_t **ret)
Definition: function.c:686
static HRESULT ObjectConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: object.c:671
static const builtin_info_t ObjectConstr_info
Definition: object.c:662
static const WCHAR ObjectW[]
Definition: global.c:48
#define PROPF_CONSTR
Definition: jscript.h:98
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by init_constructors().

◆ create_object_prototype()

HRESULT create_object_prototype ( script_ctx_t ctx,
jsdisp_t **  ret 
)

Definition at line 726 of file object.c.

727{
729}
#define NULL
Definition: types.h:112
static const builtin_info_t Object_info
Definition: object.c:255
HRESULT create_dispex(script_ctx_t *ctx, const builtin_info_t *builtin_info, jsdisp_t *prototype, jsdisp_t **dispex)
Definition: dispex.c:957

Referenced by init_global().

◆ jsdisp_define_properties()

static HRESULT jsdisp_define_properties ( script_ctx_t ctx,
jsdisp_t obj,
jsval_t  list_val 
)
static

Definition at line 412 of file object.c.

413{
414 DISPID id = DISPID_STARTENUM;
415 property_desc_t prop_desc;
416 IDispatch *list_disp;
417 jsdisp_t *list_obj, *desc_obj;
418 jsval_t desc_val;
419 BSTR name;
421
422 hres = to_object(ctx, list_val, &list_disp);
423 if(FAILED(hres))
424 return hres;
425
426 if(!(list_obj = to_jsdisp(list_disp))) {
427 FIXME("non-JS list obj\n");
428 IDispatch_Release(list_disp);
429 return E_NOTIMPL;
430 }
431
432 while(1) {
433 hres = jsdisp_next_prop(list_obj, id, TRUE, &id);
434 if(hres != S_OK)
435 break;
436
437 hres = jsdisp_propget(list_obj, id, &desc_val);
438 if(FAILED(hres))
439 break;
440
441 if(!is_object_instance(desc_val) || !get_object(desc_val) || !(desc_obj = to_jsdisp(get_object(desc_val)))) {
442 jsval_release(desc_val);
443 break;
444 }
445
446 hres = to_property_descriptor(ctx, desc_obj, &prop_desc);
447 jsdisp_release(desc_obj);
448 if(FAILED(hres))
449 break;
450
451 hres = IDispatchEx_GetMemberName(&list_obj->IDispatchEx_iface, id, &name);
452 if(SUCCEEDED(hres))
453 hres = jsdisp_define_property(obj, name, &prop_desc);
454 release_property_descriptor(&prop_desc);
455 if(FAILED(hres))
456 break;
457 }
458
459 jsdisp_release(list_obj);
460 return FAILED(hres) ? hres : S_OK;
461}
#define FIXME(fmt,...)
Definition: debug.h:111
#define E_NOTIMPL
Definition: ddrawi.h:99
#define TRUE
Definition: types.h:120
OLECHAR * BSTR
Definition: compat.h:2293
static void release_property_descriptor(property_desc_t *desc)
Definition: object.c:272
static HRESULT to_property_descriptor(script_ctx_t *ctx, jsdisp_t *attr_obj, property_desc_t *desc)
Definition: object.c:282
#define SUCCEEDED(hr)
Definition: intsafe.h:50
jsdisp_t * to_jsdisp(IDispatch *disp)
Definition: dispex.c:914
HRESULT jsdisp_define_property(jsdisp_t *obj, const WCHAR *name, property_desc_t *desc)
Definition: dispex.c:1677
HRESULT jsdisp_next_prop(jsdisp_t *obj, DISPID id, BOOL own_only, DISPID *ret)
Definition: dispex.c:1546
HRESULT jsdisp_propget(jsdisp_t *jsdisp, DISPID id, jsval_t *val)
Definition: dispex.c:1447
HRESULT to_object(script_ctx_t *, jsval_t, IDispatch **) DECLSPEC_HIDDEN
Definition: jsutils.c:816
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:268
void jsval_release(jsval_t val)
Definition: jsutils.c:191
static IDispatch * get_object(jsval_t v)
Definition: jsval.h:219
static BOOL is_object_instance(jsval_t v)
Definition: jsval.h:166
static VARIANTARG static DISPID
Definition: ordinal.c:52
Definition: jsval.h:54
IDispatchEx IDispatchEx_iface
Definition: jscript.h:231
Definition: name.c:39

Referenced by Object_create(), and Object_defineProperties().

◆ Object_create()

static HRESULT Object_create ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 590 of file object.c.

592{
593 jsdisp_t *proto = NULL, *obj;
595
596 if(!argc || (!is_object_instance(argv[0]) && !is_null(argv[0]))) {
597 FIXME("Invalid arg\n");
598 return E_INVALIDARG;
599 }
600
601 TRACE("(%s)\n", debugstr_jsval(argv[0]));
602
603 if(argc && is_object_instance(argv[0])) {
604 if(get_object(argv[0]))
606 if(!proto) {
607 FIXME("Non-JS prototype\n");
608 return E_NOTIMPL;
609 }
610 }else if(!is_null(argv[0])) {
611 FIXME("Invalid arg %s\n", debugstr_jsval(argc ? argv[0] : jsval_undefined()));
612 return E_INVALIDARG;
613 }
614
616 if(FAILED(hres))
617 return hres;
618
619 if(argc >= 2 && !is_undefined(argv[1]))
621
622 if(SUCCEEDED(hres) && r)
623 *r = jsval_obj(obj);
624 else
626 return hres;
627}
static int argc
Definition: ServiceArgs.c:12
#define E_INVALIDARG
Definition: ddrawi.h:101
static HRESULT jsdisp_define_properties(script_ctx_t *ctx, jsdisp_t *obj, jsval_t list_val)
Definition: object.c:412
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
const char * debugstr_jsval(const jsval_t) DECLSPEC_HIDDEN
Definition: jsutils.c:35
static jsval_t jsval_undefined(void)
Definition: jsval.h:137
static jsval_t jsval_obj(jsdisp_t *obj)
Definition: jsval.h:125
static BOOL is_undefined(jsval_t v)
Definition: jsval.h:171
static BOOL is_null(jsval_t v)
Definition: jsval.h:176
#define argv
Definition: mplay32.c:18
#define TRACE(s)
Definition: solgame.cpp:4

◆ Object_defineProperties()

static HRESULT Object_defineProperties ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 508 of file object.c.

510{
511 jsdisp_t *obj;
513
514 if(argc < 1 || !is_object_instance(argv[0]) || !get_object(argv[0]) || !(obj = to_jsdisp(get_object(argv[0])))) {
515 FIXME("not an object\n");
516 return E_NOTIMPL;
517 }
518
519 TRACE("%p\n", obj);
520
522 if(SUCCEEDED(hres) && r)
524 return hres;
525}
static jsdisp_t * jsdisp_addref(jsdisp_t *jsdisp)
Definition: jscript.h:262

◆ Object_defineProperty()

static HRESULT Object_defineProperty ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 463 of file object.c.

465{
466 property_desc_t prop_desc;
467 jsdisp_t *obj, *attr_obj;
468 const WCHAR *name;
469 jsstr_t *name_str;
471
472 TRACE("\n");
473
474 if(argc < 1 || !is_object_instance(argv[0]))
477 if(!obj) {
478 FIXME("not implemented non-JS object\n");
479 return E_NOTIMPL;
480 }
481
482 hres = to_flat_string(ctx, argc >= 2 ? argv[1] : jsval_undefined(), &name_str, &name);
483 if(FAILED(hres))
484 return hres;
485
486 if(argc >= 3 && is_object_instance(argv[2])) {
487 attr_obj = to_jsdisp(get_object(argv[2]));
488 if(attr_obj) {
489 hres = to_property_descriptor(ctx, attr_obj, &prop_desc);
490 }else {
491 FIXME("not implemented non-JS object\n");
492 hres = E_NOTIMPL;
493 }
494 }else {
496 }
497 jsstr_release(name_str);
498 if(FAILED(hres))
499 return hres;
500
501 hres = jsdisp_define_property(obj, name, &prop_desc);
502 release_property_descriptor(&prop_desc);
503 if(SUCCEEDED(hres) && r)
505 return hres;
506}
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440
#define JS_E_OBJECT_EXPECTED
Definition: jscript.h:555
HRESULT to_flat_string(script_ctx_t *, jsval_t, jsstr_t **, const WCHAR **) DECLSPEC_HIDDEN
Definition: jsutils.c:798
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
Definition: jsstr.h:39

◆ Object_destructor()

static void Object_destructor ( jsdisp_t dispex)
static

Definition at line 241 of file object.c.

242{
243 heap_free(dispex);
244}

◆ Object_get_value()

static HRESULT Object_get_value ( script_ctx_t ctx,
jsdisp_t jsthis,
jsval_t r 
)
static

Definition at line 227 of file object.c.

228{
229 jsstr_t *ret;
230
231 TRACE("\n");
232
234 if(!ret)
235 return E_OUTOFMEMORY;
236
237 *r = jsval_string(ret);
238 return S_OK;
239}
static const WCHAR default_valueW[]
Definition: object.c:44
static jsstr_t * jsstr_alloc(const WCHAR *str)
Definition: jsstr.h:103
static jsval_t jsval_string(jsstr_t *str)
Definition: jsval.h:109

◆ Object_getOwnPropertyDescriptor()

static HRESULT Object_getOwnPropertyDescriptor ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 527 of file object.c.

529{
530 property_desc_t prop_desc;
531 jsdisp_t *obj, *desc_obj;
532 const WCHAR *name;
533 jsstr_t *name_str;
535
536 TRACE("\n");
537
538 if(argc < 1 || !is_object_instance(argv[0]))
541 if(!obj) {
542 FIXME("not implemented non-JS object\n");
543 return E_NOTIMPL;
544 }
545
546 hres = to_flat_string(ctx, argc >= 2 ? argv[1] : jsval_undefined(), &name_str, &name);
547 if(FAILED(hres))
548 return hres;
549
550 hres = jsdisp_get_own_property(obj, name, FALSE, &prop_desc);
551 jsstr_release(name_str);
552 if(hres == DISP_E_UNKNOWNNAME) {
553 if(r) *r = jsval_undefined();
554 return S_OK;
555 }
556 if(FAILED(hres))
557 return hres;
558
559 hres = create_object(ctx, NULL, &desc_obj);
560 if(FAILED(hres))
561 return hres;
562
563 if(prop_desc.explicit_getter || prop_desc.explicit_setter) {
565 prop_desc.getter ? jsval_obj(prop_desc.getter) : jsval_undefined());
566 if(SUCCEEDED(hres))
568 prop_desc.setter ? jsval_obj(prop_desc.setter) : jsval_undefined());
569 }else {
570 hres = jsdisp_propput_name(desc_obj, valueW, prop_desc.value);
571 if(SUCCEEDED(hres))
573 jsval_bool(!!(prop_desc.flags & PROPF_WRITABLE)));
574 }
575 if(SUCCEEDED(hres))
577 jsval_bool(!!(prop_desc.flags & PROPF_ENUMERABLE)));
578 if(SUCCEEDED(hres))
580 jsval_bool(!!(prop_desc.flags & PROPF_CONFIGURABLE)));
581
582 release_property_descriptor(&prop_desc);
583 if(SUCCEEDED(hres) && r)
584 *r = jsval_obj(desc_obj);
585 else
586 jsdisp_release(desc_obj);
587 return hres;
588}
#define FALSE
Definition: types.h:117
static const WCHAR valueW[]
Definition: object.c:48
HRESULT create_object(script_ctx_t *ctx, jsdisp_t *constr, jsdisp_t **ret)
Definition: object.c:731
static const WCHAR writableW[]
Definition: object.c:49
static const WCHAR getW[]
Definition: object.c:50
static const WCHAR enumerableW[]
Definition: object.c:47
static const WCHAR configurableW[]
Definition: object.c:46
static const WCHAR setW[]
Definition: object.c:51
HRESULT jsdisp_get_own_property(jsdisp_t *obj, const WCHAR *name, BOOL flags_only, property_desc_t *desc)
Definition: dispex.c:1633
HRESULT jsdisp_define_data_property(jsdisp_t *obj, const WCHAR *name, unsigned flags, jsval_t value)
Definition: dispex.c:1801
HRESULT jsdisp_propput_name(jsdisp_t *obj, const WCHAR *name, jsval_t val)
Definition: dispex.c:1344
#define PROPF_WRITABLE
Definition: jscript.h:101
#define PROPF_CONFIGURABLE
Definition: jscript.h:102
#define PROPF_ALL
Definition: jscript.h:103
#define PROPF_ENUMERABLE
Definition: jscript.h:100
static jsval_t jsval_bool(BOOL b)
Definition: jsval.h:101
BOOL explicit_setter
Definition: jscript.h:395
jsdisp_t * setter
Definition: jscript.h:396
unsigned flags
Definition: jscript.h:389
BOOL explicit_getter
Definition: jscript.h:393
jsdisp_t * getter
Definition: jscript.h:394
jsval_t value
Definition: jscript.h:392
#define DISP_E_UNKNOWNNAME
Definition: winerror.h:2515

◆ Object_getPrototypeOf()

static HRESULT Object_getPrototypeOf ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 629 of file object.c.

631{
632 jsdisp_t *obj;
633
634 if(!argc || !is_object_instance(argv[0])) {
635 FIXME("invalid arguments\n");
636 return E_NOTIMPL;
637 }
638
639 TRACE("(%s)\n", debugstr_jsval(argv[1]));
640
642 if(!obj) {
643 FIXME("Non-JS object\n");
644 return E_NOTIMPL;
645 }
646
647 if(r)
648 *r = obj->prototype
649 ? jsval_obj(jsdisp_addref(obj->prototype))
650 : jsval_null();
651 return S_OK;
652}
static jsval_t jsval_null(void)
Definition: jsval.h:130

◆ Object_hasOwnProperty()

static HRESULT Object_hasOwnProperty ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 128 of file object.c.

130{
131 jsstr_t *name;
132 DISPID id;
133 BSTR bstr;
135
136 TRACE("\n");
137
138 if(!argc) {
139 if(r)
140 *r = jsval_bool(FALSE);
141 return S_OK;
142 }
143
144 hres = to_string(ctx, argv[0], &name);
145 if(FAILED(hres))
146 return hres;
147
148 if(is_jsdisp(jsthis)) {
149 property_desc_t prop_desc;
150 const WCHAR *name_str;
151
152 name_str = jsstr_flatten(name);
153 if(!name_str) {
155 return E_OUTOFMEMORY;
156 }
157
158 hres = jsdisp_get_own_property(jsthis->u.jsdisp, name_str, TRUE, &prop_desc);
161 return hres;
162
163 if(r) *r = jsval_bool(hres == S_OK);
164 return S_OK;
165 }
166
167
169 if(bstr)
170 jsstr_flush(name, bstr);
172 if(!bstr)
173 return E_OUTOFMEMORY;
174
175 if(is_dispex(jsthis))
176 hres = IDispatchEx_GetDispID(jsthis->u.dispex, bstr, make_grfdex(ctx, fdexNameCaseSensitive), &id);
177 else
178 hres = IDispatch_GetIDsOfNames(jsthis->u.disp, &IID_NULL, &bstr, 1, ctx->lcid, &id);
179
180 SysFreeString(bstr);
181 if(r)
183 return S_OK;
184}
GLuint id
Definition: glext.h:5910
static HRESULT to_string(VARIANT *src, BSTR *dst)
Definition: host.c:47
static BOOL is_jsdisp(vdisp_t *vdisp)
Definition: jscript.h:157
static BOOL is_dispex(vdisp_t *vdisp)
Definition: jscript.h:162
static DWORD make_grfdex(script_ctx_t *ctx, DWORD flags)
Definition: jscript.h:519
static const WCHAR * jsstr_flatten(jsstr_t *str)
Definition: jsstr.h:139
static unsigned jsstr_length(jsstr_t *str)
Definition: jsstr.h:58
static unsigned jsstr_flush(jsstr_t *str, WCHAR *buf)
Definition: jsstr.h:148
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:271
BSTR WINAPI SysAllocStringLen(const OLECHAR *str, unsigned int len)
Definition: oleaut.c:339
#define IID_NULL
Definition: guiddef.h:98
IDispatchEx * dispex
Definition: jscript.h:143
union vdisp_t::@443 u
IDispatch * disp
Definition: jscript.h:142
jsdisp_t * jsdisp
Definition: jscript.h:144

◆ Object_isPrototypeOf()

static HRESULT Object_isPrototypeOf ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 220 of file object.c.

222{
223 FIXME("\n");
224 return E_NOTIMPL;
225}

◆ Object_propertyIsEnumerable()

static HRESULT Object_propertyIsEnumerable ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 186 of file object.c.

188{
189 property_desc_t prop_desc;
190 const WCHAR *name;
191 jsstr_t *name_str;
193
194 TRACE("\n");
195
196 if(argc != 1) {
197 FIXME("argc %d not supported\n", argc);
198 return E_NOTIMPL;
199 }
200
201 if(!is_jsdisp(jsthis)) {
202 FIXME("Host object this\n");
203 return E_FAIL;
204 }
205
206 hres = to_flat_string(ctx, argv[0], &name_str, &name);
207 if(FAILED(hres))
208 return hres;
209
210 hres = jsdisp_get_own_property(jsthis->u.jsdisp, name, TRUE, &prop_desc);
211 jsstr_release(name_str);
213 return hres;
214
215 if(r)
216 *r = jsval_bool(hres == S_OK && (prop_desc.flags & PROPF_ENUMERABLE) != 0);
217 return S_OK;
218}
#define E_FAIL
Definition: ddrawi.h:102

◆ Object_toLocaleString()

static HRESULT Object_toLocaleString ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 103 of file object.c.

105{
106 TRACE("\n");
107
108 if(!is_jsdisp(jsthis)) {
109 FIXME("Host object this\n");
110 return E_FAIL;
111 }
112
113 return jsdisp_call_name(jsthis->u.jsdisp, toStringW, DISPATCH_METHOD, 0, NULL, r);
114}
static const WCHAR toStringW[]
Definition: object.c:27
HRESULT jsdisp_call_name(jsdisp_t *disp, const WCHAR *name, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: dispex.c:1124
#define DISPATCH_METHOD
Definition: oleauto.h:1006

◆ Object_toString()

static HRESULT Object_toString ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 53 of file object.c.

55{
56 jsdisp_t *jsdisp;
57 const WCHAR *str;
58
59 static const WCHAR formatW[] = {'[','o','b','j','e','c','t',' ','%','s',']',0};
60
61 static const WCHAR arrayW[] = {'A','r','r','a','y',0};
62 static const WCHAR booleanW[] = {'B','o','o','l','e','a','n',0};
63 static const WCHAR dateW[] = {'D','a','t','e',0};
64 static const WCHAR errorW[] = {'E','r','r','o','r',0};
65 static const WCHAR functionW[] = {'F','u','n','c','t','i','o','n',0};
66 static const WCHAR mathW[] = {'M','a','t','h',0};
67 static const WCHAR numberW[] = {'N','u','m','b','e','r',0};
68 static const WCHAR objectW[] = {'O','b','j','e','c','t',0};
69 static const WCHAR regexpW[] = {'R','e','g','E','x','p',0};
70 static const WCHAR stringW[] = {'S','t','r','i','n','g',0};
71 /* Keep in sync with jsclass_t enum */
72 static const WCHAR *names[] = {NULL, arrayW, booleanW, dateW, objectW, errorW,
74
75 TRACE("\n");
76
77 jsdisp = get_jsdisp(jsthis);
78 if(!jsdisp) {
79 str = objectW;
80 }else if(names[jsdisp->builtin_info->class]) {
81 str = names[jsdisp->builtin_info->class];
82 }else {
84 FIXME("jdisp->builtin_info->class = %d\n", jsdisp->builtin_info->class);
85 return E_FAIL;
86 }
87
88 if(r) {
89 jsstr_t *ret;
90 WCHAR *ptr;
91
93 if(!ret)
94 return E_OUTOFMEMORY;
95
96 swprintf(ptr, formatW, str);
97 *r = jsval_string(ret);
98 }
99
100 return S_OK;
101}
#define lstrlenW
Definition: compat.h:750
#define swprintf
Definition: precomp.h:40
#define assert(x)
Definition: debug.h:53
static const WCHAR booleanW[]
Definition: engine.c:34
static const WCHAR stringW[]
Definition: engine.c:38
static const WCHAR objectW[]
Definition: engine.c:37
static const WCHAR numberW[]
Definition: engine.c:36
static const WCHAR functionW[]
Definition: engine.c:35
GLuint GLuint * names
Definition: glext.h:11545
static const WCHAR errorW[]
Definition: htmlevent.c:61
@ JSCLASS_NONE
Definition: jscript.h:120
static jsdisp_t * get_jsdisp(vdisp_t *vdisp)
Definition: jscript.h:199
jsstr_t * jsstr_alloc_buf(unsigned len, WCHAR **buf)
Definition: jsstr.c:69
static PVOID ptr
Definition: dispmode.c:27
const WCHAR * str
jsclass_t class
Definition: jscript.h:219
const builtin_info_t * builtin_info
Definition: jscript.h:242

◆ Object_valueOf()

static HRESULT Object_valueOf ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 116 of file object.c.

118{
119 TRACE("\n");
120
121 if(r) {
122 IDispatch_AddRef(jsthis->u.disp);
123 *r = jsval_disp(jsthis->u.disp);
124 }
125 return S_OK;
126}
static jsval_t jsval_disp(IDispatch *obj)
Definition: jsval.h:117

◆ ObjectConstr_value()

static HRESULT ObjectConstr_value ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 671 of file object.c.

673{
675
676 TRACE("\n");
677
678 switch(flags) {
679 case DISPATCH_METHOD:
680 case DISPATCH_CONSTRUCT: {
681 jsdisp_t *obj;
682
683 if(argc) {
684 if(!is_undefined(argv[0]) && !is_null(argv[0]) && (!is_object_instance(argv[0]) || get_object(argv[0]))) {
685 IDispatch *disp;
686
687 hres = to_object(ctx, argv[0], &disp);
688 if(FAILED(hres))
689 return hres;
690
691 if(r)
692 *r = jsval_disp(disp);
693 else
694 IDispatch_Release(disp);
695 return S_OK;
696 }
697 }
698
700 if(FAILED(hres))
701 return hres;
702
703 if(r)
704 *r = jsval_obj(obj);
705 else
707 break;
708 }
709
710 default:
711 FIXME("unimplemented flags: %x\n", flags);
712 return E_NOTIMPL;
713 }
714
715 return S_OK;
716}
GLbitfield flags
Definition: glext.h:7161

Referenced by create_object_constr().

◆ release_property_descriptor()

static void release_property_descriptor ( property_desc_t desc)
static

Definition at line 272 of file object.c.

273{
274 if(desc->explicit_value)
275 jsval_release(desc->value);
276 if(desc->getter)
277 jsdisp_release(desc->getter);
278 if(desc->setter)
279 jsdisp_release(desc->setter);
280}
static const WCHAR desc[]
Definition: protectdata.c:36

Referenced by jsdisp_define_properties(), Object_defineProperty(), Object_getOwnPropertyDescriptor(), and to_property_descriptor().

◆ to_property_descriptor()

static HRESULT to_property_descriptor ( script_ctx_t ctx,
jsdisp_t attr_obj,
property_desc_t desc 
)
static

Definition at line 282 of file object.c.

283{
284 DISPID id;
285 jsval_t v;
286 BOOL b;
288
289 memset(desc, 0, sizeof(*desc));
290 desc->value = jsval_undefined();
291
292 hres = jsdisp_get_id(attr_obj, enumerableW, 0, &id);
293 if(SUCCEEDED(hres)) {
294 desc->mask |= PROPF_ENUMERABLE;
295 hres = jsdisp_propget(attr_obj, id, &v);
296 if(FAILED(hres))
297 return hres;
298 hres = to_boolean(v, &b);
300 if(FAILED(hres))
301 return hres;
302 if(b)
303 desc->flags |= PROPF_ENUMERABLE;
304 }else if(hres != DISP_E_UNKNOWNNAME) {
305 return hres;
306 }
307
308 hres = jsdisp_get_id(attr_obj, configurableW, 0, &id);
309 if(SUCCEEDED(hres)) {
310 desc->mask |= PROPF_CONFIGURABLE;
311 hres = jsdisp_propget(attr_obj, id, &v);
312 if(FAILED(hres))
313 return hres;
314 hres = to_boolean(v, &b);
316 if(FAILED(hres))
317 return hres;
318 if(b)
319 desc->flags |= PROPF_CONFIGURABLE;
320 }else if(hres != DISP_E_UNKNOWNNAME) {
321 return hres;
322 }
323
324 hres = jsdisp_get_id(attr_obj, valueW, 0, &id);
325 if(SUCCEEDED(hres)) {
326 hres = jsdisp_propget(attr_obj, id, &desc->value);
327 if(FAILED(hres))
328 return hres;
329 desc->explicit_value = TRUE;
330 }else if(hres != DISP_E_UNKNOWNNAME) {
331 return hres;
332 }
333
334 hres = jsdisp_get_id(attr_obj, writableW, 0, &id);
335 if(SUCCEEDED(hres)) {
336 desc->mask |= PROPF_WRITABLE;
337 hres = jsdisp_propget(attr_obj, id, &v);
338 if(SUCCEEDED(hres)) {
339 hres = to_boolean(v, &b);
341 if(SUCCEEDED(hres) && b)
342 desc->flags |= PROPF_WRITABLE;
343 }
344 }else if(hres == DISP_E_UNKNOWNNAME) {
345 hres = S_OK;
346 }
347 if(FAILED(hres)) {
349 return hres;
350 }
351
352 hres = jsdisp_get_id(attr_obj, getW, 0, &id);
353 if(SUCCEEDED(hres)) {
354 desc->explicit_getter = TRUE;
355 hres = jsdisp_propget(attr_obj, id, &v);
356 if(SUCCEEDED(hres) && !is_undefined(v)) {
357 if(!is_object_instance(v)) {
358 FIXME("getter is not an object\n");
360 hres = E_FAIL;
361 }else {
362 /* FIXME: Check IsCallable */
363 desc->getter = to_jsdisp(get_object(v));
364 if(!desc->getter)
365 FIXME("getter is not JS object\n");
366 }
367 }
368 }else if(hres == DISP_E_UNKNOWNNAME) {
369 hres = S_OK;
370 }
371 if(FAILED(hres)) {
373 return hres;
374 }
375
376 hres = jsdisp_get_id(attr_obj, setW, 0, &id);
377 if(SUCCEEDED(hres)) {
378 desc->explicit_setter = TRUE;
379 hres = jsdisp_propget(attr_obj, id, &v);
380 if(SUCCEEDED(hres) && !is_undefined(v)) {
381 if(!is_object_instance(v)) {
382 FIXME("setter is not an object\n");
384 hres = E_FAIL;
385 }else {
386 /* FIXME: Check IsCallable */
387 desc->setter = to_jsdisp(get_object(v));
388 if(!desc->setter)
389 FIXME("setter is not JS object\n");
390 }
391 }
392 }else if(hres == DISP_E_UNKNOWNNAME) {
393 hres = S_OK;
394 }
395 if(FAILED(hres)) {
397 return hres;
398 }
399
400 if(desc->explicit_getter || desc->explicit_setter) {
401 if(desc->explicit_value)
403 else if(desc->mask & PROPF_WRITABLE)
405 }
406
407 if(FAILED(hres))
409 return hres;
410}
unsigned int BOOL
Definition: ntddk_ex.h:94
const GLdouble * v
Definition: gl.h:2040
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
HRESULT jsdisp_get_id(jsdisp_t *jsdisp, const WCHAR *name, DWORD flags, DISPID *id)
Definition: dispex.c:1067
#define JS_E_INVALID_WRITABLE_PROP_DESC
Definition: jscript.h:573
HRESULT to_boolean(jsval_t, BOOL *) DECLSPEC_HIDDEN
Definition: jsutils.c:472
#define JS_E_PROP_DESC_MISMATCH
Definition: jscript.h:572
#define b
Definition: ke_i.h:79
#define memset(x, y, z)
Definition: compat.h:39

Referenced by jsdisp_define_properties(), and Object_defineProperty().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( jscript  )

Variable Documentation

◆ configurableW

const WCHAR configurableW[] = {'c','o','n','f','i','g','u','r','a','b','l','e',0}
static

Definition at line 46 of file object.c.

Referenced by Object_getOwnPropertyDescriptor(), and to_property_descriptor().

◆ createW

const WCHAR createW[] = {'c','r','e','a','t','e',0}
static

Definition at line 35 of file object.c.

Referenced by ME_WmCreate().

◆ default_valueW

const WCHAR default_valueW[] = {'[','o','b','j','e','c','t',' ','O','b','j','e','c','t',']',0}
static

Definition at line 44 of file object.c.

Referenced by Object_get_value().

◆ definePropertiesW

const WCHAR definePropertiesW[] = {'d','e','f','i','n','e','P','r','o','p','e','r','t','i','e','s',0}
static

Definition at line 42 of file object.c.

◆ definePropertyW

const WCHAR definePropertyW[] = {'d','e','f','i','n','e','P','r','o','p','e','r','t','y',0}
static

Definition at line 40 of file object.c.

◆ enumerableW

const WCHAR enumerableW[] = {'e','n','u','m','e','r','a','b','l','e',0}
static

Definition at line 47 of file object.c.

Referenced by Object_getOwnPropertyDescriptor(), and to_property_descriptor().

◆ getOwnPropertyDescriptorW

const WCHAR getOwnPropertyDescriptorW[]
static
Initial value:
=
{'g','e','t','O','w','n','P','r','o','p','e','r','t','y','D','e','s','c','r','i','p','t','o','r',0}

Definition at line 36 of file object.c.

◆ getPrototypeOfW

const WCHAR getPrototypeOfW[]
static
Initial value:
=
{'g','e','t','P','r','o','t','o','t','y','p','e','O','f',0}

Definition at line 38 of file object.c.

◆ getW

◆ hasOwnPropertyW

const WCHAR hasOwnPropertyW[] = {'h','a','s','O','w','n','P','r','o','p','e','r','t','y',0}
static

Definition at line 30 of file object.c.

◆ isPrototypeOfW

const WCHAR isPrototypeOfW[] = {'i','s','P','r','o','t','o','t','y','p','e','O','f',0}
static

Definition at line 33 of file object.c.

◆ Object_info

const builtin_info_t Object_info
static
Initial value:
= {
}
#define ARRAY_SIZE(A)
Definition: main.h:33
static HRESULT Object_get_value(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
Definition: object.c:227
static const builtin_prop_t Object_props[]
Definition: object.c:246
static void Object_destructor(jsdisp_t *dispex)
Definition: object.c:241
@ JSCLASS_OBJECT
Definition: jscript.h:130

Definition at line 255 of file object.c.

Referenced by create_object_prototype().

◆ Object_props

const builtin_prop_t Object_props[]
static
Initial value:
= {
}
static const WCHAR valueOfW[]
Definition: object.c:29
static const WCHAR propertyIsEnumerableW[]
Definition: object.c:31
static HRESULT Object_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: object.c:53
static HRESULT Object_propertyIsEnumerable(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: object.c:186
static const WCHAR hasOwnPropertyW[]
Definition: object.c:30
static const WCHAR toLocaleStringW[]
Definition: object.c:28
static HRESULT Object_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: object.c:116
static const WCHAR isPrototypeOfW[]
Definition: object.c:33
static HRESULT Object_toLocaleString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: object.c:103
static HRESULT Object_hasOwnProperty(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: object.c:128
static HRESULT Object_isPrototypeOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: object.c:220
#define PROPF_METHOD
Definition: jscript.h:97

Definition at line 246 of file object.c.

◆ ObjectConstr_info

const builtin_info_t ObjectConstr_info
static
Initial value:
= {
}
static const builtin_prop_t ObjectConstr_props[]
Definition: object.c:654
#define DEFAULT_FUNCTION_VALUE
Definition: jscript.h:315
@ JSCLASS_FUNCTION
Definition: jscript.h:126

Definition at line 662 of file object.c.

Referenced by create_object_constr().

◆ ObjectConstr_props

const builtin_prop_t ObjectConstr_props[]
static
Initial value:
= {
}
static HRESULT Object_create(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: object.c:590
static const WCHAR createW[]
Definition: object.c:35
static const WCHAR getOwnPropertyDescriptorW[]
Definition: object.c:36
static HRESULT Object_getOwnPropertyDescriptor(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: object.c:527
static const WCHAR definePropertiesW[]
Definition: object.c:42
static HRESULT Object_defineProperties(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: object.c:508
static const WCHAR getPrototypeOfW[]
Definition: object.c:38
static HRESULT Object_defineProperty(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: object.c:463
static HRESULT Object_getPrototypeOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: object.c:629
static const WCHAR definePropertyW[]
Definition: object.c:40
#define PROPF_ES5
Definition: jscript.h:108

Definition at line 654 of file object.c.

◆ ObjectInst_info

const builtin_info_t ObjectInst_info
static
Initial value:

Definition at line 264 of file object.c.

Referenced by create_object().

◆ propertyIsEnumerableW

const WCHAR propertyIsEnumerableW[]
static
Initial value:
=
{'p','r','o','p','e','r','t','y','I','s','E','n','u','m','e','r','a','b','l','e',0}

Definition at line 31 of file object.c.

◆ setW

const WCHAR setW[] = {'s','e','t',0}
static

Definition at line 51 of file object.c.

Referenced by Object_getOwnPropertyDescriptor(), and to_property_descriptor().

◆ toLocaleStringW

const WCHAR toLocaleStringW[] = {'t','o','L','o','c','a','l','e','S','t','r','i','n','g',0}
static

Definition at line 28 of file object.c.

◆ toStringW

const WCHAR toStringW[] = {'t','o','S','t','r','i','n','g',0}
static

Definition at line 27 of file object.c.

Referenced by Object_toLocaleString().

◆ valueOfW

const WCHAR valueOfW[] = {'v','a','l','u','e','O','f',0}
static

Definition at line 29 of file object.c.

◆ valueW

◆ writableW

const WCHAR writableW[] = {'w','r','i','t','a','b','l','e',0}
static

Definition at line 49 of file object.c.

Referenced by Object_getOwnPropertyDescriptor(), and to_property_descriptor().