gtypeInstance*
G_type_check_instance_cast(GTypeInstance*type_instance,G_check_instance_cast,G_type_instance,G_check_instance,G_type_cast,G_check
G型iface_型)
{
if(type_instance)
{
if(type_instance->g_class)
{
typenode*节点,*iface;
GBoolean是“可瞬间”的,检查;
node=lookup_type_node_i(type_instance->g_class->g_type);
是否可实例化=节点&节点->是否可实例化;
iface=lookup_type_node_i(iface_type);
check=是否可实例化&iface&type_node_符合_(node,iface,true,false);
如果(检查)
返回类型_实例;
如果(可实例化)
g_警告(“从`%s'到`%s'的强制转换无效”,
键入“描述性名称”(类型“实例”->g“类”->g“类型”),
类型_描述性_name_i(iface_type));
其他的
g_warning(“强制转换为“%s”中的不可实例化类型“%s”无效”,
键入“描述性名称”(类型“实例”->g“类”->g“类型”),
类型_描述性_name_i(iface_type));
}
其他的
g_warning(“强制转换到`%s'中的未通过指针无效”,
类型_描述性_name_i(iface_type));
}
返回类型_实例;
}
< /代码>
Again
#define GTK_CHECK_CAST G_TYPE_CHECK_INSTANCE_CAST
and
#define G_TYPE_CHECK_INSTANCE_CAST(instance, g_type, c_type) (_G_TYPE_CIC ((instance), (g_type), c_type))
which is...
#define _G_TYPE_CIC(ip,gt,ct) \
((ct*) g_type_check_instance_cast ((GTypeInstance*) ip, gt))
代码g_type_check_instance_cast
可以在这里找到
GTypeInstance*
g_type_check_instance_cast (GTypeInstance *type_instance,
GType iface_type)
{
if (type_instance)
{
if (type_instance->g_class)
{
TypeNode *node, *iface;
gboolean is_instantiatable, check;
node = lookup_type_node_I (type_instance->g_class->g_type);
is_instantiatable = node && node->is_instantiatable;
iface = lookup_type_node_I (iface_type);
check = is_instantiatable && iface && type_node_conforms_to_U (node, iface, TRUE, FALSE);
if (check)
return type_instance;
if (is_instantiatable)
g_warning ("invalid cast from `%s' to `%s'",
type_descriptive_name_I (type_instance->g_class->g_type),
type_descriptive_name_I (iface_type));
else
g_warning ("invalid uninstantiatable type `%s' in cast to `%s'",
type_descriptive_name_I (type_instance->g_class->g_type),
type_descriptive_name_I (iface_type));
}
else
g_warning ("invalid unclassed pointer in cast to `%s'",
type_descriptive_name_I (iface_type));
}
return type_instance;
}