diff options
author | Ian Romanick <[email protected]> | 2010-06-28 11:01:57 -0700 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2010-06-29 11:15:39 -0700 |
commit | e94642eb0d99ff7f6cdaee31ed4f5f29bdabd6f7 (patch) | |
tree | 02736d29ef22a5929f1a685879660d221b4aa701 /src | |
parent | 4b6feb0398458a69259e3b77d7a8573b926f2039 (diff) |
glsl_type: Make all static objects be class private
Diffstat (limited to 'src')
-rw-r--r-- | src/glsl/builtin_types.h | 22 | ||||
-rw-r--r-- | src/glsl/glsl_types.cpp | 32 | ||||
-rw-r--r-- | src/glsl/glsl_types.h | 57 |
3 files changed, 72 insertions, 39 deletions
diff --git a/src/glsl/builtin_types.h b/src/glsl/builtin_types.h index 526421a0174..bd8f8b583a5 100644 --- a/src/glsl/builtin_types.h +++ b/src/glsl/builtin_types.h @@ -25,13 +25,13 @@ #define Elements(x) (sizeof(x)/sizeof(*(x))) #endif -static const struct glsl_type _error_type = +const glsl_type glsl_type::_error_type = glsl_type(GL_INVALID_ENUM, GLSL_TYPE_ERROR, 0, 0, ""); -static const struct glsl_type void_type = +const glsl_type glsl_type::void_type = glsl_type(GL_INVALID_ENUM, GLSL_TYPE_VOID, 0, 0, "void"); -const glsl_type *const glsl_type::error_type = & _error_type; +const glsl_type *const glsl_type::error_type = & glsl_type::_error_type; /** \name Core built-in types * @@ -39,7 +39,7 @@ const glsl_type *const glsl_type::error_type = & _error_type; */ /*@{*/ -static const struct glsl_type builtin_core_types[] = { +const glsl_type glsl_type::builtin_core_types[] = { glsl_type(GL_BOOL, GLSL_TYPE_BOOL, 1, 1, "bool"), glsl_type(GL_BOOL_VEC2, GLSL_TYPE_BOOL, 2, 1, "bvec2"), glsl_type(GL_BOOL_VEC3, GLSL_TYPE_BOOL, 3, 1, "bvec3"), @@ -91,7 +91,7 @@ static const struct glsl_struct_field gl_DepthRangeParameters_fields[] = { { glsl_type::float_type, "diff" }, }; -static const struct glsl_type builtin_structure_types[] = { +const glsl_type glsl_type::builtin_structure_types[] = { glsl_type(gl_DepthRangeParameters_fields, Elements(gl_DepthRangeParameters_fields), "gl_DepthRangeParameters"), @@ -157,7 +157,7 @@ static const struct glsl_struct_field gl_FogParameters_fields[] = { { glsl_type::float_type, "scale" }, }; -static const struct glsl_type builtin_110_deprecated_structure_types[] = { +const glsl_type glsl_type::builtin_110_deprecated_structure_types[] = { glsl_type(gl_PointParameters_fields, Elements(gl_PointParameters_fields), "gl_PointParameters"), @@ -186,7 +186,7 @@ static const struct glsl_type builtin_110_deprecated_structure_types[] = { */ /*@{*/ -static const struct glsl_type builtin_120_types[] = { +const glsl_type glsl_type::builtin_120_types[] = { glsl_type(GL_FLOAT_MAT2x3, GLSL_TYPE_FLOAT, 3, 2, "mat2x3"), glsl_type(GL_FLOAT_MAT2x4, GLSL_TYPE_FLOAT, 4, 2, "mat2x4"), glsl_type(GL_FLOAT_MAT3x2, GLSL_TYPE_FLOAT, 2, 3, "mat3x2"), @@ -206,7 +206,7 @@ const glsl_type *const glsl_type::mat4x3_type = & builtin_120_types[5]; */ /*@{*/ -static const struct glsl_type builtin_130_types[] = { +const glsl_type glsl_type::builtin_130_types[] = { glsl_type(GL_UNSIGNED_INT, GLSL_TYPE_UINT, 1, 1, "uint"), glsl_type(GL_UNSIGNED_INT_VEC2, GLSL_TYPE_UINT, 2, 1, "uvec2"), glsl_type(GL_UNSIGNED_INT_VEC3, GLSL_TYPE_UINT, 3, 1, "uvec3"), @@ -261,7 +261,7 @@ const glsl_type *const glsl_type::uvec4_type = & builtin_130_types[3]; */ /*@{*/ -static const struct glsl_type builtin_ARB_texture_rectangle_types[] = { +const glsl_type glsl_type::builtin_ARB_texture_rectangle_types[] = { glsl_type(GL_SAMPLER_2D_RECT, GLSL_SAMPLER_DIM_RECT, 0, 0, GLSL_TYPE_FLOAT, "sampler2DRect"), glsl_type(GL_SAMPLER_2D_RECT_SHADOW, @@ -273,7 +273,7 @@ static const struct glsl_type builtin_ARB_texture_rectangle_types[] = { */ /*@{*/ -static const struct glsl_type builtin_EXT_texture_array_types[] = { +const glsl_type glsl_type::builtin_EXT_texture_array_types[] = { glsl_type(GL_SAMPLER_1D_ARRAY, GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_FLOAT, "sampler1DArray"), glsl_type(GL_SAMPLER_1D_ARRAY_SHADOW, @@ -289,7 +289,7 @@ static const struct glsl_type builtin_EXT_texture_array_types[] = { */ /*@{*/ -static const struct glsl_type builtin_EXT_texture_buffer_object_types[] = { +const glsl_type glsl_type::builtin_EXT_texture_buffer_object_types[] = { glsl_type(GL_SAMPLER_BUFFER, GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_FLOAT, "samplerBuffer"), glsl_type(GL_INT_SAMPLER_BUFFER, diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp index ff157080ff6..69bed33d815 100644 --- a/src/glsl/glsl_types.cpp +++ b/src/glsl/glsl_types.cpp @@ -46,8 +46,8 @@ add_types_to_symbol_table(glsl_symbol_table *symtab, } -static void -generate_110_types(glsl_symbol_table *symtab) +void +glsl_type::generate_110_types(glsl_symbol_table *symtab) { add_types_to_symbol_table(symtab, builtin_core_types, Elements(builtin_core_types), @@ -62,8 +62,8 @@ generate_110_types(glsl_symbol_table *symtab) } -static void -generate_120_types(glsl_symbol_table *symtab) +void +glsl_type::generate_120_types(glsl_symbol_table *symtab) { generate_110_types(symtab); @@ -72,8 +72,8 @@ generate_120_types(glsl_symbol_table *symtab) } -static void -generate_130_types(glsl_symbol_table *symtab) +void +glsl_type::generate_130_types(glsl_symbol_table *symtab) { generate_120_types(symtab); @@ -82,8 +82,9 @@ generate_130_types(glsl_symbol_table *symtab) } -static void -generate_ARB_texture_rectangle_types(glsl_symbol_table *symtab, bool warn) +void +glsl_type::generate_ARB_texture_rectangle_types(glsl_symbol_table *symtab, + bool warn) { add_types_to_symbol_table(symtab, builtin_ARB_texture_rectangle_types, Elements(builtin_ARB_texture_rectangle_types), @@ -91,8 +92,9 @@ generate_ARB_texture_rectangle_types(glsl_symbol_table *symtab, bool warn) } -static void -generate_EXT_texture_array_types(glsl_symbol_table *symtab, bool warn) +void +glsl_type::generate_EXT_texture_array_types(glsl_symbol_table *symtab, + bool warn) { add_types_to_symbol_table(symtab, builtin_EXT_texture_array_types, Elements(builtin_EXT_texture_array_types), @@ -105,13 +107,13 @@ _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state) { switch (state->language_version) { case 110: - generate_110_types(state->symbols); + glsl_type::generate_110_types(state->symbols); break; case 120: - generate_120_types(state->symbols); + glsl_type::generate_120_types(state->symbols); break; case 130: - generate_130_types(state->symbols); + glsl_type::generate_130_types(state->symbols); break; default: /* error */ @@ -119,13 +121,13 @@ _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state) } if (state->ARB_texture_rectangle_enable) { - generate_ARB_texture_rectangle_types(state->symbols, + glsl_type::generate_ARB_texture_rectangle_types(state->symbols, state->ARB_texture_rectangle_warn); } if (state->EXT_texture_array_enable && state->language_version < 130) { // These are already included in 130; don't create twice. - generate_EXT_texture_array_types(state->symbols, + glsl_type::generate_EXT_texture_array_types(state->symbols, state->EXT_texture_array_warn); } } diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h index b753742b91c..c62d290def8 100644 --- a/src/glsl/glsl_types.h +++ b/src/glsl/glsl_types.h @@ -34,6 +34,11 @@ extern "C" { #include <talloc.h> } +struct _mesa_glsl_parse_state; + +extern "C" void +_mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state); + #define GLSL_TYPE_UINT 0 #define GLSL_TYPE_INT 1 #define GLSL_TYPE_FLOAT 2 @@ -424,6 +429,45 @@ private: static int array_key_compare(const void *a, const void *b); static unsigned array_key_hash(const void *key); + + /** + * \name Pointers to various type singletons + */ + /*@{*/ + static const glsl_type _error_type; + static const glsl_type void_type; + static const glsl_type builtin_core_types[]; + static const glsl_type builtin_structure_types[]; + static const glsl_type builtin_110_deprecated_structure_types[]; + static const glsl_type builtin_120_types[]; + static const glsl_type builtin_130_types[]; + static const glsl_type builtin_ARB_texture_rectangle_types[]; + static const glsl_type builtin_EXT_texture_array_types[]; + static const glsl_type builtin_EXT_texture_buffer_object_types[]; + /*@}*/ + + /** + * \name Methods to populate a symbol table with built-in types. + * + * \internal + * This is one of the truely annoying things about C++. Methods that are + * completely internal and private to a type still have to be advertised to + * the world in a public header file. + */ + /*@{*/ + static void generate_110_types(class glsl_symbol_table *); + static void generate_120_types(class glsl_symbol_table *); + static void generate_130_types(class glsl_symbol_table *); + static void generate_ARB_texture_rectangle_types(class glsl_symbol_table *, + bool); + static void generate_EXT_texture_array_types(class glsl_symbol_table *, + bool); + /** + * This function is a friend because it needs to call the various + * generate_*_types functions and it has C linkage. + */ + friend void _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *); + /*@}*/ }; struct glsl_struct_field { @@ -431,17 +475,4 @@ struct glsl_struct_field { const char *name; }; -struct _mesa_glsl_parse_state; - -#ifdef __cplusplus -extern "C" { -#endif - -extern void -_mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state); - -#ifdef __cplusplus -} -#endif - #endif /* GLSL_TYPES_H */ |