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

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: put them in struct namespaces 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.
dmichael (off chromium) 2014/09/05 18:46:08 I would elaborate that this is for legacy APIs lik
hamaji 2014/09/08 07:34:05 Done. Ah, I have not filed the bug yet. I filed on
593 out += self.DefineStructInternals(node, rel,
594 include_version=False, comment=True)
595 else:
596 # Define an unversioned typedef for the most recent version
597 out += 'typedef struct %s %s;\n' % (
598 self.GetStructName(node, rel, include_version=True),
599 self.GetStructName(node, rel, include_version=False))
600 return out
601
602
574 def DefineStruct(self, node, releases, prefix='', comment=False): 603 def DefineStruct(self, node, releases, prefix='', comment=False):
575 __pychecker__ = 'unusednames=comment,prefix' 604 __pychecker__ = 'unusednames=comment,prefix'
576 self.LogEnter('DefineStruct %s' % node) 605 self.LogEnter('DefineStruct %s' % node)
577 out = '' 606 out = ''
578 build_list = node.GetUniqueReleases(releases) 607 build_list = node.GetUniqueReleases(releases)
579 608
580 newest_stable = None 609 newest_stable = None
581 newest_dev = None 610 newest_dev = None
582 for rel in build_list: 611 for rel in build_list:
583 channel = node.GetProperty('FILE').release_map.GetChannel(rel) 612 channel = node.GetProperty('FILE').release_map.GetChannel(rel)
(...skipping 10 matching lines...) Expand all
594 assert len(build_list) == 1 623 assert len(build_list) == 1
595 # Build the most recent one versioned, with comments 624 # Build the most recent one versioned, with comments
596 out = self.DefineStructInternals(node, last_rel, 625 out = self.DefineStructInternals(node, last_rel,
597 include_version=False, comment=True) 626 include_version=False, comment=True)
598 627
599 if node.IsA('Interface'): 628 if node.IsA('Interface'):
600 # Build the most recent one versioned, with comments 629 # Build the most recent one versioned, with comments
601 out = self.DefineStructInternals(node, last_rel, 630 out = self.DefineStructInternals(node, last_rel,
602 include_version=True, comment=True) 631 include_version=True, comment=True)
603 if last_rel == newest_stable: 632 if last_rel == newest_stable:
604 # Define an unversioned typedef for the most recent version 633 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 634
609 # Build the rest without comments and with the version number appended 635 # Build the rest without comments and with the version number appended
610 for rel in build_list[0:-1]: 636 for rel in build_list[0:-1]:
611 channel = node.GetProperty('FILE').release_map.GetChannel(rel) 637 channel = node.GetProperty('FILE').release_map.GetChannel(rel)
612 # Skip dev channel interface versions that are 638 # Skip dev channel interface versions that are
613 # Not the newest version, and 639 # Not the newest version, and
614 # Don't have an equivalent stable version. 640 # Don't have an equivalent stable version.
615 if channel == 'dev' and rel != newest_dev: 641 if channel == 'dev' and rel != newest_dev:
616 if not node.DevInterfaceMatchesStable(rel): 642 if not node.DevInterfaceMatchesStable(rel):
617 continue 643 continue
618 out += '\n' + self.DefineStructInternals(node, rel, 644 out += '\n' + self.DefineStructInternals(node, rel,
619 include_version=True, 645 include_version=True,
620 comment=False) 646 comment=False)
621 if rel == newest_stable: 647 if rel == newest_stable:
622 # Define an unversioned typedef for the most recent version 648 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 649
627 self.LogExit('Exit DefineStruct') 650 self.LogExit('Exit DefineStruct')
628 return out 651 return out
629 652
630 653
631 # 654 #
632 # Copyright and Comment 655 # Copyright and Comment
633 # 656 #
634 # Generate a comment or copyright block 657 # Generate a comment or copyright block
635 # 658 #
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 for f in ast.GetListOf('File'): 806 for f in ast.GetListOf('File'):
784 if f.GetProperty('ERRORS') > 0: 807 if f.GetProperty('ERRORS') > 0:
785 print 'Skipping %s' % f.GetName() 808 print 'Skipping %s' % f.GetName()
786 continue 809 continue
787 for node in f.GetChildren()[2:]: 810 for node in f.GetChildren()[2:]:
788 print cgen.Define(node, ast.releases, comment=True, prefix='tst_') 811 print cgen.Define(node, ast.releases, comment=True, prefix='tst_')
789 812
790 813
791 if __name__ == '__main__': 814 if __name__ == '__main__':
792 sys.exit(main(sys.argv[1:])) 815 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