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

Method build_instance

gi/arg-cache.cpp:3626–3659  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3624}
3625
3626void ArgsCache::build_instance(const GI::CallableInfo& callable) {
3627 if (!m_is_method)
3628 return;
3629
3630 Maybe<const GI::BaseInfo> interface_info = callable.container();
3631 g_assert(interface_info && "callable must be a contained type");
3632
3633 GITransfer transfer = callable.instance_ownership_transfer();
3634
3635 // These cases could be covered by the generic marshaller, except that
3636 // there's no way to get GITypeInfo for a method's instance parameter.
3637 // Instead, special-case the arguments here that would otherwise go through
3638 // the generic marshaller.
3639 // See: https://gitlab.gnome.org/GNOME/gobject-introspection/-/issues/334
3640 auto struct_info = interface_info->as<GI::InfoTag::STRUCT>();
3641 if (struct_info && struct_info->is_gtype_struct()) {
3642 set_instance(new Arg::GTypeStructInstanceIn(), transfer);
3643 return;
3644 }
3645
3646 if (auto reg_info = interface_info->as<GI::InfoTag::REGISTERED_TYPE>()) {
3647 GType gtype = reg_info->gtype();
3648
3649 if (g_type_is_a(gtype, G_TYPE_PARAM)) {
3650 set_instance(new Arg::ParamInstanceIn(), transfer);
3651 return;
3652 }
3653 }
3654
3655 build_interface_in_arg<Arg::Kind::INSTANCE>(
3656 Argument::Init{nullptr, Argument::ABSENT, transfer,
3657 GjsArgumentFlags::NONE},
3658 *interface_info);
3659}
3660
3661static constexpr bool type_tag_is_scalar(GITypeTag tag) {
3662 return GI_TYPE_TAG_IS_NUMERIC(tag) || tag == GI_TYPE_TAG_BOOLEAN ||

Callers 1

initMethod · 0.80

Calls 4

containerMethod · 0.80
is_gtype_structMethod · 0.80
gtypeMethod · 0.45

Tested by

no test coverage detected