summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2010-04-01 17:17:34 -0700
committerIan Romanick <ian.d.romanick@intel.com>2010-04-01 17:17:34 -0700
commit00e517616b722d6a1f62748d8c84004eeb814756 (patch)
treef9baf8f9f9c4f200a1eba376f37ad44d51ca48ca
parentebfdef7a83966341c27f44c83366419d4a2f7a60 (diff)
Add glsl_type::element_type and glsl_type::array_size queries
The former gets the type of elements in an array, and the later gets the declared size, if any, of the array.
-rw-r--r--glsl_types.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/glsl_types.h b/glsl_types.h
index 6c9444cbe1..33b1c98158 100644
--- a/glsl_types.h
+++ b/glsl_types.h
@@ -164,6 +164,18 @@ struct glsl_type {
const glsl_type *get_base_type() const;
/**
+ * Query the type of elements in an array
+ *
+ * \return
+ * Pointer to the type of elements in the array for array types, or \c NULL
+ * for non-array types.
+ */
+ const glsl_type *element_type() const
+ {
+ return is_array() ? fields.array : NULL;
+ }
+
+ /**
* Get the instance of a built-in scalar, vector, or matrix type
*/
static const glsl_type *get_instance(unsigned base_type, unsigned rows,
@@ -308,6 +320,19 @@ struct glsl_type {
: error_type;
}
+ /**
+ * Query the number of elements in an array type
+ *
+ * \return
+ * The number of elements in the array for array types or -1 for non-array
+ * types. If the number of elements in the array has not yet been declared,
+ * zero is returned.
+ */
+ int array_size() const
+ {
+ return is_array() ? length : -1;
+ }
+
private:
/**
* Constructor for array types