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

Side by Side Diff: ppapi/generators/idl_c_proto.py

Issue 490433002: PPAPI: make generator output a pointer to an array correctly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
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 """ Generator for C style prototypes and definitions """ 6 """ Generator for C style prototypes and definitions """
7 7
8 import glob 8 import glob
9 import os 9 import os
10 import sys 10 import sys
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 # rtype - The store or return type of the object. 377 # rtype - The store or return type of the object.
378 # name - The name of the object. 378 # name - The name of the object.
379 # arrays - A list of array dimensions as [] or [<fixed_num>]. 379 # arrays - A list of array dimensions as [] or [<fixed_num>].
380 # args - None if not a function, otherwise a list of parameters. 380 # args - None if not a function, otherwise a list of parameters.
381 # 381 #
382 def GetComponents(self, node, release, mode): 382 def GetComponents(self, node, release, mode):
383 self.LogEnter('GetComponents mode %s for %s %s' % (mode, node, release)) 383 self.LogEnter('GetComponents mode %s for %s %s' % (mode, node, release))
384 384
385 # Generate passing type by modifying root type 385 # Generate passing type by modifying root type
386 rtype = self.GetTypeByMode(node, release, mode) 386 rtype = self.GetTypeByMode(node, release, mode)
387 # If this is an array output, change it from type* foo[] to type** foo.
388 # type* foo[] means an array of pointers to type, which is confusing.
Justin Chuang 2014/08/19 17:31:13 nit: optionally elaborate more like this: Functio
dmichael (off chromium) 2014/08/19 21:43:21 I don't mean to come off as harsh, but I'm not sur
389 arrayspec = [self.GetArraySpec(array) for array in node.GetListOf('Array')]
390 if mode == 'out' and len(arrayspec) == 1 and arrayspec[0] == '[]':
391 rtype += '*'
392 del arrayspec[0]
393
387 if node.IsA('Enum', 'Interface', 'Struct'): 394 if node.IsA('Enum', 'Interface', 'Struct'):
388 rname = node.GetName() 395 rname = node.GetName()
389 else: 396 else:
390 rname = node.GetType(release).GetName() 397 rname = node.GetType(release).GetName()
391 398
392 if rname in CGen.RemapName: 399 if rname in CGen.RemapName:
393 rname = CGen.RemapName[rname] 400 rname = CGen.RemapName[rname]
394 if '%' in rtype: 401 if '%' in rtype:
395 rtype = rtype % rname 402 rtype = rtype % rname
396 name = node.GetName() 403 name = node.GetName()
397 arrayspec = [self.GetArraySpec(array) for array in node.GetListOf('Array')]
398 callnode = node.GetOneOf('Callspec') 404 callnode = node.GetOneOf('Callspec')
399 if callnode: 405 if callnode:
400 callspec = [] 406 callspec = []
401 for param in callnode.GetListOf('Param'): 407 for param in callnode.GetListOf('Param'):
402 if not param.IsRelease(release): 408 if not param.IsRelease(release):
403 continue 409 continue
404 mode = self.GetParamMode(param) 410 mode = self.GetParamMode(param)
405 ptype, pname, parray, pspec = self.GetComponents(param, release, mode) 411 ptype, pname, parray, pspec = self.GetComponents(param, release, mode)
406 callspec.append((ptype, pname, parray, pspec)) 412 callspec.append((ptype, pname, parray, pspec))
407 else: 413 else:
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 if f.GetProperty('ERRORS') > 0: 784 if f.GetProperty('ERRORS') > 0:
779 print 'Skipping %s' % f.GetName() 785 print 'Skipping %s' % f.GetName()
780 continue 786 continue
781 for node in f.GetChildren()[2:]: 787 for node in f.GetChildren()[2:]:
782 print cgen.Define(node, ast.releases, comment=True, prefix='tst_') 788 print cgen.Define(node, ast.releases, comment=True, prefix='tst_')
783 789
784 790
785 if __name__ == '__main__': 791 if __name__ == '__main__':
786 sys.exit(main(sys.argv[1:])) 792 sys.exit(main(sys.argv[1:]))
787 793
OLDNEW
« no previous file with comments | « ppapi/c/private/ppp_flash_browser_operations.h ('k') | ppapi/thunk/ppb_camera_capabilities_private_thunk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698