[gtk/wip/chergert/glproto: 489/493] allow defining more of inlinearray bits
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/chergert/glproto: 489/493] allow defining more of inlinearray bits
- Date: Fri, 19 Feb 2021 02:25:25 +0000 (UTC)
commit a3eec1bdda05af12692826dde3640ba8d597c8ff
Author: Christian Hergert <chergert redhat com>
Date: Wed Feb 17 14:32:19 2021 -0800
allow defining more of inlinearray bits
gsk/next/gskglcommandqueueprivate.h | 6 +++---
gsk/next/inlinearray.h | 42 ++++++++++++++++++-------------------
2 files changed, 24 insertions(+), 24 deletions(-)
---
diff --git a/gsk/next/gskglcommandqueueprivate.h b/gsk/next/gskglcommandqueueprivate.h
index 63d48a8dbf..f53185abce 100644
--- a/gsk/next/gskglcommandqueueprivate.h
+++ b/gsk/next/gskglcommandqueueprivate.h
@@ -167,9 +167,9 @@ typedef union _GskGLCommandBatch
G_STATIC_ASSERT (sizeof (GskGLCommandBatch) == 32);
-DEFINE_INLINE_ARRAY (GskGLCommandBatch, gsk_gl_command_batch_array)
-DEFINE_INLINE_ARRAY (GskGLCommandBind, gsk_gl_command_bind_array)
-DEFINE_INLINE_ARRAY (GskGLCommandUniform, gsk_gl_command_uniform_array)
+DEFINE_INLINE_ARRAY (GskGLCommandBatchArray, gsk_gl_command_batch_array, GskGLCommandBatch)
+DEFINE_INLINE_ARRAY (GskGLCommandBindArray, gsk_gl_command_bind_array, GskGLCommandBind)
+DEFINE_INLINE_ARRAY (GskGLCommandUniformArray, gsk_gl_command_uniform_array, GskGLCommandUniform)
struct _GskGLCommandQueue
{
diff --git a/gsk/next/inlinearray.h b/gsk/next/inlinearray.h
index 166f8f8e15..98a9255c68 100644
--- a/gsk/next/inlinearray.h
+++ b/gsk/next/inlinearray.h
@@ -1,49 +1,49 @@
#ifndef __INLINE_ARRAY_H__
#define __INLINE_ARRAY_H__
-#define DEFINE_INLINE_ARRAY(Type, prefix) \
- typedef struct _##Type##Array { \
+#define DEFINE_INLINE_ARRAY(Type, prefix, ElementType) \
+ typedef struct _##Type { \
gsize len; \
gsize allocated; \
- Type *items; \
- } Type##Array; \
+ ElementType *items; \
+ } Type; \
\
static inline void \
- prefix##_init (Type##Array *ar, \
- gsize initial_size) \
+ prefix##_init (Type *ar, \
+ gsize initial_size) \
{ \
ar->len = 0; \
ar->allocated = initial_size ? initial_size : 16; \
- ar->items = g_new0 (Type, ar->allocated); \
+ ar->items = g_new0 (ElementType, ar->allocated); \
} \
\
static inline void \
- prefix##_clear (Type##Array *ar) \
+ prefix##_clear (Type *ar) \
{ \
ar->len = 0; \
ar->allocated = 0; \
g_clear_pointer (&ar->items, g_free); \
} \
\
- static inline Type * \
- prefix##_head (Type##Array *ar) \
+ static inline ElementType * \
+ prefix##_head (Type *ar) \
{ \
return &ar->items[0]; \
} \
\
- static inline Type * \
- prefix##_tail (Type##Array *ar) \
+ static inline ElementType * \
+ prefix##_tail (Type *ar) \
{ \
return &ar->items[ar->len-1]; \
} \
\
- static inline Type * \
- prefix##_append (Type##Array *ar) \
+ static inline ElementType * \
+ prefix##_append (Type *ar) \
{ \
if G_UNLIKELY (ar->len == ar->allocated) \
{ \
ar->allocated *= 2; \
- ar->items = g_renew (Type, ar->items, ar->allocated); \
+ ar->items = g_renew (ElementType, ar->items, ar->allocated);\
} \
\
ar->len++; \
@@ -51,15 +51,15 @@
return prefix##_tail (ar); \
} \
\
- static inline Type * \
- prefix##_append_n (Type##Array *ar, \
- gsize n) \
+ static inline ElementType * \
+ prefix##_append_n (Type *ar, \
+ gsize n) \
{ \
if G_UNLIKELY ((ar->len + n) > ar->allocated) \
{ \
while ((ar->len + n) > ar->allocated) \
ar->allocated *= 2; \
- ar->items = g_renew (Type, ar->items, ar->allocated); \
+ ar->items = g_renew (ElementType, ar->items, ar->allocated);\
} \
\
ar->len += n; \
@@ -68,8 +68,8 @@
} \
\
static inline gsize \
- prefix##_index_of (Type##Array *ar, \
- const Type *element) \
+ prefix##_index_of (Type *ar, \
+ const ElementType *element) \
{ \
return element - &ar->items[0]; \
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]