2020-12-23 13:13:50 +00:00
|
|
|
#include <PropertyList.h>
|
2023-03-12 09:30:21 +00:00
|
|
|
#include <string.h>
|
2020-12-23 13:13:50 +00:00
|
|
|
|
|
|
|
#include "vkfieldsingle.h"
|
2021-01-04 06:30:27 +00:00
|
|
|
#include "vkfieldtype.h"
|
2020-12-23 13:13:50 +00:00
|
|
|
#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"];
|
2021-01-04 06:30:27 +00:00
|
|
|
type = [[FieldType fieldType:[desc getObjectAtIndex:1]] retain];
|
2020-12-23 13:13:50 +00:00
|
|
|
|
2023-03-12 09:30:21 +00:00
|
|
|
value_field = str_hold ([[item getObjectForKey:"value"] string]);
|
2020-12-23 13:13:50 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2023-03-12 09:30:21 +00:00
|
|
|
-(void) dealloc
|
|
|
|
{
|
|
|
|
[type release];
|
|
|
|
str_free (value_field);
|
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
2020-12-23 13:13:50 +00:00
|
|
|
-writeParseData
|
|
|
|
{
|
|
|
|
fprintf (output_file, "static parse_single_t parse_%s_%s_data = {\n",
|
|
|
|
struct_name, field_name);
|
2021-01-04 06:30:27 +00:00
|
|
|
[type writeParseData];
|
2020-12-23 13:13:50 +00:00
|
|
|
fprintf (output_file, "\tfield_offset (%s, %s),\n",
|
|
|
|
struct_name, value_field);
|
|
|
|
fprintf (output_file, "};\n");
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
-writeField
|
|
|
|
{
|
2021-01-04 06:30:27 +00:00
|
|
|
string parse_type = [type parseType];
|
2020-12-23 13:13:50 +00:00
|
|
|
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
|