Function loading is working again and now handles collections of requirements. Only header gen is left.

This commit is contained in:
Cody Goodson 2021-05-19 20:15:29 -05:00 committed by Charles Giessen
parent 88358fb9cf
commit ae402c6a19

View File

@ -38,6 +38,7 @@ exclusions = [
import sys import sys
import subprocess import subprocess
import pkg_resources import pkg_resources
import copy
installed = {pkg.key for pkg in pkg_resources.working_set} installed = {pkg.key for pkg in pkg_resources.working_set}
xmltodict_missing = {'xmltodict'} - installed xmltodict_missing = {'xmltodict'} - installed
@ -54,8 +55,7 @@ with urllib.request.urlopen('https://raw.githubusercontent.com/KhronosGroup/Vulk
vk_xml = xmltodict.parse(vk_xml_raw,process_namespaces=True) vk_xml = xmltodict.parse(vk_xml_raw,process_namespaces=True)
criteria = { 'extension': '', 'feature': 'VK_VERSION_1_0' } command_params = { 'return_type': '', 'args': [], 'requirements': []}
command_params = {'return_type': '', 'args': [], 'criterias': []}
device_commands = {} device_commands = {}
core_commands = {} core_commands = {}
@ -67,7 +67,7 @@ aliases = {}
for command_node in commands_node: for command_node in commands_node:
if 'proto' in command_node: if 'proto' in command_node:
command_name = command_node['proto']['name'] command_name = command_node['proto']['name']
new_command_params = command_params.copy() new_command_params = copy.deepcopy(command_params)
new_command_params['return_type'] = command_node['proto']['type'] new_command_params['return_type'] = command_node['proto']['type']
if type(command_node['param']) is list: if type(command_node['param']) is list:
new_command_params['args'] = command_node['param'] new_command_params['args'] = command_node['param']
@ -85,7 +85,7 @@ for alias in aliases:
aliased_command_params = device_commands[alias].copy() aliased_command_params = device_commands[alias].copy()
device_commands[aliases[alias]] = aliased_command_params; device_commands[aliases[alias]] = aliased_command_params;
# Add criterias for core device pfns # Add requirements for core PFN's
features_node = vk_xml['registry']['feature'] features_node = vk_xml['registry']['feature']
for feature_node in features_node: for feature_node in features_node:
for require_node in feature_node['require']: for require_node in feature_node['require']:
@ -94,67 +94,42 @@ for feature_node in features_node:
if type(require_node[param_node]) is list: if type(require_node[param_node]) is list:
for param in require_node[param_node]: for param in require_node[param_node]:
if param['@name'] in device_commands: if param['@name'] in device_commands:
new_criteria = criteria.copy() device_commands[param['@name']]['requirements'] += [[feature_node['@name']]]
new_criteria['feature'] = feature_node['@name']
device_commands[param['@name']]['criterias'] += [new_criteria]
# Add requirements for extension PFN's
extensions_node = vk_xml['registry']['extensions']['extension'] extensions_node = vk_xml['registry']['extensions']['extension']
for extension_node in extensions_node: for extension_node in extensions_node:
extension_name = extension_node['@name'] extension_name = extension_node['@name']
new_criteria = criteria.copy() if 'require' in extension_node.keys():
new_criteria['extension'] = extension_name require_nodes = extension_node['require']
new_criteria['feature'] = 'VK_VERSION_1_0' for require_node in require_nodes:
if 'require' in extension_node: requirements = [extension_name];
for require_node in extension_node['require']: if type(require_node) is not str:
if '@feature' in extension_node['require']: if 'command' in require_node.keys():
print('aye') if '@feature' in require_node.keys():
new_criteria['feature'] = extension_node['require']['@feature'] requirements.append(require_node['@feature'])
#print(extension_node['require']['command']) if '@extension' in require_node.keys():
# for command_node in extension_node['require']['command']: requirements.append(require_node['@extension'])
# for command_name in command_node['name']: if type(require_node['command']) is not list:
# print(command_name) if require_node['command']['@name'] in device_commands:
device_commands[require_node['command']['@name']]['requirements'] += [requirements]
else:
for command_node in require_node['command']:
if command_node['@name'] in device_commands:
device_commands[command_node['@name']]['requirements'] += [requirements]
elif require_node == 'command':
if type(require_nodes['command']) is not list:
if require_nodes['command']['@name'] in device_commands:
device_commands[require_nodes['command']['@name']]['requirements'] += [requirements]
else:
for command_node in require_nodes['command']:
if command_node['@name'] in device_commands:
device_commands[command_node['@name']]['requirements'] += [requirements]
# Gather extension functions # Test
#extensions = vk_xml['registry']['extensions']['extension'] for a in device_commands:
#for extension in extensions: print(device_commands[a])
# extension_name = extension['@name']
# extension_commands[(extension_name, 'VK_VERSION_1_0')] = []
# for key in extension.keys():
# if key == 'require':
# requires = [extension[key]]
# for required in requires:
# if type(required) is list:
# for n_required in required:
# if '@feature' in n_required and 'command' in n_required:
# extension_commands[(extension_name, n_required['@feature'])] = []
# commands = [n_required['command']]
# for command in commands:
# if type(command) is list:
# for n_command in command:
# if n_command['@name'] in device_commands:
# extension_commands[(extension_name, n_required['@feature'])] += [n_command['@name']]
# elif command['@name'] in device_commands:
# extension_commands[(extension_name, n_required['@feature'])] += [command['@name']]
# elif 'command' in n_required:
# commands = [n_required['command']]
# for command in commands:
# if type(command) is list:
# for n_command in command:
# if n_command['@name'] in device_commands:
# extension_commands[(extension_name, 'VK_VERSION_1_0')] += [n_command['@name']]
# elif command['@name'] in device_commands:
# extension_commands[(extension_name, 'VK_VERSION_1_0')] += [command['@name']]
# elif 'command' in required:
# commands = [required['command']]
# for command in commands:
# if type(command) is list:
# for n_command in command:
# if n_command['@name'] in device_commands:
# extension_commands[(extension_name, 'VK_VERSION_1_0')] += [n_command['@name']]
# elif command['@name'] in device_commands:
# extension_commands[(extension_name, 'VK_VERSION_1_0')] += [command['@name']]
#
# Build header
# License # License
# header = '/* \n' # header = '/* \n'