+Wed Jul 18 19:42:31 2001 Tim Janik <timj@gtk.org>
+
+ * gtype.h: if __GNUC__ is defined, inline a test for an exact type
+ match for instances and classes in G_TYPE_CHECK_INSTANCE_TYPE() and
+ G_TYPE_CHECK_CLASS_TYPE() before calling g_type_instance_is_a().
+
Sun Aug 12 02:07:10 2001 Tim Janik <timj@gtk.org>
* gvaluearray.[hc]: fix preallocation logic, support DISABLE_MEM_POOLS
}
static inline gboolean
-type_lookup_prerequisite (TypeNode *iface,
- GType prerequisite_type)
+type_lookup_prerequisite_L (TypeNode *iface,
+ GType prerequisite_type)
{
if (NODE_IS_IFACE (iface) && IFACE_NODE_N_PREREQUISITES (iface))
{
tnode = lookup_type_node_L (NODE_PARENT_TYPE (iface));
if (NODE_PARENT_TYPE (tnode) && !type_lookup_iface_entry_L (node, tnode))
{
+ /* 2001/7/31:timj: erk, i guess this warning is junk as interface derivation is flat */
g_warning ("cannot add sub-interface `%s' to type `%s' which does not conform to super-interface `%s'",
NODE_NAME (iface),
NODE_NAME (node),
NODE_NAME (tnode));
return FALSE;
}
- tnode = find_conforming_type_L (node, iface);
+ tnode = find_conforming_type_L (node, iface); // FIXME: iface overriding
if (tnode)
{
g_warning ("cannot add interface type `%s' to type `%s', since type `%s' already conforms to interface",
if (prerequisite_node->is_instantiatable)
{
guint i;
-
+
+ /* can have at most one publically installable instantiatable prerequisite */
for (i = 0; i < IFACE_NODE_N_PREREQUISITES (iface); i++)
{
TypeNode *prnode = lookup_type_node_L (IFACE_NODE_PREREQUISITES (iface)[i]);
type_iface_add_prerequisite_W (iface, prerequisite_node);
}
else
- g_warning ("prerequisite `%s' for interface `%s' is not instantiatable or interface",
+ g_warning ("prerequisite `%s' for interface `%s' is neither instantiatable nor interface",
type_descriptive_name_L (prerequisite_type),
type_descriptive_name_L (interface_type));
G_WRITE_UNLOCK (&type_rw_lock);
return TRUE;
else if (support_prerequisites &&
NODE_IS_IFACE (node) &&
- type_lookup_prerequisite (node, NODE_TYPE (iface_node)))
+ type_lookup_prerequisite_L (node, NODE_TYPE (iface_node)))
return TRUE;
else
return FALSE;
node = lookup_type_node_L (type);
if (!node)
{
- g_warning ("type id `%u' is invalid", type);
+ g_warning (G_STRLOC ": type id `%u' is invalid", type);
G_READ_UNLOCK (&type_rw_lock);
return NULL;
}
# define _G_TYPE_CCC(cp, gt, ct) ((ct*) cp)
#endif /* G_DISABLE_CAST_CHECKS */
#define _G_TYPE_CHI(ip) (g_type_check_instance ((GTypeInstance*) ip))
-#define _G_TYPE_CIT(ip, gt) (g_type_instance_is_a ((GTypeInstance*) ip, gt))
-#define _G_TYPE_CCT(cp, gt) (g_type_class_is_a ((GTypeClass*) cp, gt))
#define _G_TYPE_CVH(vl, gt) (g_type_check_value_holds ((GValue*) vl, gt))
#define _G_TYPE_CHV(vl) (g_type_check_value ((GValue*) vl))
#define _G_TYPE_IGC(ip, gt, ct) ((ct*) (((GTypeInstance*) ip)->g_class))
#define _G_TYPE_IGI(ip, gt, ct) ((ct*) g_type_interface_peek (((GTypeInstance*) ip)->g_class, gt))
+#ifdef __GNUC__
+# define _G_TYPE_CIT(ip, gt) ({ \
+ GTypeInstance *__inst = (GTypeInstance*) ip; GType __t = gt; gboolean __r; \
+ if (__inst && __inst->g_class && __inst->g_class->g_type == __t) \
+ __r = TRUE; \
+ else \
+ __r = g_type_instance_is_a (__inst, __t); \
+ __r; \
+})
+# define _G_TYPE_CCT(cp, gt) ({ \
+ GTypeClass *__class = (GTypeClass*) cp; GType __t = gt; gboolean __r; \
+ if (__class && __class->g_type == __t) \
+ __r = TRUE; \
+ else \
+ __r = g_type_class_is_a (__class, __t); \
+ __r; \
+})
+#else /* !__GNUC__ */
+# define _G_TYPE_CIT(ip, gt) (g_type_instance_is_a ((GTypeInstance*) ip, gt))
+# define _G_TYPE_CCT(cp, gt) (g_type_class_is_a ((GTypeClass*) cp, gt))
+#endif /* !__GNUC__ */
#define G_TYPE_FLAG_RESERVED_ID_BIT (1 << 30)
extern GTypeDebugFlags _g_type_debug_flags;