mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-22 02:11:19 +00:00
[util] Support struct pointer accesses in cexpr
This commit is contained in:
parent
0c1699fdbb
commit
16334158bd
2 changed files with 17 additions and 0 deletions
|
@ -113,6 +113,8 @@ void cexpr_error(exprctx_t *ctx, const char *fmt, ...) __attribute__((format(pri
|
|||
|
||||
void cexpr_struct_getfield (const exprval_t *a, const exprval_t *b,
|
||||
exprval_t *c, exprctx_t *ctx);
|
||||
void cexpr_struct_pointer_getfield (const exprval_t *a, const exprval_t *b,
|
||||
exprval_t *c, exprctx_t *ctx);
|
||||
exprval_t *cexpr_cvar (const char *name, exprctx_t *ctx);
|
||||
exprval_t *cexpr_cvar_struct (exprctx_t *ctx);
|
||||
|
||||
|
@ -132,5 +134,6 @@ extern exprtype_t cexpr_field;
|
|||
extern exprtype_t cexpr_function;
|
||||
|
||||
extern binop_t cexpr_struct_binops[];
|
||||
extern binop_t cexpr_struct_pointer_binops[];
|
||||
|
||||
#endif
|
||||
|
|
|
@ -58,6 +58,20 @@ VISIBLE binop_t cexpr_struct_binops[] = {
|
|||
{}
|
||||
};
|
||||
|
||||
VISIBLE void
|
||||
cexpr_struct_pointer_getfield (const exprval_t *a, const exprval_t *b,
|
||||
exprval_t *c, exprctx_t *ctx)
|
||||
{
|
||||
// "dereference" the pointer
|
||||
exprval_t struct_val = { a->type, *(void **) a->value };
|
||||
cexpr_struct_getfield (&struct_val, b, c, ctx);
|
||||
}
|
||||
|
||||
VISIBLE binop_t cexpr_struct_pointer_binops[] = {
|
||||
{ '.', &cexpr_field, &cexpr_exprval, cexpr_struct_pointer_getfield },
|
||||
{}
|
||||
};
|
||||
|
||||
static void
|
||||
cvar_get (const exprval_t *a, const exprval_t *b, exprval_t *c, exprctx_t *ctx)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue