OwnProperty gets a full own property descriptor by name.
(name string)
| 685 | |
| 686 | // OwnProperty gets a full own property descriptor by name. |
| 687 | func (v *Value) OwnProperty(name string) (*PropertyDescriptor, bool) { |
| 688 | if !v.isAlive() { |
| 689 | return nil, false |
| 690 | } |
| 691 | atom := v.ctx.NewAtom(name) |
| 692 | defer atom.Free() |
| 693 | |
| 694 | var desc C.JSPropertyDescriptor |
| 695 | ret := C.JS_GetOwnProperty(v.ctx.ref, &desc, v.ref, atom.ref) |
| 696 | if ret <= 0 { |
| 697 | return nil, false |
| 698 | } |
| 699 | |
| 700 | result := &PropertyDescriptor{ |
| 701 | Flags: int(desc.flags), |
| 702 | Value: &Value{ctx: v.ctx, ref: desc.value}, |
| 703 | Getter: &Value{ctx: v.ctx, ref: desc.getter}, |
| 704 | Setter: &Value{ctx: v.ctx, ref: desc.setter}, |
| 705 | } |
| 706 | return result, true |
| 707 | } |
| 708 | |
| 709 | // GetAtom gets a property by atom key. |
| 710 | func (v *Value) GetAtom(atom *Atom) *Value { |