codekingpro/portable-devtools
115k
1"""
2ISO_C_BINDING maps for f2py2e.
3Only required declarations/macros/functions will be used.
4
5Copyright 1999 -- 2011 Pearu Peterson all rights reserved.
6Copyright 2011 -- present NumPy Developers.
7Permission to use, modify, and distribute this software is given under the
8terms of the NumPy License.
9
10NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
11"""
12# These map to keys in c2py_map, via forced casting for now, see gh-25229
13iso_c_binding_map = {
14 'integer': {
15 'c_int': 'int',
16 'c_short': 'short', # 'short' <=> 'int' for now
17 'c_long': 'long', # 'long' <=> 'int' for now
18 'c_long_long': 'long_long',
19 'c_signed_char': 'signed_char',
20 'c_size_t': 'unsigned', # size_t <=> 'unsigned' for now
21 'c_int8_t': 'signed_char', # int8_t <=> 'signed_char' for now
22 'c_int16_t': 'short', # int16_t <=> 'short' for now
23 'c_int32_t': 'int', # int32_t <=> 'int' for now
24 'c_int64_t': 'long_long',
25 'c_int_least8_t': 'signed_char', # int_least8_t <=> 'signed_char' for now
26 'c_int_least16_t': 'short', # int_least16_t <=> 'short' for now
27 'c_int_least32_t': 'int', # int_least32_t <=> 'int' for now
28 'c_int_least64_t': 'long_long',
29 'c_int_fast8_t': 'signed_char', # int_fast8_t <=> 'signed_char' for now
30 'c_int_fast16_t': 'short', # int_fast16_t <=> 'short' for now
31 'c_int_fast32_t': 'int', # int_fast32_t <=> 'int' for now
32 'c_int_fast64_t': 'long_long',
33 'c_intmax_t': 'long_long', # intmax_t <=> 'long_long' for now
34 'c_intptr_t': 'long', # intptr_t <=> 'long' for now
35 'c_ptrdiff_t': 'long', # ptrdiff_t <=> 'long' for now
36 },
37 'real': {
38 'c_float': 'float',
39 'c_double': 'double',
40 'c_long_double': 'long_double'
41 },
42 'complex': {
43 'c_float_complex': 'complex_float',
44 'c_double_complex': 'complex_double',
45 'c_long_double_complex': 'complex_long_double'
46 },
47 'logical': {
48 'c_bool': 'unsigned_char' # _Bool <=> 'unsigned_char' for now
49 },
50 'character': {
51 'c_char': 'char'
52 }
53}
54
55# TODO: See gh-25229
56isoc_c2pycode_map = {}
57iso_c2py_map = {}
58
59isoc_kindmap = {}
60for fortran_type, c_type_dict in iso_c_binding_map.items():
61 for c_type in c_type_dict.keys():
62 isoc_kindmap[c_type] = fortran_type
63 