• Home
  • Raw
  • Download

Lines Matching refs:self

27 …def __init__(self, cgen, featureBitsVar, toCountVar, countVar, rootTypeVar, prefix, forApiOutput=F…  argument
28 self.cgen = cgen
29 self.featureBitsVar = featureBitsVar
30 self.toCountVar = toCountVar
31 self.rootTypeVar = rootTypeVar
32 self.countVar = countVar
33 self.prefix = prefix
34 self.forApiOutput = forApiOutput
36self.exprAccessor = lambda t: self.cgen.generalAccess(t, parentVarName = self.toCountVar, asPtr = …
37self.exprValueAccessor = lambda t: self.cgen.generalAccess(t, parentVarName = self.toCountVar, asP…
38self.exprPrimitiveValueAccessor = lambda t: self.cgen.generalAccess(t, parentVarName = self.toCoun…
40self.lenAccessor = lambda t: self.cgen.generalLengthAccess(t, parentVarName = self.toCountVar)
41self.lenAccessorGuard = lambda t: self.cgen.generalLengthAccessGuard(t, parentVarName = self.toCou…
42self.filterVarAccessor = lambda t: self.cgen.filterVarAccess(t, parentVarName = self.toCountVar)
44 self.checked = False
46 self.mapHandles = mapHandles
47 self.handleMapOverwrites = handleMapOverwrites
48 self.doFiltering = doFiltering
50 def getTypeForStreaming(self, vulkanType): argument
61 def makeCastExpr(self, vulkanType): argument
63 self.cgen.makeCTypeDecl(vulkanType, useParamName=False))
65 def genCount(self, sizeExpr): argument
66 self.cgen.stmt("*%s += %s" % (self.countVar, sizeExpr))
68 def genPrimitiveStreamCall(self, vulkanType): argument
69 self.genCount(str(self.cgen.countPrimitive(
70 self.typeInfo,
73 def genHandleMappingCall(self, vulkanType, access, lenAccess): argument
81 handle64Var = self.cgen.var()
83 self.cgen.beginIf(lenAccess)
92 self.cgen.stmt("uint64_t %s" % handle64Var)
97 if self.handleMapOverwrites:
105 self.genCount("8 * %s" % lenAccess)
112 self.genCount(handle64Bytes)
115 self.cgen.endIf()
117 def doAllocSpace(self, vulkanType): argument
120 def getOptionalStringFeatureExpr(self, vulkanType): argument
124 featureExpr = "%s & %s" % (self.featureBitsVar, splitted[1])
128 def onCheck(self, vulkanType): argument
130 if self.forApiOutput:
133 featureExpr = self.getOptionalStringFeatureExpr(vulkanType);
135 self.checked = True
137 access = self.exprAccessor(vulkanType)
141 self.cgen.line("// WARNING PTR CHECK")
142 checkAccess = self.exprAccessor(vulkanType)
144 sizeExpr = self.cgen.sizeofExpr(vulkanType)
147 self.cgen.beginIf(featureExpr)
149 self.genPrimitiveStreamCall(
153 self.cgen.endIf()
156 self.cgen.beginIf("(!(%s) || %s)" % (featureExpr, access))
158 self.cgen.beginIf(access)
161 self.cgen.beginIf("!(%s)" % checkName)
162 self.cgen.stmt(
164 self.cgen.endIf()
167 def onCheckWithNullOptionalStringFeature(self, vulkanType): argument
168self.cgen.beginIf("%s & VULKAN_STREAM_FEATURE_NULL_OPTIONAL_STRINGS_BIT" % self.featureBitsVar)
169 self.onCheck(vulkanType)
171 def endCheckWithNullOptionalStringFeature(self, vulkanType): argument
172 self.endCheck(vulkanType)
173 self.cgen.endIf()
174 self.cgen.beginElse()
176 def finalCheckWithNullOptionalStringFeature(self, vulkanType): argument
177 self.cgen.endElse()
179 def endCheck(self, vulkanType): argument
181 if self.checked:
182 self.cgen.endIf()
183 self.checked = False
185 def genFilterFunc(self, filterfunc, env): argument
216 return self.getEnvAccessExpr(atomname)
225 return self.getPointerIndirectionLevels(atomname)
259 def beginFilterGuard(self, vulkanType): argument
263 if self.doFiltering == False:
266 filterVarAccess = self.getEnvAccessExpr(vulkanType.filterVar)
272 filterFeature = "%s & VULKAN_STREAM_FEATURE_IGNORED_HANDLES_BIT" % self.featureBitsVar
278 … filterFuncExpr = self.genFilterFunc(vulkanType.filterFunc, self.currentStructInfo.environment)
284 self.cgen.beginIf(filterVarAccess)
286 self.cgen.beginIf("(!(%s) || (%s))" % (filterFeature, filterValsExpr))
288 self.cgen.beginIf("(!(%s) || (%s))" % (filterFeature, filterFuncExpr))
290 def endFilterGuard(self, vulkanType, cleanupExpr=None): argument
294 if self.doFiltering == False:
298 self.cgen.endIf()
300 self.cgen.endIf()
301 self.cgen.beginElse()
302 self.cgen.stmt(cleanupExpr)
303 self.cgen.endElse()
305 def getEnvAccessExpr(self, varName): argument
306 parentEnvEntry = self.currentStructInfo.environment.get(varName, None)
312 …envAccess = self.exprValueAccessor(list(filter(lambda member: member.paramName == varName, self.cu…
319 def getPointerIndirectionLevels(self, varName): argument
320 parentEnvEntry = self.currentStructInfo.environment.get(varName, None)
326 …return list(filter(lambda member: member.paramName == varName, self.currentStructInfo.members))[0]…
334 def onCompoundType(self, vulkanType): argument
336 access = self.exprAccessor(vulkanType)
337 lenAccess = self.lenAccessor(vulkanType)
338 lenAccessGuard = self.lenAccessorGuard(vulkanType)
340 self.beginFilterGuard(vulkanType)
343 self.doAllocSpace(vulkanType)
347 self.cgen.beginIf(lenAccessGuard)
353 self.cgen.beginFor(forInit, forCond, forIncr)
355 accessWithCast = "%s(%s)" % (self.makeCastExpr(
356 self.getTypeForStreaming(vulkanType)), access)
358 callParams = [self.featureBitsVar,
359 self.rootTypeVar, accessWithCast, self.countVar]
362 callParams.append(self.getEnvAccessExpr(localName))
364 self.cgen.funcCall(None, self.prefix + vulkanType.typeName,
368 self.cgen.endFor()
370 self.cgen.endIf()
372 self.endFilterGuard(vulkanType)
374 def onString(self, vulkanType): argument
375 access = self.exprAccessor(vulkanType)
376 self.genCount("sizeof(uint32_t) + (%s ? strlen(%s) : 0)" % (access, access))
378 def onStringArray(self, vulkanType): argument
379 access = self.exprAccessor(vulkanType)
380 lenAccess = self.lenAccessor(vulkanType)
381 lenAccessGuard = self.lenAccessorGuard(vulkanType)
383 self.genCount("sizeof(uint32_t)")
385 self.cgen.beginIf(lenAccessGuard)
386 self.cgen.beginFor("uint32_t i = 0", "i < %s" % lenAccess, "++i")
387 self.cgen.stmt("size_t l = %s[i] ? strlen(%s[i]) : 0" % (access, access))
388 self.genCount("sizeof(uint32_t) + (%s[i] ? strlen(%s[i]) : 0)" % (access, access))
389 self.cgen.endFor()
391 self.cgen.endIf()
393 def onStaticArr(self, vulkanType): argument
394 access = self.exprValueAccessor(vulkanType)
395 lenAccess = self.lenAccessor(vulkanType)
396 lenAccessGuard = self.lenAccessorGuard(vulkanType)
399 self.cgen.beginIf(lenAccessGuard)
400 finalLenExpr = "%s * %s" % (lenAccess, self.cgen.sizeofExpr(vulkanType))
402 self.cgen.endIf()
403 self.genCount(finalLenExpr)
405 def onStructExtension(self, vulkanType): argument
409 access = self.exprAccessor(vulkanType)
414 sTypeAccess = self.exprAccessor(sTypeParam)
415 self.cgen.beginIf("%s == VK_STRUCTURE_TYPE_MAX_ENUM" %
416 self.rootTypeVar)
417 self.cgen.stmt("%s = %s" % (self.rootTypeVar, sTypeAccess))
418 self.cgen.endIf()
420 self.cgen.funcCall(None, self.prefix + "extension_struct",
421 [self.featureBitsVar, self.rootTypeVar, castedAccessExpr, self.countVar])
424 def onPointer(self, vulkanType): argument
425 access = self.exprAccessor(vulkanType)
427 lenAccess = self.lenAccessor(vulkanType)
428 lenAccessGuard = self.lenAccessorGuard(vulkanType)
430 self.beginFilterGuard(vulkanType)
431 self.doAllocSpace(vulkanType)
436 if vulkanType.isHandleType() and self.mapHandles:
437 self.genHandleMappingCall(vulkanType, access, lenAccess)
439 if self.typeInfo.isNonAbiPortableType(vulkanType.typeName):
442 self.cgen.beginIf(lenAccessGuard)
443 self.cgen.beginFor("uint32_t i = 0", "i < (uint32_t)%s" % lenAccess, "++i")
444 self.genPrimitiveStreamCall(vulkanType.getForValueAccess())
445 self.cgen.endFor()
447 self.cgen.endIf()
449 self.genPrimitiveStreamCall(vulkanType.getForValueAccess())
454 lenAccess, self.cgen.sizeofExpr(vulkanType.getForValueAccess()))
458 self.cgen.sizeofExpr(vulkanType.getForValueAccess()))
460 self.cgen.beginIf(lenAccessGuard)
461 self.genCount(finalLenExpr)
463 self.cgen.endIf()
465 self.endFilterGuard(vulkanType)
467 def onValue(self, vulkanType): argument
468 self.beginFilterGuard(vulkanType)
470 if vulkanType.isHandleType() and self.mapHandles:
471 access = self.exprAccessor(vulkanType)
474 self.genHandleMappingCall(
476 elif self.typeInfo.isNonAbiPortableType(vulkanType.typeName):
477 access = self.exprPrimitiveValueAccessor(vulkanType)
478 self.genPrimitiveStreamCall(vulkanType)
480 access = self.exprAccessor(vulkanType)
481 self.genCount(self.cgen.sizeofExpr(vulkanType))
483 self.endFilterGuard(vulkanType)
485 def streamLetParameter(self, structInfo, letParamInfo): argument
486 filterFeature = "%s & VULKAN_STREAM_FEATURE_IGNORED_HANDLES_BIT" % (self.featureBitsVar)
487 self.cgen.stmt("%s %s = 1" % (letParamInfo.typeName, letParamInfo.paramName))
489 self.cgen.beginIf(filterFeature)
491 bodyExpr = self.currentStructInfo.environment[letParamInfo.paramName]["body"]
492self.cgen.stmt("%s = %s" % (letParamInfo.paramName, self.genFilterFunc(bodyExpr, self.currentStruc…
494 self.genPrimitiveStreamCall(letParamInfo)
496 self.cgen.endIf()
500 def __init__(self, module, typeInfo): argument
501 VulkanWrapperGenerator.__init__(self, module, typeInfo)
503 self.codegen = CodeGen()
505 self.featureBitsVar = "featureBits"
506 self.featureBitsVarType = makeVulkanTypeSimple(False, "uint32_t", 0, self.featureBitsVar)
507 self.countingPrefix = "count_"
508 self.countVars = ["toCount", "count"]
509 self.countVarType = makeVulkanTypeSimple(False, "size_t", 1, self.countVars[1])
510 self.voidType = makeVulkanTypeSimple(False, "void", 0)
511 self.rootTypeVar = ROOT_TYPE_VAR_NAME
513 self.countingCodegen = \
515 self.codegen,
516 self.featureBitsVar,
517 self.countVars[0],
518 self.countVars[1],
519 self.rootTypeVar,
520 self.countingPrefix)
522 self.knownDefs = {}
524 self.extensionCountingPrototype = \
525 VulkanAPI(self.countingPrefix + "extension_struct",
526 self.voidType,
527 [self.featureBitsVarType,
530 self.countVarType])
532 def onBegin(self,): argument
533 VulkanWrapperGenerator.onBegin(self)
534 self.module.appendImpl(self.codegen.makeFuncDecl(
535 self.extensionCountingPrototype))
537 def onGenType(self, typeXml, name, alias): argument
538 VulkanWrapperGenerator.onGenType(self, typeXml, name, alias)
540 if name in self.knownDefs:
543 category = self.typeInfo.categoryOf(name)
547 self.module.appendHeader(
548 self.codegen.makeFuncAlias(self.countingPrefix + name,
549 self.countingPrefix + alias))
553 structInfo = self.typeInfo.structs[name]
570 [makeVulkanTypeSimple(False, "uint32_t", 0, self.featureBitsVar),
572 typeFromName(self.countVars[0]),
573 makeVulkanTypeSimple(False, "size_t", 1, self.countVars[1])]
576 VulkanAPI(self.countingPrefix + name,
577 self.voidType,
581 VulkanAPI(self.countingPrefix + name,
582 self.voidType,
586 self.countingCodegen.cgen = cgen
587 self.countingCodegen.currentStructInfo = structInfo
588 cgen.stmt("(void)%s" % self.featureBitsVar);
589 cgen.stmt("(void)%s" % self.rootTypeVar);
590 cgen.stmt("(void)%s" % self.countVars[0]);
591 cgen.stmt("(void)%s" % self.countVars[1]);
596 self.countingCodegen.streamLetParameter(self.typeInfo, letp)
599 iterateVulkanType(self.typeInfo, member, self.countingCodegen)
601 iterateVulkanType(self.typeInfo, structInfo.members[0], self.countingCodegen)
604 self.countingCodegen.cgen = cgen
605 self.countingCodegen.currentStructInfo = structInfo
606 self.countingCodegen.doFiltering = False
607 cgen.stmt("(void)%s" % self.featureBitsVar);
608 cgen.stmt("(void)%s" % self.rootTypeVar);
609 cgen.stmt("(void)%s" % self.countVars[0]);
610 cgen.stmt("(void)%s" % self.countVars[1]);
615 self.countingCodegen.streamLetParameter(self.typeInfo, letp)
618 iterateVulkanType(self.typeInfo, member, self.countingCodegen)
620 iterateVulkanType(self.typeInfo, structInfo.members[0], self.countingCodegen)
622 self.countingCodegen.doFiltering = True
624 self.module.appendHeader(
625 self.codegen.makeFuncDecl(countingPrototype))
626 self.module.appendImpl(
627 self.codegen.makeFuncImpl(countingPrototype, structCountingDef))
630 self.module.appendHeader(
631 self.cgenHeader.makeFuncDecl(countingPrototypeNoFilter))
632 self.module.appendImpl(
633 self.cgenImpl.makeFuncImpl(
636 def onGenCmd(self, cmdinfo, name, alias): argument
637 VulkanWrapperGenerator.onGenCmd(self, cmdinfo, name, alias)
639 def doExtensionStructCountCodegen(self, cgen, extParam, forEach, funcproto): argument
644self.featureBitsVar, ROOT_TYPE_VAR_NAME, extParam.paramName))
650self.featureBitsVar, ROOT_TYPE_VAR_NAME, "(void*)%s->pNext" % accessVar, self.countVars[1]])
658 cgen.stmt("*%s += sizeof(uint32_t)" % self.countVars[1])
667 cgen.stmt("*%s += sizeof(VkStructureType)" % self.countVars[1])
674 self.emitForEachStructExtension(
682 def onEnd(self,): argument
683 VulkanWrapperGenerator.onEnd(self)
686 cgen.funcCall(None, self.countingPrefix + ext.name,
687 [self.featureBitsVar, self.rootTypeVar, castedAccess, self.countVars[1]])
689 self.module.appendImpl(
690 self.codegen.makeFuncImpl(
691 self.extensionCountingPrototype,
692 lambda cgen: self.doExtensionStructCountCodegen(
696 self.extensionCountingPrototype)))