From 8a85088196809cac2b47a84be2d7f0a1e3c67701 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Fri, 9 Jul 2010 18:46:31 +0100 Subject: [PATCH] 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. --- clutter/cogl/cogl/cogl-atlas-texture.c | 2 +- clutter/cogl/cogl/cogl-clip-stack.c | 4 +- clutter/cogl/cogl/cogl-framebuffer.c | 8 +-- clutter/cogl/cogl/cogl-material.c | 18 ++++--- clutter/cogl/cogl/cogl-object-private.h | 78 ++++++++++++++++++++++-------- clutter/cogl/cogl/cogl-sub-texture.c | 4 +- clutter/cogl/cogl/cogl-texture-2d-sliced.c | 2 +- clutter/cogl/cogl/cogl-texture-2d.c | 4 +- clutter/cogl/cogl/cogl-texture-private.h | 6 +++ clutter/cogl/cogl/cogl-texture-rectangle.c | 2 +- 10 files changed, 87 insertions(+), 41 deletions(-) diff --git a/clutter/cogl/cogl/cogl-atlas-texture.c b/clutter/cogl/cogl/cogl-atlas-texture.c index a5fc933..7db23a1 100644 --- a/clutter/cogl/cogl/cogl-atlas-texture.c +++ b/clutter/cogl/cogl/cogl-atlas-texture.c @@ -72,7 +72,7 @@ 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; diff --git a/clutter/cogl/cogl/cogl-clip-stack.c b/clutter/cogl/cogl/cogl-clip-stack.c index db9560c..120793d 100644 --- a/clutter/cogl/cogl/cogl-clip-stack.c +++ b/clutter/cogl/cogl/cogl-clip-stack.c @@ -155,7 +155,7 @@ struct _CoglClipStackEntryPath 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)) @@ -752,7 +752,7 @@ _cogl_clip_stack_copy (CoglClipStack *old_stack) { CoglClipStack *new_stack; - if (!cogl_is_clip_stack (old_stack)) + if (!_cogl_is_clip_stack (old_stack)) return NULL; new_stack = _cogl_clip_stack_new (); diff --git a/clutter/cogl/cogl/cogl-framebuffer.c b/clutter/cogl/cogl/cogl-framebuffer.c index 3d8b837..a89cf2a 100644 --- a/clutter/cogl/cogl/cogl-framebuffer.c +++ b/clutter/cogl/cogl/cogl-framebuffer.c @@ -113,7 +113,7 @@ static void _cogl_framebuffer_free (CoglFramebuffer *framebuffer); static void _cogl_onscreen_free (CoglOnscreen *onscreen); 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_DEPRECATED_REF_COUNTING (offscreen); @@ -124,7 +124,7 @@ COGL_OBJECT_DEFINE_DEPRECATED_REF_COUNTING (offscreen); */ gboolean -cogl_is_framebuffer (void *object) +_cogl_is_framebuffer (void *object) { CoglHandleObject *obj = object; @@ -635,7 +635,7 @@ _cogl_set_framebuffer_real (CoglFramebuffer *framebuffer) void 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) _cogl_set_framebuffer_real (framebuffer); @@ -668,7 +668,7 @@ cogl_push_framebuffer (CoglFramebuffer *buffer) { _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); cogl_flush (); diff --git a/clutter/cogl/cogl/cogl-material.c b/clutter/cogl/cogl/cogl-material.c index 3b2edc4..01bd2e4 100644 --- a/clutter/cogl/cogl/cogl-material.c +++ b/clutter/cogl/cogl/cogl-material.c @@ -113,7 +113,11 @@ static const CoglMaterialBackend *backends[COGL_MATERIAL_N_BACKENDS]; COGL_OBJECT_DEFINE (Material, 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 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; 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 * 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; 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 * state we want to change */ @@ -5028,7 +5032,7 @@ cogl_material_layer_get_type (CoglMaterialLayer *layer) CoglHandle 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); return _cogl_material_layer_get_texture (layer); @@ -5039,7 +5043,7 @@ _cogl_material_layer_has_user_matrix (CoglMaterialLayer *layer) { 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 = _cogl_material_layer_get_authority (layer, @@ -5094,7 +5098,7 @@ cogl_material_layer_get_min_filter (CoglMaterialLayer *layer) { 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 = _cogl_material_layer_get_authority (layer, @@ -5108,7 +5112,7 @@ cogl_material_layer_get_mag_filter (CoglMaterialLayer *layer) { 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 = _cogl_material_layer_get_authority (layer, diff --git a/clutter/cogl/cogl/cogl-object-private.h b/clutter/cogl/cogl/cogl-object-private.h index 8f56c4a..43617f1 100644 --- a/clutter/cogl/cogl/cogl-object-private.h +++ b/clutter/cogl/cogl/cogl-object-private.h @@ -109,7 +109,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_WITH_CODE(TypeName, type_name, code) \ +#define COGL_OBJECT_COMMON_DEFINE_WITH_CODE(TypeName, type_name, code) \ \ static CoglObjectClass _cogl_##type_name##_class; \ \ @@ -154,18 +154,38 @@ Cogl##TypeName * \ _cogl_##type_name##_pointer_from_handle (CoglHandle handle) \ { \ return handle; \ -} \ - \ -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_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_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) \ @@ -202,17 +222,33 @@ cogl_##type_name##_unref (void *object) \ #define COGL_OBJECT_DEFINE(TypeName, type_name) \ 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 */ -#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_WITH_CODE(TypeName, type_name, code) \ + \ +COGL_OBJECT_INTERNAL_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_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) \ COGL_HANDLE_DEFINE_WITH_CODE (TypeName, type_name, (void) 0) diff --git a/clutter/cogl/cogl/cogl-sub-texture.c b/clutter/cogl/cogl/cogl-sub-texture.c index 5d37e84..00db68b 100644 --- a/clutter/cogl/cogl/cogl-sub-texture.c +++ b/clutter/cogl/cogl/cogl-sub-texture.c @@ -42,7 +42,7 @@ 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; @@ -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 of indirection by referencing the full texture of that texture instead. */ - if (cogl_is_sub_texture (next_texture)) + if (_cogl_is_sub_texture (next_texture)) { CoglSubTexture *other_sub_tex = _cogl_sub_texture_pointer_from_handle (next_texture); diff --git a/clutter/cogl/cogl/cogl-texture-2d-sliced.c b/clutter/cogl/cogl/cogl-texture-2d-sliced.c index 1ad6dce..5f38555 100644 --- a/clutter/cogl/cogl/cogl-texture-2d-sliced.c +++ b/clutter/cogl/cogl/cogl-texture-2d-sliced.c @@ -50,7 +50,7 @@ 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; diff --git a/clutter/cogl/cogl/cogl-texture-2d.c b/clutter/cogl/cogl/cogl-texture-2d.c index e5e04f9..6a42e1e 100644 --- a/clutter/cogl/cogl/cogl-texture-2d.c +++ b/clutter/cogl/cogl/cogl-texture-2d.c @@ -44,7 +44,7 @@ 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; @@ -323,7 +323,7 @@ _cogl_texture_2d_new_from_bitmap (CoglHandle bmp_handle, void _cogl_texture_2d_externally_modified (CoglHandle handle) { - if (!cogl_is_texture_2d (handle)) + if (!_cogl_is_texture_2d (handle)) return; COGL_TEXTURE_2D (handle)->mipmaps_dirty = TRUE; diff --git a/clutter/cogl/cogl/cogl-texture-private.h b/clutter/cogl/cogl/cogl-texture-private.h index 949df57..5737e8d 100644 --- a/clutter/cogl/cogl/cogl-texture-private.h +++ b/clutter/cogl/cogl/cogl-texture-private.h @@ -165,6 +165,12 @@ _cogl_texture_register_texture_type (GQuark type); _cogl_texture_register_texture_type (_cogl_handle_ \ ## 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 _cogl_texture_foreach_sub_texture_in_region (CoglHandle handle, float virtual_tx_1, diff --git a/clutter/cogl/cogl/cogl-texture-rectangle.c b/clutter/cogl/cogl/cogl-texture-rectangle.c index ca25a40..1e35df6 100644 --- a/clutter/cogl/cogl/cogl-texture-rectangle.c +++ b/clutter/cogl/cogl/cogl-texture-rectangle.c @@ -54,7 +54,7 @@ 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; -- 2.7.4