MCPcopy Create free account
hub / github.com/GNOME/gjs / field_getter_impl

Method field_getter_impl

gi/object.cpp:617–646  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

615}
616
617bool ObjectInstance::field_getter_impl(JSContext* cx,
618 GI::AutoFieldInfo const& field,
619 JS::MutableHandleValue rval) {
620 if (!check_gobject_finalized("get any property from"))
621 return true;
622
623 GIArgument arg = { 0 };
624
625 gjs_debug_jsprop(GJS_DEBUG_GOBJECT, "Overriding %s with GObject field",
626 field.name());
627
628 GI::AutoTypeInfo type{field.type_info()};
629 if (!GI::is_supported_gobject_field_type(type)) {
630 gjs_throw(cx,
631 "Can't get field %s; GObject introspection supports only "
632 "fields with simple types, not %s",
633 field.name(), type.display_string());
634 return false;
635 }
636
637 if (field.read(m_ptr, &arg).isErr()) {
638 gjs_throw(cx, "Error getting field %s from object", field.name());
639 return false;
640 }
641
642 return gjs_value_from_gi_argument(cx, rval, type, GJS_ARGUMENT_FIELD,
643 GI_TRANSFER_EVERYTHING, &arg);
644 /* transfer is irrelevant because g_field_info_get_field() doesn't handle
645 * boxed types */
646}
647
648/* Dynamic setter for GObject properties. Returns false on OOM/exception.
649 * args.rval() becomes the "stored value" for the property. */

Callers 1

field_getterMethod · 0.45

Calls 7

gjs_throwFunction · 0.85
display_stringMethod · 0.80
readMethod · 0.80
nameMethod · 0.45
type_infoMethod · 0.45

Tested by

no test coverage detected