mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-05-31 00:30:57 +00:00
[vulkan] Support parsing numeric types
This commit is contained in:
parent
5b0da2b14c
commit
2430f44d7b
2 changed files with 52 additions and 14 deletions
|
@ -74,6 +74,9 @@ static string get_type_key (void *type, void *unused)
|
||||||
|
|
||||||
-(string) name
|
-(string) name
|
||||||
{
|
{
|
||||||
|
if (type.meta == ty_basic) {
|
||||||
|
return pr_type_name[type.type];
|
||||||
|
}
|
||||||
//FIXME extract alias name and return proper type name
|
//FIXME extract alias name and return proper type name
|
||||||
return type.encoding;
|
return type.encoding;
|
||||||
}
|
}
|
||||||
|
@ -98,16 +101,25 @@ static string get_type_key (void *type, void *unused)
|
||||||
|
|
||||||
-(string) parseType
|
-(string) parseType
|
||||||
{
|
{
|
||||||
|
if (type.meta == ty_basic) {
|
||||||
|
return "QFString";
|
||||||
|
}
|
||||||
return "no parse";
|
return "no parse";
|
||||||
}
|
}
|
||||||
|
|
||||||
-(string) parseFunc
|
-(string) parseFunc
|
||||||
{
|
{
|
||||||
|
if (type.meta == ty_basic) {
|
||||||
|
return "parse_basic";
|
||||||
|
}
|
||||||
return "0";
|
return "0";
|
||||||
}
|
}
|
||||||
|
|
||||||
-(string) parseData
|
-(string) parseData
|
||||||
{
|
{
|
||||||
|
if (type.meta == ty_basic) {
|
||||||
|
return "&cexpr_" + pr_type_name[type.type];
|
||||||
|
}
|
||||||
return "0";
|
return "0";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -135,29 +135,55 @@ typedef struct parse_custom_s {
|
||||||
} parse_custom_t;
|
} parse_custom_t;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
parse_uint32_t (const plfield_t *field, const plitem_t *item,
|
parse_basic (const plfield_t *field, const plitem_t *item,
|
||||||
void *data, plitem_t *messages, void *context)
|
void *data, plitem_t *messages, void *context)
|
||||||
{
|
{
|
||||||
int ret = 1;
|
int ret = 1;
|
||||||
|
__auto_type etype = (exprtype_t *) field->data;
|
||||||
|
exprctx_t ectx = *((parsectx_t *) context)->ectx;
|
||||||
|
exprval_t result = { etype, data };
|
||||||
|
ectx.symtab = 0;
|
||||||
|
ectx.result = &result;
|
||||||
const char *valstr = PL_String (item);
|
const char *valstr = PL_String (item);
|
||||||
//Sys_Printf ("parse_uint32_t: %s %zd %d %p %p: %s\n",
|
//Sys_Printf ("parse_uint32_t: %s %zd %d %p %p: %s\n",
|
||||||
// field->name, field->offset, field->type, field->parser,
|
// field->name, field->offset, field->type, field->parser,
|
||||||
// field->data, valstr);
|
// field->data, valstr);
|
||||||
if (strcmp (valstr, "VK_SUBPASS_EXTERNAL") == 0) {
|
if (strcmp (valstr, "VK_SUBPASS_EXTERNAL") == 0) {
|
||||||
|
//FIXME handle subpass in a separate parser?
|
||||||
*(uint32_t *) data = VK_SUBPASS_EXTERNAL;
|
*(uint32_t *) data = VK_SUBPASS_EXTERNAL;
|
||||||
} else {
|
} else {
|
||||||
char *end;
|
Sys_Printf ("parse_uint32_t: %s %zd %d %p %p %s\n",
|
||||||
unsigned long val = strtoul (valstr, &end, 0);
|
field->name, field->offset, field->type, field->parser,
|
||||||
if (*valstr && !*end && val <= 0xffffffff) {
|
field->data, valstr);
|
||||||
*(uint32_t *) data = val;
|
ret = !cexpr_eval_string (valstr, &ectx);
|
||||||
} else if (val > 0xffffffff) {
|
Sys_Printf (" %x\n", *(uint32_t *)data);
|
||||||
PL_Message (messages, item, "%lu bigger than 32 bits", val);
|
}
|
||||||
ret = 0;
|
|
||||||
} else {
|
return ret;
|
||||||
PL_Message (messages, item, "invalid char at %d in '%s'\n",
|
}
|
||||||
(int) (end - valstr), valstr);
|
|
||||||
ret = 0;
|
static int
|
||||||
}
|
parse_uint32_t (const plfield_t *field, const plitem_t *item,
|
||||||
|
void *data, plitem_t *messages, void *context)
|
||||||
|
{
|
||||||
|
int ret = 1;
|
||||||
|
exprctx_t ectx = *((parsectx_t *) context)->ectx;
|
||||||
|
exprval_t result = { &cexpr_uint, data };
|
||||||
|
ectx.symtab = 0;
|
||||||
|
ectx.result = &result;
|
||||||
|
const char *valstr = PL_String (item);
|
||||||
|
//Sys_Printf ("parse_uint32_t: %s %zd %d %p %p: %s\n",
|
||||||
|
// field->name, field->offset, field->type, field->parser,
|
||||||
|
// field->data, valstr);
|
||||||
|
if (strcmp (valstr, "VK_SUBPASS_EXTERNAL") == 0) {
|
||||||
|
//FIXME handle subpass in a separate parser?
|
||||||
|
*(uint32_t *) data = VK_SUBPASS_EXTERNAL;
|
||||||
|
} else {
|
||||||
|
Sys_Printf ("parse_uint32_t: %s %zd %d %p %p %s\n",
|
||||||
|
field->name, field->offset, field->type, field->parser,
|
||||||
|
field->data, valstr);
|
||||||
|
ret = !cexpr_eval_string (valstr, &ectx);
|
||||||
|
Sys_Printf (" %d\n", *(uint32_t *)data);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue