Integer expressions in IDL
Integer expressions in IDL are composed of named integer constants, integer literals, operators (see the table below), and grouping parentheses.
Example use of integer expressions:
const UInt8 itemHeaderLen = 2;
const UInt8 itemBlockLen = 4;
const UInt8 maxItemCount = 0X10;
const UInt64 maxLen = (2 << 3) + (itemHeaderLen + itemBlockLen * 4) * maxItemCount;
interface {
CopyPage(in array<UInt8, 4 * maxLen> page);
}
If an integer overflow occurs when computing an expression, the source code generator using the IDL file will terminate with an error.
Details on operators of integer expressions in IDL
Syntax | Operation | Precedence | Associativity | Special considerations |
---|---|---|---|---|
| Sign change | 1 | No | N/A |
| Bitwise negation | 1 | No | N/A |
| Exponentiation | 2 | No | Special considerations:
|
| Multiplication | 3 | Left | N/A |
| Integer division | 3 | Left | Special considerations:
|
| Modulo | 3 | Left | Special considerations:
|
| Addition | 4 | Left | N/A |
| Subtraction | 4 | Left | N/A |
| Bit shift left | 2* | No | Special considerations:
|
| Bit shift right | 2* | No | Special considerations:
|