@validate_conversion_arguments<EOL>def to_int(<EOL>primitive: Primitives = None, hexstr: HexStr = None, text: str = None<EOL>) -> int:
if hexstr is not None:<EOL><INDENT>return int(hexstr, <NUM_LIT:16>)<EOL><DEDENT>elif text is not None:<EOL><INDENT>return int(text)<EOL><DEDENT>elif isinstance(primitive, (bytes, bytearray)):<EOL><INDENT>return big_endian_to_int(primitive)<EOL><DEDENT>elif isinstance(primitive, str):<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>elif isinstance(primitive, (int, bool)):<EOL><INDENT>return int(primitive)<EOL><DEDENT>else:<EOL><INDENT>raise TypeError(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>".format(type(primitive))<EOL>)<EOL><DEDENT>
Converts value to its integer representation.
Values are converted this way:

 * primitive:

   * bytes, bytearrays: big-endian integer
   * bool: True => 1, False => 0
 * hexstr: interpret hex as integer
 * text: interpret as string of digits, like '12' => 12