srfi-4.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #ifndef SCM_SRFI_4_H
  2. #define SCM_SRFI_4_H
  3. /* srfi-4.c --- Homogeneous numeric vector datatypes.
  4. Copyright 2001,2004,2006,2008-2011,2014,2018
  5. Free Software Foundation, Inc.
  6. This file is part of Guile.
  7. Guile is free software: you can redistribute it and/or modify it
  8. under the terms of the GNU Lesser General Public License as published
  9. by the Free Software Foundation, either version 3 of the License, or
  10. (at your option) any later version.
  11. Guile is distributed in the hope that it will be useful, but WITHOUT
  12. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13. FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
  14. License for more details.
  15. You should have received a copy of the GNU Lesser General Public
  16. License along with Guile. If not, see
  17. <https://www.gnu.org/licenses/>. */
  18. /* FIXME move array-handle functions to array-handle.[hc] */
  19. #include "libguile/array-handle.h"
  20. SCM_API SCM scm_make_srfi_4_vector (SCM type, SCM len, SCM fill);
  21. /* Specific procedures.
  22. */
  23. #define SCM_SRFI4_DECL(tag, type) \
  24. SCM_API SCM scm_##tag##vector_p (SCM obj); \
  25. SCM_API SCM scm_make_##tag##vector (SCM n, SCM fill); \
  26. SCM_API SCM scm_take_##tag##vector (type *data, size_t n); \
  27. SCM_API SCM scm_##tag##vector (SCM l); \
  28. SCM_API SCM scm_##tag##vector_length (SCM uvec); \
  29. SCM_API SCM scm_##tag##vector_ref (SCM uvec, SCM index); \
  30. SCM_API SCM scm_##tag##vector_set_x (SCM uvec, SCM index, SCM value); \
  31. SCM_API SCM scm_##tag##vector_to_list (SCM uvec); \
  32. SCM_API SCM scm_list_to_##tag##vector (SCM l); \
  33. SCM_API SCM scm_any_to_##tag##vector (SCM obj); \
  34. SCM_API const type *scm_array_handle_##tag##_elements (scm_t_array_handle *h); \
  35. SCM_API type *scm_array_handle_##tag##_writable_elements (scm_t_array_handle *h); \
  36. SCM_API const type *scm_##tag##vector_elements (SCM uvec, size_t *lenp); \
  37. SCM_API type *scm_##tag##vector_writable_elements (SCM uvec, size_t *lenp);
  38. SCM_SRFI4_DECL (u8, uint8_t)
  39. SCM_SRFI4_DECL (s8, int8_t)
  40. SCM_SRFI4_DECL (u16, uint16_t)
  41. SCM_SRFI4_DECL (s16, int16_t)
  42. SCM_SRFI4_DECL (u32, uint32_t)
  43. SCM_SRFI4_DECL (s32, int32_t)
  44. SCM_SRFI4_DECL (u64, uint64_t)
  45. SCM_SRFI4_DECL (s64, int64_t)
  46. SCM_SRFI4_DECL (f32, float)
  47. SCM_SRFI4_DECL (f64, double)
  48. SCM_SRFI4_DECL (c32, float)
  49. SCM_SRFI4_DECL (c64, double)
  50. #undef SCM_SRFI4_DECL
  51. SCM_INTERNAL void scm_init_srfi_4 (void);
  52. #endif /* SCM_SRFI_4_H */