| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """code generator for GLES2 command buffers.""" | 6 """code generator for GLES2 command buffers.""" |
| 7 | 7 |
| 8 import itertools | 8 import itertools |
| 9 import os | 9 import os |
| 10 import os.path | 10 import os.path |
| (...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 932 'GL_RENDERBUFFER_GREEN_SIZE', | 932 'GL_RENDERBUFFER_GREEN_SIZE', |
| 933 'GL_RENDERBUFFER_BLUE_SIZE', | 933 'GL_RENDERBUFFER_BLUE_SIZE', |
| 934 'GL_RENDERBUFFER_ALPHA_SIZE', | 934 'GL_RENDERBUFFER_ALPHA_SIZE', |
| 935 'GL_RENDERBUFFER_DEPTH_SIZE', | 935 'GL_RENDERBUFFER_DEPTH_SIZE', |
| 936 'GL_RENDERBUFFER_STENCIL_SIZE', | 936 'GL_RENDERBUFFER_STENCIL_SIZE', |
| 937 'GL_RENDERBUFFER_WIDTH', | 937 'GL_RENDERBUFFER_WIDTH', |
| 938 'GL_RENDERBUFFER_HEIGHT', | 938 'GL_RENDERBUFFER_HEIGHT', |
| 939 'GL_RENDERBUFFER_INTERNAL_FORMAT', | 939 'GL_RENDERBUFFER_INTERNAL_FORMAT', |
| 940 ], | 940 ], |
| 941 }, | 941 }, |
| 942 'SamplerParameter': { |
| 943 'type': 'GLenum', |
| 944 'valid': [ |
| 945 'GL_TEXTURE_MAG_FILTER', |
| 946 'GL_TEXTURE_MIN_FILTER', |
| 947 'GL_TEXTURE_MIN_LOD', |
| 948 'GL_TEXTURE_MAX_LOD', |
| 949 'GL_TEXTURE_WRAP_S', |
| 950 'GL_TEXTURE_WRAP_T', |
| 951 'GL_TEXTURE_WRAP_R', |
| 952 'GL_TEXTURE_COMPARE_MODE', |
| 953 'GL_TEXTURE_COMPARE_FUNC', |
| 954 ], |
| 955 'invalid': [ |
| 956 'GL_GENERATE_MIPMAP', |
| 957 ], |
| 958 }, |
| 942 'ShaderParameter': { | 959 'ShaderParameter': { |
| 943 'type': 'GLenum', | 960 'type': 'GLenum', |
| 944 'valid': [ | 961 'valid': [ |
| 945 'GL_SHADER_TYPE', | 962 'GL_SHADER_TYPE', |
| 946 'GL_DELETE_STATUS', | 963 'GL_DELETE_STATUS', |
| 947 'GL_COMPILE_STATUS', | 964 'GL_COMPILE_STATUS', |
| 948 'GL_INFO_LOG_LENGTH', | 965 'GL_INFO_LOG_LENGTH', |
| 949 'GL_SHADER_SOURCE_LENGTH', | 966 'GL_SHADER_SOURCE_LENGTH', |
| 950 'GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE', | 967 'GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE', |
| 951 ], | 968 ], |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1320 # The default is 'immediate' if the command has one pointer | 1337 # The default is 'immediate' if the command has one pointer |
| 1321 # argument, otherwise 'shm'. One command is generated for each | 1338 # argument, otherwise 'shm'. One command is generated for each |
| 1322 # transfer method. Affects only commands which are not of type | 1339 # transfer method. Affects only commands which are not of type |
| 1323 # 'HandWritten', 'GETn' or 'GLcharN'. | 1340 # 'HandWritten', 'GETn' or 'GLcharN'. |
| 1324 # Note: the command arguments that affect this are the final args, | 1341 # Note: the command arguments that affect this are the final args, |
| 1325 # taking cmd_args override into consideration. | 1342 # taking cmd_args override into consideration. |
| 1326 # impl_func: Whether or not to generate the GLES2Implementation part of this | 1343 # impl_func: Whether or not to generate the GLES2Implementation part of this |
| 1327 # command. | 1344 # command. |
| 1328 # impl_decl: Whether or not to generate the GLES2Implementation declaration | 1345 # impl_decl: Whether or not to generate the GLES2Implementation declaration |
| 1329 # for this command. | 1346 # for this command. |
| 1330 # needs_size: If true a data_size field is added to the command. | 1347 # needs_size: If True a data_size field is added to the command. |
| 1331 # count: The number of units per element. For PUTn or PUT types. | 1348 # count: The number of units per element. For PUTn or PUT types. |
| 1332 # unit_test: If False no service side unit test will be generated. | 1349 # unit_test: If False no service side unit test will be generated. |
| 1333 # client_test: If False no client side unit test will be generated. | 1350 # client_test: If False no client side unit test will be generated. |
| 1334 # expectation: If False the unit test will have no expected calls. | 1351 # expectation: If False the unit test will have no expected calls. |
| 1352 # match_all: If True the unit test's EXPECT_GL will use _ for any args. |
| 1335 # gen_func: Name of function that generates GL resource for corresponding | 1353 # gen_func: Name of function that generates GL resource for corresponding |
| 1336 # bind function. | 1354 # bind function. |
| 1337 # states: array of states that get set by this function corresponding to | 1355 # states: array of states that get set by this function corresponding to |
| 1338 # the given arguments | 1356 # the given arguments |
| 1339 # state_flag: name of flag that is set to true when function is called. | 1357 # state_flag: name of flag that is set to true when function is called. |
| 1340 # no_gl: no GL function is called. | 1358 # no_gl: no GL function is called. |
| 1341 # valid_args: A dictionary of argument indices to args to use in unit tests | 1359 # valid_args: A dictionary of argument indices to args to use in unit tests |
| 1342 # when they can not be automatically determined. | 1360 # when they can not be automatically determined. |
| 1343 # pepper_interface: The pepper interface that is used for this extension | 1361 # pepper_interface: The pepper interface that is used for this extension |
| 1344 # pepper_name: The name of the function as exposed to pepper. | 1362 # pepper_name: The name of the function as exposed to pepper. |
| 1345 # pepper_args: A string representing the argument list (what would appear in | 1363 # pepper_args: A string representing the argument list (what would appear in |
| 1346 # C/C++ between the parentheses for the function declaration) | 1364 # C/C++ between the parentheses for the function declaration) |
| 1347 # that the Pepper API expects for this function. Use this only if | 1365 # that the Pepper API expects for this function. Use this only if |
| 1348 # the stable Pepper API differs from the GLES2 argument list. | 1366 # the stable Pepper API differs from the GLES2 argument list. |
| 1349 # invalid_test: False if no invalid test needed. | 1367 # invalid_test: False if no invalid test needed. |
| 1350 # shadowed: True = the value is shadowed so no glGetXXX call will be made. | 1368 # shadowed: True = the value is shadowed so no glGetXXX call will be made. |
| 1351 # first_element_only: For PUT types, True if only the first element of an | 1369 # first_element_only: For PUT types, True if only the first element of an |
| 1352 # array is used and we end up calling the single value | 1370 # array is used and we end up calling the single value |
| 1353 # corresponding function. eg. TexParameteriv -> TexParameteri | 1371 # corresponding function. eg. TexParameteriv -> TexParameteri |
| 1354 # extension: Function is an extension to GL and should not be exposed to | 1372 # extension: Function is an extension to GL and should not be exposed to |
| 1355 # pepper unless pepper_interface is defined. | 1373 # pepper unless pepper_interface is defined. |
| 1356 # extension_flag: Function is an extension and should be enabled only when | 1374 # extension_flag: Function is an extension and should be enabled only when |
| 1357 # the corresponding feature info flag is enabled. Implies | 1375 # the corresponding feature info flag is enabled. Implies |
| 1358 # 'extension': True. | 1376 # 'extension': True. |
| 1359 # not_shared: For GENn types, True if objects can't be shared between contexts | 1377 # not_shared: For GENn types, True if objects can't be shared between contexts |
| 1360 # unsafe: True = no validation is implemented on the service side and the | 1378 # unsafe: True = no validation is implemented on the service side and the |
| 1361 # command is only available with --enable-unsafe-es3-apis. | 1379 # command is only available with --enable-unsafe-es3-apis. |
| 1380 # id_mapping: A list of resource type names whose client side IDs need to be |
| 1381 # mapped to service side IDs. This is only used for unsafe APIs. |
| 1362 | 1382 |
| 1363 _FUNCTION_INFO = { | 1383 _FUNCTION_INFO = { |
| 1364 'ActiveTexture': { | 1384 'ActiveTexture': { |
| 1365 'decoder_func': 'DoActiveTexture', | 1385 'decoder_func': 'DoActiveTexture', |
| 1366 'unit_test': False, | 1386 'unit_test': False, |
| 1367 'impl_func': False, | 1387 'impl_func': False, |
| 1368 'client_test': False, | 1388 'client_test': False, |
| 1369 }, | 1389 }, |
| 1370 'AttachShader': {'decoder_func': 'DoAttachShader'}, | 1390 'AttachShader': {'decoder_func': 'DoAttachShader'}, |
| 1371 'BindAttribLocation': { | 1391 'BindAttribLocation': { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1384 'gl_test_func': 'glBindFramebufferEXT', | 1404 'gl_test_func': 'glBindFramebufferEXT', |
| 1385 'gen_func': 'GenFramebuffersEXT', | 1405 'gen_func': 'GenFramebuffersEXT', |
| 1386 'trace_level': 1, | 1406 'trace_level': 1, |
| 1387 }, | 1407 }, |
| 1388 'BindRenderbuffer': { | 1408 'BindRenderbuffer': { |
| 1389 'type': 'Bind', | 1409 'type': 'Bind', |
| 1390 'decoder_func': 'DoBindRenderbuffer', | 1410 'decoder_func': 'DoBindRenderbuffer', |
| 1391 'gl_test_func': 'glBindRenderbufferEXT', | 1411 'gl_test_func': 'glBindRenderbufferEXT', |
| 1392 'gen_func': 'GenRenderbuffersEXT', | 1412 'gen_func': 'GenRenderbuffersEXT', |
| 1393 }, | 1413 }, |
| 1414 'BindSampler': { |
| 1415 'type': 'Bind', |
| 1416 'id_mapping': [ 'Sampler' ], |
| 1417 'unsafe': True, |
| 1418 }, |
| 1394 'BindTexture': { | 1419 'BindTexture': { |
| 1395 'type': 'Bind', | 1420 'type': 'Bind', |
| 1396 'decoder_func': 'DoBindTexture', | 1421 'decoder_func': 'DoBindTexture', |
| 1397 'gen_func': 'GenTextures', | 1422 'gen_func': 'GenTextures', |
| 1398 # TODO(gman): remove this once client side caching works. | 1423 # TODO(gman): remove this once client side caching works. |
| 1399 'client_test': False, | 1424 'client_test': False, |
| 1400 'trace_level': 1, | 1425 'trace_level': 1, |
| 1401 }, | 1426 }, |
| 1402 'BlitFramebufferCHROMIUM': { | 1427 'BlitFramebufferCHROMIUM': { |
| 1403 'decoder_func': 'DoBlitFramebufferCHROMIUM', | 1428 'decoder_func': 'DoBlitFramebufferCHROMIUM', |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1683 'resource_type': 'Framebuffer', | 1708 'resource_type': 'Framebuffer', |
| 1684 'resource_types': 'Framebuffers', | 1709 'resource_types': 'Framebuffers', |
| 1685 }, | 1710 }, |
| 1686 'DeleteProgram': {'type': 'Delete', 'decoder_func': 'DoDeleteProgram'}, | 1711 'DeleteProgram': {'type': 'Delete', 'decoder_func': 'DoDeleteProgram'}, |
| 1687 'DeleteRenderbuffers': { | 1712 'DeleteRenderbuffers': { |
| 1688 'type': 'DELn', | 1713 'type': 'DELn', |
| 1689 'gl_test_func': 'glDeleteRenderbuffersEXT', | 1714 'gl_test_func': 'glDeleteRenderbuffersEXT', |
| 1690 'resource_type': 'Renderbuffer', | 1715 'resource_type': 'Renderbuffer', |
| 1691 'resource_types': 'Renderbuffers', | 1716 'resource_types': 'Renderbuffers', |
| 1692 }, | 1717 }, |
| 1718 'DeleteSamplers': { |
| 1719 'type': 'DELn', |
| 1720 'resource_type': 'Sampler', |
| 1721 'resource_types': 'Samplers', |
| 1722 'unsafe': True, |
| 1723 }, |
| 1693 'DeleteShader': {'type': 'Delete', 'decoder_func': 'DoDeleteShader'}, | 1724 'DeleteShader': {'type': 'Delete', 'decoder_func': 'DoDeleteShader'}, |
| 1694 'DeleteTextures': { | 1725 'DeleteTextures': { |
| 1695 'type': 'DELn', | 1726 'type': 'DELn', |
| 1696 'resource_type': 'Texture', | 1727 'resource_type': 'Texture', |
| 1697 'resource_types': 'Textures', | 1728 'resource_types': 'Textures', |
| 1698 }, | 1729 }, |
| 1699 'DepthRangef': { | 1730 'DepthRangef': { |
| 1700 'decoder_func': 'DoDepthRangef', | 1731 'decoder_func': 'DoDepthRangef', |
| 1701 'gl_test_func': 'glDepthRange', | 1732 'gl_test_func': 'glDepthRange', |
| 1702 }, | 1733 }, |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1790 'type': 'GENn', | 1821 'type': 'GENn', |
| 1791 'gl_test_func': 'glGenFramebuffersEXT', | 1822 'gl_test_func': 'glGenFramebuffersEXT', |
| 1792 'resource_type': 'Framebuffer', | 1823 'resource_type': 'Framebuffer', |
| 1793 'resource_types': 'Framebuffers', | 1824 'resource_types': 'Framebuffers', |
| 1794 }, | 1825 }, |
| 1795 'GenRenderbuffers': { | 1826 'GenRenderbuffers': { |
| 1796 'type': 'GENn', 'gl_test_func': 'glGenRenderbuffersEXT', | 1827 'type': 'GENn', 'gl_test_func': 'glGenRenderbuffersEXT', |
| 1797 'resource_type': 'Renderbuffer', | 1828 'resource_type': 'Renderbuffer', |
| 1798 'resource_types': 'Renderbuffers', | 1829 'resource_types': 'Renderbuffers', |
| 1799 }, | 1830 }, |
| 1831 'GenSamplers': { |
| 1832 'type': 'GENn', |
| 1833 'gl_test_func': 'glGenSamplers', |
| 1834 'resource_type': 'Sampler', |
| 1835 'resource_types': 'Samplers', |
| 1836 'unsafe': True, |
| 1837 }, |
| 1800 'GenTextures': { | 1838 'GenTextures': { |
| 1801 'type': 'GENn', | 1839 'type': 'GENn', |
| 1802 'gl_test_func': 'glGenTextures', | 1840 'gl_test_func': 'glGenTextures', |
| 1803 'resource_type': 'Texture', | 1841 'resource_type': 'Texture', |
| 1804 'resource_types': 'Textures', | 1842 'resource_types': 'Textures', |
| 1805 }, | 1843 }, |
| 1806 'GetActiveAttrib': { | 1844 'GetActiveAttrib': { |
| 1807 'type': 'Custom', | 1845 'type': 'Custom', |
| 1808 'data_transfer_methods': ['shm'], | 1846 'data_transfer_methods': ['shm'], |
| 1809 'cmd_args': | 1847 'cmd_args': |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1917 'GetProgramInfoLog': { | 1955 'GetProgramInfoLog': { |
| 1918 'type': 'STRn', | 1956 'type': 'STRn', |
| 1919 'expectation': False, | 1957 'expectation': False, |
| 1920 }, | 1958 }, |
| 1921 'GetRenderbufferParameteriv': { | 1959 'GetRenderbufferParameteriv': { |
| 1922 'type': 'GETn', | 1960 'type': 'GETn', |
| 1923 'decoder_func': 'DoGetRenderbufferParameteriv', | 1961 'decoder_func': 'DoGetRenderbufferParameteriv', |
| 1924 'gl_test_func': 'glGetRenderbufferParameterivEXT', | 1962 'gl_test_func': 'glGetRenderbufferParameterivEXT', |
| 1925 'result': ['SizedResult<GLint>'], | 1963 'result': ['SizedResult<GLint>'], |
| 1926 }, | 1964 }, |
| 1965 'GetSamplerParameterfv': { |
| 1966 'type': 'GETn', |
| 1967 'result': ['SizedResult<GLfloat>'], |
| 1968 'id_mapping': [ 'Sampler' ], |
| 1969 'unsafe': True, |
| 1970 }, |
| 1971 'GetSamplerParameteriv': { |
| 1972 'type': 'GETn', |
| 1973 'result': ['SizedResult<GLint>'], |
| 1974 'id_mapping': [ 'Sampler' ], |
| 1975 'unsafe': True, |
| 1976 }, |
| 1927 'GetShaderiv': { | 1977 'GetShaderiv': { |
| 1928 'type': 'GETn', | 1978 'type': 'GETn', |
| 1929 'decoder_func': 'DoGetShaderiv', | 1979 'decoder_func': 'DoGetShaderiv', |
| 1930 'result': ['SizedResult<GLint>'], | 1980 'result': ['SizedResult<GLint>'], |
| 1931 }, | 1981 }, |
| 1932 'GetShaderInfoLog': { | 1982 'GetShaderInfoLog': { |
| 1933 'type': 'STRn', | 1983 'type': 'STRn', |
| 1934 'get_len_func': 'glGetShaderiv', | 1984 'get_len_func': 'glGetShaderiv', |
| 1935 'get_len_enum': 'GL_INFO_LOG_LENGTH', | 1985 'get_len_enum': 'GL_INFO_LOG_LENGTH', |
| 1936 'unit_test': False, | 1986 'unit_test': False, |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2055 'IsRenderbuffer': { | 2105 'IsRenderbuffer': { |
| 2056 'type': 'Is', | 2106 'type': 'Is', |
| 2057 'decoder_func': 'DoIsRenderbuffer', | 2107 'decoder_func': 'DoIsRenderbuffer', |
| 2058 'expectation': False, | 2108 'expectation': False, |
| 2059 }, | 2109 }, |
| 2060 'IsShader': { | 2110 'IsShader': { |
| 2061 'type': 'Is', | 2111 'type': 'Is', |
| 2062 'decoder_func': 'DoIsShader', | 2112 'decoder_func': 'DoIsShader', |
| 2063 'expectation': False, | 2113 'expectation': False, |
| 2064 }, | 2114 }, |
| 2115 'IsSampler': { |
| 2116 'type': 'Is', |
| 2117 'match_all': True, |
| 2118 'unsafe': True, |
| 2119 }, |
| 2065 'IsTexture': { | 2120 'IsTexture': { |
| 2066 'type': 'Is', | 2121 'type': 'Is', |
| 2067 'decoder_func': 'DoIsTexture', | 2122 'decoder_func': 'DoIsTexture', |
| 2068 'expectation': False, | 2123 'expectation': False, |
| 2069 }, | 2124 }, |
| 2070 'LinkProgram': { | 2125 'LinkProgram': { |
| 2071 'decoder_func': 'DoLinkProgram', | 2126 'decoder_func': 'DoLinkProgram', |
| 2072 'impl_func': False, | 2127 'impl_func': False, |
| 2073 }, | 2128 }, |
| 2074 'MapBufferCHROMIUM': { | 2129 'MapBufferCHROMIUM': { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2165 'uint32_t pixels_shm_id, uint32_t pixels_shm_offset, ' | 2220 'uint32_t pixels_shm_id, uint32_t pixels_shm_offset, ' |
| 2166 'uint32_t result_shm_id, uint32_t result_shm_offset, ' | 2221 'uint32_t result_shm_id, uint32_t result_shm_offset, ' |
| 2167 'GLboolean async', | 2222 'GLboolean async', |
| 2168 'result': ['uint32_t'], | 2223 'result': ['uint32_t'], |
| 2169 'defer_reads': True, | 2224 'defer_reads': True, |
| 2170 }, | 2225 }, |
| 2171 'ReleaseShaderCompiler': { | 2226 'ReleaseShaderCompiler': { |
| 2172 'decoder_func': 'DoReleaseShaderCompiler', | 2227 'decoder_func': 'DoReleaseShaderCompiler', |
| 2173 'unit_test': False, | 2228 'unit_test': False, |
| 2174 }, | 2229 }, |
| 2230 'SamplerParameterf': { |
| 2231 'valid_args': { |
| 2232 '2': 'GL_NEAREST' |
| 2233 }, |
| 2234 'id_mapping': [ 'Sampler' ], |
| 2235 'unsafe': True, |
| 2236 }, |
| 2237 'SamplerParameterfv': { |
| 2238 'type': 'PUT', |
| 2239 'data_value': 'GL_NEAREST', |
| 2240 'count': 1, |
| 2241 'gl_test_func': 'glSamplerParameterf', |
| 2242 'decoder_func': 'DoSamplerParameterfv', |
| 2243 'first_element_only': True, |
| 2244 'id_mapping': [ 'Sampler' ], |
| 2245 'unsafe': True, |
| 2246 }, |
| 2247 'SamplerParameteri': { |
| 2248 'valid_args': { |
| 2249 '2': 'GL_NEAREST' |
| 2250 }, |
| 2251 'id_mapping': [ 'Sampler' ], |
| 2252 'unsafe': True, |
| 2253 }, |
| 2254 'SamplerParameteriv': { |
| 2255 'type': 'PUT', |
| 2256 'data_value': 'GL_NEAREST', |
| 2257 'count': 1, |
| 2258 'gl_test_func': 'glSamplerParameteri', |
| 2259 'decoder_func': 'DoSamplerParameteriv', |
| 2260 'first_element_only': True, |
| 2261 'unsafe': True, |
| 2262 }, |
| 2175 'ShaderBinary': { | 2263 'ShaderBinary': { |
| 2176 'type': 'Custom', | 2264 'type': 'Custom', |
| 2177 'client_test': False, | 2265 'client_test': False, |
| 2178 }, | 2266 }, |
| 2179 'ShaderSource': { | 2267 'ShaderSource': { |
| 2180 'type': 'Manual', | 2268 'type': 'Manual', |
| 2181 'data_transfer_methods': ['bucket'], | 2269 'data_transfer_methods': ['bucket'], |
| 2182 'needs_size': True, | 2270 'needs_size': True, |
| 2183 'client_test': False, | 2271 'client_test': False, |
| 2184 'cmd_args': | 2272 'cmd_args': |
| (...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3054 file.Write((check.strip() + "\n") % { | 3142 file.Write((check.strip() + "\n") % { |
| 3055 'cmd_name': func.name, | 3143 'cmd_name': func.name, |
| 3056 'field_name': name, | 3144 'field_name': name, |
| 3057 'offset': offset, | 3145 'offset': offset, |
| 3058 }) | 3146 }) |
| 3059 offset += _SIZE_OF_UINT32 | 3147 offset += _SIZE_OF_UINT32 |
| 3060 file.Write("\n") | 3148 file.Write("\n") |
| 3061 | 3149 |
| 3062 def WriteHandlerImplementation(self, func, file): | 3150 def WriteHandlerImplementation(self, func, file): |
| 3063 """Writes the handler implementation for this command.""" | 3151 """Writes the handler implementation for this command.""" |
| 3152 if func.IsUnsafe() and func.GetInfo('id_mapping'): |
| 3153 for id_type in func.GetInfo('id_mapping'): |
| 3154 file.Write(" group_->Get%sServiceId(%s, &%s);\n" % |
| 3155 (id_type, id_type.lower(), id_type.lower())) |
| 3064 file.Write(" %s(%s);\n" % | 3156 file.Write(" %s(%s);\n" % |
| 3065 (func.GetGLFunctionName(), func.MakeOriginalArgString(""))) | 3157 (func.GetGLFunctionName(), func.MakeOriginalArgString(""))) |
| 3066 | 3158 |
| 3067 def WriteCmdSizeTest(self, func, file): | 3159 def WriteCmdSizeTest(self, func, file): |
| 3068 """Writes the size test for a command.""" | 3160 """Writes the size test for a command.""" |
| 3069 file.Write(" EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);\n") | 3161 file.Write(" EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);\n") |
| 3070 | 3162 |
| 3071 def WriteFormatTest(self, func, file): | 3163 def WriteFormatTest(self, func, file): |
| 3072 """Writes a format test for a command.""" | 3164 """Writes a format test for a command.""" |
| 3073 file.Write("TEST_F(GLES2FormatTest, %s) {\n" % func.name) | 3165 file.Write("TEST_F(GLES2FormatTest, %s) {\n" % func.name) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 3103 """Writes the code to set data_size used in validation""" | 3195 """Writes the code to set data_size used in validation""" |
| 3104 pass | 3196 pass |
| 3105 | 3197 |
| 3106 def WriteImmediateCmdSizeTest(self, func, file): | 3198 def WriteImmediateCmdSizeTest(self, func, file): |
| 3107 """Writes a size test for an immediate version of a command.""" | 3199 """Writes a size test for an immediate version of a command.""" |
| 3108 file.Write(" // TODO(gman): Compute correct size.\n") | 3200 file.Write(" // TODO(gman): Compute correct size.\n") |
| 3109 file.Write(" EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);\n") | 3201 file.Write(" EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);\n") |
| 3110 | 3202 |
| 3111 def WriteImmediateHandlerImplementation (self, func, file): | 3203 def WriteImmediateHandlerImplementation (self, func, file): |
| 3112 """Writes the handler impl for the immediate version of a command.""" | 3204 """Writes the handler impl for the immediate version of a command.""" |
| 3205 if func.IsUnsafe() and func.GetInfo('id_mapping'): |
| 3206 for id_type in func.GetInfo('id_mapping'): |
| 3207 file.Write(" group_->Get%sServiceId(%s, &%s);\n" % |
| 3208 (id_type, id_type.lower(), id_type.lower())) |
| 3113 file.Write(" %s(%s);\n" % | 3209 file.Write(" %s(%s);\n" % |
| 3114 (func.GetGLFunctionName(), func.MakeOriginalArgString(""))) | 3210 (func.GetGLFunctionName(), func.MakeOriginalArgString(""))) |
| 3115 | 3211 |
| 3116 def WriteBucketHandlerImplementation (self, func, file): | 3212 def WriteBucketHandlerImplementation (self, func, file): |
| 3117 """Writes the handler impl for the bucket version of a command.""" | 3213 """Writes the handler impl for the bucket version of a command.""" |
| 3118 file.Write(" %s(%s);\n" % | 3214 file.Write(" %s(%s);\n" % |
| 3119 (func.GetGLFunctionName(), func.MakeOriginalArgString(""))) | 3215 (func.GetGLFunctionName(), func.MakeOriginalArgString(""))) |
| 3120 | 3216 |
| 3121 def WriteServiceHandlerFunctionHeader(self, func, file): | 3217 def WriteServiceHandlerFunctionHeader(self, func, file): |
| 3122 """Writes function header for service implementation handlers.""" | 3218 """Writes function header for service implementation handlers.""" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3206 def WriteValidUnitTest(self, func, file, test, *extras): | 3302 def WriteValidUnitTest(self, func, file, test, *extras): |
| 3207 """Writes a valid unit test for the service implementation.""" | 3303 """Writes a valid unit test for the service implementation.""" |
| 3208 if func.GetInfo('expectation') == False: | 3304 if func.GetInfo('expectation') == False: |
| 3209 test = self._remove_expected_call_re.sub('', test) | 3305 test = self._remove_expected_call_re.sub('', test) |
| 3210 name = func.name | 3306 name = func.name |
| 3211 arg_strings = [ | 3307 arg_strings = [ |
| 3212 arg.GetValidArg(func) \ | 3308 arg.GetValidArg(func) \ |
| 3213 for arg in func.GetOriginalArgs() if not arg.IsConstant() | 3309 for arg in func.GetOriginalArgs() if not arg.IsConstant() |
| 3214 ] | 3310 ] |
| 3215 gl_arg_strings = [ | 3311 gl_arg_strings = [ |
| 3216 arg.GetValidGLArg(func) \ | 3312 "_" if func.MatchAll() else arg.GetValidGLArg(func) \ |
| 3217 for arg in func.GetOriginalArgs() | 3313 for arg in func.GetOriginalArgs() |
| 3218 ] | 3314 ] |
| 3219 gl_func_name = func.GetGLTestFunctionName() | 3315 gl_func_name = func.GetGLTestFunctionName() |
| 3220 vars = { | 3316 vars = { |
| 3221 'name':name, | 3317 'name':name, |
| 3222 'gl_func_name': gl_func_name, | 3318 'gl_func_name': gl_func_name, |
| 3223 'args': ", ".join(arg_strings), | 3319 'args': ", ".join(arg_strings), |
| 3224 'gl_args': ", ".join(gl_arg_strings), | 3320 'gl_args': ", ".join(gl_arg_strings), |
| 3225 } | 3321 } |
| 3226 for extra in extras: | 3322 for extra in extras: |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3263 | 3359 |
| 3264 vars = { | 3360 vars = { |
| 3265 'name': func.name, | 3361 'name': func.name, |
| 3266 'arg_index': invalid_arg_index, | 3362 'arg_index': invalid_arg_index, |
| 3267 'value_index': value_index, | 3363 'value_index': value_index, |
| 3268 'gl_func_name': gl_func_name, | 3364 'gl_func_name': gl_func_name, |
| 3269 'args': ", ".join(arg_strings), | 3365 'args': ", ".join(arg_strings), |
| 3270 'all_but_last_args': ", ".join(arg_strings[:-1]), | 3366 'all_but_last_args': ", ".join(arg_strings[:-1]), |
| 3271 'gl_args': ", ".join(gl_arg_strings), | 3367 'gl_args': ", ".join(gl_arg_strings), |
| 3272 'parse_result': parse_result, | 3368 'parse_result': parse_result, |
| 3273 'gl_error_test': gl_error_test, | 3369 'gl_error_test': gl_error_test, |
| 3274 } | 3370 } |
| 3275 for extra in extras: | 3371 for extra in extras: |
| 3276 vars.update(extra) | 3372 vars.update(extra) |
| 3277 file.Write(test % vars) | 3373 file.Write(test % vars) |
| 3278 | 3374 |
| 3279 def WriteServiceUnitTest(self, func, file, *extras): | 3375 def WriteServiceUnitTest(self, func, file, *extras): |
| 3280 """Writes the service unit test for a command.""" | 3376 """Writes the service unit test for a command.""" |
| 3281 | 3377 |
| 3282 if func.name == 'Enable': | 3378 if func.name == 'Enable': |
| 3283 valid_test = """ | 3379 valid_test = """ |
| (...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4147 | 4243 |
| 4148 def WriteServiceUnitTest(self, func, file, *extras): | 4244 def WriteServiceUnitTest(self, func, file, *extras): |
| 4149 """Overrriden from TypeHandler.""" | 4245 """Overrriden from TypeHandler.""" |
| 4150 | 4246 |
| 4151 if len(func.GetOriginalArgs()) == 1: | 4247 if len(func.GetOriginalArgs()) == 1: |
| 4152 valid_test = """ | 4248 valid_test = """ |
| 4153 TEST_P(%(test_name)s, %(name)sValidArgs) { | 4249 TEST_P(%(test_name)s, %(name)sValidArgs) { |
| 4154 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)); | 4250 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)); |
| 4155 SpecializedSetup<cmds::%(name)s, 0>(true); | 4251 SpecializedSetup<cmds::%(name)s, 0>(true); |
| 4156 cmds::%(name)s cmd; | 4252 cmds::%(name)s cmd; |
| 4157 cmd.Init(%(args)s); | 4253 cmd.Init(%(args)s);""" |
| 4254 if func.IsUnsafe(): |
| 4255 valid_test += """ |
| 4256 decoder_->set_unsafe_es3_apis_enabled(true); |
| 4257 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 4258 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 4259 decoder_->set_unsafe_es3_apis_enabled(false); |
| 4260 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd)); |
| 4261 } |
| 4262 """ |
| 4263 else: |
| 4264 valid_test += """ |
| 4158 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 4265 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 4159 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 4266 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 4160 } | 4267 } |
| 4161 """ | 4268 """ |
| 4162 if func.GetInfo("gen_func"): | 4269 if func.GetInfo("gen_func"): |
| 4163 valid_test += """ | 4270 valid_test += """ |
| 4164 TEST_P(%(test_name)s, %(name)sValidArgsNewId) { | 4271 TEST_P(%(test_name)s, %(name)sValidArgsNewId) { |
| 4165 EXPECT_CALL(*gl_, %(gl_func_name)s(kNewServiceId)); | 4272 EXPECT_CALL(*gl_, %(gl_func_name)s(kNewServiceId)); |
| 4166 EXPECT_CALL(*gl_, %(gl_gen_func_name)s(1, _)) | 4273 EXPECT_CALL(*gl_, %(gl_gen_func_name)s(1, _)) |
| 4167 .WillOnce(SetArgumentPointee<1>(kNewServiceId)); | 4274 .WillOnce(SetArgumentPointee<1>(kNewServiceId)); |
| 4168 SpecializedSetup<cmds::%(name)s, 0>(true); | 4275 SpecializedSetup<cmds::%(name)s, 0>(true); |
| 4169 cmds::%(name)s cmd; | 4276 cmds::%(name)s cmd; |
| 4170 cmd.Init(kNewClientId); | 4277 cmd.Init(kNewClientId); |
| 4171 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 4278 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 4172 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 4279 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 4173 EXPECT_TRUE(Get%(resource_type)s(kNewClientId) != NULL); | 4280 EXPECT_TRUE(Get%(resource_type)s(kNewClientId) != NULL); |
| 4174 } | 4281 } |
| 4175 """ | 4282 """ |
| 4176 self.WriteValidUnitTest(func, file, valid_test, { | 4283 self.WriteValidUnitTest(func, file, valid_test, { |
| 4177 'resource_type': func.GetOriginalArgs()[0].resource_type, | 4284 'resource_type': func.GetOriginalArgs()[0].resource_type, |
| 4178 'gl_gen_func_name': func.GetInfo("gen_func"), | 4285 'gl_gen_func_name': func.GetInfo("gen_func"), |
| 4179 }, *extras) | 4286 }, *extras) |
| 4180 else: | 4287 else: |
| 4181 valid_test = """ | 4288 valid_test = """ |
| 4182 TEST_P(%(test_name)s, %(name)sValidArgs) { | 4289 TEST_P(%(test_name)s, %(name)sValidArgs) { |
| 4183 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)); | 4290 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)); |
| 4184 SpecializedSetup<cmds::%(name)s, 0>(true); | 4291 SpecializedSetup<cmds::%(name)s, 0>(true); |
| 4185 cmds::%(name)s cmd; | 4292 cmds::%(name)s cmd; |
| 4186 cmd.Init(%(args)s); | 4293 cmd.Init(%(args)s);""" |
| 4294 if func.IsUnsafe(): |
| 4295 valid_test += """ |
| 4296 decoder_->set_unsafe_es3_apis_enabled(true); |
| 4297 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 4298 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 4299 decoder_->set_unsafe_es3_apis_enabled(false); |
| 4300 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd)); |
| 4301 } |
| 4302 """ |
| 4303 else: |
| 4304 valid_test += """ |
| 4187 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 4305 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 4188 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 4306 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 4189 } | 4307 } |
| 4190 """ | 4308 """ |
| 4191 if func.GetInfo("gen_func"): | 4309 if func.GetInfo("gen_func"): |
| 4192 valid_test += """ | 4310 valid_test += """ |
| 4193 TEST_P(%(test_name)s, %(name)sValidArgsNewId) { | 4311 TEST_P(%(test_name)s, %(name)sValidArgsNewId) { |
| 4194 EXPECT_CALL(*gl_, %(gl_func_name)s(%(first_gl_arg)s, kNewServiceId)); | 4312 EXPECT_CALL(*gl_, %(gl_func_name)s(%(first_gl_arg)s, kNewServiceId)); |
| 4195 EXPECT_CALL(*gl_, %(gl_gen_func_name)s(1, _)) | 4313 EXPECT_CALL(*gl_, %(gl_gen_func_name)s(1, _)) |
| 4196 .WillOnce(SetArgumentPointee<1>(kNewServiceId)); | 4314 .WillOnce(SetArgumentPointee<1>(kNewServiceId)); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4232 | 4350 |
| 4233 file.Write("%s GLES2Implementation::%s(%s) {\n" % | 4351 file.Write("%s GLES2Implementation::%s(%s) {\n" % |
| 4234 (func.return_type, func.original_name, | 4352 (func.return_type, func.original_name, |
| 4235 func.MakeTypedOriginalArgString(""))) | 4353 func.MakeTypedOriginalArgString(""))) |
| 4236 file.Write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n") | 4354 file.Write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n") |
| 4237 func.WriteDestinationInitalizationValidation(file) | 4355 func.WriteDestinationInitalizationValidation(file) |
| 4238 self.WriteClientGLCallLog(func, file) | 4356 self.WriteClientGLCallLog(func, file) |
| 4239 for arg in func.GetOriginalArgs(): | 4357 for arg in func.GetOriginalArgs(): |
| 4240 arg.WriteClientSideValidationCode(file, func) | 4358 arg.WriteClientSideValidationCode(file, func) |
| 4241 | 4359 |
| 4242 code = """ if (Is%(type)sReservedId(%(id)s)) { | 4360 if func.IsUnsafe(): |
| 4361 code = """ helper_->%(name)s(%(arg_string)s); |
| 4362 CheckGLError(); |
| 4363 } |
| 4364 |
| 4365 """ |
| 4366 else: |
| 4367 code = """ if (Is%(type)sReservedId(%(id)s)) { |
| 4243 SetGLError(GL_INVALID_OPERATION, "%(name)s\", \"%(id)s reserved id"); | 4368 SetGLError(GL_INVALID_OPERATION, "%(name)s\", \"%(id)s reserved id"); |
| 4244 return; | 4369 return; |
| 4245 } | 4370 } |
| 4246 %(name)sHelper(%(arg_string)s); | 4371 %(name)sHelper(%(arg_string)s); |
| 4247 CheckGLError(); | 4372 CheckGLError(); |
| 4248 } | 4373 } |
| 4249 | 4374 |
| 4250 """ | 4375 """ |
| 4251 name_arg = None | 4376 name_arg = None |
| 4252 if len(func.GetOriginalArgs()) == 1: | 4377 if len(func.GetOriginalArgs()) == 1: |
| (...skipping 18 matching lines...) Expand all Loading... |
| 4271 return | 4396 return |
| 4272 code = """ | 4397 code = """ |
| 4273 TEST_F(GLES2ImplementationTest, %(name)s) { | 4398 TEST_F(GLES2ImplementationTest, %(name)s) { |
| 4274 struct Cmds { | 4399 struct Cmds { |
| 4275 cmds::%(name)s cmd; | 4400 cmds::%(name)s cmd; |
| 4276 }; | 4401 }; |
| 4277 Cmds expected; | 4402 Cmds expected; |
| 4278 expected.cmd.Init(%(cmd_args)s); | 4403 expected.cmd.Init(%(cmd_args)s); |
| 4279 | 4404 |
| 4280 gl_->%(name)s(%(args)s); | 4405 gl_->%(name)s(%(args)s); |
| 4281 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 4406 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));""" |
| 4407 if not func.IsUnsafe(): |
| 4408 code += """ |
| 4282 ClearCommands(); | 4409 ClearCommands(); |
| 4283 gl_->%(name)s(%(args)s); | 4410 gl_->%(name)s(%(args)s); |
| 4284 EXPECT_TRUE(NoCommandsWritten()); | 4411 EXPECT_TRUE(NoCommandsWritten());""" |
| 4412 code += """ |
| 4285 } | 4413 } |
| 4286 """ | 4414 """ |
| 4287 cmd_arg_strings = [ | 4415 cmd_arg_strings = [ |
| 4288 arg.GetValidClientSideCmdArg(func) for arg in func.GetCmdArgs() | 4416 arg.GetValidClientSideCmdArg(func) for arg in func.GetCmdArgs() |
| 4289 ] | 4417 ] |
| 4290 gl_arg_strings = [ | 4418 gl_arg_strings = [ |
| 4291 arg.GetValidClientSideArg(func) for arg in func.GetOriginalArgs() | 4419 arg.GetValidClientSideArg(func) for arg in func.GetOriginalArgs() |
| 4292 ] | 4420 ] |
| 4293 | 4421 |
| 4294 file.Write(code % { | 4422 file.Write(code % { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 4319 | 4447 |
| 4320 def WriteHandlerImplementation (self, func, file): | 4448 def WriteHandlerImplementation (self, func, file): |
| 4321 """Overrriden from TypeHandler.""" | 4449 """Overrriden from TypeHandler.""" |
| 4322 file.Write(" if (!%sHelper(n, %s)) {\n" | 4450 file.Write(" if (!%sHelper(n, %s)) {\n" |
| 4323 " return error::kInvalidArguments;\n" | 4451 " return error::kInvalidArguments;\n" |
| 4324 " }\n" % | 4452 " }\n" % |
| 4325 (func.name, func.GetLastOriginalArg().name)) | 4453 (func.name, func.GetLastOriginalArg().name)) |
| 4326 | 4454 |
| 4327 def WriteImmediateHandlerImplementation(self, func, file): | 4455 def WriteImmediateHandlerImplementation(self, func, file): |
| 4328 """Overrriden from TypeHandler.""" | 4456 """Overrriden from TypeHandler.""" |
| 4329 file.Write(" if (!%sHelper(n, %s)) {\n" | 4457 if func.IsUnsafe(): |
| 4330 " return error::kInvalidArguments;\n" | 4458 file.Write(""" for (GLsizei ii = 0; ii < n; ++ii) { |
| 4331 " }\n" % | 4459 if (group_->Get%(resource_name)sServiceId(%(last_arg_name)s[ii], NULL)) { |
| 4332 (func.original_name, func.GetLastOriginalArg().name)) | 4460 return error::kInvalidArguments; |
| 4461 } |
| 4462 } |
| 4463 scoped_ptr<GLuint[]> service_ids(new GLuint[n]); |
| 4464 gl%(func_name)s(n, service_ids.get()); |
| 4465 for (GLsizei ii = 0; ii < n; ++ii) { |
| 4466 group_->Add%(resource_name)sId(%(last_arg_name)s[ii], service_ids[ii]); |
| 4467 } |
| 4468 """ % { 'func_name': func.original_name, |
| 4469 'last_arg_name': func.GetLastOriginalArg().name, |
| 4470 'resource_name': func.GetInfo('resource_type') }) |
| 4471 else: |
| 4472 file.Write(" if (!%sHelper(n, %s)) {\n" |
| 4473 " return error::kInvalidArguments;\n" |
| 4474 " }\n" % |
| 4475 (func.original_name, func.GetLastOriginalArg().name)) |
| 4333 | 4476 |
| 4334 def WriteGLES2Implementation(self, func, file): | 4477 def WriteGLES2Implementation(self, func, file): |
| 4335 """Overrriden from TypeHandler.""" | 4478 """Overrriden from TypeHandler.""" |
| 4336 log_code = (""" GPU_CLIENT_LOG_CODE_BLOCK({ | 4479 log_code = (""" GPU_CLIENT_LOG_CODE_BLOCK({ |
| 4337 for (GLsizei i = 0; i < n; ++i) { | 4480 for (GLsizei i = 0; i < n; ++i) { |
| 4338 GPU_CLIENT_LOG(" " << i << ": " << %s[i]); | 4481 GPU_CLIENT_LOG(" " << i << ": " << %s[i]); |
| 4339 } | 4482 } |
| 4340 });""" % func.GetOriginalArgs()[1].name) | 4483 });""" % func.GetOriginalArgs()[1].name) |
| 4341 args = { | 4484 args = { |
| 4342 'log_code': log_code, | 4485 'log_code': log_code, |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4408 """Overrriden from TypeHandler.""" | 4551 """Overrriden from TypeHandler.""" |
| 4409 valid_test = """ | 4552 valid_test = """ |
| 4410 TEST_P(%(test_name)s, %(name)sValidArgs) { | 4553 TEST_P(%(test_name)s, %(name)sValidArgs) { |
| 4411 EXPECT_CALL(*gl_, %(gl_func_name)s(1, _)) | 4554 EXPECT_CALL(*gl_, %(gl_func_name)s(1, _)) |
| 4412 .WillOnce(SetArgumentPointee<1>(kNewServiceId)); | 4555 .WillOnce(SetArgumentPointee<1>(kNewServiceId)); |
| 4413 GetSharedMemoryAs<GLuint*>()[0] = kNewClientId; | 4556 GetSharedMemoryAs<GLuint*>()[0] = kNewClientId; |
| 4414 SpecializedSetup<cmds::%(name)s, 0>(true); | 4557 SpecializedSetup<cmds::%(name)s, 0>(true); |
| 4415 cmds::%(name)s cmd; | 4558 cmds::%(name)s cmd; |
| 4416 cmd.Init(%(args)s); | 4559 cmd.Init(%(args)s); |
| 4417 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 4560 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 4418 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 4561 EXPECT_EQ(GL_NO_ERROR, GetGLError());""" |
| 4419 EXPECT_TRUE(Get%(resource_name)s(kNewClientId) != NULL); | 4562 if func.IsUnsafe(): |
| 4563 valid_test += """ |
| 4564 GLuint service_id; |
| 4565 EXPECT_TRUE(Get%(resource_name)sServiceId(kNewClientId, &service_id)); |
| 4566 EXPECT_EQ(kNewServiceId, service_id) |
| 4567 } |
| 4568 """ |
| 4569 else: |
| 4570 valid_test += """ |
| 4571 EXPECT_TRUE(Get%(resource_name)s(kNewClientId, &service_id) != NULL); |
| 4420 } | 4572 } |
| 4421 """ | 4573 """ |
| 4422 self.WriteValidUnitTest(func, file, valid_test, { | 4574 self.WriteValidUnitTest(func, file, valid_test, { |
| 4423 'resource_name': func.GetInfo('resource_type'), | 4575 'resource_name': func.GetInfo('resource_type'), |
| 4424 }, *extras) | 4576 }, *extras) |
| 4425 invalid_test = """ | 4577 invalid_test = """ |
| 4426 TEST_P(%(test_name)s, %(name)sInvalidArgs) { | 4578 TEST_P(%(test_name)s, %(name)sInvalidArgs) { |
| 4427 EXPECT_CALL(*gl_, %(gl_func_name)s(_, _)).Times(0); | 4579 EXPECT_CALL(*gl_, %(gl_func_name)s(_, _)).Times(0); |
| 4428 GetSharedMemoryAs<GLuint*>()[0] = client_%(resource_name)s_id_; | 4580 GetSharedMemoryAs<GLuint*>()[0] = client_%(resource_name)s_id_; |
| 4429 SpecializedSetup<cmds::%(name)s, 0>(false); | 4581 SpecializedSetup<cmds::%(name)s, 0>(false); |
| 4430 cmds::%(name)s cmd; | 4582 cmds::%(name)s cmd; |
| 4431 cmd.Init(%(args)s); | 4583 cmd.Init(%(args)s); |
| 4432 EXPECT_EQ(error::kInvalidArguments, ExecuteCmd(cmd)); | 4584 EXPECT_EQ(error::kInvalidArguments, ExecuteCmd(cmd)); |
| 4433 } | 4585 } |
| 4434 """ | 4586 """ |
| 4435 self.WriteValidUnitTest(func, file, invalid_test, { | 4587 self.WriteValidUnitTest(func, file, invalid_test, { |
| 4436 'resource_name': func.GetInfo('resource_type').lower(), | 4588 'resource_name': func.GetInfo('resource_type').lower(), |
| 4437 }, *extras) | 4589 }, *extras) |
| 4438 | 4590 |
| 4439 def WriteImmediateServiceUnitTest(self, func, file, *extras): | 4591 def WriteImmediateServiceUnitTest(self, func, file, *extras): |
| 4440 """Overrriden from TypeHandler.""" | 4592 """Overrriden from TypeHandler.""" |
| 4441 valid_test = """ | 4593 valid_test = """ |
| 4442 TEST_P(%(test_name)s, %(name)sValidArgs) { | 4594 TEST_P(%(test_name)s, %(name)sValidArgs) { |
| 4443 EXPECT_CALL(*gl_, %(gl_func_name)s(1, _)) | 4595 EXPECT_CALL(*gl_, %(gl_func_name)s(1, _)) |
| 4444 .WillOnce(SetArgumentPointee<1>(kNewServiceId)); | 4596 .WillOnce(SetArgumentPointee<1>(kNewServiceId)); |
| 4445 cmds::%(name)s* cmd = GetImmediateAs<cmds::%(name)s>(); | 4597 cmds::%(name)s* cmd = GetImmediateAs<cmds::%(name)s>(); |
| 4446 GLuint temp = kNewClientId; | 4598 GLuint temp = kNewClientId; |
| 4447 SpecializedSetup<cmds::%(name)s, 0>(true); | 4599 SpecializedSetup<cmds::%(name)s, 0>(true);""" |
| 4600 if func.IsUnsafe(): |
| 4601 valid_test += """ |
| 4602 decoder_->set_unsafe_es3_apis_enabled(true);""" |
| 4603 valid_test += """ |
| 4448 cmd->Init(1, &temp); | 4604 cmd->Init(1, &temp); |
| 4449 EXPECT_EQ(error::kNoError, | 4605 EXPECT_EQ(error::kNoError, |
| 4450 ExecuteImmediateCmd(*cmd, sizeof(temp))); | 4606 ExecuteImmediateCmd(*cmd, sizeof(temp))); |
| 4451 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 4607 EXPECT_EQ(GL_NO_ERROR, GetGLError());""" |
| 4608 if func.IsUnsafe(): |
| 4609 valid_test += """ |
| 4610 GLuint service_id; |
| 4611 EXPECT_TRUE(Get%(resource_name)sServiceId(kNewClientId, &service_id)); |
| 4612 EXPECT_EQ(kNewServiceId, service_id); |
| 4613 decoder_->set_unsafe_es3_apis_enabled(false); |
| 4614 EXPECT_EQ(error::kUnknownCommand, |
| 4615 ExecuteImmediateCmd(*cmd, sizeof(temp))); |
| 4616 } |
| 4617 """ |
| 4618 else: |
| 4619 valid_test += """ |
| 4452 EXPECT_TRUE(Get%(resource_name)s(kNewClientId) != NULL); | 4620 EXPECT_TRUE(Get%(resource_name)s(kNewClientId) != NULL); |
| 4453 } | 4621 } |
| 4454 """ | 4622 """ |
| 4455 self.WriteValidUnitTest(func, file, valid_test, { | 4623 self.WriteValidUnitTest(func, file, valid_test, { |
| 4456 'resource_name': func.GetInfo('resource_type'), | 4624 'resource_name': func.GetInfo('resource_type'), |
| 4457 }, *extras) | 4625 }, *extras) |
| 4458 invalid_test = """ | 4626 invalid_test = """ |
| 4459 TEST_P(%(test_name)s, %(name)sInvalidArgs) { | 4627 TEST_P(%(test_name)s, %(name)sInvalidArgs) { |
| 4460 EXPECT_CALL(*gl_, %(gl_func_name)s(_, _)).Times(0); | 4628 EXPECT_CALL(*gl_, %(gl_func_name)s(_, _)).Times(0); |
| 4461 cmds::%(name)s* cmd = GetImmediateAs<cmds::%(name)s>(); | 4629 cmds::%(name)s* cmd = GetImmediateAs<cmds::%(name)s>(); |
| 4462 SpecializedSetup<cmds::%(name)s, 0>(false); | 4630 SpecializedSetup<cmds::%(name)s, 0>(false); |
| 4463 cmd->Init(1, &client_%(resource_name)s_id_); | 4631 cmd->Init(1, &client_%(resource_name)s_id_);""" |
| 4632 if func.IsUnsafe(): |
| 4633 invalid_test += """ |
| 4634 decoder_->set_unsafe_es3_apis_enabled(true); |
| 4635 EXPECT_EQ(error::kInvalidArguments, |
| 4636 ExecuteImmediateCmd(*cmd, sizeof(&client_%(resource_name)s_id_))); |
| 4637 decoder_->set_unsafe_es3_apis_enabled(false); |
| 4638 } |
| 4639 """ |
| 4640 else: |
| 4641 invalid_test += """ |
| 4464 EXPECT_EQ(error::kInvalidArguments, | 4642 EXPECT_EQ(error::kInvalidArguments, |
| 4465 ExecuteImmediateCmd(*cmd, sizeof(&client_%(resource_name)s_id_))); | 4643 ExecuteImmediateCmd(*cmd, sizeof(&client_%(resource_name)s_id_))); |
| 4466 } | 4644 } |
| 4467 """ | 4645 """ |
| 4468 self.WriteValidUnitTest(func, file, invalid_test, { | 4646 self.WriteValidUnitTest(func, file, invalid_test, { |
| 4469 'resource_name': func.GetInfo('resource_type').lower(), | 4647 'resource_name': func.GetInfo('resource_type').lower(), |
| 4470 }, *extras) | 4648 }, *extras) |
| 4471 | 4649 |
| 4472 def WriteImmediateCmdComputeSize(self, func, file): | 4650 def WriteImmediateCmdComputeSize(self, func, file): |
| 4473 """Overrriden from TypeHandler.""" | 4651 """Overrriden from TypeHandler.""" |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4737 def WriteImmediateServiceUnitTest(self, func, file, *extras): | 4915 def WriteImmediateServiceUnitTest(self, func, file, *extras): |
| 4738 """Overrriden from TypeHandler.""" | 4916 """Overrriden from TypeHandler.""" |
| 4739 valid_test = """ | 4917 valid_test = """ |
| 4740 TEST_P(%(test_name)s, %(name)sValidArgs) { | 4918 TEST_P(%(test_name)s, %(name)sValidArgs) { |
| 4741 EXPECT_CALL( | 4919 EXPECT_CALL( |
| 4742 *gl_, | 4920 *gl_, |
| 4743 %(gl_func_name)s(1, Pointee(kService%(upper_resource_name)sId))) | 4921 %(gl_func_name)s(1, Pointee(kService%(upper_resource_name)sId))) |
| 4744 .Times(1); | 4922 .Times(1); |
| 4745 cmds::%(name)s& cmd = *GetImmediateAs<cmds::%(name)s>(); | 4923 cmds::%(name)s& cmd = *GetImmediateAs<cmds::%(name)s>(); |
| 4746 SpecializedSetup<cmds::%(name)s, 0>(true); | 4924 SpecializedSetup<cmds::%(name)s, 0>(true); |
| 4747 cmd.Init(1, &client_%(resource_name)s_id_); | 4925 cmd.Init(1, &client_%(resource_name)s_id_);""" |
| 4926 if func.IsUnsafe(): |
| 4927 valid_test += """ |
| 4928 decoder_->set_unsafe_es3_apis_enabled(true);""" |
| 4929 valid_test += """ |
| 4748 EXPECT_EQ(error::kNoError, | 4930 EXPECT_EQ(error::kNoError, |
| 4749 ExecuteImmediateCmd(cmd, sizeof(client_%(resource_name)s_id_))); | 4931 ExecuteImmediateCmd(cmd, sizeof(client_%(resource_name)s_id_))); |
| 4750 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 4932 EXPECT_EQ(GL_NO_ERROR, GetGLError());""" |
| 4933 if func.IsUnsafe(): |
| 4934 valid_test += """ |
| 4935 EXPECT_FALSE(Get%(upper_resource_name)sServiceId( |
| 4936 client_%(resource_name)s_id_, NULL)); |
| 4937 decoder_->set_unsafe_es3_apis_enabled(false); |
| 4938 EXPECT_EQ(error::kUnknownCommand, |
| 4939 ExecuteImmediateCmd(cmd, sizeof(client_%(resource_name)s_id_))); |
| 4940 } |
| 4941 """ |
| 4942 else: |
| 4943 valid_test += """ |
| 4751 EXPECT_TRUE( | 4944 EXPECT_TRUE( |
| 4752 Get%(upper_resource_name)s(client_%(resource_name)s_id_) == NULL); | 4945 Get%(upper_resource_name)s(client_%(resource_name)s_id_) == NULL); |
| 4753 } | 4946 } |
| 4754 """ | 4947 """ |
| 4755 self.WriteValidUnitTest(func, file, valid_test, { | 4948 self.WriteValidUnitTest(func, file, valid_test, { |
| 4756 'resource_name': func.GetInfo('resource_type').lower(), | 4949 'resource_name': func.GetInfo('resource_type').lower(), |
| 4757 'upper_resource_name': func.GetInfo('resource_type'), | 4950 'upper_resource_name': func.GetInfo('resource_type'), |
| 4758 }, *extras) | 4951 }, *extras) |
| 4759 invalid_test = """ | 4952 invalid_test = """ |
| 4760 TEST_P(%(test_name)s, %(name)sInvalidArgs) { | 4953 TEST_P(%(test_name)s, %(name)sInvalidArgs) { |
| 4761 cmds::%(name)s& cmd = *GetImmediateAs<cmds::%(name)s>(); | 4954 cmds::%(name)s& cmd = *GetImmediateAs<cmds::%(name)s>(); |
| 4762 SpecializedSetup<cmds::%(name)s, 0>(false); | 4955 SpecializedSetup<cmds::%(name)s, 0>(false); |
| 4763 GLuint temp = kInvalidClientId; | 4956 GLuint temp = kInvalidClientId; |
| 4764 cmd.Init(1, &temp); | 4957 cmd.Init(1, &temp);""" |
| 4958 if func.IsUnsafe(): |
| 4959 invalid_test += """ |
| 4960 decoder_->set_unsafe_es3_apis_enabled(true); |
| 4961 EXPECT_EQ(error::kNoError, |
| 4962 ExecuteImmediateCmd(cmd, sizeof(temp))); |
| 4963 decoder_->set_unsafe_es3_apis_enabled(false); |
| 4964 EXPECT_EQ(error::kUnknownCommand, |
| 4965 ExecuteImmediateCmd(cmd, sizeof(temp))); |
| 4966 } |
| 4967 """ |
| 4968 else: |
| 4969 invalid_test += """ |
| 4765 EXPECT_EQ(error::kNoError, | 4970 EXPECT_EQ(error::kNoError, |
| 4766 ExecuteImmediateCmd(cmd, sizeof(temp))); | 4971 ExecuteImmediateCmd(cmd, sizeof(temp))); |
| 4767 } | 4972 } |
| 4768 """ | 4973 """ |
| 4769 self.WriteValidUnitTest(func, file, invalid_test, *extras) | 4974 self.WriteValidUnitTest(func, file, invalid_test, *extras) |
| 4770 | 4975 |
| 4771 def WriteHandlerImplementation (self, func, file): | 4976 def WriteHandlerImplementation (self, func, file): |
| 4772 """Overrriden from TypeHandler.""" | 4977 """Overrriden from TypeHandler.""" |
| 4773 file.Write(" %sHelper(n, %s);\n" % | 4978 file.Write(" %sHelper(n, %s);\n" % |
| 4774 (func.name, func.GetLastOriginalArg().name)) | 4979 (func.name, func.GetLastOriginalArg().name)) |
| 4775 | 4980 |
| 4776 def WriteImmediateHandlerImplementation (self, func, file): | 4981 def WriteImmediateHandlerImplementation (self, func, file): |
| 4777 """Overrriden from TypeHandler.""" | 4982 """Overrriden from TypeHandler.""" |
| 4778 file.Write(" %sHelper(n, %s);\n" % | 4983 if func.IsUnsafe(): |
| 4779 (func.original_name, func.GetLastOriginalArg().name)) | 4984 file.Write(""" for (GLsizei ii = 0; ii < n; ++ii) { |
| 4985 GLuint service_id = 0; |
| 4986 if (group_->Get%(resource_type)sServiceId( |
| 4987 %(last_arg_name)s[ii], &service_id)) { |
| 4988 glDelete%(resource_type)ss(1, &service_id); |
| 4989 group_->Remove%(resource_type)sId(%(last_arg_name)s[ii]); |
| 4990 } |
| 4991 } |
| 4992 """ % { 'resource_type': func.GetInfo('resource_type'), |
| 4993 'last_arg_name': func.GetLastOriginalArg().name }) |
| 4994 else: |
| 4995 file.Write(" %sHelper(n, %s);\n" % |
| 4996 (func.original_name, func.GetLastOriginalArg().name)) |
| 4780 | 4997 |
| 4781 def WriteGLES2Implementation(self, func, file): | 4998 def WriteGLES2Implementation(self, func, file): |
| 4782 """Overrriden from TypeHandler.""" | 4999 """Overrriden from TypeHandler.""" |
| 4783 impl_decl = func.GetInfo('impl_decl') | 5000 impl_decl = func.GetInfo('impl_decl') |
| 4784 if impl_decl == None or impl_decl == True: | 5001 if impl_decl == None or impl_decl == True: |
| 4785 args = { | 5002 args = { |
| 4786 'return_type': func.return_type, | 5003 'return_type': func.return_type, |
| 4787 'name': func.original_name, | 5004 'name': func.original_name, |
| 4788 'typed_args': func.MakeTypedOriginalArgString(""), | 5005 'typed_args': func.MakeTypedOriginalArgString(""), |
| 4789 'args': func.MakeOriginalArgString(""), | 5006 'args': func.MakeOriginalArgString(""), |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5223 'data_type': self.GetArrayType(func), | 5440 'data_type': self.GetArrayType(func), |
| 5224 'data_count': self.GetArrayCount(func), | 5441 'data_count': self.GetArrayCount(func), |
| 5225 'data_value': func.GetInfo('data_value') or '0', | 5442 'data_value': func.GetInfo('data_value') or '0', |
| 5226 'gl_args': ", ".join(gl_arg_strings), | 5443 'gl_args': ", ".join(gl_arg_strings), |
| 5227 'gl_any_args': ", ".join(gl_any_strings), | 5444 'gl_any_args': ", ".join(gl_any_strings), |
| 5228 } | 5445 } |
| 5229 self.WriteValidUnitTest(func, file, valid_test, extra, *extras) | 5446 self.WriteValidUnitTest(func, file, valid_test, extra, *extras) |
| 5230 | 5447 |
| 5231 invalid_test = """ | 5448 invalid_test = """ |
| 5232 TEST_P(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) { | 5449 TEST_P(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) { |
| 5233 cmds::%(name)s& cmd = *GetImmediateAs<cmds::%(name)s>(); | 5450 cmds::%(name)s& cmd = *GetImmediateAs<cmds::%(name)s>();""" |
| 5451 if func.IsUnsafe(): |
| 5452 invalid_test += """ |
| 5453 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_any_args)s, _)).Times(1); |
| 5454 """ |
| 5455 else: |
| 5456 invalid_test += """ |
| 5234 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_any_args)s, _)).Times(0); | 5457 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_any_args)s, _)).Times(0); |
| 5458 """ |
| 5459 invalid_test += """ |
| 5235 SpecializedSetup<cmds::%(name)s, 0>(false); | 5460 SpecializedSetup<cmds::%(name)s, 0>(false); |
| 5236 %(data_type)s temp[%(data_count)s] = { %(data_value)s, }; | 5461 %(data_type)s temp[%(data_count)s] = { %(data_value)s, }; |
| 5237 cmd.Init(%(all_but_last_args)s, &temp[0]); | 5462 cmd.Init(%(all_but_last_args)s, &temp[0]);""" |
| 5463 if func.IsUnsafe(): |
| 5464 invalid_test += """ |
| 5465 decoder_->set_unsafe_es3_apis_enabled(true); |
| 5238 EXPECT_EQ(error::%(parse_result)s, | 5466 EXPECT_EQ(error::%(parse_result)s, |
| 5239 ExecuteImmediateCmd(cmd, sizeof(temp)));%(gl_error_test)s | 5467 ExecuteImmediateCmd(cmd, sizeof(temp))); |
| 5468 decoder_->set_unsafe_es3_apis_enabled(false); |
| 5469 } |
| 5470 """ |
| 5471 else: |
| 5472 invalid_test += """ |
| 5473 EXPECT_EQ(error::%(parse_result)s, |
| 5474 ExecuteImmediateCmd(cmd, sizeof(temp))); |
| 5475 %(gl_error_test)s |
| 5240 } | 5476 } |
| 5241 """ | 5477 """ |
| 5242 self.WriteInvalidUnitTest(func, file, invalid_test, extra, *extras) | 5478 self.WriteInvalidUnitTest(func, file, invalid_test, extra, *extras) |
| 5243 | 5479 |
| 5244 def WriteGetDataSizeCode(self, func, file): | 5480 def WriteGetDataSizeCode(self, func, file): |
| 5245 """Overrriden from TypeHandler.""" | 5481 """Overrriden from TypeHandler.""" |
| 5246 code = """ uint32_t data_size; | 5482 code = """ uint32_t data_size; |
| 5247 if (!ComputeDataSize(1, sizeof(%s), %d, &data_size)) { | 5483 if (!ComputeDataSize(1, sizeof(%s), %d, &data_size)) { |
| 5248 return error::kOutOfBounds; | 5484 return error::kOutOfBounds; |
| 5249 } | 5485 } |
| (...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6019 if func.GetInfo('result') == None: | 6255 if func.GetInfo('result') == None: |
| 6020 func.AddInfo('result', ['uint32_t']) | 6256 func.AddInfo('result', ['uint32_t']) |
| 6021 | 6257 |
| 6022 def WriteServiceUnitTest(self, func, file, *extras): | 6258 def WriteServiceUnitTest(self, func, file, *extras): |
| 6023 """Overrriden from TypeHandler.""" | 6259 """Overrriden from TypeHandler.""" |
| 6024 valid_test = """ | 6260 valid_test = """ |
| 6025 TEST_P(%(test_name)s, %(name)sValidArgs) { | 6261 TEST_P(%(test_name)s, %(name)sValidArgs) { |
| 6026 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)); | 6262 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)); |
| 6027 SpecializedSetup<cmds::%(name)s, 0>(true); | 6263 SpecializedSetup<cmds::%(name)s, 0>(true); |
| 6028 cmds::%(name)s cmd; | 6264 cmds::%(name)s cmd; |
| 6029 cmd.Init(%(args)s%(comma)sshared_memory_id_, shared_memory_offset_); | 6265 cmd.Init(%(args)s%(comma)sshared_memory_id_, shared_memory_offset_);""" |
| 6266 if func.IsUnsafe(): |
| 6267 valid_test += """ |
| 6268 decoder_->set_unsafe_es3_apis_enabled(true);""" |
| 6269 valid_test += """ |
| 6030 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 6270 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 6031 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 6271 EXPECT_EQ(GL_NO_ERROR, GetGLError());""" |
| 6272 if func.IsUnsafe(): |
| 6273 valid_test += """ |
| 6274 decoder_->set_unsafe_es3_apis_enabled(false); |
| 6275 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd));""" |
| 6276 valid_test += """ |
| 6032 } | 6277 } |
| 6033 """ | 6278 """ |
| 6034 comma = "" | 6279 comma = "" |
| 6035 if len(func.GetOriginalArgs()): | 6280 if len(func.GetOriginalArgs()): |
| 6036 comma =", " | 6281 comma =", " |
| 6037 self.WriteValidUnitTest(func, file, valid_test, { | 6282 self.WriteValidUnitTest(func, file, valid_test, { |
| 6038 'comma': comma, | 6283 'comma': comma, |
| 6039 }, *extras) | 6284 }, *extras) |
| 6040 | 6285 |
| 6041 invalid_test = """ | 6286 invalid_test = """ |
| 6042 TEST_P(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) { | 6287 TEST_P(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) { |
| 6043 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)).Times(0); | 6288 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)).Times(0); |
| 6044 SpecializedSetup<cmds::%(name)s, 0>(false); | 6289 SpecializedSetup<cmds::%(name)s, 0>(false); |
| 6045 cmds::%(name)s cmd; | 6290 cmds::%(name)s cmd; |
| 6046 cmd.Init(%(args)s%(comma)sshared_memory_id_, shared_memory_offset_); | 6291 cmd.Init(%(args)s%(comma)sshared_memory_id_, shared_memory_offset_); |
| 6047 EXPECT_EQ(error::%(parse_result)s, ExecuteCmd(cmd));%(gl_error_test)s | 6292 EXPECT_EQ(error::%(parse_result)s, ExecuteCmd(cmd));%(gl_error_test)s |
| 6048 } | 6293 } |
| 6049 """ | 6294 """ |
| 6050 self.WriteInvalidUnitTest(func, file, invalid_test, { | 6295 self.WriteInvalidUnitTest(func, file, invalid_test, { |
| 6051 'comma': comma, | 6296 'comma': comma, |
| 6052 }, *extras) | 6297 }, *extras) |
| 6053 | 6298 |
| 6054 invalid_test = """ | 6299 invalid_test = """ |
| 6055 TEST_P(%(test_name)s, %(name)sInvalidArgsBadSharedMemoryId) { | 6300 TEST_P(%(test_name)s, %(name)sInvalidArgsBadSharedMemoryId) { |
| 6056 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)).Times(0); | 6301 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)).Times(0); |
| 6057 SpecializedSetup<cmds::%(name)s, 0>(false); | 6302 SpecializedSetup<cmds::%(name)s, 0>(false);""" |
| 6303 if func.IsUnsafe(): |
| 6304 invalid_test += """ |
| 6305 decoder_->set_unsafe_es3_apis_enabled(true);""" |
| 6306 invalid_test += """ |
| 6058 cmds::%(name)s cmd; | 6307 cmds::%(name)s cmd; |
| 6059 cmd.Init(%(args)s%(comma)skInvalidSharedMemoryId, shared_memory_offset_); | 6308 cmd.Init(%(args)s%(comma)skInvalidSharedMemoryId, shared_memory_offset_); |
| 6060 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); | 6309 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); |
| 6061 cmd.Init(%(args)s%(comma)sshared_memory_id_, kInvalidSharedMemoryOffset); | 6310 cmd.Init(%(args)s%(comma)sshared_memory_id_, kInvalidSharedMemoryOffset); |
| 6062 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); | 6311 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));""" |
| 6312 if func.IsUnsafe(): |
| 6313 invalid_test += """ |
| 6314 decoder_->set_unsafe_es3_apis_enabled(true);""" |
| 6315 invalid_test += """ |
| 6063 } | 6316 } |
| 6064 """ | 6317 """ |
| 6065 self.WriteValidUnitTest(func, file, invalid_test, { | 6318 self.WriteValidUnitTest(func, file, invalid_test, { |
| 6066 'comma': comma, | 6319 'comma': comma, |
| 6067 }, *extras) | 6320 }, *extras) |
| 6068 | 6321 |
| 6069 def WriteServiceImplementation(self, func, file): | 6322 def WriteServiceImplementation(self, func, file): |
| 6070 """Overrriden from TypeHandler.""" | 6323 """Overrriden from TypeHandler.""" |
| 6071 self.WriteServiceHandlerFunctionHeader(func, file) | 6324 self.WriteServiceHandlerFunctionHeader(func, file) |
| 6072 args = func.GetOriginalArgs() | 6325 args = func.GetOriginalArgs() |
| (...skipping 984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7057 self.type_handler.InitFunction(self) | 7310 self.type_handler.InitFunction(self) |
| 7058 | 7311 |
| 7059 def IsImmediate(self): | 7312 def IsImmediate(self): |
| 7060 """Returns whether the function is immediate data function or not.""" | 7313 """Returns whether the function is immediate data function or not.""" |
| 7061 return False | 7314 return False |
| 7062 | 7315 |
| 7063 def IsUnsafe(self): | 7316 def IsUnsafe(self): |
| 7064 """Returns whether the function has service side validation or not.""" | 7317 """Returns whether the function has service side validation or not.""" |
| 7065 return self.GetInfo('unsafe', False) | 7318 return self.GetInfo('unsafe', False) |
| 7066 | 7319 |
| 7320 def MatchAll(self): |
| 7321 """ Returns whether an EXPECT_GL arg matches any input value.""" |
| 7322 return self.GetInfo('match_all', False) |
| 7323 |
| 7067 def GetInfo(self, name, default = None): | 7324 def GetInfo(self, name, default = None): |
| 7068 """Returns a value from the function info for this function.""" | 7325 """Returns a value from the function info for this function.""" |
| 7069 if name in self.info: | 7326 if name in self.info: |
| 7070 return self.info[name] | 7327 return self.info[name] |
| 7071 return default | 7328 return default |
| 7072 | 7329 |
| 7073 def GetValidArg(self, arg): | 7330 def GetValidArg(self, arg): |
| 7074 """Gets a valid argument value for the parameter arg from the function info | 7331 """Gets a valid argument value for the parameter arg from the function info |
| 7075 if one exists.""" | 7332 if one exists.""" |
| 7076 try: | 7333 try: |
| (...skipping 1839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8916 Format(gen.generated_cpp_filenames) | 9173 Format(gen.generated_cpp_filenames) |
| 8917 | 9174 |
| 8918 if gen.errors > 0: | 9175 if gen.errors > 0: |
| 8919 print "%d errors" % gen.errors | 9176 print "%d errors" % gen.errors |
| 8920 return 1 | 9177 return 1 |
| 8921 return 0 | 9178 return 0 |
| 8922 | 9179 |
| 8923 | 9180 |
| 8924 if __name__ == '__main__': | 9181 if __name__ == '__main__': |
| 8925 sys.exit(main(sys.argv[1:])) | 9182 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |