| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # | 2 # |
| 3 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """code generator for GL command buffers.""" | 7 """code generator for GL command buffers.""" |
| 8 | 8 |
| 9 import os | 9 import os |
| 10 import os.path | 10 import os.path |
| (...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 832 # and immediate version of acommand. | 832 # and immediate version of acommand. |
| 833 # immediate: Whether or not to generate an immediate command for the GL | 833 # immediate: Whether or not to generate an immediate command for the GL |
| 834 # function. The default is if there is exactly 1 pointer argument | 834 # function. The default is if there is exactly 1 pointer argument |
| 835 # in the GL function an immediate command is generated. | 835 # in the GL function an immediate command is generated. |
| 836 # impl_func: Whether or not to generate the GLES2Implementation part of this | 836 # impl_func: Whether or not to generate the GLES2Implementation part of this |
| 837 # command. | 837 # command. |
| 838 # needs_size: If true a data_size field is added to the command. | 838 # needs_size: If true a data_size field is added to the command. |
| 839 # data_type: The type of data the command uses. For PUTn or PUT types. | 839 # data_type: The type of data the command uses. For PUTn or PUT types. |
| 840 # count: The number of units per element. For PUTn or PUT types. | 840 # count: The number of units per element. For PUTn or PUT types. |
| 841 # unit_test: If False no unit test will be generated. | 841 # unit_test: If False no unit test will be generated. |
| 842 # expectation: If False the unit test will have no expected calls. | |
| 843 | 842 |
| 844 _FUNCTION_INFO = { | 843 _FUNCTION_INFO = { |
| 845 'ActiveTexture': {'decoder_func': 'DoActiveTexture', 'expection': False}, | 844 'ActiveTexture': {'decoder_func': 'DoActiveTexture'}, |
| 846 'BindAttribLocation': {'type': 'GLchar'}, | 845 'BindAttribLocation': {'type': 'GLchar'}, |
| 847 'BindBuffer': {'decoder_func': 'DoBindBuffer'}, | 846 'BindBuffer': {'decoder_func': 'DoBindBuffer'}, |
| 848 'BindFramebuffer': {'decoder_func': 'glBindFramebufferEXT'}, | 847 'BindFramebuffer': {'decoder_func': 'glBindFramebufferEXT'}, |
| 849 'BindRenderbuffer': {'decoder_func': 'glBindRenderbufferEXT'}, | 848 'BindRenderbuffer': {'decoder_func': 'glBindRenderbufferEXT'}, |
| 850 'BindTexture': {'decoder_func': 'DoBindTexture'}, | 849 'BindTexture': {'decoder_func': 'DoBindTexture'}, |
| 851 'BufferData': {'type': 'Manual', 'immediate': True}, | 850 'BufferData': {'type': 'Manual', 'immediate': True}, |
| 852 'BufferSubData': {'type': 'Data'}, | 851 'BufferSubData': {'type': 'Data'}, |
| 853 'CheckFramebufferStatus': {'decoder_func': 'glCheckFramebufferStatusEXT'}, | 852 'CheckFramebufferStatus': {'decoder_func': 'glCheckFramebufferStatusEXT'}, |
| 854 'ClearDepthf': {'decoder_func': 'glClearDepth'}, | 853 'ClearDepthf': {'decoder_func': 'glClearDepth'}, |
| 855 'CompileShader': {'decoder_func': 'DoCompileShader', 'unit_test': False}, | 854 'CompileShader': {'decoder_func': 'DoCompileShader', 'unit_test': False}, |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 918 'immediate': False, | 917 'immediate': False, |
| 919 'cmd_args': 'GLidProgram program, void* result, uint32 result_size', | 918 'cmd_args': 'GLidProgram program, void* result, uint32 result_size', |
| 920 'result': ['SizedResult<GLuint>'], | 919 'result': ['SizedResult<GLuint>'], |
| 921 }, | 920 }, |
| 922 'GetAttribLocation': { | 921 'GetAttribLocation': { |
| 923 'type': 'HandWritten', | 922 'type': 'HandWritten', |
| 924 'immediate': True, | 923 'immediate': True, |
| 925 'needs_size': True, | 924 'needs_size': True, |
| 926 'cmd_args': | 925 'cmd_args': |
| 927 'GLidProgram program, const char* name, NonImmediate GLint* location', | 926 'GLidProgram program, const char* name, NonImmediate GLint* location', |
| 928 'result': ['GLint'], | |
| 929 }, | 927 }, |
| 930 'GetBooleanv': {'type': 'GETn'}, | 928 'GetBooleanv': {'type': 'GETn'}, |
| 931 'GetBufferParameteriv': {'type': 'GETn'}, | 929 'GetBufferParameteriv': {'type': 'GETn'}, |
| 932 'GetError': { | 930 'GetError': {'type': 'Is', 'decoder_func': 'GetGLError'}, |
| 933 'type': 'Is', | |
| 934 'decoder_func': | |
| 935 'GetGLError', | |
| 936 'impl_func': False, | |
| 937 'result': ['GLenum'], | |
| 938 }, | |
| 939 'GetFloatv': {'type': 'GETn'}, | 931 'GetFloatv': {'type': 'GETn'}, |
| 940 'GetFramebufferAttachmentParameteriv': { | 932 'GetFramebufferAttachmentParameteriv': { |
| 941 'type': 'GETn', | 933 'type': 'GETn', |
| 942 'decoder_func': 'glGetFramebufferAttachmentParameterivEXT', | 934 'decoder_func': 'glGetFramebufferAttachmentParameterivEXT', |
| 943 }, | 935 }, |
| 944 'GetIntegerv': {'type': 'GETn'}, | 936 'GetIntegerv': {'type': 'GETn'}, |
| 945 'GetProgramiv': {'type': 'GETn'}, | 937 'GetProgramiv': {'type': 'GETn'}, |
| 946 'GetProgramInfoLog': { | 938 'GetProgramInfoLog': {'type': 'STRn'}, |
| 947 'type': 'STRn', | |
| 948 'get_len_func': 'glGetProgramiv', | |
| 949 'get_len_enum': 'GL_INFO_LOG_LENGTH', | |
| 950 }, | |
| 951 'GetRenderbufferParameteriv': { | 939 'GetRenderbufferParameteriv': { |
| 952 'type': 'GETn', | 940 'type': 'GETn', |
| 953 'decoder_func': 'glGetRenderbufferParameterivEXT', | 941 'decoder_func': 'glGetRenderbufferParameterivEXT', |
| 954 }, | 942 }, |
| 955 'GetShaderiv': {'type': 'GETn', 'decoder_func': 'DoGetShaderiv'}, | 943 'GetShaderiv': {'type': 'GETn'}, |
| 956 'GetShaderInfoLog': { | 944 'GetShaderInfoLog': {'type': 'STRn'}, |
| 957 'type': 'STRn', | |
| 958 'get_len_func': 'glGetShaderiv', | |
| 959 'get_len_enum': 'GL_INFO_LOG_LENGTH', | |
| 960 }, | |
| 961 'GetShaderPrecisionFormat': { | 945 'GetShaderPrecisionFormat': { |
| 962 'type': 'Custom', | 946 'type': 'Custom', |
| 963 'immediate': False, | 947 'immediate': False, |
| 964 'cmd_args': | 948 'cmd_args': |
| 965 'GLenumShaderType shadertype, GLenumShaderPrecision precisiontype, ' | 949 'GLenumShaderType shadertype, GLenumShaderPrecision precisiontype, ' |
| 966 'void* result', | 950 'void* result', |
| 967 'result': [ | 951 'result': [ |
| 968 'int32 success', | 952 'int32 success', |
| 969 'int32 min_range', | 953 'int32 min_range', |
| 970 'int32 max_range', | 954 'int32 max_range', |
| 971 'int32 precision', | 955 'int32 precision', |
| 972 ], | 956 ], |
| 973 }, | 957 }, |
| 974 'GetShaderSource': { | 958 'GetShaderSource': {'type': 'STRn', 'decoder_func': 'DoGetShaderSource'}, |
| 975 'type': 'STRn', | |
| 976 'decoder_func': 'DoGetShaderSource', | |
| 977 'get_len_func': 'DoGetShaderiv', | |
| 978 'get_len_enum': 'GL_SHADER_SOURCE_LENGTH', | |
| 979 'unit_test': False, | |
| 980 }, | |
| 981 'GetString': { | |
| 982 'type': 'Custom', | |
| 983 'cmd_args': 'GLenumStringType name, uint32 bucket_id', | |
| 984 }, | |
| 985 'GetTexParameterfv': {'type': 'GETn'}, | 959 'GetTexParameterfv': {'type': 'GETn'}, |
| 986 'GetTexParameteriv': {'type': 'GETn'}, | 960 'GetTexParameteriv': {'type': 'GETn'}, |
| 987 'GetUniformfv': { | 961 'GetUniformfv': { |
| 988 'type': 'Custom', | 962 'type': 'Custom', |
| 989 'immediate': False, | 963 'immediate': False, |
| 990 'result': ['SizedResult<GLfloat>'], | 964 'result': ['SizedResult<GLfloat>'], |
| 991 }, | 965 }, |
| 992 'GetUniformiv': { | 966 'GetUniformiv': { |
| 993 'type': 'Custom', | 967 'type': 'Custom', |
| 994 'immediate': False, | 968 'immediate': False, |
| 995 'result': ['SizedResult<GLint>'], | 969 'result': ['SizedResult<GLint>'], |
| 996 }, | 970 }, |
| 997 'GetUniformLocation': { | 971 'GetUniformLocation': { |
| 998 'type': 'HandWritten', | 972 'type': 'HandWritten', |
| 999 'immediate': True, | 973 'immediate': True, |
| 1000 'needs_size': True, | 974 'needs_size': True, |
| 1001 'cmd_args': | 975 'cmd_args': |
| 1002 'GLidProgram program, const char* name, NonImmediate GLint* location', | 976 'GLidProgram program, const char* name, NonImmediate GLint* location', |
| 1003 'result': ['GLint'], | |
| 1004 }, | 977 }, |
| 1005 'GetVertexAttribfv': {'type': 'GETn'}, | 978 'GetVertexAttribfv': {'type': 'GETn'}, |
| 1006 'GetVertexAttribiv': {'type': 'GETn'}, | 979 'GetVertexAttribiv': {'type': 'GETn'}, |
| 1007 'GetVertexAttribPointerv': { | 980 'GetVertexAttribPointerv': { |
| 1008 'type': 'Custom', | 981 'type': 'Custom', |
| 1009 'immediate': False, | 982 'immediate': False, |
| 1010 'result': ['SizedResult<GLuint>'], | 983 'result': ['SizedResult<GLuint>'], |
| 1011 }, | 984 }, |
| 1012 'IsBuffer': {'type': 'Is'}, | 985 'IsBuffer': {'type': 'Is'}, |
| 1013 'IsEnabled': {'type': 'Is'}, | 986 'IsEnabled': {'type': 'Is'}, |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1192 self.Write("#ifndef %s\n" % self.guard) | 1165 self.Write("#ifndef %s\n" % self.guard) |
| 1193 self.Write("#define %s\n\n" % self.guard) | 1166 self.Write("#define %s\n\n" % self.guard) |
| 1194 | 1167 |
| 1195 def Close(self): | 1168 def Close(self): |
| 1196 self.Write("#endif // %s\n\n" % self.guard) | 1169 self.Write("#endif // %s\n\n" % self.guard) |
| 1197 CWriter.Close(self) | 1170 CWriter.Close(self) |
| 1198 | 1171 |
| 1199 class TypeHandler(object): | 1172 class TypeHandler(object): |
| 1200 """This class emits code for a particular type of function.""" | 1173 """This class emits code for a particular type of function.""" |
| 1201 | 1174 |
| 1202 _remove_expected_call_re = re.compile(r' EXPECT_CALL.*?;\n', re.S) | |
| 1203 | |
| 1204 def __init__(self): | 1175 def __init__(self): |
| 1205 pass | 1176 pass |
| 1206 | 1177 |
| 1207 def InitFunction(self, func): | 1178 def InitFunction(self, func): |
| 1208 """Add or adjust anything type specific for this function.""" | 1179 """Add or adjust anything type specific for this function.""" |
| 1209 if func.GetInfo('needs_size'): | 1180 if func.GetInfo('needs_size'): |
| 1210 func.AddCmdArg(Argument('data_size', 'uint32')) | 1181 func.AddCmdArg(Argument('data_size', 'uint32')) |
| 1211 | 1182 |
| 1212 def AddImmediateFunction(self, generator, func): | 1183 def AddImmediateFunction(self, generator, func): |
| 1213 """Adds an immediate version of a function.""" | 1184 """Adds an immediate version of a function.""" |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1385 self.WriteGetDataSizeCode(func, file) | 1356 self.WriteGetDataSizeCode(func, file) |
| 1386 last_arg.WriteGetCode(file) | 1357 last_arg.WriteGetCode(file) |
| 1387 func.WriteHandlerValidation(file) | 1358 func.WriteHandlerValidation(file) |
| 1388 func.WriteHandlerImplementation(file) | 1359 func.WriteHandlerImplementation(file) |
| 1389 file.Write(" return error::kNoError;\n") | 1360 file.Write(" return error::kNoError;\n") |
| 1390 file.Write("}\n") | 1361 file.Write("}\n") |
| 1391 file.Write("\n") | 1362 file.Write("\n") |
| 1392 | 1363 |
| 1393 def WriteValidUnitTest(self, func, file, test, extra = {}): | 1364 def WriteValidUnitTest(self, func, file, test, extra = {}): |
| 1394 """Writes a valid unit test.""" | 1365 """Writes a valid unit test.""" |
| 1395 if func.GetInfo('expection') == False: | |
| 1396 test = self._remove_expected_call_re.sub('', test) | |
| 1397 name = func.name | 1366 name = func.name |
| 1398 arg_strings = [] | 1367 arg_strings = [] |
| 1399 count = 0 | 1368 count = 0 |
| 1400 for arg in func.GetOriginalArgs(): | 1369 for arg in func.GetOriginalArgs(): |
| 1401 arg_strings.append(arg.GetValidArg(count, 0)) | 1370 arg_strings.append(arg.GetValidArg(count, 0)) |
| 1402 count += 1 | 1371 count += 1 |
| 1403 gl_arg_strings = [] | 1372 gl_arg_strings = [] |
| 1404 count = 0 | 1373 count = 0 |
| 1405 for arg in func.GetOriginalArgs(): | 1374 for arg in func.GetOriginalArgs(): |
| 1406 gl_arg_strings.append(arg.GetValidGLArg(count, 0)) | 1375 gl_arg_strings.append(arg.GetValidGLArg(count, 0)) |
| 1407 count += 1 | 1376 count += 1 |
| 1408 gl_func_name = func.GetGLTestFunctionName() | 1377 gl_func_name = func.GetGLTestFunctionName() |
| 1409 vars = { | 1378 vars = { |
| 1410 'test_name': 'GLES2DecoderTest%d' % file.file_num, | 1379 'test_name': 'GLES2DecoderTest%d' % file.file_num, |
| 1411 'name':name, | 1380 'name':name, |
| 1412 'gl_func_name': gl_func_name, | 1381 'gl_func_name': gl_func_name, |
| 1413 'args': ", ".join(arg_strings), | 1382 'args': ", ".join(arg_strings), |
| 1414 'gl_args': ", ".join(gl_arg_strings), | 1383 'gl_args': ", ".join(gl_arg_strings), |
| 1415 } | 1384 } |
| 1416 vars.update(extra) | 1385 vars.update(extra) |
| 1417 file.Write(test % vars) | 1386 file.Write(test % vars) |
| 1418 | 1387 |
| 1419 def WriteInvalidUnitTest(self, func, file, test, extra = {}): | 1388 def WriteInvalidUnitTest(self, func, file, test, extra = {}): |
| 1420 """Writes a invalid unit test.""" | 1389 """Writes a invalid unit test.""" |
| 1421 arg_index = 0 | 1390 arg_index = 0 |
| 1422 for arg in func.GetOriginalArgs(): | 1391 for arg in func.GetOriginalArgs(): |
| 1423 num_invalid_values = arg.GetNumInvalidValues(func) | 1392 num_invalid_values = arg.GetNumInvalidValues() |
| 1424 for value_index in range(0, num_invalid_values): | 1393 for value_index in range(0, num_invalid_values): |
| 1425 arg_strings = [] | 1394 arg_strings = [] |
| 1426 parse_result = "kNoError" | 1395 parse_result = "kNoError" |
| 1427 gl_error = None | 1396 gl_error = None |
| 1428 count = 0 | 1397 count = 0 |
| 1429 for arg in func.GetOriginalArgs(): | 1398 for arg in func.GetOriginalArgs(): |
| 1430 if count == arg_index: | 1399 if count == arg_index: |
| 1431 (arg_string, parse_result, gl_error) = arg.GetInvalidArg( | 1400 (arg_string, parse_result, gl_error) = arg.GetInvalidArg( |
| 1432 count, value_index) | 1401 count, value_index) |
| 1433 else: | 1402 else: |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1485 self.WriteInvalidUnitTest(func, file, invalid_test) | 1454 self.WriteInvalidUnitTest(func, file, invalid_test) |
| 1486 | 1455 |
| 1487 def WriteImmediateServiceUnitTest(self, func, file): | 1456 def WriteImmediateServiceUnitTest(self, func, file): |
| 1488 """Writes the service unit test for an immediate command.""" | 1457 """Writes the service unit test for an immediate command.""" |
| 1489 file.Write("// TODO(gman): %s\n" % func.name) | 1458 file.Write("// TODO(gman): %s\n" % func.name) |
| 1490 | 1459 |
| 1491 def WriteImmediateValidationCode(self, func, file): | 1460 def WriteImmediateValidationCode(self, func, file): |
| 1492 """Writes the validation code for an immediate version of a command.""" | 1461 """Writes the validation code for an immediate version of a command.""" |
| 1493 pass | 1462 pass |
| 1494 | 1463 |
| 1495 def WriteGLES2ImplementationDeclaration(self, func, file): | 1464 def WriteGLES2ImplementationHeader(self, func, file): |
| 1496 """Writes the GLES2 Implemention declaration.""" | 1465 """Writes the GLES2 Implemention declaration.""" |
| 1497 file.Write("%s %s(%s);\n" % | |
| 1498 (func.return_type, func.original_name, | |
| 1499 func.MakeTypedOriginalArgString(""))) | |
| 1500 file.Write("\n") | |
| 1501 | |
| 1502 def WriteGLES2ImplementationHeader(self, func, file): | |
| 1503 """Writes the GLES2 Implemention.""" | |
| 1504 impl_func = func.GetInfo('impl_func') | 1466 impl_func = func.GetInfo('impl_func') |
| 1505 if func.can_auto_generate and (impl_func == None or impl_func == True): | 1467 if func.can_auto_generate and (impl_func == None or impl_func == True): |
| 1506 file.Write("%s %s(%s) {\n" % | 1468 file.Write("%s %s(%s) {\n" % |
| 1507 (func.return_type, func.original_name, | 1469 (func.return_type, func.original_name, |
| 1508 func.MakeTypedOriginalArgString(""))) | 1470 func.MakeTypedOriginalArgString(""))) |
| 1509 for arg in func.GetOriginalArgs(): | |
| 1510 arg.WriteClientSideValidationCode(file) | |
| 1511 file.Write(" helper_->%s(%s);\n" % | 1471 file.Write(" helper_->%s(%s);\n" % |
| 1512 (func.name, func.MakeOriginalArgString(""))) | 1472 (func.name, func.MakeOriginalArgString(""))) |
| 1513 file.Write("}\n") | 1473 file.Write("}\n") |
| 1514 file.Write("\n") | 1474 file.Write("\n") |
| 1515 else: | 1475 else: |
| 1516 self.WriteGLES2ImplementationDeclaration(func, file) | 1476 file.Write("%s %s(%s);\n" % |
| 1477 (func.return_type, func.original_name, |
| 1478 func.MakeTypedOriginalArgString(""))) |
| 1479 file.Write("\n") |
| 1517 | 1480 |
| 1518 def WriteImmediateCmdComputeSize(self, func, file): | 1481 def WriteImmediateCmdComputeSize(self, func, file): |
| 1519 """Writes the size computation code for the immediate version of a cmd.""" | 1482 """Writes the size computation code for the immediate version of a cmd.""" |
| 1520 file.Write(" static uint32 ComputeSize(uint32 size_in_bytes) {\n") | 1483 file.Write(" static uint32 ComputeSize(uint32 size_in_bytes) {\n") |
| 1521 file.Write(" return static_cast<uint32>(\n") | 1484 file.Write(" return static_cast<uint32>(\n") |
| 1522 file.Write(" sizeof(ValueType) + // NOLINT\n") | 1485 file.Write(" sizeof(ValueType) + // NOLINT\n") |
| 1523 file.Write(" RoundSizeToMultipleOfEntries(size_in_bytes));\n") | 1486 file.Write(" RoundSizeToMultipleOfEntries(size_in_bytes));\n") |
| 1524 file.Write(" }\n") | 1487 file.Write(" }\n") |
| 1525 file.Write("\n") | 1488 file.Write("\n") |
| 1526 | 1489 |
| (...skipping 1492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3019 class IsHandler(TypeHandler): | 2982 class IsHandler(TypeHandler): |
| 3020 """Handler for glIs____ type and glGetError functions.""" | 2983 """Handler for glIs____ type and glGetError functions.""" |
| 3021 | 2984 |
| 3022 def __init__(self): | 2985 def __init__(self): |
| 3023 TypeHandler.__init__(self) | 2986 TypeHandler.__init__(self) |
| 3024 | 2987 |
| 3025 def InitFunction(self, func): | 2988 def InitFunction(self, func): |
| 3026 """Overrriden from TypeHandler.""" | 2989 """Overrriden from TypeHandler.""" |
| 3027 func.AddCmdArg(Argument("result_shm_id", 'uint32')) | 2990 func.AddCmdArg(Argument("result_shm_id", 'uint32')) |
| 3028 func.AddCmdArg(Argument("result_shm_offset", 'uint32')) | 2991 func.AddCmdArg(Argument("result_shm_offset", 'uint32')) |
| 3029 if func.GetInfo('result') == None: | |
| 3030 func.AddInfo('result', ['uint32']) | |
| 3031 | 2992 |
| 3032 def WriteServiceUnitTest(self, func, file): | 2993 def WriteServiceUnitTest(self, func, file): |
| 3033 """Overrriden from TypeHandler.""" | 2994 """Overrriden from TypeHandler.""" |
| 3034 valid_test = """ | 2995 valid_test = """ |
| 3035 TEST_F(%(test_name)s, %(name)sValidArgs) { | 2996 TEST_F(%(test_name)s, %(name)sValidArgs) { |
| 3036 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)); | 2997 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)); |
| 3037 SpecializedSetup<%(name)s, 0>(); | 2998 SpecializedSetup<%(name)s, 0>(); |
| 3038 %(name)s cmd; | 2999 %(name)s cmd; |
| 3039 cmd.Init(%(args)s%(comma)sshared_memory_id_, shared_memory_offset_); | 3000 cmd.Init(%(args)s%(comma)sshared_memory_id_, shared_memory_offset_); |
| 3040 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 3001 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3076 " c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));\n") | 3037 " c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));\n") |
| 3077 func.WriteHandlerValidation(file) | 3038 func.WriteHandlerValidation(file) |
| 3078 file.Write(" *result_dst = %s(%s);\n" % | 3039 file.Write(" *result_dst = %s(%s);\n" % |
| 3079 (func.GetGLFunctionName(), func.MakeOriginalArgString(""))) | 3040 (func.GetGLFunctionName(), func.MakeOriginalArgString(""))) |
| 3080 file.Write(" return error::kNoError;\n") | 3041 file.Write(" return error::kNoError;\n") |
| 3081 file.Write("}\n") | 3042 file.Write("}\n") |
| 3082 file.Write("\n") | 3043 file.Write("\n") |
| 3083 | 3044 |
| 3084 def WriteGLES2ImplementationHeader(self, func, file): | 3045 def WriteGLES2ImplementationHeader(self, func, file): |
| 3085 """Overrriden from TypeHandler.""" | 3046 """Overrriden from TypeHandler.""" |
| 3086 impl_func = func.GetInfo('impl_func') | 3047 file.Write("%s %s(%s) {\n" % |
| 3087 if impl_func == None or impl_func == True: | 3048 (func.return_type, func.original_name, |
| 3088 file.Write("%s %s(%s) {\n" % | 3049 func.MakeTypedOriginalArgString(""))) |
| 3089 (func.return_type, func.original_name, | 3050 arg_string = func.MakeOriginalArgString("") |
| 3090 func.MakeTypedOriginalArgString(""))) | 3051 comma = "" |
| 3091 file.Write(" typedef %s::Result Result;\n" % func.original_name) | 3052 if len(arg_string) > 0: |
| 3092 file.Write(" Result* result = GetResultAs<Result*>();\n") | 3053 comma = ", " |
| 3093 file.Write(" *result = 0;\n") | 3054 file.Write(" helper_->%s(%s%sresult_shm_id(), result_shm_offset());\n" % |
| 3094 arg_string = func.MakeOriginalArgString("") | 3055 (func.name, arg_string, comma)) |
| 3095 comma = "" | 3056 file.Write(" WaitForCmd();\n") |
| 3096 if len(arg_string) > 0: | 3057 file.Write(" return GetResultAs<%s>();\n" % |
| 3097 comma = ", " | 3058 func.return_type) |
| 3098 file.Write(" helper_->%s(%s%sresult_shm_id(), result_shm_offset());\n" % | 3059 file.Write("}\n") |
| 3099 (func.name, arg_string, comma)) | 3060 file.Write("\n") |
| 3100 file.Write(" WaitForCmd();\n") | |
| 3101 file.Write(" return *result;\n") | |
| 3102 file.Write("}\n") | |
| 3103 file.Write("\n") | |
| 3104 else: | |
| 3105 self.WriteGLES2ImplementationDeclaration(func, file) | |
| 3106 | 3061 |
| 3107 | 3062 |
| 3108 class STRnHandler(TypeHandler): | 3063 class STRnHandler(TypeHandler): |
| 3109 """Handler for GetProgramInfoLog, GetShaderInfoLog and GetShaderSource.""" | 3064 """Handler for GetProgramInfoLog, GetShaderInfoLog and GetShaderSource.""" |
| 3110 | 3065 |
| 3111 def __init__(self): | 3066 def __init__(self): |
| 3112 TypeHandler.__init__(self) | 3067 TypeHandler.__init__(self) |
| 3113 | 3068 |
| 3114 def InitFunction(self, func): | |
| 3115 """Overrriden from TypeHandler.""" | |
| 3116 # remove all but the first cmd args. | |
| 3117 cmd_args = func.GetCmdArgs() | |
| 3118 func.ClearCmdArgs() | |
| 3119 func.AddCmdArg(cmd_args[0]) | |
| 3120 # add on a bucket id. | |
| 3121 func.AddCmdArg(Argument('bucket_id', 'uint32')) | |
| 3122 | |
| 3123 def WriteGLES2ImplementationHeader(self, func, file): | 3069 def WriteGLES2ImplementationHeader(self, func, file): |
| 3124 """Overrriden from TypeHandler.""" | 3070 """Overrriden from TypeHandler.""" |
| 3125 code = """%(return_type)s %(func_name)s(%(args)s) { | 3071 file.Write("// TODO(gman): Implement this\n") |
| 3126 helper_->SetBucketSize(kResultBucketId, 0); | 3072 TypeHandler.WriteGLES2ImplementationHeader(self, func, file) |
| 3127 helper_->%(func_name)s(%(id_name)s, kResultBucketId); | |
| 3128 std::string str; | |
| 3129 if (GetBucketAsString(kResultBucketId, &str)) { | |
| 3130 GLsizei max_size = | |
| 3131 std::min(static_cast<size_t>(%(bufsize_name)s) - 1, str.size()); | |
| 3132 if (%(length_name)s != NULL) { | |
| 3133 *%(length_name)s = max_size; | |
| 3134 } | |
| 3135 memcpy(%(dest_name)s, str.c_str(), max_size); | |
| 3136 %(dest_name)s[max_size] = '\\0'; | |
| 3137 } | |
| 3138 } | |
| 3139 """ | |
| 3140 args = func.GetOriginalArgs() | |
| 3141 file.Write(code % { | |
| 3142 'return_type': func.return_type, | |
| 3143 'func_name': func.original_name, | |
| 3144 'args': func.MakeTypedOriginalArgString(""), | |
| 3145 'id_name': args[0].name, | |
| 3146 'bufsize_name': args[1].name, | |
| 3147 'length_name': args[2].name, | |
| 3148 'dest_name': args[3].name, | |
| 3149 }) | |
| 3150 | 3073 |
| 3151 def WriteServiceUnitTest(self, func, file): | 3074 def WriteServiceUnitTest(self, func, file): |
| 3152 """Overrriden from TypeHandler.""" | 3075 """Overrriden from TypeHandler.""" |
| 3153 valid_test = """ | 3076 file.Write("// TODO(gman): %s\n\n" % func.name) |
| 3154 TEST_F(%(test_name)s, %(name)sValidArgs) { | |
| 3155 const char* kInfo = "hello"; | |
| 3156 const uint32 kBucketId = 123; | |
| 3157 SpecializedSetup<%(name)s, 0>(); | |
| 3158 %(expect_len_code)s | |
| 3159 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)) | |
| 3160 .WillOnce(DoAll(SetArgumentPointee<2>(strlen(kInfo)), | |
| 3161 SetArrayArgument<3>(kInfo, kInfo + strlen(kInfo) + 1))); | |
| 3162 %(name)s cmd; | |
| 3163 cmd.Init(%(args)s); | |
| 3164 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 3165 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId); | |
| 3166 ASSERT_TRUE(bucket != NULL); | |
| 3167 EXPECT_EQ(strlen(kInfo) + 1, bucket->size()); | |
| 3168 EXPECT_EQ(0, memcmp(bucket->GetData(0, bucket->size()), kInfo, | |
| 3169 bucket->size())); | |
| 3170 } | |
| 3171 """ | |
| 3172 args = func.GetOriginalArgs() | |
| 3173 id_name = args[0].GetValidGLArg(0, 0) | |
| 3174 get_len_func = func.GetInfo('get_len_func') | |
| 3175 get_len_enum = func.GetInfo('get_len_enum') | |
| 3176 sub = { | |
| 3177 'id_name': id_name, | |
| 3178 'get_len_func': get_len_func, | |
| 3179 'get_len_enum': get_len_enum, | |
| 3180 'gl_args': '%s, strlen(kInfo) + 1, _, _' % args[0].GetValidGLArg(0, 0), | |
| 3181 'args': '%s, kBucketId' % args[0].GetValidArg(0, 0), | |
| 3182 'expect_len_code': '', | |
| 3183 } | |
| 3184 if get_len_func[0:2] == 'gl': | |
| 3185 sub['expect_len_code'] = ( | |
| 3186 " EXPECT_CALL(*gl_, %s(%s, %s, _))\n" | |
| 3187 " .WillOnce(SetArgumentPointee<2>(strlen(kInfo)));") % ( | |
| 3188 get_len_func[2:], id_name, get_len_enum) | |
| 3189 self.WriteValidUnitTest(func, file, valid_test, sub) | |
| 3190 | 3077 |
| 3191 invalid_test = """ | 3078 def WriteImmediateServiceUnitTest(self, func, file): |
| 3192 TEST_F(%(test_name)s, %(name)sInvalidArgs) { | 3079 """Overrriden from TypeHandler.""" |
| 3193 const uint32 kBucketId = 123; | 3080 file.Write("// TODO(gman): %s\n\n" % func.name) |
| 3194 EXPECT_CALL(*gl_, %(gl_func_name)s(_, _, _, _)) | |
| 3195 .Times(0); | |
| 3196 %(name)s cmd; | |
| 3197 cmd.Init(kInvalidClientId, kBucketId); | |
| 3198 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 3199 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
| 3200 } | |
| 3201 """ | |
| 3202 self.WriteValidUnitTest(func, file, invalid_test) | |
| 3203 | 3081 |
| 3204 def WriteServiceImplementation(self, func, file): | 3082 def WriteServiceImplementation(self, func, file): |
| 3205 """Overrriden from TypeHandler.""" | 3083 """Overrriden from TypeHandler.""" |
| 3206 file.Write( | 3084 file.Write( |
| 3207 "error::Error GLES2DecoderImpl::Handle%s(\n" % func.name) | 3085 "error::Error GLES2DecoderImpl::Handle%s(\n" % func.name) |
| 3208 file.Write( | 3086 file.Write( |
| 3209 " uint32 immediate_data_size, const gles2::%s& c) {\n" % func.name) | 3087 " uint32 immediate_data_size, const gles2::%s& c) {\n" % func.name) |
| 3210 args = func.GetCmdArgs() | 3088 args = func.GetOriginalArgs() |
| 3211 id_arg = args[0] | 3089 all_but_last_2_args = args[:-2] |
| 3212 bucket_arg = args[1] | 3090 for arg in all_but_last_2_args: |
| 3213 id_arg.WriteGetCode(file) | 3091 arg.WriteGetCode(file) |
| 3214 bucket_arg.WriteGetCode(file) | 3092 self.WriteGetDataSizeCode(func, file) |
| 3215 id_arg.WriteValidationCode(file) | 3093 size_arg = args[-2] |
| 3216 file.Write(" GLint len = 0;\n") | 3094 file.Write(" uint32 size_shm_id = c.%s_shm_id;\n" % size_arg.name) |
| 3217 file.Write(" %s(%s, %s, &len);\n" % ( | 3095 file.Write(" uint32 size_shm_offset = c.%s_shm_offset;\n" % size_arg.name) |
| 3218 func.GetInfo('get_len_func'), id_arg.name, | 3096 file.Write(" GLsizei* length = NULL;\n") |
| 3219 func.GetInfo('get_len_enum'))) | 3097 file.Write(" if (size_shm_id != 0 || size_shm_offset != 0) {\n" |
| 3220 file.Write(" Bucket* bucket = CreateBucket(%s);\n" % bucket_arg.name) | 3098 " length = GetSharedMemoryAs<GLsizei*>(\n" |
| 3221 file.Write(" bucket->SetSize(len + 1);\n"); | 3099 " size_shm_id, size_shm_offset, sizeof(*length));\n" |
| 3100 " if (!length) {\n" |
| 3101 " return error::kOutOfBounds;\n" |
| 3102 " }\n" |
| 3103 " }\n") |
| 3104 dest_arg = args[-1] |
| 3105 bufsize_arg = args[-3] |
| 3222 file.Write( | 3106 file.Write( |
| 3223 " %s(%s, len + 1, &len, bucket->GetDataAs<GLchar*>(0, len + 1));\n" % | 3107 " %s %s = GetSharedMemoryAs<%s>(\n" % |
| 3224 (func.GetGLFunctionName(), id_arg.name)) | 3108 (dest_arg.type, dest_arg.name, dest_arg.type)) |
| 3109 file.Write( |
| 3110 " c.%s_shm_id, c.%s_shm_offset, %s);\n" % |
| 3111 (dest_arg.name, dest_arg.name, bufsize_arg.name)) |
| 3112 for arg in all_but_last_2_args + [dest_arg]: |
| 3113 arg.WriteValidationCode(file) |
| 3114 func.WriteValidationCode(file) |
| 3115 func.WriteHandlerImplementation(file) |
| 3225 file.Write(" return error::kNoError;\n") | 3116 file.Write(" return error::kNoError;\n") |
| 3226 file.Write("}\n") | 3117 file.Write("}\n") |
| 3227 file.Write("\n") | 3118 file.Write("\n") |
| 3228 | 3119 |
| 3229 | 3120 |
| 3230 class FunctionInfo(object): | 3121 class FunctionInfo(object): |
| 3231 """Holds info about a function.""" | 3122 """Holds info about a function.""" |
| 3232 | 3123 |
| 3233 def __init__(self, info, type_handler): | 3124 def __init__(self, info, type_handler): |
| 3234 for key in info: | 3125 for key in info: |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3271 def AddInitArgs(self, args): | 3162 def AddInitArgs(self, args): |
| 3272 """Adds init arguments for this argument to the given list.""" | 3163 """Adds init arguments for this argument to the given list.""" |
| 3273 return args.append(self) | 3164 return args.append(self) |
| 3274 | 3165 |
| 3275 def GetValidArg(self, offset, index): | 3166 def GetValidArg(self, offset, index): |
| 3276 return str(offset + 1) | 3167 return str(offset + 1) |
| 3277 | 3168 |
| 3278 def GetValidGLArg(self, offset, index): | 3169 def GetValidGLArg(self, offset, index): |
| 3279 return str(offset + 1) | 3170 return str(offset + 1) |
| 3280 | 3171 |
| 3281 def GetNumInvalidValues(self, func): | 3172 def GetNumInvalidValues(self): |
| 3282 """returns the number of invalid values to be tested.""" | 3173 """returns the number of invalid values to be tested.""" |
| 3283 return 0 | 3174 return 0 |
| 3284 | 3175 |
| 3285 def GetInvalidArg(self, offset, index): | 3176 def GetInvalidArg(self, offset, index): |
| 3286 """returns an invalid value and expected parse result by index.""" | 3177 """returns an invalid value and expected parse result by index.""" |
| 3287 return ("---ERROR0---", "---ERROR2---", None) | 3178 return ("---ERROR0---", "---ERROR2---", None) |
| 3288 | 3179 |
| 3289 def WriteGetCode(self, file): | 3180 def WriteGetCode(self, file): |
| 3290 """Writes the code to get an argument from a command structure.""" | 3181 """Writes the code to get an argument from a command structure.""" |
| 3291 file.Write(" %s %s = static_cast<%s>(c.%s);\n" % | 3182 file.Write(" %s %s = static_cast<%s>(c.%s);\n" % |
| 3292 (self.type, self.name, self.type, self.name)) | 3183 (self.type, self.name, self.type, self.name)) |
| 3293 | 3184 |
| 3294 def WriteValidationCode(self, file): | 3185 def WriteValidationCode(self, file): |
| 3295 """Writes the validation code for an argument.""" | 3186 """Writes the validation code for an argument.""" |
| 3296 pass | 3187 if self.type == 'GLsizei' or self.type == 'GLsizeiptr': |
| 3297 | 3188 file.Write(" if (%s < 0) {\n" % self.name) |
| 3298 def WriteClientSideValidationCode(self, file): | 3189 file.Write(" SetGLError(GL_INVALID_VALUE);\n") |
| 3299 """Writes the validation code for an argument.""" | 3190 file.Write(" return error::kNoError;\n") |
| 3300 pass | 3191 file.Write(" }\n") |
| 3301 | 3192 |
| 3302 def WriteGetAddress(self, file): | 3193 def WriteGetAddress(self, file): |
| 3303 """Writes the code to get the address this argument refers to.""" | 3194 """Writes the code to get the address this argument refers to.""" |
| 3304 pass | 3195 pass |
| 3305 | 3196 |
| 3306 def GetImmediateVersion(self): | 3197 def GetImmediateVersion(self): |
| 3307 """Gets the immediate version of this argument.""" | 3198 """Gets the immediate version of this argument.""" |
| 3308 return self | 3199 return self |
| 3309 | 3200 |
| 3310 | 3201 |
| 3311 class SizeArgument(Argument): | 3202 class SizeArgument(Argument): |
| 3312 """class for GLsizei and GLsizeiptr.""" | |
| 3313 | 3203 |
| 3314 def __init__(self, name, type): | 3204 def __init__(self, name, type): |
| 3315 Argument.__init__(self, name, type) | 3205 Argument.__init__(self, name, type) |
| 3316 | 3206 |
| 3317 def GetNumInvalidValues(self, func): | 3207 def GetNumInvalidValues(self): |
| 3318 """overridden from Argument.""" | 3208 """overridden from Argument.""" |
| 3319 if func.is_immediate: | |
| 3320 return 0 | |
| 3321 return 1 | 3209 return 1 |
| 3322 | 3210 |
| 3323 def GetInvalidArg(self, offset, index): | 3211 def GetInvalidArg(self, offset, index): |
| 3324 """overridden from Argument.""" | 3212 """returns an invalid value and expected parse result by index.""" |
| 3325 return ("-1", "kNoError", "GL_INVALID_VALUE") | 3213 return ("-1", "kNoError", "GL_INVALID_VALUE") |
| 3326 | 3214 |
| 3327 def WriteValidationCode(self, file): | |
| 3328 """overridden from Argument.""" | |
| 3329 file.Write(" if (%s < 0) {\n" % self.name) | |
| 3330 file.Write(" SetGLError(GL_INVALID_VALUE);\n") | |
| 3331 file.Write(" return error::kNoError;\n") | |
| 3332 file.Write(" }\n") | |
| 3333 | |
| 3334 def WriteClientSideValidationCode(self, file): | |
| 3335 """overridden from Argument.""" | |
| 3336 file.Write(" if (%s < 0) {\n" % self.name) | |
| 3337 file.Write(" SetGLError(GL_INVALID_VALUE);\n") | |
| 3338 file.Write(" return;\n") | |
| 3339 file.Write(" }\n") | |
| 3340 | 3215 |
| 3341 class EnumBaseArgument(Argument): | 3216 class EnumBaseArgument(Argument): |
| 3342 """Base class for EnumArgument, IntArgument and BoolArgument""" | 3217 """Base calss for EnumArgument, IntArgument and BoolArgument""" |
| 3343 | 3218 |
| 3344 def __init__(self, name, gl_type, type, gl_error): | 3219 def __init__(self, name, gl_type, type, gl_error): |
| 3345 Argument.__init__(self, name, gl_type) | 3220 Argument.__init__(self, name, gl_type) |
| 3346 | 3221 |
| 3347 self.local_type = type | 3222 self.local_type = type |
| 3348 self.gl_error = gl_error | 3223 self.gl_error = gl_error |
| 3349 name = type[len(gl_type):] | 3224 name = type[len(gl_type):] |
| 3350 self.enum_info = _ENUM_LISTS[name] | 3225 self.enum_info = _ENUM_LISTS[name] |
| 3351 | 3226 |
| 3352 def WriteValidationCode(self, file): | 3227 def WriteValidationCode(self, file): |
| 3353 file.Write(" if (!Validate%s(%s)) {\n" % (self.local_type, self.name)) | 3228 file.Write(" if (!Validate%s(%s)) {\n" % (self.local_type, self.name)) |
| 3354 file.Write(" SetGLError(%s);\n" % self.gl_error) | 3229 file.Write(" SetGLError(%s);\n" % self.gl_error) |
| 3355 file.Write(" return error::kNoError;\n") | 3230 file.Write(" return error::kNoError;\n") |
| 3356 file.Write(" }\n") | 3231 file.Write(" }\n") |
| 3357 | 3232 |
| 3358 def GetValidArg(self, offset, index): | 3233 def GetValidArg(self, offset, index): |
| 3359 if 'valid' in self.enum_info: | 3234 if 'valid' in self.enum_info: |
| 3360 valid = self.enum_info['valid'] | 3235 valid = self.enum_info['valid'] |
| 3361 num_valid = len(valid) | 3236 num_valid = len(valid) |
| 3362 if index >= num_valid: | 3237 if index >= num_valid: |
| 3363 index = num_valid - 1 | 3238 index = num_valid - 1 |
| 3364 return valid[index] | 3239 return valid[index] |
| 3365 return str(offset + 1) | 3240 return str(offset + 1) |
| 3366 | 3241 |
| 3367 def GetValidGLArg(self, offset, index): | 3242 def GetValidGLArg(self, offset, index): |
| 3368 return self.GetValidArg(offset, index) | 3243 return self.GetValidArg(offset, index) |
| 3369 | 3244 |
| 3370 def GetNumInvalidValues(self, func): | 3245 def GetNumInvalidValues(self): |
| 3371 """returns the number of invalid values to be tested.""" | 3246 """returns the number of invalid values to be tested.""" |
| 3372 if 'invalid' in self.enum_info: | 3247 if 'invalid' in self.enum_info: |
| 3373 invalid = self.enum_info['invalid'] | 3248 invalid = self.enum_info['invalid'] |
| 3374 return len(invalid) | 3249 return len(invalid) |
| 3375 return 0 | 3250 return 0 |
| 3376 | 3251 |
| 3377 def GetInvalidArg(self, offset, index): | 3252 def GetInvalidArg(self, offset, index): |
| 3378 """returns an invalid value by index.""" | 3253 """returns an invalid value by index.""" |
| 3379 if 'invalid' in self.enum_info: | 3254 if 'invalid' in self.enum_info: |
| 3380 invalid = self.enum_info['invalid'] | 3255 invalid = self.enum_info['invalid'] |
| 3381 num_invalid = len(invalid) | 3256 num_invalid = len(invalid) |
| 3382 if index >= num_invalid: | 3257 if index >= num_invalid: |
| 3383 index = num_invalid - 1 | 3258 index = num_invalid - 1 |
| 3384 return (invalid[index], "kNoError", self.gl_error) | 3259 return (invalid[index], "kNoError", "GL_INVALID_ENUM") |
| 3385 return ("---ERROR1---", "kNoError", self.gl_error) | 3260 return ("---ERROR1---", "kNoError", "GL_INVALID_ENUM") |
| 3386 | 3261 |
| 3387 | 3262 |
| 3388 class EnumArgument(EnumBaseArgument): | 3263 class EnumArgument(EnumBaseArgument): |
| 3389 """A class that represents a GLenum argument""" | 3264 """A class that represents a GLenum argument""" |
| 3390 | 3265 |
| 3391 def __init__(self, name, type): | 3266 def __init__(self, name, type): |
| 3392 EnumBaseArgument.__init__(self, name, "GLenum", type, "GL_INVALID_ENUM") | 3267 EnumBaseArgument.__init__(self, name, "GLenum", type, "GL_INVALID_ENUM") |
| 3393 | 3268 |
| 3394 | 3269 |
| 3395 class IntArgument(EnumBaseArgument): | 3270 class IntArgument(EnumBaseArgument): |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3456 return True | 3331 return True |
| 3457 | 3332 |
| 3458 def GetValidArg(self, offset, index): | 3333 def GetValidArg(self, offset, index): |
| 3459 """Overridden from Argument.""" | 3334 """Overridden from Argument.""" |
| 3460 return "shared_memory_id_, shared_memory_offset_" | 3335 return "shared_memory_id_, shared_memory_offset_" |
| 3461 | 3336 |
| 3462 def GetValidGLArg(self, offset, index): | 3337 def GetValidGLArg(self, offset, index): |
| 3463 """Overridden from Argument.""" | 3338 """Overridden from Argument.""" |
| 3464 return "reinterpret_cast<%s>(shared_memory_address_)" % self.type | 3339 return "reinterpret_cast<%s>(shared_memory_address_)" % self.type |
| 3465 | 3340 |
| 3466 def GetNumInvalidValues(self, func): | 3341 def GetNumInvalidValues(self): |
| 3467 """Overridden from Argument.""" | 3342 """Overridden from Argument.""" |
| 3468 return 2 | 3343 return 2 |
| 3469 | 3344 |
| 3470 def GetInvalidArg(self, offset, index): | 3345 def GetInvalidArg(self, offset, index): |
| 3471 """Overridden from Argument.""" | 3346 """Overridden from Argument.""" |
| 3472 if index == 0: | 3347 if index == 0: |
| 3473 return ("kInvalidSharedMemoryId, 0", "kOutOfBounds", None) | 3348 return ("kInvalidSharedMemoryId, 0", "kOutOfBounds", None) |
| 3474 else: | 3349 else: |
| 3475 return ("shared_memory_id_, kInvalidSharedMemoryOffset", | 3350 return ("shared_memory_id_, kInvalidSharedMemoryOffset", |
| 3476 "kOutOfBounds", None) | 3351 "kOutOfBounds", None) |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3558 self.info = info | 3433 self.info = info |
| 3559 self.type_handler = info.type_handler | 3434 self.type_handler = info.type_handler |
| 3560 self.return_type = return_type | 3435 self.return_type = return_type |
| 3561 self.original_args = original_args | 3436 self.original_args = original_args |
| 3562 self.num_pointer_args = num_pointer_args | 3437 self.num_pointer_args = num_pointer_args |
| 3563 self.can_auto_generate = num_pointer_args == 0 and return_type == "void" | 3438 self.can_auto_generate = num_pointer_args == 0 and return_type == "void" |
| 3564 self.cmd_args = cmd_args | 3439 self.cmd_args = cmd_args |
| 3565 self.init_args = init_args | 3440 self.init_args = init_args |
| 3566 self.args_for_cmds = args_for_cmds | 3441 self.args_for_cmds = args_for_cmds |
| 3567 self.type_handler.InitFunction(self) | 3442 self.type_handler.InitFunction(self) |
| 3568 self.is_immediate = False | |
| 3569 | 3443 |
| 3570 def IsType(self, type_name): | 3444 def IsType(self, type_name): |
| 3571 """Returns true if function is a certain type.""" | 3445 """Returns true if function is a certain type.""" |
| 3572 return self.info.type == type_name | 3446 return self.info.type == type_name |
| 3573 | 3447 |
| 3574 def GetInfo(self, name): | 3448 def GetInfo(self, name): |
| 3575 """Returns a value from the function info for this function.""" | 3449 """Returns a value from the function info for this function.""" |
| 3576 if hasattr(self.info, name): | 3450 if hasattr(self.info, name): |
| 3577 return getattr(self.info, name) | 3451 return getattr(self.info, name) |
| 3578 return None | 3452 return None |
| 3579 | 3453 |
| 3580 def AddInfo(self, name, value): | |
| 3581 """Adds an info.""" | |
| 3582 setattr(self.info, name, value) | |
| 3583 | |
| 3584 def GetGLFunctionName(self): | 3454 def GetGLFunctionName(self): |
| 3585 """Gets the function to call to execute GL for this command.""" | 3455 """Gets the function to call to execute GL for this command.""" |
| 3586 if self.GetInfo('decoder_func'): | 3456 if self.GetInfo('decoder_func'): |
| 3587 return self.GetInfo('decoder_func') | 3457 return self.GetInfo('decoder_func') |
| 3588 return "gl%s" % self.original_name | 3458 return "gl%s" % self.original_name |
| 3589 | 3459 |
| 3590 def GetGLTestFunctionName(self): | 3460 def GetGLTestFunctionName(self): |
| 3591 gl_func_name = self.GetInfo('gl_test_func') | 3461 gl_func_name = self.GetInfo('gl_test_func') |
| 3592 if gl_func_name == None: | 3462 if gl_func_name == None: |
| 3593 gl_func_name = self.GetGLFunctionName() | 3463 gl_func_name = self.GetGLFunctionName() |
| 3594 if gl_func_name.startswith("gl"): | 3464 if gl_func_name.startswith("gl"): |
| 3595 gl_func_name = gl_func_name[2:] | 3465 gl_func_name = gl_func_name[2:] |
| 3596 else: | 3466 else: |
| 3597 gl_func_name = self.original_name | 3467 gl_func_name = self.original_name |
| 3598 return gl_func_name | 3468 return gl_func_name |
| 3599 | 3469 |
| 3600 def AddCmdArg(self, arg): | 3470 def AddCmdArg(self, arg): |
| 3601 """Adds a cmd argument to this function.""" | 3471 """Adds a cmd argument to this function.""" |
| 3602 self.cmd_args.append(arg) | 3472 self.cmd_args.append(arg) |
| 3603 | 3473 |
| 3604 def GetCmdArgs(self): | 3474 def GetCmdArgs(self): |
| 3605 """Gets the command args for this function.""" | 3475 """Gets the command args for this function.""" |
| 3606 return self.cmd_args | 3476 return self.cmd_args |
| 3607 | 3477 |
| 3608 def ClearCmdArgs(self): | |
| 3609 """Clears the command args for this function.""" | |
| 3610 self.cmd_args = [] | |
| 3611 | |
| 3612 def GetInitArgs(self): | 3478 def GetInitArgs(self): |
| 3613 """Gets the init args for this function.""" | 3479 """Gets the init args for this function.""" |
| 3614 return self.init_args | 3480 return self.init_args |
| 3615 | 3481 |
| 3616 def GetOriginalArgs(self): | 3482 def GetOriginalArgs(self): |
| 3617 """Gets the original arguments to this function.""" | 3483 """Gets the original arguments to this function.""" |
| 3618 return self.original_args | 3484 return self.original_args |
| 3619 | 3485 |
| 3620 def GetLastOriginalArg(self): | 3486 def GetLastOriginalArg(self): |
| 3621 """Gets the last original argument to this function.""" | 3487 """Gets the last original argument to this function.""" |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3773 self, | 3639 self, |
| 3774 func.original_name, | 3640 func.original_name, |
| 3775 "%sImmediate" % func.name, | 3641 "%sImmediate" % func.name, |
| 3776 func.info, | 3642 func.info, |
| 3777 func.return_type, | 3643 func.return_type, |
| 3778 new_args, | 3644 new_args, |
| 3779 new_args_for_cmds, | 3645 new_args_for_cmds, |
| 3780 cmd_args, | 3646 cmd_args, |
| 3781 new_init_args, | 3647 new_init_args, |
| 3782 0) | 3648 0) |
| 3783 self.is_immediate = True | |
| 3784 | 3649 |
| 3785 def WriteServiceImplementation(self, file): | 3650 def WriteServiceImplementation(self, file): |
| 3786 """Overridden from Function""" | 3651 """Overridden from Function""" |
| 3787 self.type_handler.WriteImmediateServiceImplementation(self, file) | 3652 self.type_handler.WriteImmediateServiceImplementation(self, file) |
| 3788 | 3653 |
| 3789 def WriteHandlerImplementation(self, file): | 3654 def WriteHandlerImplementation(self, file): |
| 3790 """Overridden from Function""" | 3655 """Overridden from Function""" |
| 3791 self.type_handler.WriteImmediateHandlerImplementation(self, file) | 3656 self.type_handler.WriteImmediateHandlerImplementation(self, file) |
| 3792 | 3657 |
| 3793 def WriteServiceUnitTest(self, file): | 3658 def WriteServiceUnitTest(self, file): |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4196 | 4061 |
| 4197 if options.generate_command_id_tests: | 4062 if options.generate_command_id_tests: |
| 4198 gen.WriteCommandIdTest("common/gles2_cmd_id_test_autogen.h") | 4063 gen.WriteCommandIdTest("common/gles2_cmd_id_test_autogen.h") |
| 4199 | 4064 |
| 4200 if gen.errors > 0: | 4065 if gen.errors > 0: |
| 4201 print "%d errors" % gen.errors | 4066 print "%d errors" % gen.errors |
| 4202 sys.exit(1) | 4067 sys.exit(1) |
| 4203 | 4068 |
| 4204 if __name__ == '__main__': | 4069 if __name__ == '__main__': |
| 4205 main(sys.argv[1:]) | 4070 main(sys.argv[1:]) |
| OLD | NEW |