Fix add-ons with Python 3.12 by replacing "imp" with "importlib"
[blender-addons.git] / io_scene_fbx / data_types.py
blob328ba3a9c27f3f7fb2ab7b12e88cc7ee10505c61
1 # SPDX-FileCopyrightText: 2006-2012 assimp team
2 # SPDX-FileCopyrightText: 2013 Blender Foundation
4 # SPDX-License-Identifier: GPL-2.0-or-later
6 BOOL = b'B'[0]
7 CHAR = b'C'[0]
8 INT8 = b'Z'[0]
9 INT16 = b'Y'[0]
10 INT32 = b'I'[0]
11 INT64 = b'L'[0]
12 FLOAT32 = b'F'[0]
13 FLOAT64 = b'D'[0]
14 BYTES = b'R'[0]
15 STRING = b'S'[0]
16 INT32_ARRAY = b'i'[0]
17 INT64_ARRAY = b'l'[0]
18 FLOAT32_ARRAY = b'f'[0]
19 FLOAT64_ARRAY = b'd'[0]
20 BOOL_ARRAY = b'b'[0]
21 BYTE_ARRAY = b'c'[0]
23 # Some other misc defines
24 # Known combinations so far - supposed meaning: A = animatable, A+ = animated, U = UserProp
25 # VALID_NUMBER_FLAGS = {b'A', b'A+', b'AU', b'A+U'} # Not used...
27 # array types - actual length may vary (depending on underlying C implementation)!
28 import array
30 # For now, bytes and bool are assumed always 1byte.
31 ARRAY_BOOL = 'b'
32 ARRAY_BYTE = 'B'
34 ARRAY_INT32 = None
35 ARRAY_INT64 = None
36 for _t in 'ilq':
37 size = array.array(_t).itemsize
38 if size == 4:
39 ARRAY_INT32 = _t
40 elif size == 8:
41 ARRAY_INT64 = _t
42 if ARRAY_INT32 and ARRAY_INT64:
43 break
44 if not ARRAY_INT32:
45 raise Exception("Impossible to get a 4-bytes integer type for array!")
46 if not ARRAY_INT64:
47 raise Exception("Impossible to get an 8-bytes integer type for array!")
49 ARRAY_FLOAT32 = None
50 ARRAY_FLOAT64 = None
51 for _t in 'fd':
52 size = array.array(_t).itemsize
53 if size == 4:
54 ARRAY_FLOAT32 = _t
55 elif size == 8:
56 ARRAY_FLOAT64 = _t
57 if ARRAY_FLOAT32 and ARRAY_FLOAT64:
58 break
59 if not ARRAY_FLOAT32:
60 raise Exception("Impossible to get a 4-bytes float type for array!")
61 if not ARRAY_FLOAT64:
62 raise Exception("Impossible to get an 8-bytes float type for array!")