mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 21:02:50 +00:00
c1b85a3db7
This allows the likes of: qfv_pushconstantrangeinfo_s = { .name = qfv_pushconstantrangeinfo_t; .type = (QFDictionary); .dictionary = { .parse = { type = (labeledarray, qfv_pushconstantinfo_t, name); size = num_pushconstants; values = pushconstants; }; stageFlags = $name.auto; }; stageFlags = auto; }; Leading to: pushConstants = { vertex = { Model = mat4; blend = float; }; fragment = { colors = uint; base_color = vec4; fog = vec4; }; }; Where the label of the labeled array (which pushConstants is) is actually an enum flag and the dictionary value is another labeled array.
52 lines
1.3 KiB
R
52 lines
1.3 KiB
R
#include <PropertyList.h>
|
|
|
|
#include "vkfieldlabeledarray.h"
|
|
#include "vkfieldtype.h"
|
|
#include "vkgen.h"
|
|
#include "vkstruct.h"
|
|
#include "vktype.h"
|
|
|
|
@implementation LabeledArrayField
|
|
|
|
-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"];
|
|
string label_field = [[desc getObjectAtIndex:2] string];
|
|
Type *t = [[Type lookup:[type type]] resolveType];
|
|
if ([t isKindOfClass:[Struct class]]) {
|
|
Struct *s = (Struct *) t;
|
|
[s setLabelField:label_field];
|
|
}
|
|
|
|
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 = QFDictionary,\n");
|
|
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_labeledarray (&%s_field, item, "
|
|
"data, messages, context)) {\n", field_name);
|
|
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",
|
|
field_name, "QFDictionary", "labeledarray", struct_name,
|
|
field_name);
|
|
return self;
|
|
}
|
|
|
|
@end
|