[gtk+/wip/otte/shader: 143/150] gsksltype: Add gsk_sl_type_is_basic()



commit e198044dec3fe980510ca4a71c941b47c45d0c96
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 c7276f9..78c897b 100644
--- a/gsk/gskslexpression.c
+++ b/gsk/gskslexpression.c
@@ -2331,7 +2331,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 0edc49c..df6affa 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 74524a8..42d4495 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]