mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 04:42:32 +00:00
[util] Add size_t support to cexpr
This commit is contained in:
parent
80aec45e35
commit
91c5baa708
3 changed files with 52 additions and 2 deletions
|
@ -109,6 +109,7 @@ char *cexpr_yyget_text (void *scanner);
|
|||
|
||||
extern exprtype_t cexpr_int;
|
||||
extern exprtype_t cexpr_uint;
|
||||
extern exprtype_t cexpr_size_t;
|
||||
extern exprtype_t cexpr_float;
|
||||
extern exprtype_t cexpr_double;
|
||||
extern exprtype_t cexpr_exprval;
|
||||
|
|
|
@ -160,6 +160,52 @@ exprtype_t cexpr_uint = {
|
|||
uint_unops,
|
||||
};
|
||||
|
||||
BINOP(size_t, shl, unsigned, <<)
|
||||
BINOP(size_t, shr, unsigned, >>)
|
||||
BINOP(size_t, add, unsigned, +)
|
||||
BINOP(size_t, sub, unsigned, -)
|
||||
BINOP(size_t, mul, unsigned, *)
|
||||
BINOP(size_t, div, unsigned, /)
|
||||
BINOP(size_t, band, unsigned, &)
|
||||
BINOP(size_t, bor, unsigned, |)
|
||||
BINOP(size_t, xor, unsigned, ^)
|
||||
BINOP(size_t, rem, unsigned, %)
|
||||
|
||||
UNOP(size_t, pos, unsigned, +)
|
||||
UNOP(size_t, neg, unsigned, -)
|
||||
UNOP(size_t, tnot, unsigned, !)
|
||||
UNOP(size_t, bnot, unsigned, ~)
|
||||
|
||||
binop_t size_t_binops[] = {
|
||||
{ SHL, &cexpr_size_t, &cexpr_size_t, size_t_shl },
|
||||
{ SHR, &cexpr_size_t, &cexpr_size_t, size_t_shr },
|
||||
{ '+', &cexpr_size_t, &cexpr_size_t, size_t_add },
|
||||
{ '-', &cexpr_size_t, &cexpr_size_t, size_t_sub },
|
||||
{ '*', &cexpr_size_t, &cexpr_size_t, size_t_mul },
|
||||
{ '/', &cexpr_size_t, &cexpr_size_t, size_t_div },
|
||||
{ '&', &cexpr_size_t, &cexpr_size_t, size_t_band },
|
||||
{ '|', &cexpr_size_t, &cexpr_size_t, size_t_bor },
|
||||
{ '^', &cexpr_size_t, &cexpr_size_t, size_t_xor },
|
||||
{ '%', &cexpr_size_t, &cexpr_size_t, size_t_rem },
|
||||
{ MOD, &cexpr_size_t, &cexpr_size_t, size_t_rem },
|
||||
{}
|
||||
};
|
||||
|
||||
unop_t size_t_unops[] = {
|
||||
{ '+', &cexpr_size_t, size_t_pos },
|
||||
{ '-', &cexpr_size_t, size_t_neg },
|
||||
{ '!', &cexpr_size_t, size_t_tnot },
|
||||
{ '~', &cexpr_size_t, size_t_bnot },
|
||||
{}
|
||||
};
|
||||
|
||||
exprtype_t cexpr_size_t = {
|
||||
"size_t",
|
||||
sizeof (size_t),
|
||||
size_t_binops,
|
||||
size_t_unops,
|
||||
};
|
||||
|
||||
BINOP(float, add, float, +)
|
||||
BINOP(float, sub, float, -)
|
||||
BINOP(float, mul, float, *)
|
||||
|
|
|
@ -65,6 +65,9 @@
|
|||
if (name == "uint32_t") {
|
||||
return "cexpr_uint";
|
||||
}
|
||||
if (name == "size_t") {
|
||||
return "cexpr_size_t";
|
||||
}
|
||||
return [alias cexprType];
|
||||
}
|
||||
|
||||
|
@ -80,7 +83,7 @@
|
|||
return [enumObj parseType];
|
||||
}
|
||||
}
|
||||
if (name == "uint32_t") {
|
||||
if (name == "uint32_t" || name == "size_t") {
|
||||
return "QFString";
|
||||
}
|
||||
return [alias parseType];
|
||||
|
@ -116,7 +119,7 @@
|
|||
return [enumObj parseData];
|
||||
}
|
||||
}
|
||||
if (name == "uint32_t") {
|
||||
if (name == "uint32_t" || name == "size_t") {
|
||||
return "0";
|
||||
}
|
||||
return [alias parseData];
|
||||
|
|
Loading…
Reference in a new issue