module GICrystal

Overview

This module have types, functions and macros used by the generated bindings, if you are just using the bindings you should never deal with any of this.

Extended Modules

Defined in:

lib/gi-crystal/src/bindings/g_object/gi_crystal.cr
lib/gi-crystal/src/gi-crystal.cr
lib/gi-crystal/src/gi_crystal/closure_data_manager.cr
lib/gi-crystal/src/gi_crystal/util.cr

Constant Summary

GC_COLLECTED_QDATA_KEY = LibGLib.g_quark_from_static_string("gi-crystal::gc-collected")

See declare_new_method.

INSTANCE_QDATA_KEY = LibGLib.g_quark_from_static_string("gi-crystal::instance")

See declare_new_method.

Instance Method Summary

Macro Summary

Instance Method Detail

def finalize_instance(object : GObject::Object) #

Finalize this object, called by GObject::Object#finalize


def finalize_instance(object : GObject::ParamSpec) #

Finalize this object, called by GObject::ParamSpec#finalize


def gc_collected?(object : GObject::Object) : Bool #

Return true if GC already collected the original wrapper of this object.


def instance_pointer(object : GObject::Object) : Pointer(Void) #

Return a pointer to the original wrapper for this object.


Macro Detail

macro declare_new_method(type, qdata_get_func, qdata_set_func) #

This declare the new method on a instance of type type, qdata_get_func and qdata_set_func are functions used to set/get qdata on objects, e.g. g_object_get_qdata/g_object_set_qdata for GObjects.

GICrystal stores two qdatas in objects on following keys:

  • INSTANCE_QDATA_KEY: Store the pointer of Crystal wrapper for this C object.
  • GC_COLLECTED_QDATA_KEY: Store 1 if the GC was called for the Crystal wrapper, 0 otherwise.

INSTANCE_QDATA_KEY is used when a object comes from a C function and instead of allocate a new wrapper for it we just restore the old one. GC_COLLECTED_QDATA_KEY is used to avoid to restore a wrapper that was already collected by GC.

This is mainly used for GObject::Object, since GObject::ParamSpec doesn't support casts on GICrystal.


macro require(namespace, version) #

A macro to check if a binding was generated and require it