MCPcopy Create free account
hub / github.com/SaschaWillems/VulkanCapsViewer / TypeContainer

Class TypeContainer

tools/deviceExtensionsFileGenerator.php:27–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25 */
26
27 class TypeContainer
28{
29
30 public $property_types;
31 public $feature_types;
32 public $aliases;
33
34 private function getActualType($type, $xml)
35 {
36 if ($type['alias']) {
37 foreach ($xml->types->type as $alias_type) {
38 if ($alias_type['name'] && strcasecmp($alias_type['name'], $type['alias']) === 0) {
39 $this->aliases[(string)$type['name']] = $alias_type;
40 return $alias_type;
41 }
42 }
43 }
44 return $type;
45 }
46
47 function __construct($xml)
48 {
49 // We're only interested in types extending VkPhysicalDeviceProperties2 or VkPhysicalDeviceFeatures2
50 foreach ($xml->types->type as $type) {
51 $actual_type = $this->getActualType($type, $xml);
52 if (($actual_type['structextends']) && (strcasecmp($actual_type['structextends'], 'VkPhysicalDeviceProperties2') === 0)) {
53 $this->property_types[] = $actual_type;
54 }
55 if (($actual_type['structextends']) && (stripos($actual_type['structextends'], 'VkPhysicalDeviceFeatures2') !== false)) {
56 $this->feature_types[] = $actual_type;
57 }
58 }
59 }
60
61 /**
62 * Checks if the given type is aliased, and returns the type name to look for
63 */
64 private function getActualTypeName($type_name)
65 {
66 $actual_name = $type_name;
67 if ($this->aliases[(string)$type_name]) {
68 $actual_name = $this->aliases[(string)$type_name]['name'];
69 }
70 return $actual_name;
71 }
72
73 public function getProperties2Type($name)
74 {
75 $actual_name = $this->getActualTypeName($name);
76 foreach ($this->property_types as $property_type) {
77 if (strcasecmp($property_type['name'], $actual_name) === 0) {
78 return $property_type;
79 }
80 }
81 return null;
82 }
83
84 public function getFeatures2Type($name)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected