[vkgen] Clean up most of the generated header

I'll probably completely remove it as only vkparse.c includes it, but
this tidies things up a bit and even simplifies vkgen's loops a little.
This commit is contained in:
Bill Currie 2023-02-09 21:20:27 +09:00
parent 7aa5470c68
commit d34e6cffdf
8 changed files with 57 additions and 50 deletions

View file

@ -9,6 +9,7 @@
{
int prefix_length;
}
-(void) writeForward;
-(void) writeTable;
-(void) writeSymtabInit;
-(void) writeSymtabEntry;

View file

@ -83,6 +83,11 @@ skip_value(string name)
return !num_values;
}
-(void) writeForward
{
fprintf (output_file, "static exprenum_t %s_enum;\n", [self name]);
}
-(void) writeTable
{
int strip_bit = 0;
@ -123,7 +128,7 @@ skip_value(string name)
}
fprintf (output_file, "};\n");
}
fprintf (output_file, "exprsym_t %s_symbols[] = {\n", [self name]);
fprintf (output_file, "static exprsym_t %s_symbols[] = {\n", [self name]);
for (int i = 0, index = 0; i < type.strct.num_fields; i++) {
qfot_var_t *var = &type.strct.fields[i];
if (skip_value (var.name)) {
@ -151,10 +156,10 @@ skip_value(string name)
}
fprintf (output_file, "\t{ }\n");
fprintf (output_file, "};\n");
fprintf (output_file, "exprtab_t %s_symtab = {\n", [self name]);
fprintf (output_file, "static exprtab_t %s_symtab = {\n", [self name]);
fprintf (output_file, "\t%s_symbols,\n", [self name]);
fprintf (output_file, "};\n");
fprintf (output_file, "exprenum_t %s_enum = {\n", [self name]);
fprintf (output_file, "static exprenum_t %s_enum = {\n", [self name]);
fprintf (output_file, "\t&%s_type,\n", [self name]);
fprintf (output_file, "\t&%s_symtab,\n", [self name]);
fprintf (output_file, "};\n");
@ -177,10 +182,7 @@ skip_value(string name)
" const plitem_t *item, void *data, plitem_t *messages,"
" void *context);\n",
[self name]);
fprintf (header_file, "extern exprenum_t %s_enum;\n", [self name]);
fprintf (header_file, "extern exprtype_t %s_type;\n", [self name]);
fprintf (header_file, "extern exprtab_t %s_symtab;\n", [self name]);
fprintf (header_file, "extern exprsym_t %s_symbols[];\n", [self name]);
}
-(void) writeSymtabInit

View file

@ -11,6 +11,7 @@
Type *ele_type;
int ele_count;
}
-(void) writeForward;
-(void) writeTable;
-(void) writeSymtabInit;
-(void) writeSymtabEntry;

View file

@ -37,6 +37,10 @@
}
}
-(void) writeForward
{
}
-(void) writeTable
{
fprintf (output_file, "static parse_fixed_array_t parse_%s_data = {\n",

View file

@ -223,12 +223,9 @@ main(int argc, string *argv)
if ([obj name] == "VkStructureType") {
continue;
}
if ([obj class] != [Enum class]) {
continue;
}
arp_start ();
[obj writeTable];
[obj writeForward];
arp_end ();
}
for (int i = [output_types count]; i-- > 0; ) {
@ -236,22 +233,6 @@ main(int argc, string *argv)
if ([obj name] == "VkStructureType") {
continue;
}
if ([obj class] != [FixedArray class]) {
continue;
}
arp_start ();
[obj writeTable];
arp_end ();
}
for (int i = [output_types count]; i-- > 0; ) {
id obj = [output_types objectAtIndex:i];
if ([obj name] == "VkStructureType") {
continue;
}
if ([obj class] != [Struct class]) {
continue;
}
arp_start ();
[obj writeTable];

View file

@ -15,6 +15,7 @@
}
-(void) queueFieldTypes;
-(qfot_var_t *)findField:(string) fieldName;
-(void) writeForward;
-(void) writeTable;
-(void) writeSymtabInit;
-(void) writeSymtabEntry;

View file

@ -31,6 +31,11 @@
{
qfot_struct_t *strct =&type.strct;
PLItem *field_dict = [parse getObjectForKey:[self name]];
int readonly = [field_dict string] == "readonly";
if (readonly) {
return;
}
for (int i = 0; i < strct.num_fields; i++) {
qfot_var_t *var = &strct.fields[i];
@ -78,6 +83,18 @@
return str_upper (s);
}
-(void) writeForward
{
PLItem *field_dict = [parse getObjectForKey:[self name]];
int readonly = [field_dict string] == "readonly";
if (!readonly) {
fprintf (output_file, "static int %s (const plfield_t *field,"
" const plitem_t *item, void *data, plitem_t *messages,"
" void *context);\n",
[self parseFunc]);
}
}
-(void) writeTable
{
PLItem *field_dict = [parse getObjectForKey:[self name]];
@ -85,6 +102,7 @@
Array *field_defs = [Array array];
int have_sType = 0;
int have_pNext = 0;
int readonly = [field_dict string] == "readonly";
if ([parse string] == "skip") {
return;
@ -138,6 +156,7 @@
FieldDef *field_def = [field_defs objectAtIndex:i];
[field_def writeParseData];
}
if (!readonly) {
fprintf (output_file, "static plfield_t %s_fields[] = {\n", [self outname]);
fprintf (output_file,
"\t{\"@inherit\", 0, QFString, parse_inherit, &%s_fields},\n",
@ -154,11 +173,7 @@
fprintf (output_file, "\t{ }\n");
fprintf (output_file, "};\n");
fprintf (header_file, "int %s (const plfield_t *field,"
" const plitem_t *item, void *data, plitem_t *messages,"
" void *context);\n",
[self parseFunc]);
fprintf (output_file, "int %s (const plfield_t *field,"
fprintf (output_file, "static int %s (const plfield_t *field,"
" const plitem_t *item, void *data, plitem_t *messages,"
" void *context)\n",
[self parseFunc]);
@ -182,6 +197,7 @@
fprintf (output_file, "{\"%s\", %s, sizeof(%s)};\n",
[self outname], [self parseFunc], [self outname]);
}
}
fprintf (output_file, "static exprsym_t %s_symbols[] = {\n", [self outname]);
if (field_defs) {

View file

@ -74,6 +74,7 @@
values = pPreserveAttachments;
};
};
VkPhysicalDeviceLimits = readonly;
VkRenderPassCreateInfo = {
//flags = auto; reserved for future use (Bits enum does not exist)
attachments = {