static void ada_class_record_init (GObjectClass* klass, gpointer class_data) { GType type = G_TYPE_FROM_CLASS (klass); GType parent = g_type_parent (type); GTypeQuery query; GTypeQuery parent_query; const AdaGObjectClass ada_klass = (AdaGObjectClass)class_data; g_type_query (type, &query); g_type_query (parent, &parent_query); /* Initialize the function pointers for the new signals to NULL */ memset ((char*)(klass) + parent_query.class_size, 0, query.class_size - parent_query.class_size); /* Set a pointer to the AdaGObjectClass, so that we can retrieve it * later from a type. */ SET_ADA_CLASS_FROM_C_CLASS(klass, ada_klass); if (ada_klass->class_init) { ada_klass->class_init (klass); } }
static VALUE rg_instance_size(VALUE self) { GTypeQuery query; g_type_query(rbgobj_gtype_get(self), &query); return UINT2NUM(query.instance_size); }
static GType test_type_get_type(void) { static GType gtype = 0; GType parent_type; if (gtype == 0) { GTypeInfo *type_info; GTypeQuery query; parent_type = g_type_from_name("PyGObject"); if (parent_type == 0) g_error("could not get PyGObject from testmodule"); type_info = (GTypeInfo *)g_new0(GTypeInfo, 1); g_type_query(parent_type, &query); type_info->class_size = (guint16)query.class_size; type_info->instance_size = (guint16)query.instance_size; gtype = g_type_register_static(parent_type, "TestType", type_info, 0); if (!gtype) g_error("Could not register TestType"); } return gtype; }
static GType goo_canvas_accessible_get_type (void) { static GType g_define_type_id = 0; if (G_UNLIKELY (g_define_type_id == 0)) { AtkObjectFactory *factory; GType parent_atk_type; GTypeQuery query; GTypeInfo tinfo = { 0 }; /* Gail doesn't declare its classes publicly, so we have to do a query to find the size of the class and instances. */ factory = atk_registry_get_factory (atk_get_default_registry (), GTK_TYPE_WIDGET); if (!factory) return G_TYPE_INVALID; parent_atk_type = atk_object_factory_get_accessible_type (factory); if (!parent_atk_type) return G_TYPE_INVALID; g_type_query (parent_atk_type, &query); tinfo.class_init = (GClassInitFunc) goo_canvas_accessible_class_init; tinfo.class_size = query.class_size; tinfo.instance_size = query.instance_size; g_define_type_id = g_type_register_static (parent_atk_type, "GooCanvasAccessible", &tinfo, 0); } return g_define_type_id; }
gboolean gst_v4l2_transform_register (GstPlugin * plugin, const gchar * basename, const gchar * device_path, GstCaps * sink_caps, GstCaps * src_caps) { GTypeQuery type_query; GTypeInfo type_info = { 0, }; GType type, subtype; gchar *type_name; GstV4l2TransformCData *cdata; cdata = g_new0 (GstV4l2TransformCData, 1); cdata->device = g_strdup (device_path); cdata->sink_caps = gst_caps_ref (sink_caps); cdata->src_caps = gst_caps_ref (src_caps); type = gst_v4l2_transform_get_type (); g_type_query (type, &type_query); memset (&type_info, 0, sizeof (type_info)); type_info.class_size = type_query.class_size; type_info.instance_size = type_query.instance_size; type_info.class_init = gst_v4l2_transform_subclass_init; type_info.class_data = cdata; type_info.instance_init = gst_v4l2_transform_subinstance_init; type_name = g_strdup_printf ("v4l2%sconvert", basename); subtype = g_type_register_static (type, type_name, &type_info, 0); gst_element_register (plugin, type_name, GST_RANK_NONE, subtype); g_free (type_name); return TRUE; }
/** * panel_a11y_query_accessible_parent_type * @type: widget type * @type_info: accessible object type info to complete * * Standard hack which figures out the #GType of the accessible * object for @type's parent type. Also, fills out the class_size * and instance_size of @type_info to match the size of the parent * type. * * Basically, this is the hack to use if you want to derive from * an accessible object implementation in gail. * * Returns: the #GType of @type's parent's accessible peer */ GType panel_a11y_query_accessible_parent_type (GType type, GTypeInfo *type_info) { AtkObjectFactory *factory; GType parent_type; GType accessible_parent_type; g_return_val_if_fail (G_TYPE_IS_OBJECT (type), G_TYPE_INVALID); parent_type = g_type_parent (type); factory = atk_registry_get_factory (atk_get_default_registry (), parent_type); accessible_parent_type = atk_object_factory_get_accessible_type (factory); if (type_info) { GTypeQuery query; g_type_query (accessible_parent_type, &query); type_info->class_size = query.class_size; type_info->instance_size = query.instance_size; } return atk_object_factory_get_accessible_type (factory); }
dt_control_signal_t *dt_control_signal_init() { dt_control_signal_t *ctlsig = g_malloc(sizeof(dt_control_signal_t)); memset(ctlsig, 0, sizeof(dt_control_signal_t)); /* setup dummy gobject typeinfo */ GTypeQuery query; GTypeInfo type_info = { 0, (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) NULL, (GClassFinalizeFunc) NULL, NULL, 0,0, (GInstanceInitFunc) NULL }; g_type_query(G_TYPE_OBJECT, &query); type_info.class_size = query.class_size; type_info.instance_size = query.instance_size; _signal_type = g_type_register_static(G_TYPE_OBJECT, "DarktableSignals", &type_info, 0); /* create our pretty empty gobject */ ctlsig->sink = g_object_new(_signal_type,NULL); /* create the signals */ for (int k=0; k<DT_SIGNAL_COUNT; k++) g_signal_newv(_signal_description[k].name, _signal_type, G_SIGNAL_RUN_LAST,0, _signal_description[k].accumulator,_signal_description[k].accu_data, _signal_description[k].c_marshaller,_signal_description[k].return_type, _signal_description[k].n_params,_signal_description[k].param_types); return ctlsig; }
static VALUE type_class_size(VALUE self) { GTypeQuery query; g_type_query(rbgobj_gtype_get(self), &query); return UINT2NUM(query.class_size); }
dt_control_signal_t *dt_control_signal_init() { dt_control_signal_t *ctlsig = g_malloc(sizeof(dt_control_signal_t)); memset(ctlsig, 0, sizeof(dt_control_signal_t)); /* setup dummy gobject typeinfo */ GTypeQuery query; GType type; GTypeInfo type_info = { 0, (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) NULL, (GClassFinalizeFunc) NULL, NULL, 0,0, (GInstanceInitFunc) NULL}; g_type_query(G_TYPE_OBJECT, &query); type_info.class_size = query.class_size; type_info.instance_size = query.instance_size; type = g_type_register_static(G_TYPE_OBJECT, "DarktableSignals", &type_info, 0); /* create our pretty empty gobject */ ctlsig->sink = g_object_new(type,NULL); /* create the signals */ for (int k=0;k<DT_SIGNAL_COUNT;k++) g_signal_new(_signal_name[k], G_TYPE_OBJECT, G_SIGNAL_RUN_LAST,0,NULL,NULL, g_cclosure_marshal_VOID__VOID,G_TYPE_NONE,0); return ctlsig; }
GType ev_view_accessible_get_type (void) { static GType type = 0; if (G_UNLIKELY (type == 0)) { GTypeInfo tinfo = { 0, /* class size */ (GBaseInitFunc) NULL, /* base init */ (GBaseFinalizeFunc) NULL, /* base finalize */ (GClassInitFunc) ev_view_accessible_class_init, /* class init */ (GClassFinalizeFunc) NULL, /* class finalize */ NULL, /* class data */ 0, /* instance size */ 0, /* nb preallocs */ (GInstanceInitFunc) NULL, /* instance init */ NULL /* value table */ }; const GInterfaceInfo atk_text_info = { (GInterfaceInitFunc) ev_view_accessible_text_iface_init, (GInterfaceFinalizeFunc) NULL, NULL }; const GInterfaceInfo atk_action_info = { (GInterfaceInitFunc) ev_view_accessible_action_iface_init, (GInterfaceFinalizeFunc) NULL, NULL }; /* * Figure out the size of the class and instance * we are deriving from */ AtkObjectFactory *factory; GType derived_type; GTypeQuery query; GType derived_atk_type; derived_type = g_type_parent (EV_TYPE_VIEW); factory = atk_registry_get_factory (atk_get_default_registry (), derived_type); derived_atk_type = atk_object_factory_get_accessible_type (factory); g_type_query (derived_atk_type, &query); tinfo.class_size = query.class_size; tinfo.instance_size = query.instance_size; type = g_type_register_static (derived_atk_type, "EvViewAccessible", &tinfo, 0); g_type_add_interface_static (type, ATK_TYPE_TEXT, &atk_text_info); g_type_add_interface_static (type, ATK_TYPE_ACTION, &atk_action_info); } return type; }
GType accessible_image_view_get_type (void) { static GType type = 0; if (!type) { static GTypeInfo tinfo = { 0, (GBaseInitFunc) NULL, /* base init */ (GBaseFinalizeFunc) NULL, /* base finalize */ (GClassInitFunc) accessible_image_view_class_init, /* class init */ (GClassFinalizeFunc) NULL, /* class finalize */ NULL, /* class data */ 0, /* instance size */ 0, /* nb preallocs */ (GInstanceInitFunc) accessible_image_view_object_init, /* instance init */ NULL /* value table */ }; static const GInterfaceInfo atk_image_info = { (GInterfaceInitFunc) atk_image_interface_init, (GInterfaceFinalizeFunc) NULL, NULL }; /* * Figure out the size of the class and instance * we are deriving from */ AtkObjectFactory *factory; GType derived_type; GTypeQuery query; GType derived_atk_type; derived_type = g_type_parent (TYPE_IMAGE_VIEW); factory = atk_registry_get_factory (atk_get_default_registry(), derived_type); derived_atk_type = atk_object_factory_get_accessible_type (factory); g_type_query (derived_atk_type, &query); tinfo.class_size = query.class_size; tinfo.instance_size = query.instance_size; type = g_type_register_static(derived_atk_type, "AccessibleImageView", &tinfo, 0); g_type_add_interface_static (type, ATK_TYPE_IMAGE, &atk_image_info); } return type; }
GType ea_jump_button_get_type (void) { static GType type = 0; AtkObjectFactory *factory; GTypeQuery query; GType derived_atk_type; if (!type) { static GTypeInfo tinfo = { sizeof (EaJumpButtonClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ea_jump_button_class_init, (GClassFinalizeFunc) NULL, /* class_data */ NULL, sizeof (EaJumpButton), /* n_preallocs */ 0, (GInstanceInitFunc) NULL, /* value_table */ NULL }; static const GInterfaceInfo atk_action_info = { (GInterfaceInitFunc) atk_action_interface_init, (GInterfaceFinalizeFunc) NULL, NULL }; /* * Figure out the size of the class and instance * we are run-time deriving from (atk object for * GNOME_TYPE_CANVAS_ITEM, in this case) */ factory = atk_registry_get_factory ( atk_get_default_registry (), GNOME_TYPE_CANVAS_ITEM); derived_atk_type = atk_object_factory_get_accessible_type (factory); g_type_query (derived_atk_type, &query); tinfo.class_size = query.class_size; tinfo.instance_size = query.instance_size; /* we inherit the component and other * interfaces from GNOME_TYPE_CANVAS_ITEM */ type = g_type_register_static ( derived_atk_type, "EaJumpButton", &tinfo, 0); g_type_add_interface_static ( type, ATK_TYPE_ACTION, &atk_action_info); } return type; }
/** * swfdec_as_native_function_set_construct_type: * @function: a #SwfdecAsNativeFunction * @type: #GType used when constructing an object with @function * * Sets the @type to be used when using @function as a constructor. If this is * not set, using @function as a constructor will create a #SwfdecAsObject. **/ void swfdec_as_native_function_set_construct_type (SwfdecAsNativeFunction *function, GType type) { GTypeQuery query; g_return_if_fail (SWFDEC_IS_AS_NATIVE_FUNCTION (function)); g_return_if_fail (g_type_is_a (type, SWFDEC_TYPE_AS_OBJECT)); g_type_query (type, &query); function->construct_type = type; function->construct_size = query.instance_size; }
GType ea_minicard_get_type (void) { static GType type = 0; AtkObjectFactory *factory; GTypeQuery query; GType derived_atk_type; if (!type) { static GTypeInfo tinfo = { sizeof (EaMinicardClass), (GBaseInitFunc) NULL, /* base_init */ (GBaseFinalizeFunc) NULL, /* base_finalize */ (GClassInitFunc) ea_minicard_class_init, (GClassFinalizeFunc) NULL, /* class_finalize */ NULL, /* class_data */ sizeof (EaMinicard), 0, /* n_preallocs */ (GInstanceInitFunc) NULL, /* instance init */ NULL /* value table */ }; static const GInterfaceInfo atk_action_info = { (GInterfaceInitFunc) atk_action_interface_init, (GInterfaceFinalizeFunc) NULL, NULL }; /* * Figure out the size of the class and instance * we are run-time deriving from (GailWidget, in this case) */ factory = atk_registry_get_factory ( atk_get_default_registry (), GNOME_TYPE_CANVAS_GROUP); derived_atk_type = atk_object_factory_get_accessible_type (factory); g_type_query (derived_atk_type, &query); tinfo.class_size = query.class_size; tinfo.instance_size = query.instance_size; type = g_type_register_static ( derived_atk_type, "EaMinicard", &tinfo, 0); g_type_add_interface_static ( type, ATK_TYPE_ACTION, &atk_action_info); } return type; }
GType gtksharp_register_type (gchar *name, GType parent) { GTypeQuery query; GTypeInfo info = {0, NULL, NULL, NULL, NULL, NULL, 0, 0, NULL, NULL }; g_type_query (parent, &query); info.class_size = query.class_size; info.instance_size = query.instance_size; return g_type_register_static (parent, name, &info, 0); }
gint64 gimp_g_type_instance_get_memsize (GTypeInstance *instance) { if (instance) { GTypeQuery type_query; g_type_query (G_TYPE_FROM_INSTANCE (instance), &type_query); return type_query.instance_size; } return 0; }
/* register a new dynamic sub-class with the name 'type_name'.. this gives us * a way to use the same (for example) GstOmxMp3Dec element mapping to * multiple different element names with different OMX library implementations * and/or component names */ static GType create_subtype (GType parent_type, const gchar * type_name) { GTypeQuery q; GTypeInfo i = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; if (!type_name) return 0; g_type_query (parent_type, &q); i.class_size = q.class_size; i.instance_size = q.instance_size; return g_type_register_static (parent_type, type_name, &i, 0); }
/** * eel_accessibility_create_derived_type: * @type_name: the name for the new accessible type eg. NautilusIconCanvasItemAccessible * @existing_gobject_with_proxy: the GType of an object that has a registered factory that * manufactures the type we want to inherit from. ie. to inherit from a GailCanvasItem * we need to pass GNOME_TYPE_CANVAS_ITEM - since GailCanvasItem is registered against * that type. * @opt_gail_parent_class: the name of the Gail class to derive from eg. GailCanvasItem * @class_init: the init function to run for this class * * This should be run to register the type, it can subsequently be run with * the same name and will not re-register it, but simply return it. * * NB. to do instance init, you prolly want to override AtkObject::initialize * * Return value: the registered type, or 0 on failure. **/ GType eel_accessibility_create_derived_type (const char *type_name, GType existing_gobject_with_proxy, EelAccessibilityClassInitFn class_init) { GType type; GType parent_atk_type; GTypeInfo tinfo = { 0 }; GTypeQuery query; AtkObjectFactory *factory; if ((type = g_type_from_name (type_name))) { return type; } factory = atk_registry_get_factory (atk_get_default_registry (), existing_gobject_with_proxy); if (!factory) { return G_TYPE_INVALID; } parent_atk_type = atk_object_factory_get_accessible_type (factory); if (!parent_atk_type) { return G_TYPE_INVALID; } /* * Figure out the size of the class and instance * we are deriving from */ g_type_query (parent_atk_type, &query); if (class_init) { tinfo.class_init = (GClassInitFunc) class_init; } tinfo.class_size = query.class_size; tinfo.instance_size = query.instance_size; /* Register the type */ type = g_type_register_static ( parent_atk_type, type_name, &tinfo, 0); return type; }
static GType mcus_led_accessible_get_type (void) { static GType type = 0; /* Action interface Name etc. ... */ if (G_UNLIKELY (type == 0)) { const GInterfaceInfo atk_image_info = { (GInterfaceInitFunc) mcus_led_accessible_image_interface_init, (GInterfaceFinalizeFunc) NULL, NULL }; GType parent_atk_type; GTypeInfo tinfo = { 0 }; GTypeQuery query; AtkObjectFactory *factory; if ((type = g_type_from_name ("MCUSLEDAccessible"))) return type; factory = atk_registry_get_factory (atk_get_default_registry (), GTK_TYPE_IMAGE); if (!factory) return G_TYPE_INVALID; parent_atk_type = atk_object_factory_get_accessible_type (factory); if (!parent_atk_type) return G_TYPE_INVALID; /* Figure out the size of the class and instance we are deriving from */ g_type_query (parent_atk_type, &query); tinfo.class_init = (GClassInitFunc) mcus_led_accessible_class_init; tinfo.class_size = query.class_size; tinfo.instance_size = query.instance_size; /* Register the type */ type = g_type_register_static (parent_atk_type, "MCUSLEDAccessible", &tinfo, 0); g_type_add_interface_static (type, ATK_TYPE_IMAGE, &atk_image_info); } return type; }
GType gal_a11y_type_register_static_with_private (GType parent_type, const gchar *type_name, GTypeInfo *info, GTypeFlags flags, gint priv_size, gint *priv_offset) { GTypeQuery query; g_type_query (parent_type, &query); info->class_size = query.class_size; info->instance_size = query.instance_size + priv_size; if (priv_offset) *priv_offset = query.instance_size; return g_type_register_static (parent_type, type_name, info, flags); }
static GType mate_druid_accessible_get_type (void) { static GType type = 0; if (!type) { GTypeInfo tinfo = { 0, /* class size */ (GBaseInitFunc) NULL, /* base init */ (GBaseFinalizeFunc) NULL, /* base finalize */ (GClassInitFunc) mate_druid_accessible_class_init, (GClassFinalizeFunc) NULL, /* class finalize */ NULL, /* class data */ 0, /* instance size */ 0, /* nb preallocs */ (GInstanceInitFunc) NULL, /* instance init */ NULL /* value table */ }; /* * Figure out the size of the class and instance * we are deriving from */ AtkObjectFactory *factory; GType derived_type; GTypeQuery query; GType derived_atk_type; derived_type = g_type_parent (MATE_TYPE_DRUID); factory = atk_registry_get_factory (atk_get_default_registry (), derived_type); derived_atk_type = atk_object_factory_get_accessible_type (factory); g_type_query (derived_atk_type, &query); tinfo.class_size = query.class_size; tinfo.instance_size = query.instance_size; type = g_type_register_static (derived_atk_type, "MateDruidAccessible", &tinfo, 0); } return type; }
GType ea_gnome_calendar_get_type (void) { static GType type = 0; AtkObjectFactory *factory; GTypeQuery query; GType derived_atk_type; if (!type) { static GTypeInfo tinfo = { sizeof (EaGnomeCalendarClass), (GBaseInitFunc) NULL, /* base init */ (GBaseFinalizeFunc) NULL, /* base finalize */ (GClassInitFunc) ea_gnome_calendar_class_init, /* class init */ (GClassFinalizeFunc) NULL, /* class finalize */ NULL, /* class data */ sizeof (EaGnomeCalendar), /* instance size */ 0, /* nb preallocs */ (GInstanceInitFunc) NULL, /* instance init */ NULL /* value table */ }; /* * Figure out the size of the class and instance * we are run-time deriving from (GailWidget, in this case) */ factory = atk_registry_get_factory (atk_get_default_registry (), GTK_TYPE_WIDGET); derived_atk_type = atk_object_factory_get_accessible_type (factory); g_type_query (derived_atk_type, &query); tinfo.class_size = query.class_size; tinfo.instance_size = query.instance_size; type = g_type_register_static (derived_atk_type, "EaGnomeCalendar", &tinfo, 0); } return type; }
void drw_cc_panel_register_type (GTypeModule *module) { GType parent_type, g_define_type_id; GTypeQuery query; GTypeInfo type_info = { 0, (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) drw_cc_panel_class_init, (GClassFinalizeFunc) drw_cc_panel_class_finalize, NULL, 0, 0, (GInstanceInitFunc) drw_cc_panel_init, NULL }; parent_type = g_type_from_name ("CcPanel"); if (parent_type == 0 || !g_type_is_a (parent_type, GTK_TYPE_WIDGET)) { drw_cc_panel_type = G_TYPE_INVALID; return; } g_type_query (parent_type, &query); type_info.class_size = query.class_size; type_info.instance_size = query.instance_size; g_define_type_id = drw_cc_panel_type = g_type_module_register_type (module, parent_type, "DrwCcPanel", &type_info, 0); g_io_extension_point_implement (CC_SHELL_PANEL_EXTENSION_POINT, g_define_type_id, "typing-break", 0); }
static VALUE type_register(int argc, VALUE* argv, VALUE self) { VALUE type_name, flags; volatile VALUE class_init_proc = Qnil; GType parent_type; GTypeInfo* info; rb_scan_args(argc, argv, "03", &type_name, &info, &flags); { const RGObjClassInfo* cinfo = rbgobj_lookup_class(self); if (cinfo->klass == self) rb_raise(rb_eTypeError, "already registered"); } { VALUE superclass = rb_funcall(self, rb_intern("superclass"), 0); const RGObjClassInfo* cinfo = rbgobj_lookup_class(superclass); if (cinfo->klass != superclass) rb_raise(rb_eTypeError, "super class must be registered to GLib"); parent_type = cinfo->gtype; } if (NIL_P(type_name)) { VALUE s = rb_funcall(self, rb_intern("name"), 0); if (strlen(StringValuePtr(s)) == 0) rb_raise(rb_eTypeError, "can't determine type name"); type_name = rb_funcall( rb_eval_string("lambda{|x| x.gsub(/::/,'') }"), rb_intern("call"), 1, s); } { GTypeQuery query; g_type_query(parent_type, &query); info = g_new0(GTypeInfo, 1); info->class_size = query.class_size; info->base_init = NULL; info->base_finalize = NULL; info->class_init = class_init_func; info->class_finalize = NULL; info->class_data = (gpointer)class_init_proc; info->instance_size = query.instance_size; info->n_preallocs = 0; info->instance_init = NULL; info->value_table = NULL; } { GType type = g_type_register_static(parent_type, StringValuePtr(type_name), info, NIL_P(flags) ? 0 : NUM2INT(flags)); G_RELATIVE(self, class_init_proc); rbgobj_register_class(self, type, TRUE, TRUE); { RGObjClassInfo* cinfo = (RGObjClassInfo*)rbgobj_lookup_class(self); cinfo->flags |= RBGOBJ_DEFINED_BY_RUBY; } { GType parent = g_type_parent(type); const RGObjClassInfo* cinfo = GTYPE2CINFO(parent); VALUE m = rb_define_module_under(self, RubyGObjectHookModule); if (! (cinfo->flags & RBGOBJ_DEFINED_BY_RUBY)) { rb_define_method(m, "initialize", gobj_initialize, -1); } rb_include_module(self, m); } return Qnil; } }
GType peas_extension_register_subclass (GType parent_type, GType *extension_types) { guint i; GString *type_name; GType the_type; type_name = g_string_new (g_type_name (parent_type)); for (i = 0; extension_types[i] != 0; ++i) { /* Use something that is not allowed in symbol names */ g_string_append_c (type_name, '+'); g_string_append (type_name, g_type_name (extension_types[i])); } the_type = g_type_from_name (type_name->str); if (the_type == G_TYPE_INVALID) { GTypeQuery query; GTypeInfo type_info = { 0, (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) extension_subclass_init, (GClassFinalizeFunc) NULL, g_memdup (extension_types, sizeof (GType) * (i + 1)), 0, 0, (GInstanceInitFunc) extension_subclass_instance_init, NULL }; GInterfaceInfo iface_info = { (GInterfaceInitFunc) implement_interface_methods, (GInterfaceFinalizeFunc) NULL, NULL }; g_debug ("Registering new type '%s'", type_name->str); g_type_query (parent_type, &query); type_info.class_size = query.class_size; type_info.instance_size = query.instance_size; the_type = g_type_register_static (parent_type, type_name->str, &type_info, 0); iface_info.interface_data = GSIZE_TO_POINTER (the_type); for (i = 0; extension_types[i] != 0; ++i) g_type_add_interface_static (the_type, extension_types[i], &iface_info); } /* Must be done outside of type registration * in the event that the same type is requested again. */ for (i = 0; extension_types[i] != 0; ++i) { if (!g_type_is_a (the_type, extension_types[i])) { g_warning ("Type '%s' is invalid", type_name->str); the_type = G_TYPE_INVALID; break; } } g_string_free (type_name, TRUE); return the_type; }
GType gucharmap_chartable_accessible_get_type (void) { static volatile gsize type__volatile = 0; if (g_once_init_enter (&type__volatile)) { GTypeInfo typeinfo = { 0 /* filled in by the code below */, (GBaseInitFunc) NULL, /* base init */ (GBaseFinalizeFunc) NULL, /* base finalize */ (GClassInitFunc) gucharmap_chartable_accessible_class_init, /* class init */ (GClassFinalizeFunc) NULL, /* class finalize */ NULL, /* class data */ 0 /* filled in by the code below */, 0, /* nb preallocs */ (GInstanceInitFunc) gucharmap_chartable_accessible_init, /* instance init */ NULL /* value table */ }; const GInterfaceInfo atk_table_info = { (GInterfaceInitFunc) gucharmap_chartable_accessible_table_interface_init, (GInterfaceFinalizeFunc) NULL, NULL }; const GInterfaceInfo atk_component_info = { (GInterfaceInitFunc) gucharmap_chartable_accessible_component_interface_init, (GInterfaceFinalizeFunc) NULL, NULL }; AtkObjectFactory *factory; GType derived_type; GTypeQuery query; GType derived_atk_type; GType type; /* Figure out the size of the class and instance we are deriving from */ derived_type = g_type_parent (GUCHARMAP_TYPE_CHARTABLE); factory = atk_registry_get_factory (atk_get_default_registry (), derived_type); derived_atk_type = atk_object_factory_get_accessible_type (factory); g_type_query (derived_atk_type, &query); typeinfo.class_size = query.class_size; typeinfo.instance_size = query.instance_size; type = g_type_register_static (derived_atk_type, "GucharmapChartableAccessible", &typeinfo, 0); g_type_add_interface_static (type, ATK_TYPE_TABLE, &atk_table_info); g_type_add_interface_static (type, ATK_TYPE_COMPONENT, &atk_component_info); g_once_init_leave (&type__volatile, type); } return type__volatile; }
GType ea_day_view_main_item_get_type (void) { static GType type = 0; AtkObjectFactory *factory; GTypeQuery query; GType derived_atk_type; if (!type) { static GTypeInfo tinfo = { sizeof (EaDayViewMainItemClass), (GBaseInitFunc) NULL, /* base init */ (GBaseFinalizeFunc) NULL, /* base finalize */ (GClassInitFunc) ea_day_view_main_item_class_init, (GClassFinalizeFunc) NULL, /* class finalize */ NULL, /* class data */ sizeof (EaDayViewMainItem), /* instance size */ 0, /* nb preallocs */ (GInstanceInitFunc) NULL, /* instance init */ NULL /* value table */ }; static const GInterfaceInfo atk_component_info = { (GInterfaceInitFunc) atk_component_interface_init, (GInterfaceFinalizeFunc) NULL, NULL }; static const GInterfaceInfo atk_table_info = { (GInterfaceInitFunc) atk_table_interface_init, (GInterfaceFinalizeFunc) NULL, NULL }; static const GInterfaceInfo atk_selection_info = { (GInterfaceInitFunc) atk_selection_interface_init, (GInterfaceFinalizeFunc) NULL, NULL }; /* * Figure out the size of the class and instance * we are run-time deriving from (GailCanvasItem, in this case) * */ factory = atk_registry_get_factory ( atk_get_default_registry (), e_day_view_main_item_get_type ()); derived_atk_type = atk_object_factory_get_accessible_type (factory); g_type_query (derived_atk_type, &query); tinfo.class_size = query.class_size; tinfo.instance_size = query.instance_size; type = g_type_register_static ( derived_atk_type, "EaDayViewMainItem", &tinfo, 0); g_type_add_interface_static ( type, ATK_TYPE_COMPONENT, &atk_component_info); g_type_add_interface_static ( type, ATK_TYPE_TABLE, &atk_table_info); g_type_add_interface_static ( type, ATK_TYPE_SELECTION, &atk_selection_info); } return type; }
void rbgobj_register_type(VALUE klass, VALUE type_name, GClassInitFunc class_init) { GType parent_type; GTypeInfo *info; { const RGObjClassInfo *cinfo = rbgobj_lookup_class(klass); if (cinfo->klass == klass) rb_raise(rb_eTypeError, "already registered class: <%s>", RBG_INSPECT(klass)); } { VALUE superclass = rb_funcall(klass, rb_intern("superclass"), 0); const RGObjClassInfo *cinfo = rbgobj_lookup_class(superclass); if (cinfo->klass != superclass) rb_raise(rb_eTypeError, "super class must be registered to GLib: <%s>", RBG_INSPECT(superclass)); parent_type = cinfo->gtype; } if (NIL_P(type_name)) { VALUE klass_name = rb_funcall(klass, rb_intern("name"), 0); if (strlen(StringValueCStr(klass_name)) == 0) rb_raise(rb_eTypeError, "can't determine type name: <%s>", RBG_INSPECT(klass)); type_name = rb_funcall(klass_name, rb_intern("gsub"), 2, rb_str_new_cstr("::"), rb_str_new_cstr("")); } { GTypeQuery query; g_type_query(parent_type, &query); /* TODO: Why new? g_type_register_static() doesn’t retain a copy, so * this should be allocated on the stack. */ info = g_new0(GTypeInfo, 1); info->class_size = query.class_size; info->base_init = NULL; info->base_finalize = NULL; info->class_init = class_init; info->class_finalize = NULL; info->class_data = NULL; info->instance_size = query.instance_size; info->n_preallocs = 0; info->instance_init = NULL; info->value_table = NULL; } { GType type = g_type_register_static(parent_type, StringValueCStr(type_name), info, 0); rbgobj_register_class(klass, type, TRUE, TRUE); { RGObjClassInfo *cinfo = (RGObjClassInfo *)rbgobj_lookup_class(klass); cinfo->flags |= RBGOBJ_DEFINED_BY_RUBY; } { GType parent = g_type_parent(type); const RGObjClassInfo *cinfo = GTYPE2CINFO(parent); VALUE initialize_module; initialize_module = rb_define_module_under(klass, RubyGObjectHookModule); if (!(cinfo->flags & RBGOBJ_DEFINED_BY_RUBY)) { rbg_define_method(initialize_module, "initialize", rg_initialize, -1); } rb_include_module(klass, initialize_module); } } }
GimpObject * gimp_gegl_get_config_proxy (const gchar *operation, GType parent_type) { GType config_type; g_return_val_if_fail (operation != NULL, NULL); g_return_val_if_fail (g_type_is_a (parent_type, GIMP_TYPE_OBJECT), NULL); if (! config_types) config_types = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify) g_free, NULL); config_type = (GType) g_hash_table_lookup (config_types, operation); if (! config_type) { GTypeQuery query; g_type_query (parent_type, &query); { GTypeInfo info = { query.class_size, (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gimp_gegl_config_class_init, NULL, /* class_finalize */ operation, query.instance_size, 0, /* n_preallocs */ (GInstanceInitFunc) NULL, }; const GInterfaceInfo config_info = { (GInterfaceInitFunc) gimp_gegl_config_config_iface_init, NULL, /* interface_finalize */ NULL /* interface_data */ }; gchar *type_name = g_strdup_printf ("GimpGegl-%s-config", operation); g_strcanon (type_name, G_CSET_DIGITS "-" G_CSET_a_2_z G_CSET_A_2_Z, '-'); config_type = g_type_register_static (parent_type, type_name, &info, 0); g_free (type_name); g_type_add_interface_static (config_type, GIMP_TYPE_CONFIG, &config_info); g_hash_table_insert (config_types, g_strdup (operation), (gpointer) config_type); } } return g_object_new (config_type, NULL); }
GType ea_cal_view_event_get_type (void) { static GType type = 0; AtkObjectFactory *factory; GTypeQuery query; GType derived_atk_type; if (!type) { static GTypeInfo tinfo = { sizeof (EaCalViewEventClass), (GBaseInitFunc) NULL, /* base init */ (GBaseFinalizeFunc) NULL, /* base finalize */ (GClassInitFunc) ea_cal_view_event_class_init, /* class init */ (GClassFinalizeFunc) NULL, /* class finalize */ NULL, /* class data */ sizeof (EaCalViewEvent), /* instance size */ 0, /* nb preallocs */ (GInstanceInitFunc) ea_cal_view_event_init, /* instance init */ NULL /* value table */ }; static const GInterfaceInfo atk_component_info = { (GInterfaceInitFunc) atk_component_interface_init, (GInterfaceFinalizeFunc) NULL, NULL }; static const GInterfaceInfo atk_action_info = { (GInterfaceInitFunc) atk_action_interface_init, (GInterfaceFinalizeFunc) NULL, NULL }; /* * Figure out the size of the class and instance * we are run-time deriving from (atk object for E_TEXT, in this case) */ factory = atk_registry_get_factory ( atk_get_default_registry (), E_TYPE_TEXT); derived_atk_type = atk_object_factory_get_accessible_type (factory); g_type_query (derived_atk_type, &query); tinfo.class_size = query.class_size; tinfo.instance_size = query.instance_size; /* we inherit the component, text and other interfaces from E_TEXT */ type = g_type_register_static ( derived_atk_type, "EaCalViewEvent", &tinfo, 0); g_type_add_interface_static ( type, ATK_TYPE_COMPONENT, &atk_component_info); g_type_add_interface_static ( type, ATK_TYPE_ACTION, &atk_action_info); } return type; }