mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-12-12 05:31:59 +00:00
8271860fb3
I want to support reading VkPhysicalDeviceLimits but it has some arrays. While I don't need to parse them (VkPhysicalDeviceLimits should be treated as read-only), I do need to be able to access them in property list expressions, and vkgen generates the cexpr type descriptors too. However, I will probably want to parse arrays some time in the future.
92 lines
2 KiB
R
92 lines
2 KiB
R
#include <hash.h>
|
|
#include <qfile.h>
|
|
#include <runtime.h>
|
|
#include <string.h>
|
|
#include <types.h>
|
|
#include <Array.h>
|
|
#include <PropertyList.h>
|
|
|
|
#include "vkfielddef.h"
|
|
#include "vkgen.h"
|
|
#include "vkfixedarray.h"
|
|
|
|
@implementation FixedArray
|
|
|
|
-initWithType: (qfot_type_t *) type
|
|
{
|
|
if (!(self = [super initWithType: type])) {
|
|
return nil;
|
|
}
|
|
ele_type = [Type fromType: type.array.type];
|
|
ele_count = type.array.size;
|
|
return self;
|
|
}
|
|
|
|
-(string) name
|
|
{
|
|
return sprintf ("%s_array_%d", [ele_type name], ele_count);
|
|
}
|
|
|
|
-(void) addToQueue
|
|
{
|
|
string name = [self name];
|
|
if (!Hash_Find (processed_types, name)) {
|
|
//printf (" +%s\n", name);
|
|
Hash_Add (processed_types, (void *) name);
|
|
[queue addObject: self];
|
|
}
|
|
}
|
|
|
|
-(void) writeTable
|
|
{
|
|
fprintf (output_file, "static parse_fixed_array_t parse_%s_data = {\n",
|
|
[self name]);
|
|
fprintf (output_file, "\t%s,\n", [ele_type parseType]);
|
|
fprintf (output_file, "\tsizeof (%s),\n", [ele_type name]);
|
|
fprintf (output_file, "\t%s,\n", [ele_type parseFunc]);
|
|
fprintf (output_file, "\t%d,\n", ele_count);
|
|
fprintf (output_file, "};\n");
|
|
|
|
fprintf (output_file, "exprarray_t %s_array = {\n", [self name]);
|
|
fprintf (output_file, "\t&%s,\n", [ele_type cexprType]);
|
|
fprintf (output_file, "\t%d,\n", ele_count);
|
|
fprintf (output_file, "};\n");
|
|
fprintf (output_file, "exprtype_t %s_type = {\n", [self name]);
|
|
fprintf (output_file, "\t\"%s[%d]\",\n", [ele_type name], ele_count);
|
|
fprintf (output_file, "\t%d * sizeof (%s),\n", ele_count, [ele_type name]);
|
|
fprintf (output_file, "\tcexpr_array_binops,\n");
|
|
fprintf (output_file, "\t0,\n");
|
|
fprintf (output_file, "\t&%s_array,\n", [self name]);
|
|
fprintf (output_file, "};\n");
|
|
fprintf (output_file, "\n");
|
|
fprintf (header_file, "extern exprtype_t %s_type;\n", [self name]);
|
|
}
|
|
|
|
-(void) writeSymtabInit
|
|
{
|
|
}
|
|
|
|
-(void) writeSymtabEntry
|
|
{
|
|
}
|
|
|
|
-(string) cexprType
|
|
{
|
|
return [self name] + "_type";
|
|
}
|
|
|
|
-(string) parseType
|
|
{
|
|
return "QFMultiType | (1 << QFString) | (1 << QFArray)";
|
|
}
|
|
|
|
-(string) parseFunc
|
|
{
|
|
return "parse_fixed_array";
|
|
}
|
|
|
|
-(string) parseData
|
|
{
|
|
return "&parse_" + [self name] + "_data";;
|
|
}
|
|
@end
|