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

Method check_param

scripts/xml_consistency.py:367–423  ·  view source on GitHub ↗

Check a member of a struct or a param of a function. Called from check_params.

(self, param)

Source from the content-addressed store, hash-verified

365 self.record_error(message)
366
367 def check_param(self, param):
368 """Check a member of a struct or a param of a function.
369
370 Called from check_params."""
371 super().check_param(param)
372
373 param_text = ''.join(param.itertext())
374 param_name = getElemName(param)
375 param_type = param.find('type').text
376
377 # Make sure parameter/member name and type name do not collide (pub2679)
378 if param_name == param_type:
379 message = f'{self.entity}.{param_name} member/parameter has an identical type name {param_type}, which is not allowed. Removing window system prefixes from the member/parameter is the most common fix.'
380 self.record_error(message, elem=param)
381
382 # The name match error above can happen with external types
383 if not self.is_api_type(param):
384 return
385
386 # Make sure the number of leading 'p' matches the pointer count.
387 pointercount = param.find('type').tail
388 if pointercount:
389 pointercount = pointercount.count('*')
390 if pointercount:
391 prefix = 'p' * pointercount
392 if not param_name.startswith(prefix):
393 message = "Apparently incorrect pointer-related name prefix for {} - expected it to start with '{}'".format(
394 param_text, prefix)
395 if (self.entity, param_type, param_name) in CHECK_PARAM_POINTER_NAME_EXCEPTIONS:
396 self.record_warning('(Allowed exception)', message, elem=param)
397 else:
398 self.record_error(message, elem=param)
399
400 # Make sure no members have optional="false" attributes
401 optional = param.get('optional')
402 if optional == 'false':
403 message = f'{self.entity}.{param_name} member has disallowed \'optional="false"\' attribute (remove this attribute)'
404 self.record_error(message, elem=param)
405
406 # Make sure members of VkQueue type do not have `externsync="true"` to account for
407 # VK_KHR_internally_synchronized_queues
408 if param_type == 'VkQueue':
409 externsync = param.get('externsync')
410 if externsync and externsync == 'true':
411 message = f'{self.entity}.{param_name} member has disallowed \'externsync="true"\' attribute,\n\
412which conflicts with VK_KHR_internally_synchronized_queues. Use \'externsync="maybe"\''
413 self.record_error(message, elem=param)
414
415 # Make sure pNext members have optional="true" attributes
416 if param_name == self.conventions.nextpointer_member_name:
417 optional = param.get('optional')
418 if optional is None or optional != 'true':
419 message = f'{self.entity}.pNext member is missing \'optional="true"\' attribute'
420 if self.entity in CHECK_MEMBER_PNEXT_OPTIONAL_EXCEPTIONS:
421 self.record_warning('(Allowed exception)', message, elem=param)
422 else:
423 self.record_error(message, elem=param)
424

Callers

nothing calls this directly

Calls 5

getElemNameFunction · 0.90
record_errorMethod · 0.80
is_api_typeMethod · 0.80
record_warningMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected