0
0
Fork 0
mirror of https://git.code.sf.net/p/quake/quakeforge synced 2024-12-19 00:51:51 +00:00
quakeforge/libs/video/renderer/vulkan/vkgen/vkfieldsingle.r
Bill Currie a6a3d4c6b5 [vulkan] Make array and single parsing smarter
Array and single type overrides now allow the parsing of the items
themselves to be customized. This makes it easy to handle arrays and
pointers to single items while also using custom specifications, rather
than relying entirely on the custom override.
2021-01-04 15:30:27 +09:00

43 lines
987 B
R

#include <PropertyList.h>
#include "vkfieldsingle.h"
#include "vkfieldtype.h"
#include "vkgen.h"
#include "vktype.h"
@implementation SingleField
-init:(PLItem *) item struct:(Struct *)strct field:(string)fname
{
self = [super init:item struct:strct field:fname];
if (!self) {
return self;
}
PLItem *desc = [item getObjectForKey:"type"];
type = [[FieldType fieldType:[desc getObjectAtIndex:1]] retain];
value_field = [[item getObjectForKey:"value"] string];
return self;
}
-writeParseData
{
fprintf (output_file, "static parse_single_t parse_%s_%s_data = {\n",
struct_name, field_name);
[type writeParseData];
fprintf (output_file, "\tfield_offset (%s, %s),\n",
struct_name, value_field);
fprintf (output_file, "};\n");
return self;
}
-writeField
{
string parse_type = [type parseType];
fprintf (output_file, "\t{\"%s\", 0, %s, parse_%s, &parse_%s_%s_data},\n",
field_name, parse_type, "single", struct_name, field_name);
return self;
}
@end