MCPcopy Create free account
hub / github.com/buke/quickjs-go / DefinePropertyValue

Method DefinePropertyValue

value.go:638–652  ·  view source on GitHub ↗

DefinePropertyValue defines a value property by name.

(name string, value *Value, flags int)

Source from the content-addressed store, hash-verified

636
637// DefinePropertyValue defines a value property by name.
638func (v *Value) DefinePropertyValue(name string, value *Value, flags int) bool {
639 if !v.isAlive() || !value.belongsTo(v.ctx) {
640 return false
641 }
642 atom := v.ctx.NewAtom(name)
643 defer atom.Free()
644
645 // JS_DefinePropertyValue consumes `dup` but does not consume `atom`.
646 dup := C.JS_DupValue(v.ctx.ref, value.ref)
647 ret := C.JS_DefinePropertyValue(v.ctx.ref, v.ref, atom.ref, dup, C.int(flags))
648 if ret < 0 {
649 return false
650 }
651 return ret == 1
652}
653
654// DefinePropertyGetSet defines an accessor property by name.
655func (v *Value) DefinePropertyGetSet(name string, getter *Value, setter *Value, flags int) bool {

Calls 4

isAliveMethod · 0.95
FreeMethod · 0.95
belongsToMethod · 0.80
NewAtomMethod · 0.80