Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(297)

Side by Side Diff: gpu/command_buffer/build_gles2_cmd_buffer.py

Issue 2692573002: Auto-generate null checks for pointer arguemnts in the passthrough cmd decoder. (Closed)
Patch Set: use nullptr instead of NULL Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | gpu/command_buffer/service/gles2_cmd_decoder_passthrough_handlers_autogen.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 4978 matching lines...) Expand 10 before | Expand all | Expand 10 after
4989 f.write(""" error::Error error = Do%(name)s(%(args)s); 4989 f.write(""" error::Error error = Do%(name)s(%(args)s);
4990 if (error != error::kNoError) { 4990 if (error != error::kNoError) {
4991 return error; 4991 return error;
4992 }""" % {'name': func.original_name, 4992 }""" % {'name': func.original_name,
4993 'args': func.MakePassthroughServiceDoerArgString("")}) 4993 'args': func.MakePassthroughServiceDoerArgString("")})
4994 4994
4995 def WritePassthroughServiceImplementation(self, func, f): 4995 def WritePassthroughServiceImplementation(self, func, f):
4996 """Writes the service implementation for a command.""" 4996 """Writes the service implementation for a command."""
4997 self.WritePassthroughServiceFunctionHeader(func, f) 4997 self.WritePassthroughServiceFunctionHeader(func, f)
4998 self.WriteServiceHandlerArgGetCode(func, f) 4998 self.WriteServiceHandlerArgGetCode(func, f)
4999 func.WritePassthroughHandlerValidation(f)
4999 self.WritePassthroughServiceFunctionDoerCall(func, f) 5000 self.WritePassthroughServiceFunctionDoerCall(func, f)
5000 f.write(" return error::kNoError;\n") 5001 f.write(" return error::kNoError;\n")
5001 f.write("}\n") 5002 f.write("}\n")
5002 f.write("\n") 5003 f.write("\n")
5003 5004
5004 def WritePassthroughImmediateServiceImplementation(self, func, f): 5005 def WritePassthroughImmediateServiceImplementation(self, func, f):
5005 """Writes the service implementation for a command.""" 5006 """Writes the service implementation for a command."""
5006 self.WritePassthroughServiceFunctionHeader(func, f) 5007 self.WritePassthroughServiceFunctionHeader(func, f)
5007 self.WriteImmediateServiceHandlerArgGetCode(func, f) 5008 self.WriteImmediateServiceHandlerArgGetCode(func, f)
5009 func.WritePassthroughHandlerValidation(f)
5008 self.WritePassthroughServiceFunctionDoerCall(func, f) 5010 self.WritePassthroughServiceFunctionDoerCall(func, f)
5009 f.write(" return error::kNoError;\n") 5011 f.write(" return error::kNoError;\n")
5010 f.write("}\n") 5012 f.write("}\n")
5011 f.write("\n") 5013 f.write("\n")
5012 5014
5013 def WritePassthroughBucketServiceImplementation(self, func, f): 5015 def WritePassthroughBucketServiceImplementation(self, func, f):
5014 """Writes the service implementation for a command.""" 5016 """Writes the service implementation for a command."""
5015 self.WritePassthroughServiceFunctionHeader(func, f) 5017 self.WritePassthroughServiceFunctionHeader(func, f)
5016 self.WriteBucketServiceHandlerArgGetCode(func, f) 5018 self.WriteBucketServiceHandlerArgGetCode(func, f)
5019 func.WritePassthroughHandlerValidation(f)
5017 self.WritePassthroughServiceFunctionDoerCall(func, f) 5020 self.WritePassthroughServiceFunctionDoerCall(func, f)
5018 f.write(" return error::kNoError;\n") 5021 f.write(" return error::kNoError;\n")
5019 f.write("}\n") 5022 f.write("}\n")
5020 f.write("\n") 5023 f.write("\n")
5021 5024
5022 def WriteHandlerExtensionCheck(self, func, f): 5025 def WriteHandlerExtensionCheck(self, func, f):
5023 if func.GetInfo('extension_flag'): 5026 if func.GetInfo('extension_flag'):
5024 f.write(" if (!features().%s) {\n" % func.GetInfo('extension_flag')) 5027 f.write(" if (!features().%s) {\n" % func.GetInfo('extension_flag'))
5025 f.write(" return error::kUnknownCommand;") 5028 f.write(" return error::kUnknownCommand;")
5026 f.write(" }\n\n") 5029 f.write(" }\n\n")
(...skipping 3552 matching lines...) Expand 10 before | Expand all | Expand 10 after
8579 f.write("%s%s = %s;\n" % (' ' * indent, self.name, var)) 8582 f.write("%s%s = %s;\n" % (' ' * indent, self.name, var))
8580 8583
8581 def WriteArgAccessor(self, f): 8584 def WriteArgAccessor(self, f):
8582 """Writes specialized accessor for argument.""" 8585 """Writes specialized accessor for argument."""
8583 pass 8586 pass
8584 8587
8585 def WriteValidationCode(self, f, func): 8588 def WriteValidationCode(self, f, func):
8586 """Writes the validation code for an argument.""" 8589 """Writes the validation code for an argument."""
8587 pass 8590 pass
8588 8591
8592 def WritePassthroughValidationCode(self, f, func):
8593 """Writes the passthrough validation code for an argument."""
8594 pass
8595
8589 def WriteClientSideValidationCode(self, f, func): 8596 def WriteClientSideValidationCode(self, f, func):
8590 """Writes the validation code for an argument.""" 8597 """Writes the validation code for an argument."""
8591 pass 8598 pass
8592 8599
8593 def WriteDestinationInitalizationValidation(self, f, func): 8600 def WriteDestinationInitalizationValidation(self, f, func):
8594 """Writes the client side destintion initialization validation.""" 8601 """Writes the client side destintion initialization validation."""
8595 pass 8602 pass
8596 8603
8597 def WriteDestinationInitalizationValidatationIfNeeded(self, f, func): 8604 def WriteDestinationInitalizationValidatationIfNeeded(self, f, func):
8598 """Writes the client side destintion initialization validation if needed.""" 8605 """Writes the client side destintion initialization validation if needed."""
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
8866 f.write(" c, data_size, immediate_data_size);\n") 8873 f.write(" c, data_size, immediate_data_size);\n")
8867 8874
8868 def WriteValidationCode(self, f, func): 8875 def WriteValidationCode(self, f, func):
8869 """Overridden from Argument.""" 8876 """Overridden from Argument."""
8870 if self.optional: 8877 if self.optional:
8871 return 8878 return
8872 f.write(" if (%s == NULL) {\n" % self.name) 8879 f.write(" if (%s == NULL) {\n" % self.name)
8873 f.write(" return error::kOutOfBounds;\n") 8880 f.write(" return error::kOutOfBounds;\n")
8874 f.write(" }\n") 8881 f.write(" }\n")
8875 8882
8883 def WritePassthroughValidationCode(self, f, func):
8884 """Overridden from Argument."""
8885 if self.optional:
8886 return
8887 f.write(" if (%s == nullptr) {\n" % self.name)
8888 f.write(" return error::kOutOfBounds;\n")
8889 f.write(" }\n")
8890
8876 def GetImmediateVersion(self): 8891 def GetImmediateVersion(self):
8877 """Overridden from Argument.""" 8892 """Overridden from Argument."""
8878 return None 8893 return None
8879 8894
8880 def WriteDestinationInitalizationValidation(self, f, func): 8895 def WriteDestinationInitalizationValidation(self, f, func):
8881 """Overridden from Argument.""" 8896 """Overridden from Argument."""
8882 self.WriteDestinationInitalizationValidatationIfNeeded(f, func) 8897 self.WriteDestinationInitalizationValidatationIfNeeded(f, func)
8883 8898
8884 def GetLogArg(self): 8899 def GetLogArg(self):
8885 """Overridden from Argument.""" 8900 """Overridden from Argument."""
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
9495 """Makes a string of the arguments for the LOG macros""" 9510 """Makes a string of the arguments for the LOG macros"""
9496 args = self.GetOriginalArgs() 9511 args = self.GetOriginalArgs()
9497 return ' << ", " << '.join([arg.GetLogArg() for arg in args]) 9512 return ' << ", " << '.join([arg.GetLogArg() for arg in args])
9498 9513
9499 def WriteHandlerValidation(self, f): 9514 def WriteHandlerValidation(self, f):
9500 """Writes validation code for the function.""" 9515 """Writes validation code for the function."""
9501 for arg in self.GetOriginalArgs(): 9516 for arg in self.GetOriginalArgs():
9502 arg.WriteValidationCode(f, self) 9517 arg.WriteValidationCode(f, self)
9503 self.WriteValidationCode(f) 9518 self.WriteValidationCode(f)
9504 9519
9520 def WritePassthroughHandlerValidation(self, f):
9521 """Writes validation code for the function."""
9522 for arg in self.GetOriginalArgs():
9523 arg.WritePassthroughValidationCode(f, self)
9524
9505 def WriteHandlerImplementation(self, f): 9525 def WriteHandlerImplementation(self, f):
9506 """Writes the handler implementation for this command.""" 9526 """Writes the handler implementation for this command."""
9507 self.type_handler.WriteHandlerImplementation(self, f) 9527 self.type_handler.WriteHandlerImplementation(self, f)
9508 9528
9509 def WriteValidationCode(self, f): 9529 def WriteValidationCode(self, f):
9510 """Writes the validation code for a command.""" 9530 """Writes the validation code for a command."""
9511 pass 9531 pass
9512 9532
9513 def WriteCmdFlag(self, f): 9533 def WriteCmdFlag(self, f):
9514 """Writes the cmd cmd_flags constant.""" 9534 """Writes the cmd cmd_flags constant."""
(...skipping 1688 matching lines...) Expand 10 before | Expand all | Expand 10 after
11203 Format(gen.generated_cpp_filenames) 11223 Format(gen.generated_cpp_filenames)
11204 11224
11205 if gen.errors > 0: 11225 if gen.errors > 0:
11206 print "%d errors" % gen.errors 11226 print "%d errors" % gen.errors
11207 return 1 11227 return 1
11208 return 0 11228 return 0
11209 11229
11210 11230
11211 if __name__ == '__main__': 11231 if __name__ == '__main__':
11212 sys.exit(main(sys.argv[1:])) 11232 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | gpu/command_buffer/service/gles2_cmd_decoder_passthrough_handlers_autogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698