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

Method SetAtom

value.go:719–730  ·  view source on GitHub ↗

SetAtom sets a property by atom key.

(atom *Atom, val *Value)

Source from the content-addressed store, hash-verified

717
718// SetAtom sets a property by atom key.
719func (v *Value) SetAtom(atom *Atom, val *Value) bool {
720 if !v.isAlive() || atom == nil || atom.ctx == nil || atom.ctx != v.ctx || !atom.ctx.hasValidRef() || !val.belongsTo(v.ctx) {
721 return false
722 }
723 // JS_SetProperty consumes `dup` but borrows `atom`.
724 dup := C.JS_DupValue(v.ctx.ref, val.ref)
725 ret := C.JS_SetProperty(v.ctx.ref, v.ref, atom.ref, dup)
726 if ret < 0 {
727 return false
728 }
729 return ret == 1
730}
731
732// GetInt64 gets a property by int64 key.
733func (v *Value) GetInt64(idx int64) *Value {

Calls 3

isAliveMethod · 0.95
hasValidRefMethod · 0.80
belongsToMethod · 0.80