MCPcopy Index your code
hub / github.com/KhronosGroup/Vulkan-Docs / protectLanguageC

Function protectLanguageC

scripts/parse_dependency.py:298–319  ·  view source on GitHub ↗

Return protect expression translated to a form suitable for use in C preprocessor conditionals (#if expressions). This wraps each identifier in defined() and converts operators: - '+' becomes '&&' (AND) - ',' becomes '||' (OR) Supports '!' prefix on identifiers fo

(protect)

Source from the content-addressed store, hash-verified

296 return dependencyLanguage(dependency, leafMarkup = leafMarkupC, opMarkup = opMarkupC, parenthesize = True)
297
298def protectLanguageC(protect):
299 """Return protect expression translated to a form suitable for
300 use in C preprocessor conditionals (#if expressions).
301
302 This wraps each identifier in defined() and converts operators:
303 - '+' becomes '&&' (AND)
304 - ',' becomes '||' (OR)
305 Supports '!' prefix on identifiers for NOT:
306 - '!A' becomes '!defined(A)'
307
308 Examples:
309 'VK_A,VK_B' -> 'defined(VK_A) || defined(VK_B)'
310 'VK_A+VK_B' -> 'defined(VK_A) && defined(VK_B)'
311 '(VK_A+VK_B),VK_C' -> '(defined(VK_A) && defined(VK_B)) || defined(VK_C)'
312 'VK_A+!VK_B' -> 'defined(VK_A) && !defined(VK_B)'
313
314 - protect - the protect expression string"""
315 global exprStack
316 exprStack = []
317 protectBNF().parse_string(protect, parse_all=True)
318 return evalDependencyLanguage(exprStack, leafMarkupCProtect, opMarkupC,
319 parenthesize=True, root=True, parent_op=None)
320
321def evalDependencyNames(stack):
322 """Evaluate an expression stack, returning the set of extension and

Callers 1

genProtectDirectiveFunction · 0.90

Calls 2

protectBNFFunction · 0.85
evalDependencyLanguageFunction · 0.85

Tested by

no test coverage detected