mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-22 02:11:19 +00:00
[cexpr] Add support for casting plitems
This allows using references in expressions, eg: $frames.size * size_t($properties.limits.maxSamplers) As references remain property list items until actually evaluated.
This commit is contained in:
parent
e7b067d6a9
commit
062f616548
1 changed files with 15 additions and 0 deletions
|
@ -118,6 +118,14 @@ CAST_TO (float)
|
|||
CAST_TO (double)
|
||||
#undef CAST_TO
|
||||
|
||||
static void
|
||||
cast_plitem (const exprval_t **params, exprval_t *result, exprctx_t *context)
|
||||
{
|
||||
// first argument is ignored because cexpr_cast_plitem is meant to used
|
||||
// in an operator list
|
||||
cexpr_cast_plitem (0, params[0], result, context);
|
||||
}
|
||||
|
||||
FUNC2 (min, int, int, min)
|
||||
FUNC2 (min, uint, uint, min)
|
||||
FUNC2 (min, size_t, size_t, min)
|
||||
|
@ -171,6 +179,12 @@ static exprtype_t *double_params[] = {
|
|||
&cexpr_double,
|
||||
};
|
||||
|
||||
static exprtype_t *plitem_params[] = {
|
||||
&cexpr_plitem,
|
||||
&cexpr_plitem,
|
||||
&cexpr_plitem,
|
||||
};
|
||||
|
||||
#define FUNC(name, rtype, n, ptype) \
|
||||
{ &cexpr_##rtype, n, ptype##_params, FNAME(name, rtype, ptype) }
|
||||
|
||||
|
@ -228,6 +242,7 @@ static exprfunc_t rtype##_func[] = { \
|
|||
FUNC (cast, rtype, 1, size_t), \
|
||||
FUNC (cast, rtype, 1, float), \
|
||||
FUNC (cast, rtype, 1, double), \
|
||||
{ &cexpr_##rtype, 1, plitem_params, cast_plitem }, \
|
||||
{} \
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue