static VALUE rg_iface_struct(VALUE self) { GIInterfaceInfo *info; info = SELF(self); return GI_BASE_INFO2RVAL_WITH_UNREF(g_interface_info_get_iface_struct(info)); }
static void generic_interface_init (gpointer iface, gpointer data) { GIInterfaceInfo *info = data; GIStructInfo *struct_info; gint n, i; struct_info = g_interface_info_get_iface_struct (info); n = g_interface_info_get_n_vfuncs (info); for (i = 0; i < n; i++) { GIVFuncInfo *vfunc_info; const gchar *vfunc_name; GIFieldInfo *field_info; gint field_offset; GITypeInfo *field_type_info; gchar *perl_method_name; GPerlI11nPerlCallbackInfo *callback_info; vfunc_info = g_interface_info_get_vfunc (info, i); vfunc_name = g_base_info_get_name (vfunc_info); /* FIXME: g_vfunc_info_get_offset does not seem to work here. */ field_info = get_field_info (struct_info, vfunc_name); g_assert (field_info); field_offset = g_field_info_get_offset (field_info); field_type_info = g_field_info_get_type (field_info); perl_method_name = g_ascii_strup (vfunc_name, -1); callback_info = create_perl_callback_closure_for_named_sub ( field_type_info, perl_method_name); dwarn ("installing vfunc %s as %s at offset %d (vs. %d) inside %p\n", vfunc_name, perl_method_name, field_offset, g_vfunc_info_get_offset (vfunc_info), iface); G_STRUCT_MEMBER (gpointer, iface, field_offset) = callback_info->closure; g_base_info_unref (field_type_info); g_base_info_unref (field_info); g_base_info_unref (vfunc_info); } g_base_info_unref (struct_info); }
static void create_native_closure (GType interface_type, GIInterfaceInfo *iface_info, GIVFuncInfo *vfunc_info, MethodImpl *impl) { GIFunctionInfo *invoker_info; GIStructInfo *struct_info; GIFieldInfo *field_info; GITypeInfo *type_info; GICallbackInfo *callback_info; guint n_fields, i; gboolean found_field_info; invoker_info = g_vfunc_info_get_invoker (vfunc_info); if (invoker_info == NULL) { g_debug ("No invoker for VFunc '%s.%s'", g_base_info_get_name (iface_info), g_base_info_get_name (vfunc_info)); return; } struct_info = g_interface_info_get_iface_struct (iface_info); n_fields = g_struct_info_get_n_fields (struct_info); found_field_info = FALSE; for (i = 0; i < n_fields; i++) { field_info = g_struct_info_get_field (struct_info, i); if (strcmp (g_base_info_get_name (field_info), g_base_info_get_name (vfunc_info)) == 0) { found_field_info = TRUE; break; } g_base_info_unref (field_info); } if (!found_field_info) { g_debug ("No struct field for VFunc '%s.%s'", g_base_info_get_name (iface_info), g_base_info_get_name (vfunc_info)); g_base_info_unref (struct_info); g_base_info_unref (invoker_info); return; } type_info = g_field_info_get_type (field_info); g_assert (g_type_info_get_tag (type_info) == GI_TYPE_TAG_INTERFACE); callback_info = g_type_info_get_interface (type_info); g_assert (g_base_info_get_type (callback_info) == GI_INFO_TYPE_CALLBACK); impl->interface_type = interface_type; impl->invoker_info = invoker_info; impl->method_name = g_base_info_get_name (invoker_info); impl->closure = g_callable_info_prepare_closure (callback_info, &impl->cif, handle_method_impl, impl); impl->struct_offset = g_field_info_get_offset (field_info); g_base_info_unref (callback_info); g_base_info_unref (type_info); g_base_info_unref (field_info); g_base_info_unref (struct_info); }