[gtk+/wip/otte/shader: 191/226] gsksltype: Add gsk_sl_type_is_basic()



commit 6a95433046c8501f8d7daad5b26c8bfcbb13542a
Author: Benjamin Otte <otte redhat com>
Date:   Tue Oct 17 16:55:27 2017 +0200

    gsksltype: Add gsk_sl_type_is_basic()
    
    That way, code doesn't have to do if (is_vector() || is_matrix() ||
    is_scalar()) everywhere.

 gsk/gskslexpression.c  |    2 +-
 gsk/gskslstatement.c   |    2 +-
 gsk/gsksltype.c        |    8 ++++++++
 gsk/gsksltypeprivate.h |    1 +
 4 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/gsk/gskslexpression.c b/gsk/gskslexpression.c
index 6f7ec10..550d5e0 100644
--- a/gsk/gskslexpression.c
+++ b/gsk/gskslexpression.c
@@ -2330,7 +2330,7 @@ gsk_sl_expression_parse_unary (GskSlScope        *scope,
       gsk_sl_preprocessor_consume (preproc, negation);
       negation->expr = gsk_sl_expression_parse_unary (scope, preproc);
       type = gsk_sl_expression_get_return_type (negation->expr);
-      if (!gsk_sl_type_is_scalar (type) && !gsk_sl_type_is_vector (type) && !gsk_sl_type_is_matrix (type))
+      if (!gsk_sl_type_is_basic (type))
         {
           gsk_sl_preprocessor_error (preproc, TYPE_MISMATCH,
                                      "Negation only works on scalars, vectors and matrices, not on %s.",
diff --git a/gsk/gskslstatement.c b/gsk/gskslstatement.c
index ca4708f..56fc2ac 100644
--- a/gsk/gskslstatement.c
+++ b/gsk/gskslstatement.c
@@ -769,7 +769,7 @@ its_a_type:
             GskSlStatementExpression *statement_expression;
                 
             statement_expression = gsk_sl_statement_new (GskSlStatementExpression, 
&GSK_SL_STATEMENT_EXPRESSION);
-            if (gsk_sl_type_is_scalar (type) || gsk_sl_type_is_vector (type) || gsk_sl_type_is_matrix (type))
+            if (gsk_sl_type_is_basic (type))
               {
                 statement_expression->expression = gsk_sl_expression_parse_constructor (scope, preproc, 
type);
               }
diff --git a/gsk/gsksltype.c b/gsk/gsksltype.c
index c4050de..4afd840 100644
--- a/gsk/gsksltype.c
+++ b/gsk/gsksltype.c
@@ -2057,6 +2057,14 @@ gsk_sl_type_is_matrix (const GskSlType *type)
 }
 
 gboolean
+gsk_sl_type_is_basic (const GskSlType *type)
+{
+  return gsk_sl_type_is_scalar (type)
+      || gsk_sl_type_is_vector (type)
+      || gsk_sl_type_is_matrix (type);
+}
+
+gboolean
 gsk_sl_type_is_struct (const GskSlType *type)
 {
   return type->class == &GSK_SL_TYPE_STRUCT;
diff --git a/gsk/gsksltypeprivate.h b/gsk/gsksltypeprivate.h
index 55b6956..567762c 100644
--- a/gsk/gsksltypeprivate.h
+++ b/gsk/gsksltypeprivate.h
@@ -48,6 +48,7 @@ gboolean                gsk_sl_type_is_void                     (const GskSlType
 gboolean                gsk_sl_type_is_scalar                   (const GskSlType     *type);
 gboolean                gsk_sl_type_is_vector                   (const GskSlType     *type);
 gboolean                gsk_sl_type_is_matrix                   (const GskSlType     *type);
+gboolean                gsk_sl_type_is_basic                    (const GskSlType     *type);
 gboolean                gsk_sl_type_is_struct                   (const GskSlType     *type);
 gboolean                gsk_sl_type_is_block                    (const GskSlType     *type);
 gboolean                gsk_sl_type_is_opaque                   (const GskSlType     *type);


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