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

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

Issue 538903002: Generate Pepper IDL for OpenGLES2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more comments Created 6 years, 3 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 | « ppapi/c/ppb_opengles2.h ('k') | ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c » ('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 """ 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 'float_t': 'float', 167 'float_t': 'float',
168 'double_t': 'double', 168 'double_t': 'double',
169 'handle_t': 'int', 169 'handle_t': 'int',
170 'mem_t': 'void*', 170 'mem_t': 'void*',
171 'mem_ptr_t': 'void**', 171 'mem_ptr_t': 'void**',
172 'str_t': 'char*', 172 'str_t': 'char*',
173 'cstr_t': 'const char*', 173 'cstr_t': 'const char*',
174 'interface_t' : 'const void*' 174 'interface_t' : 'const void*'
175 } 175 }
176 176
177 # Tell how to handle pointers to GL types.
178 for gltype in ['GLbitfield', 'GLboolean', 'GLbyte', 'GLclampf',
179 'GLclampx', 'GLenum', 'GLfixed', 'GLfloat', 'GLint',
180 'GLintptr', 'GLshort', 'GLsizei', 'GLsizeiptr',
181 'GLubyte', 'GLuint', 'GLushort']:
182 ptrtype = gltype + '_ptr_t'
183 TypeMap[ptrtype] = {
184 'in': 'const %s',
185 'inout': '%s',
186 'out': '%s',
187 'return': 'const %s',
188 'store': '%s'
189 }
190 RemapName[ptrtype] = '%s*' % gltype
191
177 def __init__(self): 192 def __init__(self):
178 self.dbg_depth = 0 193 self.dbg_depth = 0
179 194
180 # 195 #
181 # Debug Logging functions 196 # Debug Logging functions
182 # 197 #
183 def Log(self, txt): 198 def Log(self, txt):
184 if not GetOption('cgen_debug'): return 199 if not GetOption('cgen_debug'): return
185 tabs = ' ' * self.dbg_depth 200 tabs = ' ' * self.dbg_depth
186 print '%s%s' % (tabs, txt) 201 print '%s%s' % (tabs, txt)
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 if channel == 'stable' and child.NodeIsDevOnly(): 579 if channel == 'stable' and child.NodeIsDevOnly():
565 continue 580 continue
566 member = self.Define(child, [release], tabs=1, comment=comment) 581 member = self.Define(child, [release], tabs=1, comment=comment)
567 if not member: 582 if not member:
568 continue 583 continue
569 members.append(member) 584 members.append(member)
570 out += '%s\n};\n' % '\n'.join(members) 585 out += '%s\n};\n' % '\n'.join(members)
571 return out 586 return out
572 587
573 588
589 def DefineUnversionedInterface(self, node, rel):
590 out = '\n'
591 if node.GetProperty('force_struct_namespace'):
592 # Duplicate the definition to put it in struct namespace. This
593 # attribute is only for legacy APIs like OpenGLES2 and new APIs
594 # must not use this. See http://crbug.com/411799
595 out += self.DefineStructInternals(node, rel,
596 include_version=False, comment=True)
597 else:
598 # Define an unversioned typedef for the most recent version
599 out += 'typedef struct %s %s;\n' % (
600 self.GetStructName(node, rel, include_version=True),
601 self.GetStructName(node, rel, include_version=False))
602 return out
603
604
574 def DefineStruct(self, node, releases, prefix='', comment=False): 605 def DefineStruct(self, node, releases, prefix='', comment=False):
575 __pychecker__ = 'unusednames=comment,prefix' 606 __pychecker__ = 'unusednames=comment,prefix'
576 self.LogEnter('DefineStruct %s' % node) 607 self.LogEnter('DefineStruct %s' % node)
577 out = '' 608 out = ''
578 build_list = node.GetUniqueReleases(releases) 609 build_list = node.GetUniqueReleases(releases)
579 610
580 newest_stable = None 611 newest_stable = None
581 newest_dev = None 612 newest_dev = None
582 for rel in build_list: 613 for rel in build_list:
583 channel = node.GetProperty('FILE').release_map.GetChannel(rel) 614 channel = node.GetProperty('FILE').release_map.GetChannel(rel)
(...skipping 10 matching lines...) Expand all
594 assert len(build_list) == 1 625 assert len(build_list) == 1
595 # Build the most recent one versioned, with comments 626 # Build the most recent one versioned, with comments
596 out = self.DefineStructInternals(node, last_rel, 627 out = self.DefineStructInternals(node, last_rel,
597 include_version=False, comment=True) 628 include_version=False, comment=True)
598 629
599 if node.IsA('Interface'): 630 if node.IsA('Interface'):
600 # Build the most recent one versioned, with comments 631 # Build the most recent one versioned, with comments
601 out = self.DefineStructInternals(node, last_rel, 632 out = self.DefineStructInternals(node, last_rel,
602 include_version=True, comment=True) 633 include_version=True, comment=True)
603 if last_rel == newest_stable: 634 if last_rel == newest_stable:
604 # Define an unversioned typedef for the most recent version 635 out += self.DefineUnversionedInterface(node, last_rel)
605 out += '\ntypedef struct %s %s;\n' % (
606 self.GetStructName(node, last_rel, include_version=True),
607 self.GetStructName(node, last_rel, include_version=False))
608 636
609 # Build the rest without comments and with the version number appended 637 # Build the rest without comments and with the version number appended
610 for rel in build_list[0:-1]: 638 for rel in build_list[0:-1]:
611 channel = node.GetProperty('FILE').release_map.GetChannel(rel) 639 channel = node.GetProperty('FILE').release_map.GetChannel(rel)
612 # Skip dev channel interface versions that are 640 # Skip dev channel interface versions that are
613 # Not the newest version, and 641 # Not the newest version, and
614 # Don't have an equivalent stable version. 642 # Don't have an equivalent stable version.
615 if channel == 'dev' and rel != newest_dev: 643 if channel == 'dev' and rel != newest_dev:
616 if not node.DevInterfaceMatchesStable(rel): 644 if not node.DevInterfaceMatchesStable(rel):
617 continue 645 continue
618 out += '\n' + self.DefineStructInternals(node, rel, 646 out += '\n' + self.DefineStructInternals(node, rel,
619 include_version=True, 647 include_version=True,
620 comment=False) 648 comment=False)
621 if rel == newest_stable: 649 if rel == newest_stable:
622 # Define an unversioned typedef for the most recent version 650 out += self.DefineUnversionedInterface(node, rel)
623 out += '\ntypedef struct %s %s;\n' % (
624 self.GetStructName(node, rel, include_version=True),
625 self.GetStructName(node, rel, include_version=False))
626 651
627 self.LogExit('Exit DefineStruct') 652 self.LogExit('Exit DefineStruct')
628 return out 653 return out
629 654
630 655
631 # 656 #
632 # Copyright and Comment 657 # Copyright and Comment
633 # 658 #
634 # Generate a comment or copyright block 659 # Generate a comment or copyright block
635 # 660 #
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 for f in ast.GetListOf('File'): 808 for f in ast.GetListOf('File'):
784 if f.GetProperty('ERRORS') > 0: 809 if f.GetProperty('ERRORS') > 0:
785 print 'Skipping %s' % f.GetName() 810 print 'Skipping %s' % f.GetName()
786 continue 811 continue
787 for node in f.GetChildren()[2:]: 812 for node in f.GetChildren()[2:]:
788 print cgen.Define(node, ast.releases, comment=True, prefix='tst_') 813 print cgen.Define(node, ast.releases, comment=True, prefix='tst_')
789 814
790 815
791 if __name__ == '__main__': 816 if __name__ == '__main__':
792 sys.exit(main(sys.argv[1:])) 817 sys.exit(main(sys.argv[1:]))
793
OLDNEW
« no previous file with comments | « ppapi/c/ppb_opengles2.h ('k') | ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698