[mutter/wip/nielsdg/coglhandle-stepped-approach: 2/4] cogl: Deduplicate cogl_is_* macro generation



commit 397f6067f4c8a881e255646c0db2a189b569ae06
Author: Niels De Graef <niels degraef barco com>
Date:   Wed Feb 20 14:23:37 2019 +0100

    cogl: Deduplicate cogl_is_* macro generation
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/451

 cogl/cogl/cogl-object-private.h       | 42 +++++++++--------------------------
 cogl/cogl/cogl-pipeline-layer-state.c | 10 ++++-----
 2 files changed, 15 insertions(+), 37 deletions(-)
---
diff --git a/cogl/cogl/cogl-object-private.h b/cogl/cogl/cogl-object-private.h
index 510d992f2..fc3832671 100644
--- a/cogl/cogl/cogl-object-private.h
+++ b/cogl/cogl/cogl-object-private.h
@@ -193,14 +193,7 @@ _cogl_##type_name##_object_new (Cogl##TypeName *new_obj)                \
   _cogl_object_##type_name##_inc ();                                    \
   _COGL_OBJECT_DEBUG_NEW (TypeName, obj);                               \
   return new_obj;                                                       \
-}
-
-#define COGL_OBJECT_DEFINE_WITH_CODE_GTYPE(TypeName, type_name, code)   \
-                                                                        \
-COGL_OBJECT_COMMON_DEFINE_WITH_CODE(TypeName,                           \
-                                    type_name,                          \
-                                    do { code; } while (0);             \
-                                    _COGL_GTYPE_INIT_CLASS (type_name)) \
+}                                                                       \
                                                                         \
 gboolean                                                                \
 cogl_is_##type_name (void *object)                                      \
@@ -213,35 +206,20 @@ cogl_is_##type_name (void *object)                                      \
   return obj->klass == &_cogl_##type_name##_class;                      \
 }
 
-#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;                                             \
+#define COGL_OBJECT_DEFINE_WITH_CODE_GTYPE(TypeName, type_name, code)   \
                                                                         \
-  if (object == NULL)                                                   \
-    return FALSE;                                                       \
+COGL_OBJECT_COMMON_DEFINE_WITH_CODE(TypeName,                           \
+                                    type_name,                          \
+                                    do { code; } while (0);             \
+                                    _COGL_GTYPE_INIT_CLASS (type_name))
+
+#define COGL_OBJECT_DEFINE_WITH_CODE(TypeName, type_name, code)         \
                                                                         \
-  return obj->klass == &_cogl_##type_name##_class;                      \
-}
+COGL_OBJECT_COMMON_DEFINE_WITH_CODE(TypeName, type_name, code)
 
 #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 == &_cogl_##type_name##_class;                      \
-}
+COGL_OBJECT_COMMON_DEFINE_WITH_CODE(TypeName, type_name, code)
 
 #define COGL_OBJECT_DEFINE_DEPRECATED_REF_COUNTING(type_name)   \
                                                                 \
diff --git a/cogl/cogl/cogl-pipeline-layer-state.c b/cogl/cogl/cogl-pipeline-layer-state.c
index ea29982e0..a8fe5bd82 100644
--- a/cogl/cogl/cogl-pipeline-layer-state.c
+++ b/cogl/cogl/cogl-pipeline-layer-state.c
@@ -624,7 +624,7 @@ _cogl_pipeline_layer_get_wrap_mode_s (CoglPipelineLayer *layer)
   CoglPipelineLayer     *authority;
   const CoglSamplerCacheEntry *sampler_state;
 
-  _COGL_RETURN_VAL_IF_FAIL (_cogl_is_pipeline_layer (layer), FALSE);
+  _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline_layer (layer), FALSE);
 
   /* Now find the ancestor of the layer that is the authority for the
    * state we want to change */
@@ -661,7 +661,7 @@ _cogl_pipeline_layer_get_wrap_mode_t (CoglPipelineLayer *layer)
   CoglPipelineLayer     *authority;
   const CoglSamplerCacheEntry *sampler_state;
 
-  _COGL_RETURN_VAL_IF_FAIL (_cogl_is_pipeline_layer (layer), FALSE);
+  _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline_layer (layer), FALSE);
 
   /* Now find the ancestor of the layer that is the authority for the
    * state we want to change */
@@ -1476,7 +1476,7 @@ cogl_pipeline_set_layer_matrix (CoglPipeline *pipeline,
 CoglTexture *
 _cogl_pipeline_layer_get_texture (CoglPipelineLayer *layer)
 {
-  _COGL_RETURN_VAL_IF_FAIL (_cogl_is_pipeline_layer (layer), NULL);
+  _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline_layer (layer), NULL);
 
   return _cogl_pipeline_layer_get_texture_real (layer);
 }
@@ -1561,7 +1561,7 @@ _cogl_pipeline_layer_get_min_filter (CoglPipelineLayer *layer)
 {
   CoglPipelineLayer *authority;
 
-  _COGL_RETURN_VAL_IF_FAIL (_cogl_is_pipeline_layer (layer), 0);
+  _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline_layer (layer), 0);
 
   authority =
     _cogl_pipeline_layer_get_authority (layer,
@@ -1575,7 +1575,7 @@ _cogl_pipeline_layer_get_mag_filter (CoglPipelineLayer *layer)
 {
   CoglPipelineLayer *authority;
 
-  _COGL_RETURN_VAL_IF_FAIL (_cogl_is_pipeline_layer (layer), 0);
+  _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline_layer (layer), 0);
 
   authority =
     _cogl_pipeline_layer_get_authority (layer,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]