123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302 |
- package goja
- import (
- "reflect"
- "github.com/dop251/goja/unistring"
- )
- type lazyObject struct {
- val *Object
- create func(*Object) objectImpl
- }
- func (o *lazyObject) className() string {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.className()
- }
- func (o *lazyObject) getIdx(p valueInt, receiver Value) Value {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.getIdx(p, receiver)
- }
- func (o *lazyObject) getSym(p *Symbol, receiver Value) Value {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.getSym(p, receiver)
- }
- func (o *lazyObject) getOwnPropIdx(idx valueInt) Value {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.getOwnPropIdx(idx)
- }
- func (o *lazyObject) getOwnPropSym(s *Symbol) Value {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.getOwnPropSym(s)
- }
- func (o *lazyObject) hasPropertyIdx(idx valueInt) bool {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.hasPropertyIdx(idx)
- }
- func (o *lazyObject) hasPropertySym(s *Symbol) bool {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.hasPropertySym(s)
- }
- func (o *lazyObject) hasOwnPropertyIdx(idx valueInt) bool {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.hasOwnPropertyIdx(idx)
- }
- func (o *lazyObject) hasOwnPropertySym(s *Symbol) bool {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.hasOwnPropertySym(s)
- }
- func (o *lazyObject) defineOwnPropertyStr(name unistring.String, desc PropertyDescriptor, throw bool) bool {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.defineOwnPropertyStr(name, desc, throw)
- }
- func (o *lazyObject) defineOwnPropertyIdx(name valueInt, desc PropertyDescriptor, throw bool) bool {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.defineOwnPropertyIdx(name, desc, throw)
- }
- func (o *lazyObject) defineOwnPropertySym(name *Symbol, desc PropertyDescriptor, throw bool) bool {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.defineOwnPropertySym(name, desc, throw)
- }
- func (o *lazyObject) deleteIdx(idx valueInt, throw bool) bool {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.deleteIdx(idx, throw)
- }
- func (o *lazyObject) deleteSym(s *Symbol, throw bool) bool {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.deleteSym(s, throw)
- }
- func (o *lazyObject) getStr(name unistring.String, receiver Value) Value {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.getStr(name, receiver)
- }
- func (o *lazyObject) getOwnPropStr(name unistring.String) Value {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.getOwnPropStr(name)
- }
- func (o *lazyObject) setOwnStr(p unistring.String, v Value, throw bool) bool {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.setOwnStr(p, v, throw)
- }
- func (o *lazyObject) setOwnIdx(p valueInt, v Value, throw bool) bool {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.setOwnIdx(p, v, throw)
- }
- func (o *lazyObject) setOwnSym(p *Symbol, v Value, throw bool) bool {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.setOwnSym(p, v, throw)
- }
- func (o *lazyObject) setForeignStr(p unistring.String, v, receiver Value, throw bool) (bool, bool) {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.setForeignStr(p, v, receiver, throw)
- }
- func (o *lazyObject) setForeignIdx(p valueInt, v, receiver Value, throw bool) (bool, bool) {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.setForeignIdx(p, v, receiver, throw)
- }
- func (o *lazyObject) setForeignSym(p *Symbol, v, receiver Value, throw bool) (bool, bool) {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.setForeignSym(p, v, receiver, throw)
- }
- func (o *lazyObject) hasPropertyStr(name unistring.String) bool {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.hasPropertyStr(name)
- }
- func (o *lazyObject) hasOwnPropertyStr(name unistring.String) bool {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.hasOwnPropertyStr(name)
- }
- func (o *lazyObject) _putProp(unistring.String, Value, bool, bool, bool) Value {
- panic("cannot use _putProp() in lazy object")
- }
- func (o *lazyObject) _putSym(*Symbol, Value) {
- panic("cannot use _putSym() in lazy object")
- }
- func (o *lazyObject) toPrimitiveNumber() Value {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.toPrimitiveNumber()
- }
- func (o *lazyObject) toPrimitiveString() Value {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.toPrimitiveString()
- }
- func (o *lazyObject) toPrimitive() Value {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.toPrimitive()
- }
- func (o *lazyObject) assertCallable() (call func(FunctionCall) Value, ok bool) {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.assertCallable()
- }
- func (o *lazyObject) assertConstructor() func(args []Value, newTarget *Object) *Object {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.assertConstructor()
- }
- func (o *lazyObject) deleteStr(name unistring.String, throw bool) bool {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.deleteStr(name, throw)
- }
- func (o *lazyObject) proto() *Object {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.proto()
- }
- func (o *lazyObject) hasInstance(v Value) bool {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.hasInstance(v)
- }
- func (o *lazyObject) isExtensible() bool {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.isExtensible()
- }
- func (o *lazyObject) preventExtensions(throw bool) bool {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.preventExtensions(throw)
- }
- func (o *lazyObject) iterateStringKeys() iterNextFunc {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.iterateStringKeys()
- }
- func (o *lazyObject) iterateSymbols() iterNextFunc {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.iterateSymbols()
- }
- func (o *lazyObject) iterateKeys() iterNextFunc {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.iterateKeys()
- }
- func (o *lazyObject) export(ctx *objectExportCtx) interface{} {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.export(ctx)
- }
- func (o *lazyObject) exportType() reflect.Type {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.exportType()
- }
- func (o *lazyObject) equal(other objectImpl) bool {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.equal(other)
- }
- func (o *lazyObject) stringKeys(all bool, accum []Value) []Value {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.stringKeys(all, accum)
- }
- func (o *lazyObject) symbols(all bool, accum []Value) []Value {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.symbols(all, accum)
- }
- func (o *lazyObject) keys(all bool, accum []Value) []Value {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.keys(all, accum)
- }
- func (o *lazyObject) setProto(proto *Object, throw bool) bool {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.setProto(proto, throw)
- }
- func (o *lazyObject) sortLen() int64 {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.sortLen()
- }
- func (o *lazyObject) sortGet(i int64) Value {
- obj := o.create(o.val)
- o.val.self = obj
- return obj.sortGet(i)
- }
- func (o *lazyObject) swap(i, j int64) {
- obj := o.create(o.val)
- o.val.self = obj
- obj.swap(i, j)
- }
|