2020-12-23 13:13:50 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <PropertyList.h>
|
|
|
|
|
|
|
|
#include "vkfieldarray.h"
|
|
|
|
#include "vkfieldauto.h"
|
2020-12-23 16:36:17 +00:00
|
|
|
#include "vkfieldcustom.h"
|
2020-12-23 13:13:50 +00:00
|
|
|
#include "vkfielddata.h"
|
|
|
|
#include "vkfielddef.h"
|
2023-02-10 00:37:09 +00:00
|
|
|
#include "vkfieldignore.h"
|
2023-02-10 10:36:53 +00:00
|
|
|
#include "vkfieldlabeledarray.h"
|
|
|
|
#include "vkfieldlabeledsingle.h"
|
2022-11-26 13:15:15 +00:00
|
|
|
#include "vkfieldreadonly.h"
|
2020-12-23 13:13:50 +00:00
|
|
|
#include "vkfieldsingle.h"
|
|
|
|
#include "vkfieldstring.h"
|
|
|
|
#include "vkstruct.h"
|
|
|
|
|
|
|
|
@implementation FieldDef
|
|
|
|
|
|
|
|
+fielddef:(PLItem *)item struct:(Struct *)strct field:(string)fname
|
|
|
|
{
|
|
|
|
string record = [item string];
|
|
|
|
PLItem *type_desc = [item getObjectForKey:"type"];
|
|
|
|
|
|
|
|
if (!item) {
|
|
|
|
record = "auto";
|
|
|
|
}
|
|
|
|
if (!record) {
|
|
|
|
if (item && !type_desc) {
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
record = [type_desc string];
|
|
|
|
if (!record) {
|
|
|
|
record = [[type_desc getObjectAtIndex:0] string];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
switch (record) {
|
|
|
|
case "auto":
|
|
|
|
return [[[AutoField alloc] init:item struct:strct field:fname] autorelease];
|
2020-12-23 16:36:17 +00:00
|
|
|
case "custom":
|
|
|
|
return [[[CustomField alloc] init:item struct:strct field:fname] autorelease];
|
2020-12-23 13:13:50 +00:00
|
|
|
case "string":
|
|
|
|
return [[[StringField alloc] init:item struct:strct field:fname] autorelease];
|
|
|
|
case "data":
|
|
|
|
return [[[DataField alloc] init:item struct:strct field:fname] autorelease];
|
|
|
|
case "single":
|
|
|
|
return [[[SingleField alloc] init:item struct:strct field:fname] autorelease];
|
|
|
|
case "array":
|
|
|
|
return [[[ArrayField alloc] init:item struct:strct field:fname] autorelease];
|
2023-02-10 10:36:53 +00:00
|
|
|
case "labeledarray":
|
|
|
|
return [[[LabeledArrayField alloc] init:item struct:strct field:fname] autorelease];
|
|
|
|
case "labeledsingle":
|
|
|
|
return [[[LabeledSingleField alloc] init:item struct:strct field:fname] autorelease];
|
2022-11-26 13:15:15 +00:00
|
|
|
case "readonly":
|
|
|
|
return [[[ReadOnlyField alloc] init:item struct:strct field:fname] autorelease];
|
2023-02-10 00:37:09 +00:00
|
|
|
case "ignore":
|
|
|
|
return [[[IgnoreField alloc] init:item struct:strct field:fname] autorelease];
|
2020-12-23 13:13:50 +00:00
|
|
|
}
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
-init:(PLItem *)item struct:(Struct *)strct field:(string)fname
|
|
|
|
{
|
|
|
|
self = [super init];
|
|
|
|
if (!self) {
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
line = [item line];
|
|
|
|
struct_name = str_hold ([strct outname]);
|
|
|
|
field_name = str_hold (fname);
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
-fromField:(qfot_var_t *)field struct:(Struct *)strct
|
|
|
|
{
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)dealloc
|
|
|
|
{
|
|
|
|
str_free (struct_name);
|
|
|
|
str_free (field_name);
|
2021-12-24 04:58:16 +00:00
|
|
|
[super dealloc];
|
2020-12-23 13:13:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-writeParseData
|
2023-06-16 09:53:37 +00:00
|
|
|
{
|
|
|
|
fprintf (output_file, "undefined record type parse data: %d\n", line);
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
-writeParse
|
2020-12-23 13:13:50 +00:00
|
|
|
{
|
|
|
|
fprintf (output_file, "undefined record type parse: %d\n", line);
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
-writeField
|
|
|
|
{
|
|
|
|
fprintf (output_file, "undefined record type field: %d\n", line);
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
-writeSymbol
|
|
|
|
{
|
|
|
|
fprintf (output_file,
|
|
|
|
"\t{\"%s\", 0/*FIXME*/, (void *) field_offset (%s, %s)},\n",
|
|
|
|
field_name, struct_name, value_field);
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(string) name
|
|
|
|
{
|
|
|
|
return field_name;
|
|
|
|
}
|
|
|
|
|
2021-12-04 00:29:38 +00:00
|
|
|
-(int) searchType
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2020-12-23 13:13:50 +00:00
|
|
|
@end
|