/* _slang_typeof_operation() */
+/**
+ * Determine the return type of a function.
+ * \param name name of the function
+ * \param params array of function parameters
+ * \param num_params number of parameters
+ * \param space namespace to use
+ * \param spec returns the function's type
+ * \param atoms atom pool
+ * \return GL_TRUE for success, GL_FALSE if failure
+ */
static GLboolean
-typeof_existing_function(const char *name, slang_operation * params,
- GLuint num_params, slang_assembly_name_space * space,
- slang_type_specifier * spec, slang_atom_pool * atoms)
+typeof_existing_function(const char *name, const slang_operation * params,
+ GLuint num_params,
+ const slang_assembly_name_space * space,
+ slang_type_specifier * spec,
+ slang_atom_pool * atoms)
{
slang_atom atom;
GLboolean exists;
atom = slang_atom_pool_atom(atoms, name);
- if (!_slang_typeof_function
- (atom, params, num_params, space, spec, &exists, atoms))
+ if (!_slang_typeof_function(atom, params, num_params, space, spec,
+ &exists, atoms))
return GL_FALSE;
return exists;
}
GLboolean
-_slang_typeof_operation(slang_assemble_ctx * A, slang_operation * op,
+_slang_typeof_operation(const slang_assemble_ctx * A,
+ const slang_operation * op,
slang_assembly_typeinfo * ti)
{
return _slang_typeof_operation_(op, &A->space, ti, A->atoms);
}
+
+/**
+ * Determine the return type of an operation.
+ * \param op the operation node
+ * \param space the namespace to use
+ * \param ti the returned type
+ * \param atoms atom pool
+ * \return GL_TRUE for success, GL_FALSE if failure
+ */
GLboolean
-_slang_typeof_operation_(slang_operation * op,
- slang_assembly_name_space * space,
+_slang_typeof_operation_(const slang_operation * op,
+ const slang_assembly_name_space * space,
slang_assembly_typeinfo * ti,
slang_atom_pool * atoms)
{
/*case slang_oper_lshift: */
/*case slang_oper_rshift: */
case slang_oper_add:
- if (!typeof_existing_function
- ("+", op->children, 2, space, &ti->spec, atoms))
+ if (!typeof_existing_function("+", op->children, 2, space,
+ &ti->spec, atoms))
return GL_FALSE;
break;
case slang_oper_subtract:
- if (!typeof_existing_function
- ("-", op->children, 2, space, &ti->spec, atoms))
+ if (!typeof_existing_function("-", op->children, 2, space,
+ &ti->spec, atoms))
return GL_FALSE;
break;
case slang_oper_multiply:
- if (!typeof_existing_function
- ("*", op->children, 2, space, &ti->spec, atoms))
+ if (!typeof_existing_function("*", op->children, 2, space,
+ &ti->spec, atoms))
return GL_FALSE;
break;
case slang_oper_divide:
- if (!typeof_existing_function
- ("/", op->children, 2, space, &ti->spec, atoms))
+ if (!typeof_existing_function("/", op->children, 2, space,
+ &ti->spec, atoms))
return GL_FALSE;
break;
/*case slang_oper_modulus: */
{
GLboolean exists;
- if (!_slang_typeof_function
- (op->a_id, op->children, op->num_children, space, &ti->spec,
- &exists, atoms))
+ if (!_slang_typeof_function(op->a_id, op->children, op->num_children,
+ space, &ti->spec, &exists, atoms))
return GL_FALSE;
if (!exists) {
slang_struct *s =
return GL_TRUE;
}
-/* _slang_typeof_function() */
+
+/**
+ * Determine the return type of a function.
+ * \param a_name the function name
+ * \param param function parameters (overloading)
+ * \param num_params number of parameters to function
+ * \param space namespace to search
+ * \param exists returns GL_TRUE or GL_FALSE to indicate existance of function
+ * \return GL_TRUE for success, GL_FALSE if failure (bad function name)
+ */
GLboolean
-_slang_typeof_function(slang_atom a_name, slang_operation * params,
- GLuint num_params, slang_assembly_name_space * space,
+_slang_typeof_function(slang_atom a_name, const slang_operation * params,
+ GLuint num_params,
+ const slang_assembly_name_space * space,
slang_type_specifier * spec, GLboolean * exists,
slang_atom_pool * atoms)
{
- slang_function *fun;
-
- fun =
- _slang_locate_function(space->funcs, a_name, params, num_params, space,
- atoms);
+ slang_function *fun = _slang_locate_function(space->funcs, a_name, params,
+ num_params, space, atoms);
*exists = fun != NULL;
- if (fun == NULL)
- return GL_TRUE;
+ if (!fun)
+ return GL_TRUE; /* yes, not false */
return slang_type_specifier_copy(spec, &fun->header.type.specifier);
}
-/* _slang_type_is_matrix() */
+
+/**
+ * Determine if a type is a matrix.
+ * \return GL_TRUE if is a matrix, GL_FALSE otherwise.
+ */
GLboolean
_slang_type_is_matrix(slang_type_specifier_type ty)
{
}
}
-/* _slang_type_is_vector() */
+/**
+ * Determine if a type is a vector.
+ * \return GL_TRUE if is a vector, GL_FALSE otherwise.
+ */
GLboolean
_slang_type_is_vector(slang_type_specifier_type ty)
{
}
}
-/* _slang_type_base_of_vector() */
+/**
+ * Given a vector type, return the type of the vector's elements
+ */
slang_type_specifier_type
_slang_type_base(slang_type_specifier_type ty)
{
}
}
-/* _slang_type_dim */
+/**
+ * Return the number of elements in a vector or matrix type
+ */
GLuint
_slang_type_dim(slang_type_specifier_type ty)
{
extern "C" {
#endif
+
+/**
+ * The basic shading language types (float, vec4, mat3, etc)
+ */
typedef enum slang_type_specifier_type_
{
- slang_spec_void,
- slang_spec_bool,
- slang_spec_bvec2,
- slang_spec_bvec3,
- slang_spec_bvec4,
- slang_spec_int,
- slang_spec_ivec2,
- slang_spec_ivec3,
- slang_spec_ivec4,
- slang_spec_float,
- slang_spec_vec2,
- slang_spec_vec3,
- slang_spec_vec4,
- slang_spec_mat2,
- slang_spec_mat3,
- slang_spec_mat4,
- slang_spec_sampler1D,
- slang_spec_sampler2D,
- slang_spec_sampler3D,
- slang_spec_samplerCube,
- slang_spec_sampler1DShadow,
- slang_spec_sampler2DShadow,
- slang_spec_struct,
- slang_spec_array
+ slang_spec_void,
+ slang_spec_bool,
+ slang_spec_bvec2,
+ slang_spec_bvec3,
+ slang_spec_bvec4,
+ slang_spec_int,
+ slang_spec_ivec2,
+ slang_spec_ivec3,
+ slang_spec_ivec4,
+ slang_spec_float,
+ slang_spec_vec2,
+ slang_spec_vec3,
+ slang_spec_vec4,
+ slang_spec_mat2,
+ slang_spec_mat3,
+ slang_spec_mat4,
+ slang_spec_sampler1D,
+ slang_spec_sampler2D,
+ slang_spec_sampler3D,
+ slang_spec_samplerCube,
+ slang_spec_sampler1DShadow,
+ slang_spec_sampler2DShadow,
+ slang_spec_struct,
+ slang_spec_array
} slang_type_specifier_type;
+
+/**
+ * Describes more sophisticated types, like structs and arrays.
+ */
typedef struct slang_type_specifier_
{
- slang_type_specifier_type type;
- struct slang_struct_ *_struct; /* type: spec_struct */
- struct slang_type_specifier_ *_array; /* type: spec_array */
+ slang_type_specifier_type type;
+ struct slang_struct_ *_struct; /**< type: spec_struct */
+ struct slang_type_specifier_ *_array; /**< type: spec_array */
} slang_type_specifier;
-GLvoid slang_type_specifier_ctr (slang_type_specifier *);
-GLvoid slang_type_specifier_dtr (slang_type_specifier *);
-GLboolean slang_type_specifier_copy (slang_type_specifier *, const slang_type_specifier *);
-GLboolean slang_type_specifier_equal (const slang_type_specifier *, const slang_type_specifier *);
+
+extern GLvoid
+slang_type_specifier_ctr(slang_type_specifier *);
+
+extern GLvoid
+slang_type_specifier_dtr(slang_type_specifier *);
+
+extern GLboolean
+slang_type_specifier_copy(slang_type_specifier *, const slang_type_specifier *);
+
+extern GLboolean
+slang_type_specifier_equal(const slang_type_specifier *,
+ const slang_type_specifier *);
+
typedef struct slang_assembly_typeinfo_
{
- GLboolean can_be_referenced;
- GLboolean is_swizzled;
- slang_swizzle swz;
- slang_type_specifier spec;
- GLuint array_len;
+ GLboolean can_be_referenced;
+ GLboolean is_swizzled;
+ slang_swizzle swz;
+ slang_type_specifier spec;
+ GLuint array_len;
} slang_assembly_typeinfo;
-GLboolean slang_assembly_typeinfo_construct (slang_assembly_typeinfo *);
-GLvoid slang_assembly_typeinfo_destruct (slang_assembly_typeinfo *);
+extern GLboolean
+slang_assembly_typeinfo_construct(slang_assembly_typeinfo *);
-/*
+extern GLvoid
+slang_assembly_typeinfo_destruct(slang_assembly_typeinfo *);
+
+
+/**
* Retrieves type information about an operation.
* Returns GL_TRUE on success.
* Returns GL_FALSE otherwise.
*/
-GLboolean _slang_typeof_operation (slang_assemble_ctx *, struct slang_operation_ *,
- slang_assembly_typeinfo *);
-GLboolean _slang_typeof_operation_ (struct slang_operation_ *, slang_assembly_name_space *,
- slang_assembly_typeinfo *, slang_atom_pool *);
+extern GLboolean
+_slang_typeof_operation(const slang_assemble_ctx *,
+ const struct slang_operation_ *,
+ slang_assembly_typeinfo *);
-/*
+extern GLboolean
+_slang_typeof_operation_(const struct slang_operation_ *,
+ const slang_assembly_name_space *,
+ slang_assembly_typeinfo *, slang_atom_pool *);
+
+/**
* Retrieves type of a function prototype, if one exists.
* Returns GL_TRUE on success, even if the function was not found.
* Returns GL_FALSE otherwise.
*/
-GLboolean _slang_typeof_function (slang_atom a_name, struct slang_operation_ *params,
- GLuint num_params, slang_assembly_name_space *, slang_type_specifier *spec, GLboolean *exists,
- slang_atom_pool *);
+extern GLboolean
+_slang_typeof_function(slang_atom a_name,
+ const struct slang_operation_ *params,
+ GLuint num_params, const slang_assembly_name_space *,
+ slang_type_specifier *spec, GLboolean *exists,
+ slang_atom_pool *);
+
+extern GLboolean
+_slang_type_is_matrix(slang_type_specifier_type);
+
+extern GLboolean
+_slang_type_is_vector(slang_type_specifier_type);
-GLboolean _slang_type_is_matrix (slang_type_specifier_type);
+extern slang_type_specifier_type
+_slang_type_base(slang_type_specifier_type);
-GLboolean _slang_type_is_vector (slang_type_specifier_type);
+extern GLuint
+_slang_type_dim(slang_type_specifier_type);
-slang_type_specifier_type _slang_type_base (slang_type_specifier_type);
-GLuint _slang_type_dim (slang_type_specifier_type);
#ifdef __cplusplus
}