1 # -*- coding: utf-8 -*-
3 #-------------------------------------------------------------------------
4 # drawElements Quality Program utilities
5 # --------------------------------------
7 # Copyright 2015 The Android Open Source Project
9 # Licensed under the Apache License, Version 2.0 (the "License");
10 # you may not use this file except in compliance with the License.
11 # You may obtain a copy of the License at
13 # http://www.apache.org/licenses/LICENSE-2.0
15 # Unless required by applicable law or agreed to in writing, software
16 # distributed under the License is distributed on an "AS IS" BASIS,
17 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 # See the License for the specific language governing permissions and
19 # limitations under the License.
21 #-------------------------------------------------------------------------
26 # \todo [arttu 2012-12-20] Current set tests variable names only, add function names, structure names, and field selectors.
30 identifierCaseTemplate = """
36 precision mediump float;
43 float ${{IDENTIFIER}} = 1.0;
52 class IdentifierCase(ShaderCase):
53 def __init__(self, name, identifier):
55 self.identifier = identifier
58 params = { "NAME" : self.name,
59 "IDENTIFIER" : self.identifier }
60 return fillTemplate(identifierCaseTemplate, params)
66 "attribute", "const", "uniform", "varying", "break", "continue", "do", "for", "while",
67 "if", "else", "in", "out", "inout", "float", "int", "void", "bool", "true", "false",
68 "lowp", "mediump", "highp", "precision", "invariant", "discard", "return", "mat2", "mat3",
69 "mat4", "vec2", "vec3", "vec4", "ivec2", "ivec3", "ivec4", "bvec2", "bvec3", "bvec4",
70 "sampler2D", "samplerCube", "struct"
74 "asm", "class", "union", "enum", "typedef", "template", "this", "packed", "goto", "switch",
75 "default", "inline", "noinline", "volatile", "public", "static", "extern", "external",
76 "interface", "flat", "long", "short", "double", "half", "fixed", "unsigned", "superp",
77 "input", "output", "hvec2", "hvec3", "hvec4", "dvec2", "dvec3", "dvec4", "fvec2", "fvec3",
78 "fvec4", "sampler1D", "sampler3D", "sampler1DShadow", "sampler2DShadow", "sampler2DRect",
79 "sampler3DRect", "sampler2DRectShadow", "sizeof", "cast", "namespace", "using"
82 INVALID_IDENTIFIERS = [
83 ("two_underscores_begin", "__invalid"),
84 ("two_underscores_middle", "in__valid"),
85 ("two_underscores_end", "invalid__"),
86 ("gl_begin", "gl_Invalid"),
88 ("digit_begin", "0invalid")
95 invalidIdentifiers = []
97 for keyword in KEYWORDS:
98 keywords.append(IdentifierCase(keyword, keyword)) # Keywords
100 for keyword in RESERVED_KEYWORDS:
101 reservedKeywords.append(IdentifierCase(keyword, keyword)) # Reserved keywords
103 for (name, identifier) in INVALID_IDENTIFIERS:
104 invalidIdentifiers.append(IdentifierCase(name, identifier)) # Invalid identifiers
107 CaseGroup("keywords", "Usage of keywords as identifiers.", keywords),
108 CaseGroup("reserved_keywords", "Usage of reserved keywords as identifiers.", reservedKeywords),
109 CaseGroup("invalid_identifiers", "Usage of invalid identifiers.", invalidIdentifiers)
114 if __name__ == "__main__":
115 print "Generating shader case files."
116 writeAllCases("keywords.test", keywordCases)