khash_for_primitive_helper.pxi.in 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. """
  2. Template for wrapping khash-tables for each primitive `dtype`
  3. WARNING: DO NOT edit .pxi FILE directly, .pxi is generated from .pxi.in
  4. """
  5. {{py:
  6. # name, c_type
  7. primitive_types = [('int64', 'int64_t'),
  8. ('uint64', 'uint64_t'),
  9. ('float64', 'float64_t'),
  10. ('int32', 'int32_t'),
  11. ('uint32', 'uint32_t'),
  12. ('float32', 'float32_t'),
  13. ('int16', 'int16_t'),
  14. ('uint16', 'uint16_t'),
  15. ('int8', 'int8_t'),
  16. ('uint8', 'uint8_t'),
  17. ('complex64', 'khcomplex64_t'),
  18. ('complex128', 'khcomplex128_t'),
  19. ]
  20. }}
  21. {{for name, c_type in primitive_types}}
  22. cdef extern from "khash_python.h":
  23. ctypedef struct kh_{{name}}_t:
  24. khuint_t n_buckets, size, n_occupied, upper_bound
  25. uint32_t *flags
  26. {{c_type}} *keys
  27. size_t *vals
  28. kh_{{name}}_t* kh_init_{{name}}() nogil
  29. void kh_destroy_{{name}}(kh_{{name}}_t*) nogil
  30. void kh_clear_{{name}}(kh_{{name}}_t*) nogil
  31. khuint_t kh_get_{{name}}(kh_{{name}}_t*, {{c_type}}) nogil
  32. void kh_resize_{{name}}(kh_{{name}}_t*, khuint_t) nogil
  33. khuint_t kh_put_{{name}}(kh_{{name}}_t*, {{c_type}}, int*) nogil
  34. void kh_del_{{name}}(kh_{{name}}_t*, khuint_t) nogil
  35. bint kh_exist_{{name}}(kh_{{name}}_t*, khiter_t) nogil
  36. {{endfor}}