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

Function mergeInternalFeatures

scripts/reg.py:171–271  ·  view source on GitHub ↗

Merge internal API features (apitype='internal') into their public dependents. This processes the tree to find features marked with apitype='internal' and merges their , , and blocks into the first public feature that depends on them. After merging, the inte

(tree, apiName)

Source from the content-addressed store, hash-verified

169
170
171def mergeInternalFeatures(tree, apiName):
172 """Merge internal API features (apitype='internal') into their public dependents.
173
174 This processes the tree to find features marked with apitype='internal' and merges
175 their <require>, <deprecate>, and <remove> blocks into the first public feature
176 that depends on them. After merging, the internal features are removed from the tree.
177
178 tree - Element at the root of the hierarchy (typically <registry>)
179 apiName - the API name to process (e.g., 'vulkan', 'vulkansc')
180 """
181 import copy
182
183 # Find all features in the tree
184 features = tree.findall('feature')
185
186 # Separate internal and public features
187 internal_features = []
188 public_features = []
189
190 for feature in features:
191 api = feature.get('api', '')
192 apitype = feature.get('apitype', '')
193
194 # Only process features matching the target API
195 if apiName not in api.split(','):
196 continue
197
198 if apitype == 'internal':
199 internal_features.append(feature)
200 else:
201 public_features.append(feature)
202
203 # Build a simple dependency map from the 'depends' attributes
204 def get_dependencies(feature):
205 """Extract all dependencies from a feature's depends attribute."""
206 depends = feature.get('depends', '')
207 if not depends:
208 return set()
209 # Parse the depends expression - for simplicity, extract feature names
210 # Dependencies can be like "VK_VERSION_1_0" or "VK_VERSION_1_0+VK_KHR_feature"
211 deps = set()
212 # Split on + and , to get individual dependencies
213 for dep in depends.replace('+', ',').split(','):
214 dep = dep.strip()
215 if dep:
216 deps.add(dep)
217 return deps
218
219 def has_dependency(feature, target_name, all_features_map, visited=None):
220 """Check if feature depends on target_name (directly or transitively)."""
221 if visited is None:
222 visited = set()
223
224 feature_name = feature.get('name')
225 if feature_name in visited:
226 return False
227 visited.add(feature_name)
228

Callers 1

parseTreeMethod · 0.85

Calls 3

has_dependencyFunction · 0.85
appendMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected