class GObject::TypeModule

Overview

#GTypeModule provides a simple implementation of the #GTypePlugin interface.

The model of #GTypeModule is a dynamically loaded module which implements some number of types and interface implementations.

When the module is loaded, it registers its types and interfaces using g_type_module_register_type() and g_type_module_add_interface(). As long as any instances of these types and interface implementations are in use, the module is kept loaded. When the types and interfaces are gone, the module may be unloaded. If the types and interfaces become used again, the module will be reloaded. Note that the last reference cannot be released from within the module code, since that would lead to the caller's code being unloaded before g_object_unref() returns to it.

Keeping track of whether the module should be loaded or not is done by using a use count - it starts at zero, and whenever it is greater than zero, the module is loaded. The use count is maintained internally by the type system, but also can be explicitly controlled by g_type_module_use() and g_type_module_unuse(). Typically, when loading a module for the first type, g_type_module_use() will be used to load it so that it can initialize its types. At some later point, when the module no longer needs to be loaded except for the type implementations it contains, g_type_module_unuse() is called.

#GTypeModule does not actually provide any implementation of module loading and unloading. To create a particular module type you must derive from #GTypeModule and implement the load and unload functions in #GTypeModuleClass.

Included Modules

Direct Known Subclasses

Defined in:

lib/gi-crystal/src/auto/g_object-2.0/type_module.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from module GObject::TypePlugin

complete_interface_info(instance_type : UInt64, interface_type : UInt64, info : GObject::InterfaceInfo) : Nil complete_interface_info, complete_type_info(g_type : UInt64, info : GObject::TypeInfo, value_table : GObject::TypeValueTable) : Nil complete_type_info, to_unsafe to_unsafe, unuse : Nil unuse, use : Nil use

Constructor methods inherited from module GObject::TypePlugin

cast(obj : GObject::Object) : self cast

Class methods inherited from module GObject::TypePlugin

cast?(obj : GObject::Object) : self | Nil cast?, g_type : UInt64 g_type

Instance methods inherited from class GObject::Object

==(other : self) ==, bind_property(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags) : GObject::Binding bind_property, bind_property_full(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags, transform_to : GObject::Closure, transform_from : GObject::Closure) : GObject::Binding bind_property_full, data(key : String) : Pointer(Void) | Nil data, finalize finalize, freeze_notify : Nil freeze_notify, getv(names : Enumerable(String), values : Enumerable(_)) : Nil getv, hash(hasher) hash, notify(property_name : String) : Nil notify, notify_by_pspec(pspec : GObject::ParamSpec) : Nil notify_by_pspec, notify_signal notify_signal, property(property_name : String, value : _) : Nil property, qdata(quark : UInt32) : Pointer(Void) | Nil qdata, ref_count : UInt32 ref_count, run_dispose : Nil run_dispose, set_data(key : String, data : Pointer(Void) | Nil) : Nil set_data, set_property(property_name : String, value : _) : Nil set_property, steal_data(key : String) : Pointer(Void) | Nil steal_data, steal_qdata(quark : UInt32) : Pointer(Void) | Nil steal_qdata, thaw_notify : Nil thaw_notify, to_unsafe : Pointer(Void) to_unsafe, watch_closure(closure : GObject::Closure) : Nil watch_closure

Constructor methods inherited from class GObject::Object

cast(obj : GObject::Object) : self cast, new(pointer : Pointer(Void), transfer : GICrystal::Transfer)
new
new
, newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter)) : self newv

Class methods inherited from class GObject::Object

cast?(obj : GObject::Object) : self | Nil cast?, compat_control(what : UInt64, data : Pointer(Void) | Nil) : UInt64 compat_control, g_type : UInt64 g_type, interface_find_property(g_iface : GObject::TypeInterface, property_name : String) : GObject::ParamSpec interface_find_property, interface_list_properties(g_iface : GObject::TypeInterface) : Enumerable(GObject::ParamSpec) interface_list_properties

Macros inherited from class GObject::Object

previous_vfunc(*args) previous_vfunc, previous_vfunc!(*args) previous_vfunc!, signal(signature) signal

Constructor Detail

def self.new #

Initialize a new TypeModule.


[View source]

Class Method Detail

def self.g_type : UInt64 #

Returns the type id (GType) registered in GLib type system.


[View source]

Instance Method Detail

def ==(other : self) #
Description copied from class Reference

Returns true if this reference is the same as other. Invokes same?.


def add_interface(instance_type : UInt64, interface_type : UInt64, interface_info : GObject::InterfaceInfo) : Nil #

Registers an additional interface for a type, whose interface lives in the given type plugin. If the interface was already registered for the type in this plugin, nothing will be done.

As long as any instances of the type exist, the type plugin will not be unloaded.

Since 2.56 if module is nil this will call g_type_add_interface_static() instead. This can be used when making a static build of the module.


[View source]
def hash(hasher) #
Description copied from class Reference

See Object#hash(hasher)


def name=(name : String) : Nil #

Sets the name for a #GTypeModule


[View source]
def register_enum(name : String, const_static_values : GObject::EnumValue) : UInt64 #

Looks up or registers an enumeration that is implemented with a particular type plugin. If a type with name type_name was previously registered, the #GType identifier for the type is returned, otherwise the type is newly registered, and the resulting #GType identifier returned.

As long as any instances of the type exist, the type plugin will not be unloaded.

Since 2.56 if module is nil this will call g_type_register_static() instead. This can be used when making a static build of the module.


[View source]
def register_flags(name : String, const_static_values : GObject::FlagsValue) : UInt64 #

Looks up or registers a flags type that is implemented with a particular type plugin. If a type with name type_name was previously registered, the #GType identifier for the type is returned, otherwise the type is newly registered, and the resulting #GType identifier returned.

As long as any instances of the type exist, the type plugin will not be unloaded.

Since 2.56 if module is nil this will call g_type_register_static() instead. This can be used when making a static build of the module.


[View source]
def register_type(parent_type : UInt64, type_name : String, type_info : GObject::TypeInfo, flags : GObject::TypeFlags) : UInt64 #

Looks up or registers a type that is implemented with a particular type plugin. If a type with name type_name was previously registered, the #GType identifier for the type is returned, otherwise the type is newly registered, and the resulting #GType identifier returned.

When reregistering a type (typically because a module is unloaded then reloaded, and reinitialized), module and parent_type must be the same as they were previously.

As long as any instances of the type exist, the type plugin will not be unloaded.

Since 2.56 if module is nil this will call g_type_register_static() instead. This can be used when making a static build of the module.


[View source]
def unuse : Nil #

Decreases the use count of a #GTypeModule by one. If the result is zero, the module will be unloaded. (However, the #GTypeModule will not be freed, and types associated with the #GTypeModule are not unregistered. Once a #GTypeModule is initialized, it must exist forever.)


[View source]
def use : Bool #

Increases the use count of a #GTypeModule by one. If the use count was zero before, the plugin will be loaded. If loading the plugin fails, the use count is reset to its prior value.


[View source]