_isocbind.py 2.3 KB

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