macro in gtk

来源:互联网 发布:mac 将wma转换成mp3 编辑:程序博客网 时间:2024/06/07 11:31

GTK_WINDOW is a macro that does the cast.

As seen here

#define GTK_WINDOW(obj)  (GTK_CHECK_CAST ((obj), GTK_TYPE_WINDOW, GtkWindow))

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))

The code for g_type_check_instance_cast can be found here

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;}
share|edit|flag
0 0
原创粉丝点击