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