Don't define public cogl_is_* functions for internal types

This adds a COGL_OBJECT_INTERNAL_DEFINE macro and friends that are the
same as COGL_OBJECT_DEFINE except that they prefix the cogl_is_*
function with an underscore so that it doesn't get exported in the
shared library.
This commit is contained in:
Neil Roberts 2010-07-09 18:46:31 +01:00
parent 0e839c3769
commit 8a85088196
10 changed files with 87 additions and 41 deletions

View File

@ -72,7 +72,7 @@
static void _cogl_atlas_texture_free (CoglAtlasTexture *sub_tex); static void _cogl_atlas_texture_free (CoglAtlasTexture *sub_tex);
COGL_TEXTURE_DEFINE (AtlasTexture, atlas_texture); COGL_TEXTURE_INTERNAL_DEFINE (AtlasTexture, atlas_texture);
static const CoglTextureVtable cogl_atlas_texture_vtable; static const CoglTextureVtable cogl_atlas_texture_vtable;

View File

@ -155,7 +155,7 @@ struct _CoglClipStackEntryPath
static void _cogl_clip_stack_free (CoglClipStack *stack); static void _cogl_clip_stack_free (CoglClipStack *stack);
COGL_OBJECT_DEFINE (ClipStack, clip_stack); COGL_OBJECT_INTERNAL_DEFINE (ClipStack, clip_stack);
#define COGL_CLIP_STACK(stack) ((CoglClipStack *) (stack)) #define COGL_CLIP_STACK(stack) ((CoglClipStack *) (stack))
@ -752,7 +752,7 @@ _cogl_clip_stack_copy (CoglClipStack *old_stack)
{ {
CoglClipStack *new_stack; CoglClipStack *new_stack;
if (!cogl_is_clip_stack (old_stack)) if (!_cogl_is_clip_stack (old_stack))
return NULL; return NULL;
new_stack = _cogl_clip_stack_new (); new_stack = _cogl_clip_stack_new ();

View File

@ -113,7 +113,7 @@ static void _cogl_framebuffer_free (CoglFramebuffer *framebuffer);
static void _cogl_onscreen_free (CoglOnscreen *onscreen); static void _cogl_onscreen_free (CoglOnscreen *onscreen);
static void _cogl_offscreen_free (CoglOffscreen *offscreen); static void _cogl_offscreen_free (CoglOffscreen *offscreen);
COGL_OBJECT_DEFINE (Onscreen, onscreen); COGL_OBJECT_INTERNAL_DEFINE (Onscreen, onscreen);
COGL_OBJECT_DEFINE (Offscreen, offscreen); COGL_OBJECT_DEFINE (Offscreen, offscreen);
COGL_OBJECT_DEFINE_DEPRECATED_REF_COUNTING (offscreen); COGL_OBJECT_DEFINE_DEPRECATED_REF_COUNTING (offscreen);
@ -124,7 +124,7 @@ COGL_OBJECT_DEFINE_DEPRECATED_REF_COUNTING (offscreen);
*/ */
gboolean gboolean
cogl_is_framebuffer (void *object) _cogl_is_framebuffer (void *object)
{ {
CoglHandleObject *obj = object; CoglHandleObject *obj = object;
@ -635,7 +635,7 @@ _cogl_set_framebuffer_real (CoglFramebuffer *framebuffer)
void void
cogl_set_framebuffer (CoglFramebuffer *framebuffer) cogl_set_framebuffer (CoglFramebuffer *framebuffer)
{ {
g_return_if_fail (cogl_is_framebuffer (framebuffer)); g_return_if_fail (_cogl_is_framebuffer (framebuffer));
if (_cogl_get_framebuffer () != framebuffer) if (_cogl_get_framebuffer () != framebuffer)
_cogl_set_framebuffer_real (framebuffer); _cogl_set_framebuffer_real (framebuffer);
@ -668,7 +668,7 @@ cogl_push_framebuffer (CoglFramebuffer *buffer)
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
g_return_if_fail (cogl_is_framebuffer (buffer)); g_return_if_fail (_cogl_is_framebuffer (buffer));
g_assert (ctx->framebuffer_stack); g_assert (ctx->framebuffer_stack);
cogl_flush (); cogl_flush ();

View File

@ -113,7 +113,11 @@ static const CoglMaterialBackend *backends[COGL_MATERIAL_N_BACKENDS];
COGL_OBJECT_DEFINE (Material, material); COGL_OBJECT_DEFINE (Material, material);
COGL_OBJECT_DEFINE_DEPRECATED_REF_COUNTING (material); COGL_OBJECT_DEFINE_DEPRECATED_REF_COUNTING (material);
COGL_OBJECT_DEFINE (MaterialLayer, material_layer); /* This type was made deprecated before the cogl_is_material_layer
function was ever exposed in the public headers so there's no need
to make the cogl_is_material_layer function public. We use INTERNAL
so that the cogl_is_* function won't get defined */
COGL_OBJECT_INTERNAL_DEFINE (MaterialLayer, material_layer);
static void static void
texture_unit_init (CoglTextureUnit *unit, int index_) texture_unit_init (CoglTextureUnit *unit, int index_)
@ -2425,7 +2429,7 @@ cogl_material_layer_get_wrap_mode_s (CoglMaterialLayer *layer)
CoglMaterialLayerState change = COGL_MATERIAL_LAYER_STATE_WRAP_MODES; CoglMaterialLayerState change = COGL_MATERIAL_LAYER_STATE_WRAP_MODES;
CoglMaterialLayer *authority; CoglMaterialLayer *authority;
g_return_val_if_fail (cogl_is_material_layer (layer), FALSE); g_return_val_if_fail (_cogl_is_material_layer (layer), FALSE);
/* Now find the ancestor of the layer that is the authority for the /* Now find the ancestor of the layer that is the authority for the
* state we want to change */ * state we want to change */
@ -2460,7 +2464,7 @@ cogl_material_layer_get_wrap_mode_t (CoglMaterialLayer *layer)
CoglMaterialLayerState change = COGL_MATERIAL_LAYER_STATE_WRAP_MODES; CoglMaterialLayerState change = COGL_MATERIAL_LAYER_STATE_WRAP_MODES;
CoglMaterialLayer *authority; CoglMaterialLayer *authority;
g_return_val_if_fail (cogl_is_material_layer (layer), FALSE); g_return_val_if_fail (_cogl_is_material_layer (layer), FALSE);
/* Now find the ancestor of the layer that is the authority for the /* Now find the ancestor of the layer that is the authority for the
* state we want to change */ * state we want to change */
@ -5028,7 +5032,7 @@ cogl_material_layer_get_type (CoglMaterialLayer *layer)
CoglHandle CoglHandle
cogl_material_layer_get_texture (CoglMaterialLayer *layer) cogl_material_layer_get_texture (CoglMaterialLayer *layer)
{ {
g_return_val_if_fail (cogl_is_material_layer (layer), g_return_val_if_fail (_cogl_is_material_layer (layer),
COGL_INVALID_HANDLE); COGL_INVALID_HANDLE);
return _cogl_material_layer_get_texture (layer); return _cogl_material_layer_get_texture (layer);
@ -5039,7 +5043,7 @@ _cogl_material_layer_has_user_matrix (CoglMaterialLayer *layer)
{ {
CoglMaterialLayer *authority; CoglMaterialLayer *authority;
g_return_val_if_fail (cogl_is_material_layer (layer), FALSE); g_return_val_if_fail (_cogl_is_material_layer (layer), FALSE);
authority = authority =
_cogl_material_layer_get_authority (layer, _cogl_material_layer_get_authority (layer,
@ -5094,7 +5098,7 @@ cogl_material_layer_get_min_filter (CoglMaterialLayer *layer)
{ {
CoglMaterialLayer *authority; CoglMaterialLayer *authority;
g_return_val_if_fail (cogl_is_material_layer (layer), 0); g_return_val_if_fail (_cogl_is_material_layer (layer), 0);
authority = authority =
_cogl_material_layer_get_authority (layer, _cogl_material_layer_get_authority (layer,
@ -5108,7 +5112,7 @@ cogl_material_layer_get_mag_filter (CoglMaterialLayer *layer)
{ {
CoglMaterialLayer *authority; CoglMaterialLayer *authority;
g_return_val_if_fail (cogl_is_material_layer (layer), 0); g_return_val_if_fail (_cogl_is_material_layer (layer), 0);
authority = authority =
_cogl_material_layer_get_authority (layer, _cogl_material_layer_get_authority (layer,

View File

@ -109,7 +109,7 @@ struct _CoglObject
#define _COGL_HANDLE_DEBUG_UNREF _COGL_OBJECT_DEBUG_UNREF #define _COGL_HANDLE_DEBUG_UNREF _COGL_OBJECT_DEBUG_UNREF
#define COGL_HANDLE_DEBUG_FREE COGL_OBJECT_DEBUG_FREE #define COGL_HANDLE_DEBUG_FREE COGL_OBJECT_DEBUG_FREE
#define COGL_OBJECT_DEFINE_WITH_CODE(TypeName, type_name, code) \ #define COGL_OBJECT_COMMON_DEFINE_WITH_CODE(TypeName, type_name, code) \
\ \
static CoglObjectClass _cogl_##type_name##_class; \ static CoglObjectClass _cogl_##type_name##_class; \
\ \
@ -154,18 +154,38 @@ Cogl##TypeName * \
_cogl_##type_name##_pointer_from_handle (CoglHandle handle) \ _cogl_##type_name##_pointer_from_handle (CoglHandle handle) \
{ \ { \
return handle; \ return handle; \
} \ }
\
gboolean \ #define COGL_OBJECT_DEFINE_WITH_CODE(TypeName, type_name, code) \
cogl_is_##type_name (void *object) \ \
{ \ COGL_OBJECT_COMMON_DEFINE_WITH_CODE(TypeName, type_name, code) \
CoglObject *obj = object; \ \
\ gboolean \
if (object == NULL) \ cogl_is_##type_name (void *object) \
return FALSE; \ { \
\ CoglObject *obj = object; \
return (obj->klass->type == \ \
_cogl_object_##type_name##_get_type ()); \ if (object == NULL) \
return FALSE; \
\
return (obj->klass->type == \
_cogl_object_##type_name##_get_type ()); \
}
#define COGL_OBJECT_INTERNAL_DEFINE_WITH_CODE(TypeName, type_name, code) \
\
COGL_OBJECT_COMMON_DEFINE_WITH_CODE(TypeName, type_name, code) \
\
gboolean \
_cogl_is_##type_name (void *object) \
{ \
CoglObject *obj = object; \
\
if (object == NULL) \
return FALSE; \
\
return (obj->klass->type == \
_cogl_object_##type_name##_get_type ()); \
} }
#define COGL_OBJECT_DEFINE_DEPRECATED_REF_COUNTING(type_name) \ #define COGL_OBJECT_DEFINE_DEPRECATED_REF_COUNTING(type_name) \
@ -202,17 +222,33 @@ cogl_##type_name##_unref (void *object) \
#define COGL_OBJECT_DEFINE(TypeName, type_name) \ #define COGL_OBJECT_DEFINE(TypeName, type_name) \
COGL_OBJECT_DEFINE_WITH_CODE (TypeName, type_name, (void) 0) COGL_OBJECT_DEFINE_WITH_CODE (TypeName, type_name, (void) 0)
#define COGL_OBJECT_INTERNAL_DEFINE(TypeName, type_name) \
COGL_OBJECT_INTERNAL_DEFINE_WITH_CODE (TypeName, type_name, (void) 0)
/* For temporary compatability */ /* For temporary compatability */
#define COGL_HANDLE_DEFINE_WITH_CODE(TypeName, type_name, code) \ #define COGL_HANDLE_INTERNAL_DEFINE_WITH_CODE(TypeName, type_name, code) \
\ \
COGL_OBJECT_DEFINE_WITH_CODE (TypeName, type_name, code) \ COGL_OBJECT_INTERNAL_DEFINE_WITH_CODE (TypeName, type_name, code) \
\ \
static Cogl##TypeName * \ static Cogl##TypeName * \
_cogl_##type_name##_handle_new (CoglHandle handle) \ _cogl_##type_name##_handle_new (CoglHandle handle) \
{ \ { \
return _cogl_##type_name##_object_new (handle); \ return _cogl_##type_name##_object_new (handle); \
} }
#define COGL_HANDLE_DEFINE_WITH_CODE(TypeName, type_name, code) \
\
COGL_OBJECT_DEFINE_WITH_CODE (TypeName, type_name, code) \
\
static Cogl##TypeName * \
_cogl_##type_name##_handle_new (CoglHandle handle) \
{ \
return _cogl_##type_name##_object_new (handle); \
}
#define COGL_HANDLE_INTERNAL_DEFINE(TypeName, type_name) \
COGL_HANDLE_INTERNAL_DEFINE_WITH_CODE (TypeName, type_name, (void) 0)
#define COGL_HANDLE_DEFINE(TypeName, type_name) \ #define COGL_HANDLE_DEFINE(TypeName, type_name) \
COGL_HANDLE_DEFINE_WITH_CODE (TypeName, type_name, (void) 0) COGL_HANDLE_DEFINE_WITH_CODE (TypeName, type_name, (void) 0)

View File

@ -42,7 +42,7 @@
static void _cogl_sub_texture_free (CoglSubTexture *sub_tex); static void _cogl_sub_texture_free (CoglSubTexture *sub_tex);
COGL_TEXTURE_DEFINE (SubTexture, sub_texture); COGL_TEXTURE_INTERNAL_DEFINE (SubTexture, sub_texture);
static const CoglTextureVtable cogl_sub_texture_vtable; static const CoglTextureVtable cogl_sub_texture_vtable;
@ -274,7 +274,7 @@ _cogl_sub_texture_new (CoglHandle next_texture,
/* If the next texture is also a sub texture we can avoid one level /* If the next texture is also a sub texture we can avoid one level
of indirection by referencing the full texture of that texture of indirection by referencing the full texture of that texture
instead. */ instead. */
if (cogl_is_sub_texture (next_texture)) if (_cogl_is_sub_texture (next_texture))
{ {
CoglSubTexture *other_sub_tex = CoglSubTexture *other_sub_tex =
_cogl_sub_texture_pointer_from_handle (next_texture); _cogl_sub_texture_pointer_from_handle (next_texture);

View File

@ -50,7 +50,7 @@
static void _cogl_texture_2d_sliced_free (CoglTexture2DSliced *tex_2ds); static void _cogl_texture_2d_sliced_free (CoglTexture2DSliced *tex_2ds);
COGL_TEXTURE_DEFINE (Texture2DSliced, texture_2d_sliced); COGL_TEXTURE_INTERNAL_DEFINE (Texture2DSliced, texture_2d_sliced);
static const CoglTextureVtable cogl_texture_2d_sliced_vtable; static const CoglTextureVtable cogl_texture_2d_sliced_vtable;

View File

@ -44,7 +44,7 @@
static void _cogl_texture_2d_free (CoglTexture2D *tex_2d); static void _cogl_texture_2d_free (CoglTexture2D *tex_2d);
COGL_TEXTURE_DEFINE (Texture2D, texture_2d); COGL_TEXTURE_INTERNAL_DEFINE (Texture2D, texture_2d);
static const CoglTextureVtable cogl_texture_2d_vtable; static const CoglTextureVtable cogl_texture_2d_vtable;
@ -323,7 +323,7 @@ _cogl_texture_2d_new_from_bitmap (CoglHandle bmp_handle,
void void
_cogl_texture_2d_externally_modified (CoglHandle handle) _cogl_texture_2d_externally_modified (CoglHandle handle)
{ {
if (!cogl_is_texture_2d (handle)) if (!_cogl_is_texture_2d (handle))
return; return;
COGL_TEXTURE_2D (handle)->mipmaps_dirty = TRUE; COGL_TEXTURE_2D (handle)->mipmaps_dirty = TRUE;

View File

@ -165,6 +165,12 @@ _cogl_texture_register_texture_type (GQuark type);
_cogl_texture_register_texture_type (_cogl_handle_ \ _cogl_texture_register_texture_type (_cogl_handle_ \
## type_name ## _get_type ())) ## type_name ## _get_type ()))
#define COGL_TEXTURE_INTERNAL_DEFINE(TypeName, type_name) \
COGL_HANDLE_INTERNAL_DEFINE_WITH_CODE \
(TypeName, type_name, \
_cogl_texture_register_texture_type (_cogl_handle_ \
## type_name ## _get_type ()))
void void
_cogl_texture_foreach_sub_texture_in_region (CoglHandle handle, _cogl_texture_foreach_sub_texture_in_region (CoglHandle handle,
float virtual_tx_1, float virtual_tx_1,

View File

@ -54,7 +54,7 @@
static void _cogl_texture_rectangle_free (CoglTextureRectangle *tex_rect); static void _cogl_texture_rectangle_free (CoglTextureRectangle *tex_rect);
COGL_TEXTURE_DEFINE (TextureRectangle, texture_rectangle); COGL_TEXTURE_INTERNAL_DEFINE (TextureRectangle, texture_rectangle);
static const CoglTextureVtable cogl_texture_rectangle_vtable; static const CoglTextureVtable cogl_texture_rectangle_vtable;