2020-12-23 16:36:17 +00:00
|
|
|
#include <PropertyList.h>
|
2021-01-04 10:28:27 +00:00
|
|
|
#include <string.h>
|
2020-12-23 16:36:17 +00:00
|
|
|
|
|
|
|
#include "vkfieldcustom.h"
|
2021-01-05 14:42:30 +00:00
|
|
|
#include "vkfieldtype.h"
|
2020-12-23 16:36:17 +00:00
|
|
|
#include "vkgen.h"
|
|
|
|
#include "vktype.h"
|
|
|
|
|
|
|
|
@implementation CustomField
|
|
|
|
|
|
|
|
-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"];
|
2021-01-05 14:42:30 +00:00
|
|
|
pltype = str_hold (parseItemType ([desc getObjectAtIndex:1]));
|
2021-01-04 10:28:27 +00:00
|
|
|
parser = str_hold ([[desc getObjectAtIndex:2] string]);
|
2020-12-23 16:36:17 +00:00
|
|
|
|
|
|
|
fields = [item getObjectForKey:"fields"];
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2021-01-04 10:28:27 +00:00
|
|
|
-(void)dealloc
|
|
|
|
{
|
|
|
|
str_free (pltype);
|
|
|
|
str_free (parser);
|
2021-12-24 04:58:16 +00:00
|
|
|
[super dealloc];
|
2021-01-04 10:28:27 +00:00
|
|
|
}
|
|
|
|
|
2020-12-23 16:36:17 +00:00
|
|
|
-writeParseData
|
|
|
|
{
|
2020-12-24 02:50:52 +00:00
|
|
|
fprintf (output_file, "static size_t parse_%s_%s_offsets[] = {\n",
|
2020-12-23 16:36:17 +00:00
|
|
|
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, "};\n");
|
|
|
|
|
|
|
|
fprintf (output_file, "static parse_custom_t parse_%s_%s_data = {\n",
|
|
|
|
struct_name, field_name);
|
|
|
|
fprintf (output_file, "\t%s,\n", parser);
|
2020-12-24 02:50:52 +00:00
|
|
|
fprintf (output_file, "\tparse_%s_%s_offsets,\n",
|
2020-12-23 16:36:17 +00:00
|
|
|
struct_name, field_name);
|
|
|
|
fprintf (output_file, "\t%d,\n", [fields count]);
|
|
|
|
fprintf (output_file, "};\n");
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
-writeField
|
|
|
|
{
|
|
|
|
fprintf (output_file, "\t{\"%s\", 0, %s, parse_%s, &parse_%s_%s_data},\n",
|
|
|
|
field_name, pltype, "custom", struct_name, field_name);
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
-writeSymbol
|
|
|
|
{
|
|
|
|
fprintf (output_file,
|
|
|
|
"\t{\"%s\", 0/*FIXME*/, 0/*(void *) field_offset (%s, %s)*/},\n",
|
|
|
|
field_name, struct_name, "FIXME");
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2021-12-04 00:29:38 +00:00
|
|
|
-(int) searchType
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-12-23 16:36:17 +00:00
|
|
|
@end
|