/**
 * g_interface_info_get_constant:
 * @info: a #GIInterfaceInfo
 * @n: index of constant to get
 *
 * Obtain an interface type constant at index @n.
 *
 * Returns: (transfer full): the #GIConstantInfo. Free the struct by calling
 * g_base_info_unref() when done.
 */
GIConstantInfo *
g_interface_info_get_constant (GIInterfaceInfo *info,
                               gint             n)
{
    gint offset;
    GIRealInfo *rinfo = (GIRealInfo *)info;
    Header *header;
    InterfaceBlob *blob;

    g_return_val_if_fail (info != NULL, NULL);
    g_return_val_if_fail (GI_IS_INTERFACE_INFO (info), NULL);

    header = (Header *)rinfo->typelib->data;
    blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];

    offset = rinfo->offset + header->interface_blob_size
             + (blob->n_prerequisites + (blob->n_prerequisites % 2)) * 2
             + blob->n_properties * header->property_blob_size
             + blob->n_methods * header->function_blob_size
             + blob->n_signals * header->signal_blob_size
             + blob->n_vfuncs * header->vfunc_blob_size
             + n * header->constant_blob_size;

    return (GIConstantInfo *) g_info_new (GI_INFO_TYPE_CONSTANT, (GIBaseInfo*)info,
                                          rinfo->typelib, offset);
}
/**
 * g_interface_info_get_n_prerequisites:
 * @info: a #GIInterfaceInfo
 *
 * Obtain the number of prerequisites for this interface type.
 * A prerequisites is another interface that needs to be implemented for
 * interface, similar to an base class for GObjects.
 *
 * Returns: number of prerequisites
 */
gint
g_interface_info_get_n_prerequisites (GIInterfaceInfo *info)
{
    GIRealInfo *rinfo = (GIRealInfo *)info;
    InterfaceBlob *blob;

    g_return_val_if_fail (info != NULL, 0);
    g_return_val_if_fail (GI_IS_INTERFACE_INFO (info), 0);

    blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];

    return blob->n_prerequisites;
}
/**
 * g_interface_info_get_prerequisite:
 * @info: a #GIInterfaceInfo
 * @n: index of prerequisites to get
 *
 * Obtain an interface type prerequisites index @n.
 *
 * Returns: (transfer full): the prerequisites as a #GIBaseInfo. Free the struct by calling
 * g_base_info_unref() when done.
 */
GIBaseInfo *
g_interface_info_get_prerequisite (GIInterfaceInfo *info,
                                   gint            n)
{
    GIRealInfo *rinfo = (GIRealInfo *)info;
    InterfaceBlob *blob;

    g_return_val_if_fail (info != NULL, NULL);
    g_return_val_if_fail (GI_IS_INTERFACE_INFO (info), NULL);

    blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];

    return _g_info_from_entry (rinfo->repository,
                               rinfo->typelib, blob->prerequisites[n]);
}
/**
 * g_interface_info_get_iface_struct:
 * @info: a #GIInterfaceInfo
 *
 * Returns the layout C structure associated with this #GInterface.
 *
 * Returns: (transfer full): the #GIStructInfo or %NULL. Free it with
 * g_base_info_unref() when done.
 */
GIStructInfo *
g_interface_info_get_iface_struct (GIInterfaceInfo *info)
{
    GIRealInfo *rinfo = (GIRealInfo *)info;
    InterfaceBlob *blob;

    g_return_val_if_fail (info != NULL, NULL);
    g_return_val_if_fail (GI_IS_INTERFACE_INFO (info), NULL);

    blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];

    if (blob->gtype_struct)
        return (GIStructInfo *) _g_info_from_entry (rinfo->repository,
                rinfo->typelib, blob->gtype_struct);
    else
        return NULL;
}
/**
 * g_interface_info_get_property:
 * @info: a #GIInterfaceInfo
 * @n: index of property to get
 *
 * Obtain an interface type property at index @n.
 *
 * Returns: (transfer full): the #GIPropertyInfo. Free the struct by calling
 * g_base_info_unref() when done.
 */
GIPropertyInfo *
g_interface_info_get_property (GIInterfaceInfo *info,
                               gint            n)
{
    gint offset;
    GIRealInfo *rinfo = (GIRealInfo *)info;
    Header *header;
    InterfaceBlob *blob;

    g_return_val_if_fail (info != NULL, NULL);
    g_return_val_if_fail (GI_IS_INTERFACE_INFO (info), NULL);

    header = (Header *)rinfo->typelib->data;
    blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];

    offset = rinfo->offset + header->interface_blob_size
             + (blob->n_prerequisites + (blob->n_prerequisites % 2)) * 2
             + n * header->property_blob_size;

    return (GIPropertyInfo *) g_info_new (GI_INFO_TYPE_PROPERTY, (GIBaseInfo*)info,
                                          rinfo->typelib, offset);
}
Beispiel #6
0
static GISignalInfo *
_pygi_lookup_signal_from_g_type (GType g_type,
                                 const gchar *signal_name)
{
    GIRepository *repository;
    GIBaseInfo *info;
    GISignalInfo *signal_info = NULL;

    repository = g_irepository_get_default();
    info = g_irepository_find_by_gtype (repository, g_type);
    if (info == NULL)
        return NULL;

    if (GI_IS_OBJECT_INFO (info))
        signal_info = g_object_info_find_signal ((GIObjectInfo *) info,
                                                 signal_name);
    else if (GI_IS_INTERFACE_INFO (info))
        signal_info = g_interface_info_find_signal ((GIInterfaceInfo *) info,
                                                    signal_name);

    g_base_info_unref (info);
    return signal_info;
}
/**
 * g_interface_info_find_vfunc:
 * @info: a #GIInterfaceInfo
 * @name: The name of a virtual function to find.
 *
 * Locate a virtual function slot with name @name. See the documentation
 * for g_object_info_find_vfunc() for more information on virtuals.
 *
 * Returns: (transfer full): the #GIVFuncInfo, or %NULL. Free it with
 * g_base_info_unref() when done.
 */
GIVFuncInfo *
g_interface_info_find_vfunc (GIInterfaceInfo *info,
                             const gchar  *name)
{
    gint offset;
    GIRealInfo *rinfo = (GIRealInfo *)info;
    Header *header;
    InterfaceBlob *blob;

    g_return_val_if_fail (info != NULL, NULL);
    g_return_val_if_fail (GI_IS_INTERFACE_INFO (info), NULL);

    header = (Header *)rinfo->typelib->data;
    blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset];

    offset = rinfo->offset + header->interface_blob_size
             + (blob->n_prerequisites + blob->n_prerequisites % 2) * 2
             + blob->n_properties * header->property_blob_size
             + blob->n_methods * header->function_blob_size
             + blob->n_signals * header->signal_blob_size;

    return _g_base_info_find_vfunc (rinfo, offset, blob->n_vfuncs, name);
}