Lines Matching refs:self
100 def __init__(self, elem): argument
101 self.required = False
102 self.declared = False
103 self.elem = elem
104 def resetState(self): argument
105 self.required = False
106 self.declared = False
112 def __init__(self, elem): argument
113 BaseInfo.__init__(self, elem)
119 def __init__(self, elem): argument
120 BaseInfo.__init__(self, elem)
121 self.enums = {}
128 def __init__(self, elem): argument
129 BaseInfo.__init__(self, elem)
130 self.type = elem.get('type')
131 if (self.type == None):
132 self.type = ''
142 def __init__(self, elem): argument
143 BaseInfo.__init__(self, elem)
144 self.glxtype = None
145 self.glxopcode = None
146 self.glxequiv = None
147 self.vecequiv = None
158 def __init__(self, elem): argument
159 BaseInfo.__init__(self, elem)
160 self.name = elem.get('name')
164 self.category = 'VERSION'
165 self.number = elem.get('number')
167 self.category = self.name.split('_', 2)[1]
168 self.number = "0"
169 self.emit = False
236 def __init__(self, argument
246 self.filename = filename
247 self.apiname = apiname
248 self.profile = profile
249 self.versions = self.emptyRegex(versions)
250 self.emitversions = self.emptyRegex(emitversions)
251 self.defaultExtensions = defaultExtensions
252 self.addExtensions = self.emptyRegex(addExtensions)
253 self.removeExtensions = self.emptyRegex(removeExtensions)
254 self.sortProcedure = sortProcedure
258 def emptyRegex(self,pat): argument
290 def __init__(self, argument
309 GeneratorOptions.__init__(self, filename, apiname, profile,
312 self.prefixText = prefixText
313 self.genFuncPointers = genFuncPointers
314 self.protectFile = protectFile
315 self.protectFeature = protectFeature
316 self.protectProto = protectProto
317 self.protectProtoStr = protectProtoStr
318 self.apicall = apicall
319 self.apientry = apientry
320 self.apientryp = apientryp
351 def __init__(self, argument
355 self.outFile = None
356 self.errFile = errFile
357 self.warnFile = warnFile
358 self.diagFile = diagFile
360 self.featureName = None
361 self.genOpts = None
370 def logMsg(self, level, *args): argument
375 if (self.errFile != None):
376 write(strfile.getvalue(), file=self.errFile)
379 if (self.warnFile != None):
380 write('WARNING:', *args, file=self.warnFile)
382 if (self.diagFile != None):
383 write('DIAG:', *args, file=self.diagFile)
388 def beginFile(self, genOpts): argument
389 self.genOpts = genOpts
393 if (self.genOpts.filename != None):
394 self.outFile = open(self.genOpts.filename, 'w')
396 self.outFile = sys.stdout
397 def endFile(self): argument
398 self.errFile and self.errFile.flush()
399 self.warnFile and self.warnFile.flush()
400 self.diagFile and self.diagFile.flush()
401 self.outFile.flush()
402 if (self.outFile != sys.stdout and self.outFile != sys.stderr):
403 self.outFile.close()
404 self.genOpts = None
406 def beginFeature(self, interface, emit): argument
407 self.emit = emit
408 self.featureName = interface.get('name')
410 self.featureExtraProtect = interface.get('protect')
411 def endFeature(self): argument
413 self.featureName = None
414 self.featureExtraProtect = None
417 def genType(self, typeinfo, name): argument
418 if (self.featureName == None):
423 def genEnum(self, enuminfo, name): argument
424 if (self.featureName == None):
429 def genCmd(self, cmd, name): argument
430 if (self.featureName == None):
454 def __init__(self, argument
458 OutputGenerator.__init__(self, errFile, warnFile, diagFile)
460 self.typeBody = ''
461 self.enumBody = ''
462 self.cmdBody = ''
467 def makeCDecls(self, cmd): argument
472 pdecl = self.genOpts.apicall
491 pdecl += self.genOpts.apientry + text + tail
492 tdecl += '(' + self.genOpts.apientryp + 'PFN' + text.upper() + 'PROC' + tail + ')'
512 def newline(self): argument
513 write('', file=self.outFile)
515 def beginFile(self, genOpts): argument
516 OutputGenerator.beginFile(self, genOpts)
520 if (genOpts.protectFile and self.genOpts.filename):
521 headerSym = '__' + re.sub('\.h', '_h_', os.path.basename(self.genOpts.filename))
522 write('#ifndef', headerSym, file=self.outFile)
523 write('#define', headerSym, '1', file=self.outFile)
524 self.newline()
525 write('#ifdef __cplusplus', file=self.outFile)
526 write('extern "C" {', file=self.outFile)
527 write('#endif', file=self.outFile)
528 self.newline()
533 write(s, file=self.outFile)
538 write('/* Generated C header for:', file=self.outFile)
539 write(' * API:', genOpts.apiname, file=self.outFile)
541 write(' * Profile:', genOpts.profile, file=self.outFile)
542 write(' * Versions considered:', genOpts.versions, file=self.outFile)
543 write(' * Versions emitted:', genOpts.emitversions, file=self.outFile)
544 write(' * Default extensions included:', genOpts.defaultExtensions, file=self.outFile)
545 write(' * Additional extensions included:', genOpts.addExtensions, file=self.outFile)
546 write(' * Extensions removed:', genOpts.removeExtensions, file=self.outFile)
547 write(' */', file=self.outFile)
548 def endFile(self): argument
551 self.newline()
552 write('#ifdef __cplusplus', file=self.outFile)
553 write('}', file=self.outFile)
554 write('#endif', file=self.outFile)
555 if (self.genOpts.protectFile and self.genOpts.filename):
556 self.newline()
557 write('#endif', file=self.outFile)
559 OutputGenerator.endFile(self)
560 def beginFeature(self, interface, emit): argument
562 OutputGenerator.beginFeature(self, interface, emit)
567 self.typeBody = ''
568 self.enumBody = ''
569 self.cmdPointerBody = ''
570 self.cmdBody = ''
571 def endFeature(self): argument
574 if (self.emit):
575 self.newline()
576 if (self.genOpts.protectFeature):
577 write('#ifndef', self.featureName, file=self.outFile)
578 write('#define', self.featureName, '1', file=self.outFile)
579 if (self.typeBody != ''):
580 write(self.typeBody, end='', file=self.outFile)
584 if (self.featureExtraProtect != None):
585 write('#ifdef', self.featureExtraProtect, file=self.outFile)
586 if (self.enumBody != ''):
587 write(self.enumBody, end='', file=self.outFile)
588 if (self.genOpts.genFuncPointers and self.cmdPointerBody != ''):
589 write(self.cmdPointerBody, end='', file=self.outFile)
590 if (self.cmdBody != ''):
591 if (self.genOpts.protectProto):
592 write('#ifdef', self.genOpts.protectProtoStr, file=self.outFile)
593 write(self.cmdBody, end='', file=self.outFile)
594 if (self.genOpts.protectProto):
595 write('#endif', file=self.outFile)
596 if (self.featureExtraProtect != None):
597 write('#endif /*', self.featureExtraProtect, '*/', file=self.outFile)
598 if (self.genOpts.protectFeature):
599 write('#endif /*', self.featureName, '*/', file=self.outFile)
601 OutputGenerator.endFeature(self)
604 def genType(self, typeinfo, name): argument
605 OutputGenerator.genType(self, typeinfo, name)
614 s += self.genOpts.apientry + noneStr(elem.tail)
618 self.typeBody += s + "\n"
621 def genEnum(self, enuminfo, name): argument
622 OutputGenerator.genEnum(self, enuminfo, name)
625 self.enumBody += '#define ' + name.ljust(33) + ' ' + enuminfo.elem.get('value')
630 self.enumBody += enuminfo.type
631 self.enumBody += "\n"
634 def genCmd(self, cmdinfo, name): argument
635 OutputGenerator.genCmd(self, cmdinfo, name)
637 decls = self.makeCDecls(cmdinfo.elem)
638 self.cmdBody += decls[0]
639 if (self.genOpts.genFuncPointers):
640 self.cmdPointerBody += decls[1]
677 def __init__(self): argument
678 self.tree = None
679 self.typedict = {}
680 self.groupdict = {}
681 self.enumdict = {}
682 self.cmddict = {}
683 self.apidict = {}
684 self.extensions = []
685 self.extdict = {}
688 self.gen = OutputGenerator()
689 self.genOpts = None
690 self.emitFeatures = False
691 def loadElementTree(self, tree): argument
693 self.tree = tree
694 self.parseTree()
695 def loadFile(self, file): argument
697 self.tree = etree.parse(file)
698 self.parseTree()
699 def setGenerator(self, gen): argument
701 self.gen = gen
711 def addElementInfo(self, elem, info, infoName, dictionary): argument
717 self.gen.logMsg('warn', '*** Attempt to redefine',
726 def lookupElementInfo(self, fname, dictionary): argument
727 key = (fname, self.genOpts.apiname)
736 def parseTree(self): argument
739 self.reg = self.tree.getroot()
747 self.typedict = {}
748 for type in self.reg.findall('types/type'):
753 self.addElementInfo(type, TypeInfo(type), 'type', self.typedict)
759 self.groupdict = {}
760 for group in self.reg.findall('groups/group'):
761 self.addElementInfo(group, GroupInfo(group), 'group', self.groupdict)
769 self.enumdict = {}
770 for enum in self.reg.findall('enums/enum'):
771 self.addElementInfo(enum, EnumInfo(enum), 'enum', self.enumdict)
779 self.cmddict = {}
780 for cmd in self.reg.findall('commands/command'):
786 self.addElementInfo(cmd, ci, 'command', self.cmddict)
791 self.apidict = {}
792 for feature in self.reg.findall('feature'):
794 self.addElementInfo(feature, ai, 'feature', self.apidict)
795 self.extensions = self.reg.findall('extensions/extension')
796 self.extdict = {}
797 for feature in self.extensions:
799 self.addElementInfo(feature, ei, 'extension', self.extdict)
800 def dumpReg(self, maxlen = 40, filehandle = sys.stdout): argument
806 for name in self.typedict:
807 tobj = self.typedict[name]
810 for name in self.groupdict:
811 gobj = self.groupdict[name]
814 for name in self.enumdict:
815 eobj = self.enumdict[name]
818 for name in self.cmddict:
819 cobj = self.cmddict[name]
822 for key in self.apidict:
824 etree.tostring(self.apidict[key].elem)[0:maxlen], file=filehandle)
826 for key in self.extdict:
828 etree.tostring(self.extdict[key].elem)[0:maxlen], file=filehandle)
836 def markTypeRequired(self, typename, required): argument
838 self.gen.logMsg('diag', '*** tagging type:', typename, '-> required =', required)
840 type = self.lookupElementInfo(typename, self.typedict)
847 self.gen.logMsg('diag', '*** Generating dependent type',
849 self.markTypeRequired(depType, required)
852 self.gen.logMsg('warn', '*** type:', typename , 'IS NOT DEFINED')
856 def markRequired(self, features, required): argument
858 …self.gen.logMsg('diag', '*** markRequired (features = <too long to print>, required =', required, …
863 self.markTypeRequired(typeElem.get('name'), required)
866 self.gen.logMsg('diag', '*** tagging enum:', name, '-> required =', required)
867 enum = self.lookupElementInfo(name, self.enumdict)
871 self.gen.logMsg('warn', '*** enum:', name , 'IS NOT DEFINED')
874 self.gen.logMsg('diag', '*** tagging command:', name, '-> required =', required)
875 cmd = self.lookupElementInfo(name, self.cmddict)
887 …self.gen.logMsg('diag', '*** markRequired: command implicitly requires dependent type', ptype.text)
888 self.markTypeRequired(ptype.text, required)
890 self.gen.logMsg('warn', '*** command:', name, 'IS NOT DEFINED')
896 def requireAndRemoveFeatures(self, interface, api, profile): argument
901 self.markRequired(feature,True)
905 self.markRequired(feature,False)
913 def generateFeature(self, fname, ftype, dictionary, genProc): argument
914 f = self.lookupElementInfo(fname, dictionary)
917 self.gen.logMsg('diag', '*** No entry found for feature', fname,
923 self.gen.logMsg('diag', '*** Skipping', ftype, fname, '(not required)')
926 self.gen.logMsg('diag', '*** Skipping', ftype, fname, '(already declared)')
937 self.gen.logMsg('diag', '*** Generating required dependent type',
939 self.generateFeature(depname, 'type', self.typedict,
940 self.gen.genType)
944 self.gen.logMsg('diag', '*** Generating required parameter type',
946 self.generateFeature(depname, 'type', self.typedict,
947 self.gen.genType)
950 if self.emitFeatures:
951 self.gen.logMsg('diag', '*** Emitting', ftype, 'decl for', fname)
954 self.gen.logMsg('diag', '*** Skipping', ftype, fname,
962 def generateRequiredInterface(self, interface): argument
969 self.generateFeature(t.get('name'), 'type', self.typedict,
970 self.gen.genType)
972 self.generateFeature(e.get('name'), 'enum', self.enumdict,
973 self.gen.genEnum)
975 self.generateFeature(c.get('name'), 'command', self.cmddict,
976 self.gen.genCmd)
981 def apiGen(self, genOpts): argument
984 self.gen.logMsg('diag', '*******************************************')
985 self.gen.logMsg('diag', ' Registry.apiGen file:', genOpts.filename,
988 self.gen.logMsg('diag', '*******************************************')
990 self.genOpts = genOpts
992 self.apiReset()
995 regVersions = re.compile(self.genOpts.versions)
996 regEmitVersions = re.compile(self.genOpts.emitversions)
997 regAddExtensions = re.compile(self.genOpts.addExtensions)
998 regRemoveExtensions = re.compile(self.genOpts.removeExtensions)
1003 for key in self.apidict:
1004 fi = self.apidict[key]
1006 if (api == self.genOpts.apiname):
1015 self.gen.logMsg('diag', '*** NOT tagging feature api =', api,
1019 self.gen.logMsg('diag', '*** NOT including feature api =', api,
1023 self.gen.logMsg('diag', '*** NOT including feature api =', api,
1027 self.gen.logMsg('warn', '*** No matching API versions found!')
1034 for key in self.extdict:
1035 ei = self.extdict[key]
1044 if (self.genOpts.defaultExtensions and
1045 re.match(pat, self.genOpts.defaultExtensions)):
1046 self.gen.logMsg('diag', '*** Including extension',
1055 self.gen.logMsg('diag', '*** Including extension',
1063 self.gen.logMsg('diag', '*** Removing extension',
1073 self.gen.logMsg('diag', '*** NOT including extension',
1077 if (self.genOpts.sortProcedure):
1078 self.genOpts.sortProcedure(features)
1088 … self.gen.logMsg('diag', '*** PASS 1: TAG FEATURES ********************************************')
1090 self.gen.logMsg('diag', '*** PASS 1: Tagging required and removed features for',
1092 self.requireAndRemoveFeatures(f.elem, self.genOpts.apiname, self.genOpts.profile)
1097 … self.gen.logMsg('diag', '*** PASS 2: GENERATE INTERFACES FOR FEATURES ************************')
1098 self.gen.beginFile(self.genOpts)
1100 self.gen.logMsg('diag', '*** PASS 2: Generating interface for',
1102 emit = self.emitFeatures = f.emit
1104 self.gen.logMsg('diag', '*** PASS 2: NOT declaring feature',
1108 self.gen.beginFeature(f.elem, emit)
1109 self.generateRequiredInterface(f.elem)
1110 self.gen.endFeature()
1111 self.gen.endFile()
1115 def apiReset(self): argument
1117 for type in self.typedict:
1118 self.typedict[type].resetState()
1119 for enum in self.enumdict:
1120 self.enumdict[enum].resetState()
1121 for cmd in self.cmddict:
1122 self.cmddict[cmd].resetState()
1123 for cmd in self.apidict:
1124 self.apidict[cmd].resetState()
1128 def validateGroups(self): argument
1132 self.gen.logMsg('diag', '*** VALIDATING GROUP ATTRIBUTES ***')
1133 for cmd in self.reg.findall('commands/command'):
1139 if (group not in self.groupdict.keys()):
1153 if (group not in self.groupdict.keys()):
1160 self.gen.logMsg('diag', '*** SUMMARY OF UNRECOGNIZED GROUPS ***')
1162 self.gen.logMsg('diag', ' ', key, ' occurred ', badGroup[key], ' times')