2020-07-03 16:40:02 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "vkalias.h"
|
|
|
|
#include "vkenum.h"
|
|
|
|
#include "vkgen.h"
|
|
|
|
#include "vkstruct.h"
|
|
|
|
|
|
|
|
@implementation Alias
|
|
|
|
-(string) name
|
|
|
|
{
|
|
|
|
return type.alias.name;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(Type *) resolveType
|
|
|
|
{
|
|
|
|
return [Type findType: type.alias.aux_type];
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)addToQueue
|
|
|
|
{
|
|
|
|
Type *alias = [Type findType:type.alias.full_type];
|
|
|
|
string name = [self name];
|
|
|
|
|
|
|
|
if ([alias name] == "VkFlags") {
|
|
|
|
if (str_mid (name, -5) == "Flags") {
|
|
|
|
string tag = str_mid (name, 0, -1) + "Bits";
|
|
|
|
id enumObj = [(id) Hash_Find (available_types, tag) resolveType];
|
|
|
|
[enumObj addToQueue];
|
|
|
|
}
|
|
|
|
} else if (name == "VkBool32") {
|
2021-01-12 04:07:51 +00:00
|
|
|
id enumObj = [(id) Hash_Find (available_types, name) resolveType];
|
|
|
|
[enumObj addToQueue];
|
2020-07-03 16:40:02 +00:00
|
|
|
} else if ([alias class] == [Enum class]
|
|
|
|
|| [alias class] == [Struct class]) {
|
|
|
|
[alias addToQueue];
|
|
|
|
} else if (alias.type.meta == ty_basic && alias.type.type == ev_pointer) {
|
|
|
|
Type *type = [Type findType:alias.type.fldptr.aux_type];
|
|
|
|
if (!type) {
|
2021-01-12 04:07:51 +00:00
|
|
|
// pointer to opaque struct. Probably
|
|
|
|
// VK_DEFINE_NON_DISPATCHABLE_HANDLE or VK_DEFINE_HANDLE
|
2020-07-03 16:40:02 +00:00
|
|
|
string createInfo = name + "CreateInfo";
|
|
|
|
id structObj = (id) Hash_Find (available_types, createInfo);
|
|
|
|
if (structObj) {
|
|
|
|
[structObj addToQueue];
|
|
|
|
}
|
|
|
|
} else if ([type class] == [Alias class]) {
|
|
|
|
type = [type resolveType];
|
|
|
|
if ([type class] == [Struct class]) {
|
|
|
|
[type addToQueue];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-07-05 05:59:56 +00:00
|
|
|
|
2020-12-21 09:38:31 +00:00
|
|
|
-(string) cexprType
|
|
|
|
{
|
|
|
|
Type *alias = [Type findType:type.alias.full_type];
|
|
|
|
string name = [self name];
|
|
|
|
|
|
|
|
if ([alias name] == "VkFlags") {
|
|
|
|
if (str_mid (name, -5) == "Flags") {
|
|
|
|
string tag = str_mid (name, 0, -1) + "Bits";
|
|
|
|
id enumObj = [(id) Hash_Find (available_types, tag) resolveType];
|
|
|
|
return [enumObj cexprType];
|
|
|
|
}
|
|
|
|
}
|
2021-01-12 04:07:51 +00:00
|
|
|
if (name == "VkBool32") {
|
|
|
|
id enumObj = [(id) Hash_Find (available_types, name) resolveType];
|
|
|
|
return [enumObj cexprType];
|
|
|
|
}
|
2020-12-21 09:38:31 +00:00
|
|
|
if (name == "uint32_t") {
|
|
|
|
return "cexpr_uint";
|
|
|
|
}
|
2020-12-23 05:06:20 +00:00
|
|
|
if (name == "size_t") {
|
|
|
|
return "cexpr_size_t";
|
|
|
|
}
|
2020-12-21 09:38:31 +00:00
|
|
|
return [alias cexprType];
|
|
|
|
}
|
|
|
|
|
2020-07-05 05:59:56 +00:00
|
|
|
-(string) parseType
|
|
|
|
{
|
|
|
|
Type *alias = [Type findType:type.alias.full_type];
|
|
|
|
string name = [self name];
|
|
|
|
|
|
|
|
if ([alias name] == "VkFlags") {
|
|
|
|
if (str_mid (name, -5) == "Flags") {
|
|
|
|
string tag = str_mid (name, 0, -1) + "Bits";
|
|
|
|
id enumObj = [(id) Hash_Find (available_types, tag) resolveType];
|
|
|
|
return [enumObj parseType];
|
|
|
|
}
|
|
|
|
}
|
2021-01-12 04:07:51 +00:00
|
|
|
if (name == "VkBool32") {
|
|
|
|
id enumObj = [(id) Hash_Find (available_types, name) resolveType];
|
|
|
|
return [enumObj parseType];
|
|
|
|
}
|
2020-12-23 05:06:20 +00:00
|
|
|
if (name == "uint32_t" || name == "size_t") {
|
2020-07-05 05:59:56 +00:00
|
|
|
return "QFString";
|
|
|
|
}
|
|
|
|
return [alias parseType];
|
|
|
|
}
|
|
|
|
|
|
|
|
-(string) parseFunc
|
|
|
|
{
|
|
|
|
Type *alias = [Type findType:type.alias.full_type];
|
|
|
|
string name = [self name];
|
|
|
|
|
|
|
|
if ([alias name] == "VkFlags") {
|
|
|
|
if (str_mid (name, -5) == "Flags") {
|
|
|
|
string tag = str_mid (name, 0, -1) + "Bits";
|
|
|
|
id enumObj = [(id) Hash_Find (available_types, tag) resolveType];
|
|
|
|
return [enumObj parseFunc];
|
|
|
|
}
|
|
|
|
}
|
2021-01-12 04:07:51 +00:00
|
|
|
if (name == "VkBool32") {
|
|
|
|
id enumObj = [(id) Hash_Find (available_types, name) resolveType];
|
|
|
|
return [enumObj parseFunc];
|
|
|
|
}
|
2020-07-05 05:59:56 +00:00
|
|
|
if (name == "uint32_t") {
|
|
|
|
return "parse_uint32_t";
|
|
|
|
}
|
|
|
|
return [alias parseFunc];
|
|
|
|
}
|
|
|
|
|
|
|
|
-(string) parseData
|
|
|
|
{
|
|
|
|
Type *alias = [Type findType:type.alias.full_type];
|
|
|
|
string name = [self name];
|
|
|
|
|
|
|
|
if ([alias name] == "VkFlags") {
|
|
|
|
if (str_mid (name, -5) == "Flags") {
|
|
|
|
string tag = str_mid (name, 0, -1) + "Bits";
|
|
|
|
id enumObj = [(id) Hash_Find (available_types, tag) resolveType];
|
|
|
|
return [enumObj parseData];
|
|
|
|
}
|
|
|
|
}
|
2021-01-12 04:07:51 +00:00
|
|
|
if (name == "VkBool32") {
|
|
|
|
id enumObj = [(id) Hash_Find (available_types, name) resolveType];
|
|
|
|
return [enumObj parseData];
|
|
|
|
}
|
2021-01-23 11:39:09 +00:00
|
|
|
if (name == "uint32_t") {
|
2020-07-05 05:59:56 +00:00
|
|
|
return "0";
|
|
|
|
}
|
2021-01-23 11:39:09 +00:00
|
|
|
if (name == "size_t") {
|
|
|
|
return "&cexpr_size_t";
|
|
|
|
}
|
2020-07-05 05:59:56 +00:00
|
|
|
return [alias parseData];
|
|
|
|
}
|
2020-07-03 16:40:02 +00:00
|
|
|
@end
|