mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-27 14:42:07 +00:00
403c6eea73
Ruamoko currently doesn't support `const`, so that's not relevant, but recognizing `char *` (via a hack to work around what looks like a bug with type aliasing) allows strings to be handled without having to use a custom parser. Things are still a little clunky for custom parsers, but this seems to be a good start.
45 lines
954 B
R
45 lines
954 B
R
#include <PropertyList.h>
|
|
|
|
#include "vkfieldstring.h"
|
|
#include "vkgen.h"
|
|
|
|
@implementation StringField
|
|
|
|
-init:(PLItem *) item struct:(Struct *)strct field:(string)fname
|
|
{
|
|
self = [super init:item struct:strct field:fname];
|
|
if (!self) {
|
|
return self;
|
|
}
|
|
|
|
value_field = fname;
|
|
if (item) {
|
|
value_field = [[item getObjectForKey:"string"] string];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
+fielddef:(PLItem *)item struct:(Struct *)strct field:(string)fname
|
|
{
|
|
return [[[StringField alloc] init:item struct:strct field:fname]
|
|
autorelease];
|
|
}
|
|
|
|
-writeParseData
|
|
{
|
|
fprintf (output_file, "static parse_string_t parse_%s_%s_data = {\n",
|
|
struct_name, field_name);
|
|
fprintf (output_file, "\tfield_offset (%s, %s),\n",
|
|
struct_name, value_field);
|
|
fprintf (output_file, "};\n");
|
|
return self;
|
|
}
|
|
|
|
-writeField
|
|
{
|
|
fprintf (output_file, "\t{\"%s\", 0, %s, parse_%s, &parse_%s_%s_data},\n",
|
|
field_name, "QFString", "string", struct_name, field_name);
|
|
return self;
|
|
}
|
|
|
|
@end
|