Add COGL_{OBJECT,HANDLE}_DEFINE_WITH_CODE

This macro is similar to COGL_HANDLE_DEFINE_WITH_CODE except that it
allows a snippet of code to be inserted into the _get_type()
function. This is similar to how G_DEFINE_TYPE_WITH_CODE
works. COGL_HANDLE_DEFINE is now just a wrapper around
COGL_HANDLE_DEFINE_WITH_CODE.
This commit is contained in:
Neil Roberts 2010-06-11 13:44:27 +01:00
parent 97225a96a6
commit 5ea8c5bd12

View File

@ -106,7 +106,7 @@ struct _CoglObject
#define _COGL_HANDLE_DEBUG_UNREF _COGL_OBJECT_DEBUG_UNREF
#define COGL_HANDLE_DEBUG_FREE COGL_OBJECT_DEBUG_FREE
#define COGL_OBJECT_DEFINE(TypeName, type_name) \
#define COGL_OBJECT_DEFINE_WITH_CODE(TypeName, type_name, code) \
\
static CoglObjectClass _cogl_##type_name##_class; \
\
@ -115,7 +115,10 @@ _cogl_object_##type_name##_get_type (void) \
{ \
static GQuark type = 0; \
if (!type) \
type = g_quark_from_static_string ("Cogl"#TypeName); \
{ \
type = g_quark_from_static_string ("Cogl"#TypeName); \
{ code; } \
} \
return type; \
} \
\
@ -191,10 +194,13 @@ cogl_##type_name##_unref (void *object) \
cogl_handle_unref (object); \
}
#define COGL_OBJECT_DEFINE(TypeName, type_name) \
COGL_OBJECT_DEFINE_WITH_CODE (TypeName, type_name, (void) 0)
/* For temporary compatability */
#define COGL_HANDLE_DEFINE(TypeName, type_name) \
#define COGL_HANDLE_DEFINE_WITH_CODE(TypeName, type_name, code) \
\
COGL_OBJECT_DEFINE (TypeName, type_name) \
COGL_OBJECT_DEFINE_WITH_CODE (TypeName, type_name, code) \
\
static Cogl##TypeName * \
_cogl_##type_name##_handle_new (CoglHandle handle) \
@ -202,5 +208,8 @@ _cogl_##type_name##_handle_new (CoglHandle handle) \
return _cogl_##type_name##_object_new (handle); \
}
#define COGL_HANDLE_DEFINE(TypeName, type_name) \
COGL_HANDLE_DEFINE_WITH_CODE (TypeName, type_name, (void) 0)
#endif /* __COGL_OBJECT_PRIVATE_H */