mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
[vkparse] Add support for inheriting objects
It simply parses the referenced plist dictionary (via @inherit = plist.path;) into the current data block, then allows the data to be overwritten by the current plist dictionary. This may be a bit iffy for any allocated resources, so some care must be taken, but it seems to work nicely.
This commit is contained in:
parent
bbbdc41af3
commit
eb4d566801
2 changed files with 21 additions and 0 deletions
|
@ -130,6 +130,9 @@
|
||||||
[field_def writeParseData];
|
[field_def writeParseData];
|
||||||
}
|
}
|
||||||
fprintf (output_file, "static plfield_t %s_fields[] = {\n", [self outname]);
|
fprintf (output_file, "static plfield_t %s_fields[] = {\n", [self outname]);
|
||||||
|
fprintf (output_file,
|
||||||
|
"\t{\"@inherit\", 0, QFString, parse_inherit, &%s_fields},\n",
|
||||||
|
[self outname]);
|
||||||
for (int i = [field_defs count]; i-- > 0; ) {
|
for (int i = [field_defs count]; i-- > 0; ) {
|
||||||
FieldDef *field_def = [field_defs objectAtIndex:i];
|
FieldDef *field_def = [field_defs objectAtIndex:i];
|
||||||
[field_def writeField];
|
[field_def writeField];
|
||||||
|
|
|
@ -376,6 +376,24 @@ parse_custom (const plfield_t *field, const plitem_t *item,
|
||||||
return custom->parse (item, offsets, messages, context);
|
return custom->parse (item, offsets, messages, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
parse_inherit (const plfield_t *field, const plitem_t *item,
|
||||||
|
void *data, plitem_t *messages, void *context)
|
||||||
|
{
|
||||||
|
exprctx_t ectx = *((parsectx_t *)context)->ectx;
|
||||||
|
plitem_t *inheritItem = 0;
|
||||||
|
exprval_t result = { &cexpr_plitem, &inheritItem };
|
||||||
|
ectx.result = &result;
|
||||||
|
const char *inheritstr = PL_String (item);
|
||||||
|
Sys_MaskPrintf (SYS_vulkan_parse, "parse_inherit: %s\n", inheritstr);
|
||||||
|
int ret = !cexpr_eval_string (inheritstr, &ectx);
|
||||||
|
if (ret) {
|
||||||
|
ret = PL_ParseStruct (field->data, inheritItem, data, messages,
|
||||||
|
context);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
parse_RGBA (const plitem_t *item, void **data,
|
parse_RGBA (const plitem_t *item, void **data,
|
||||||
plitem_t *messages, parsectx_t *context)
|
plitem_t *messages, parsectx_t *context)
|
||||||
|
|
Loading…
Reference in a new issue