mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
[vkgen] Support custom parsers for .parse blocks
This let me keep clearValue's simple default rgba float interpretation, but also have full control over access to the float32, int32 and uint32 fields.
This commit is contained in:
parent
2b2398b193
commit
4adb7dfbd1
3 changed files with 41 additions and 10 deletions
|
@ -31,14 +31,18 @@
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
static void
|
||||
write_parse_data (CustomField *self, string indent)
|
||||
{
|
||||
}
|
||||
|
||||
-writeParseData
|
||||
{
|
||||
fprintf (output_file, "static size_t parse_%s_%s_offsets[] = {\n",
|
||||
struct_name, field_name);
|
||||
for (int i = 0, count = [fields count]; i < count; i++) {
|
||||
string field = [[fields getObjectAtIndex:i] string];
|
||||
fprintf (output_file, "\tfield_offset (%s, %s),\n",
|
||||
struct_name, field);
|
||||
fprintf (output_file, "\tfield_offset (%s, %s),\n", struct_name, field);
|
||||
}
|
||||
fprintf (output_file, "};\n");
|
||||
|
||||
|
@ -52,6 +56,20 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
-writeParse
|
||||
{
|
||||
fprintf (output_file, "\t\tplfield_t %s_field = {\n", field_name);
|
||||
fprintf (output_file, "\t\t\t.name = \"%s\",\n", field_name);
|
||||
fprintf (output_file, "\t\t\t.type = %s,\n", pltype);
|
||||
fprintf (output_file, "\t\t\t.data = &parse_%s_%s_data,\n",
|
||||
struct_name, field_name);
|
||||
fprintf (output_file, "\t\t};\n");
|
||||
fprintf (output_file, "\t\tif (!parse_custom (&parse_field, item, data, messages, context)) {\n");
|
||||
fprintf (output_file, "\t\t\treturn 0;\n");
|
||||
fprintf (output_file, "\t\t}\n");
|
||||
return self;
|
||||
}
|
||||
|
||||
-writeField
|
||||
{
|
||||
fprintf (output_file, "\t{\"%s\", 0, %s, parse_%s, &parse_%s_%s_data},\n",
|
||||
|
|
|
@ -85,19 +85,20 @@
|
|||
|
||||
-writeParseData
|
||||
{
|
||||
fprintf (output_file, "undefined record type parse data: %d\n", line);
|
||||
fprintf (output_file, "%@ undefined record type parse data: %d\n",
|
||||
self, line);
|
||||
return self;
|
||||
}
|
||||
|
||||
-writeParse
|
||||
{
|
||||
fprintf (output_file, "undefined record type parse: %d\n", line);
|
||||
fprintf (output_file, "%@ undefined record type parse: %d\n", self, line);
|
||||
return self;
|
||||
}
|
||||
|
||||
-writeField
|
||||
{
|
||||
fprintf (output_file, "undefined record type field: %d\n", line);
|
||||
fprintf (output_file, "%@ undefined record type field: %d\n", self, line);
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ search = (
|
|||
VkPipelineColorBlendStateCreateInfo,
|
||||
VkPipelineDynamicStateCreateInfo,
|
||||
VkDescriptorSetLayoutBinding,
|
||||
VkClearColorValue,
|
||||
VkClearValue,
|
||||
VkPhysicalDeviceLimits,
|
||||
VkRenderPassMultiviewCreateInfo,
|
||||
|
@ -173,12 +174,23 @@ parse = {
|
|||
//flags = auto; reserved for future use (Bits enum does not exist)
|
||||
patchControlPoints = auto;
|
||||
};
|
||||
VkClearColorValue = skip;
|
||||
VkClearValue = {
|
||||
color = {
|
||||
type = (custom, QFString, parse_RGBA);
|
||||
fields = (color);
|
||||
VkClearColorValue = {
|
||||
.type = (QFString, QFDictionary);
|
||||
.string = {
|
||||
.parse = {
|
||||
type = (custom, QFString, parse_RGBA);
|
||||
fields = (float32);
|
||||
};
|
||||
};
|
||||
.dictionary = {
|
||||
.parse = auto;
|
||||
};
|
||||
float32 = auto;
|
||||
int32 = auto;
|
||||
uint32 = auto;
|
||||
};
|
||||
VkClearValue = {
|
||||
color = auto;
|
||||
depthStencil = auto;
|
||||
};
|
||||
VkRenderPassMultiviewCreateInfo = {
|
||||
|
|
Loading…
Reference in a new issue