SetAtom sets a property by atom key.
(atom *Atom, val *Value)
| 717 | |
| 718 | // SetAtom sets a property by atom key. |
| 719 | func (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. |
| 733 | func (v *Value) GetInt64(idx int64) *Value { |