Lines Matching refs:self
19 def __init__(self, argument
72 GeneratorOptions.__init__(self, **kwargs)
74 self.prefixText = prefixText
77 self.genFuncPointers = genFuncPointers
80 self.protectFile = protectFile
83 self.protectFeature = protectFeature
86 self.protectProto = protectProto
89 self.protectProtoStr = protectProtoStr
92 self.apicall = apicall
95 self.apientry = apientry
98 self.apientryp = apientryp
101 self.indentFuncProto = indentFuncProto
104 self.indentFuncPointer = indentFuncPointer
107 self.alignFuncParam = alignFuncParam
110 self.genEnumBeginEndRange = genEnumBeginEndRange
113 self.genAliasMacro = genAliasMacro
116 self.aliasMacro = aliasMacro
119 self.codeGenerator = True
131 def __init__(self, *args, **kwargs): argument
134 self.sections = {section: [] for section in self.ALL_SECTIONS}
135 self.feature_not_empty = False
136 self.may_alias = None
138 def beginFile(self, genOpts): argument
139 OutputGenerator.beginFile(self, genOpts)
143 if genOpts.protectFile and self.genOpts.filename:
145 os.path.basename(self.genOpts.filename)).upper()
146 write('#ifndef', headerSym, file=self.outFile)
147 write('#define', headerSym, '1', file=self.outFile)
148 self.newline()
153 write(s, file=self.outFile)
156 self.newline()
157 write('#ifdef __cplusplus', file=self.outFile)
158 write('extern "C" {', file=self.outFile)
159 write('#endif', file=self.outFile)
160 self.newline()
162 def endFile(self): argument
165 self.newline()
166 write('#ifdef __cplusplus', file=self.outFile)
167 write('}', file=self.outFile)
168 write('#endif', file=self.outFile)
169 if self.genOpts.protectFile and self.genOpts.filename:
170 self.newline()
171 write('#endif', file=self.outFile)
173 OutputGenerator.endFile(self)
175 def beginFeature(self, interface, emit): argument
177 OutputGenerator.beginFeature(self, interface, emit)
182 self.sections = {section: [] for section in self.ALL_SECTIONS}
183 self.feature_not_empty = False
185 def endFeature(self): argument
188 if self.emit:
189 if self.feature_not_empty:
190 … if self.genOpts.conventions.writeFeature(self.featureExtraProtect, self.genOpts.filename):
191 self.newline()
192 if self.genOpts.protectFeature:
193 write('#ifndef', self.featureName, file=self.outFile)
197 if self.featureExtraProtect is not None:
198 write('#ifdef', self.featureExtraProtect, file=self.outFile)
199 self.newline()
200 write('#define', self.featureName, '1', file=self.outFile)
201 for section in self.TYPE_SECTIONS:
202 contents = self.sections[section]
204 write('\n'.join(contents), file=self.outFile)
205 if self.genOpts.genFuncPointers and self.sections['commandPointer']:
206 write('\n'.join(self.sections['commandPointer']), file=self.outFile)
207 self.newline()
208 if self.sections['command']:
209 if self.genOpts.protectProto:
210 write(self.genOpts.protectProto,
211 self.genOpts.protectProtoStr, file=self.outFile)
212 write('\n'.join(self.sections['command']), end='', file=self.outFile)
213 if self.genOpts.protectProto:
214 write('#endif', file=self.outFile)
216 self.newline()
217 if self.featureExtraProtect is not None:
218 write('#endif /*', self.featureExtraProtect, '*/', file=self.outFile)
219 if self.genOpts.protectFeature:
220 write('#endif /*', self.featureName, '*/', file=self.outFile)
222 OutputGenerator.endFeature(self)
224 def appendSection(self, section, text): argument
227 self.sections[section].append(text)
228 self.feature_not_empty = True
230 def genType(self, typeinfo, name, alias): argument
232 OutputGenerator.genType(self, typeinfo, name, alias)
250 self.genStruct(typeinfo, name, alias)
263 body += self.genOpts.apientry + noneStr(elem.tail)
270 self.appendSection(section, body)
272 def genProtectString(self, protect_str): argument
296 def typeMayAlias(self, typeName): argument
297 if not self.may_alias:
302 self.may_alias = set(typeName
303 for typeName, data in self.registry.typedict.items()
308 for otherType in self.registry.typedict.values())
309 self.may_alias.update(set(x for x in parent_structs
311 return typeName in self.may_alias
313 def genStruct(self, typeinfo, typeName, alias): argument
325 OutputGenerator.genStruct(self, typeinfo, typeName, alias)
333 (protect_begin, protect_end) = self.genProtectString(typeElem.get('protect'))
341 if self.genOpts.genAliasMacro and self.typeMayAlias(typeName):
342 body += ' ' + self.genOpts.aliasMacro
346 targetLen = self.getMaxCParamTypeLength(typeinfo)
348 body += self.makeCParamDecl(member, targetLen + 4)
354 self.appendSection('struct', body)
356 def genGroup(self, groupinfo, groupName, alias=None): argument
363 OutputGenerator.genGroup(self, groupinfo, groupName, alias)
377 self.appendSection(section, body)
379 … (section, body) = self.buildEnumCDecl(self.genOpts.genEnumBeginEndRange, groupinfo, groupName)
380 self.appendSection(section, "\n" + body)
382 def genEnum(self, enuminfo, name, alias): argument
387 OutputGenerator.genEnum(self, enuminfo, name, alias)
388 (_, strVal) = self.enumToValue(enuminfo.elem, False)
390 self.appendSection('enum', body)
392 def genCmd(self, cmdinfo, name, alias): argument
394 OutputGenerator.genCmd(self, cmdinfo, name, alias)
402 decls = self.makeCDecls(cmdinfo.elem)
403 self.appendSection('command', prefix + decls[0] + '\n')
404 if self.genOpts.genFuncPointers:
405 self.appendSection('commandPointer', decls[1])