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

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

Issue 7715036: More multi-version support (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | ppapi/generators/idl_c_header.py » ('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/python 1 #!/usr/bin/python
2 # 2 #
3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2011 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 """Nodes for PPAPI IDL AST.""" 7 """Nodes for PPAPI IDL AST."""
8 8
9 from idl_namespace import IDLNamespace, IDLVersionMap 9 from idl_namespace import IDLNamespace, IDLVersionMap
10 from idl_node import IDLAttribute, IDLFile, IDLNode 10 from idl_node import IDLAttribute, IDLFile, IDLNode
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 71
72 class IDLFileTypeResolver(IDLVisitor): 72 class IDLFileTypeResolver(IDLVisitor):
73 def VisitFilter(self, node, data): 73 def VisitFilter(self, node, data):
74 return not node.IsA('Comment', 'Copyright') 74 return not node.IsA('Comment', 'Copyright')
75 75
76 def Arrive(self, node, filenode): 76 def Arrive(self, node, filenode):
77 # Track the file node to update errors 77 # Track the file node to update errors
78 if node.IsA('File'): 78 if node.IsA('File'):
79 node.SetProperty('FILE', node) 79 node.SetProperty('FILE', node)
80 80
81
82 # If this node has a TYPEREF, resolve it to a version list 81 # If this node has a TYPEREF, resolve it to a version list
83 typeref = node.property_node.GetPropertyLocal('TYPEREF') 82 typeref = node.property_node.GetPropertyLocal('TYPEREF')
84 if typeref: 83 if typeref:
85 node.typelist = node.parent.namespace.FindList(typeref) 84 node.typelist = node.parent.namespace.FindList(typeref)
86 if not node.typelist: 85 if not node.typelist:
87 node.Error('Could not resolve %s.' % typeref) 86 node.Error('Could not resolve %s.' % typeref)
88 else: 87 else:
89 node.typelist = None 88 node.typelist = None
90 return filenode 89 return filenode
91 90
92 91
92 class IDLReleaseResolver(IDLVisitor):
93 def VisitFilter(self, node, data):
94 return node.IsA('AST','File', 'Label')
95
96 def Depart(self, node, data, childdata):
97 if node.IsA('Label'):
98 return set([child.name for child in GetListOf('LabelItem')])
99 return childdata
93 100
94 class IDLVersionMapDefault(IDLVersionMap): 101 class IDLVersionMapDefault(IDLVersionMap):
95 def GetRelease(self, version): 102 def GetRelease(self, version):
96 return 'M13' 103 return 'M13'
97 104
98 def GetVersion(self, release): 105 def GetVersion(self, release):
99 return float(0.0) 106 return float(0.0)
100 107
101 # 108 #
102 # IDLAst 109 # IDLAst
103 # 110 #
104 # A specialized version of the IDLNode for containing the whole of the 111 # A specialized version of the IDLNode for containing the whole of the
105 # AST. The specialized BuildTree function pulls the per file namespaces 112 # AST. The specialized BuildTree function pulls the per file namespaces
106 # into the global AST namespace and checks for collisions. 113 # into the global AST namespace and checks for collisions.
107 # 114 #
108 class IDLAst(IDLNode): 115 class IDLAst(IDLNode):
109 def __init__(self, children): 116 def __init__(self, children):
110 objs = [] 117 objs = []
111 118
112 builtin = None 119 builtin = None
113 extranodes = [] 120 extranodes = []
114 for filenode in children: 121 for filenode in children:
115 if filenode.GetProperty('NAME') == 'pp_stdint.idl': 122 if filenode.GetProperty('NAME') == 'pp_stdint.idl':
116 builtin = filenode 123 builtin = filenode
117 break 124 break
118 125
119 # if not builtin:
120 # builtin = IDLFile('pp_stdint.idl', [])
121 # extranodes = [builtin]
122
123 # for name in BuiltIn:
124 # nameattr = IDLAttribute('NAME', name)
125 # typenode = IDLNode('Type', 'BuiltIn', 1, 0, [nameattr])
126 # builtin.AddChild(typenode)
127
128 IDLNode.__init__(self, 'AST', 'BuiltIn', 1, 0, extranodes + children) 126 IDLNode.__init__(self, 'AST', 'BuiltIn', 1, 0, extranodes + children)
129 self.SetProperty('LABEL', IDLVersionMapDefault()) 127 self.SetProperty('LABEL', IDLVersionMapDefault())
130 self.Resolve() 128 self.Resolve()
131 129
132 def Resolve(self): 130 def Resolve(self):
133 self.namespace = IDLNamespace(None) 131 self.namespace = IDLNamespace(None)
134 self.namespace.name = 'AST' 132 self.namespace.name = 'AST'
135 IDLNamespaceLabelResolver().Visit(self, self.namespace) 133 IDLNamespaceLabelResolver().Visit(self, self.namespace)
136 IDLFileTypeResolver().Visit(self, None) 134 IDLFileTypeResolver().Visit(self, None)
137 135
136 # Build an ordered list of all releases
137 self.releases = set()
138 for filenode in self.GetListOf('File'):
139 vmap = filenode.GetProperty('LABEL')
140 self.releases |= set(vmap.releases)
141 self.releases = sorted(self.releases)
142
138 def SetTypeInfo(self, name, properties): 143 def SetTypeInfo(self, name, properties):
139 node = self.namespace[name] 144 node = self.namespace[name]
140 for prop in properties: 145 for prop in properties:
141 node.properties[prop] = properties[prop] 146 node.properties[prop] = properties[prop]
142 147
143 148
OLDNEW
« no previous file with comments | « no previous file | ppapi/generators/idl_c_header.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698