summaryrefslogtreecommitdiff
path: root/libguile/srfi-4.h
diff options
context:
space:
mode:
authorDaniel Llorens <lloda@sarc.name>2020-02-05 17:35:57 +0100
committerDaniel Llorens <lloda@sarc.name>2021-08-17 14:11:11 +0200
commit926f70f9b589eaa43e9b066e8cdd58e0d67435ed (patch)
treeba0db8004068fe0896717d5c44b6c3b4a74e47a1 /libguile/srfi-4.h
parent3df3ba1a2c956bba122328e1fc4be614171a4f42 (diff)
downloadguile-926f70f9b589eaa43e9b066e8cdd58e0d67435ed.tar.gz
Refactor srfi-4 declarations
Diffstat (limited to 'libguile/srfi-4.h')
-rw-r--r--libguile/srfi-4.h277
1 files changed, 31 insertions, 246 deletions
diff --git a/libguile/srfi-4.h b/libguile/srfi-4.h
index 3f279e6ef..c885f7a47 100644
--- a/libguile/srfi-4.h
+++ b/libguile/srfi-4.h
@@ -2,7 +2,7 @@
#define SCM_SRFI_4_H
/* srfi-4.c --- Homogeneous numeric vector datatypes.
- Copyright 2001,2004,2006,2008-2011,2014,2018
+ Copyright 2001,2004,2006,2008-2011,2014,2018,2021
Free Software Foundation, Inc.
This file is part of Guile.
@@ -26,254 +26,39 @@
SCM_API SCM scm_make_srfi_4_vector (SCM type, SCM len, SCM fill);
-
/* Specific procedures.
*/
-SCM_API SCM scm_u8vector_p (SCM obj);
-SCM_API SCM scm_make_u8vector (SCM n, SCM fill);
-SCM_API SCM scm_take_u8vector (uint8_t *data, size_t n);
-SCM_API SCM scm_u8vector (SCM l);
-SCM_API SCM scm_u8vector_length (SCM uvec);
-SCM_API SCM scm_u8vector_ref (SCM uvec, SCM index);
-SCM_API SCM scm_u8vector_set_x (SCM uvec, SCM index, SCM value);
-SCM_API SCM scm_u8vector_to_list (SCM uvec);
-SCM_API SCM scm_list_to_u8vector (SCM l);
-SCM_API SCM scm_any_to_u8vector (SCM obj);
-SCM_API const uint8_t *scm_array_handle_u8_elements (scm_t_array_handle *h);
-SCM_API uint8_t *scm_array_handle_u8_writable_elements (scm_t_array_handle *h);
-SCM_API const uint8_t *scm_u8vector_elements (SCM uvec,
- scm_t_array_handle *h,
- size_t *lenp, ssize_t *incp);
-SCM_API uint8_t *scm_u8vector_writable_elements (SCM uvec,
- scm_t_array_handle *h,
- size_t *lenp,
- ssize_t *incp);
-
-SCM_API SCM scm_s8vector_p (SCM obj);
-SCM_API SCM scm_make_s8vector (SCM n, SCM fill);
-SCM_API SCM scm_take_s8vector (int8_t *data, size_t n);
-SCM_API SCM scm_s8vector (SCM l);
-SCM_API SCM scm_s8vector_length (SCM uvec);
-SCM_API SCM scm_s8vector_ref (SCM uvec, SCM index);
-SCM_API SCM scm_s8vector_set_x (SCM uvec, SCM index, SCM value);
-SCM_API SCM scm_s8vector_to_list (SCM uvec);
-SCM_API SCM scm_list_to_s8vector (SCM l);
-SCM_API SCM scm_any_to_s8vector (SCM obj);
-SCM_API const int8_t *scm_array_handle_s8_elements (scm_t_array_handle *h);
-SCM_API int8_t *scm_array_handle_s8_writable_elements (scm_t_array_handle *h);
-SCM_API const int8_t *scm_s8vector_elements (SCM uvec,
- scm_t_array_handle *h,
- size_t *lenp, ssize_t *incp);
-SCM_API int8_t *scm_s8vector_writable_elements (SCM uvec,
- scm_t_array_handle *h,
- size_t *lenp,
- ssize_t *incp);
-
-SCM_API SCM scm_u16vector_p (SCM obj);
-SCM_API SCM scm_make_u16vector (SCM n, SCM fill);
-SCM_API SCM scm_take_u16vector (uint16_t *data, size_t n);
-SCM_API SCM scm_u16vector (SCM l);
-SCM_API SCM scm_u16vector_length (SCM uvec);
-SCM_API SCM scm_u16vector_ref (SCM uvec, SCM index);
-SCM_API SCM scm_u16vector_set_x (SCM uvec, SCM index, SCM value);
-SCM_API SCM scm_u16vector_to_list (SCM uvec);
-SCM_API SCM scm_list_to_u16vector (SCM l);
-SCM_API SCM scm_any_to_u16vector (SCM obj);
-SCM_API const uint16_t *scm_array_handle_u16_elements (scm_t_array_handle *h);
-SCM_API uint16_t *scm_array_handle_u16_writable_elements (scm_t_array_handle *h);
-SCM_API const uint16_t *scm_u16vector_elements (SCM uvec,
- scm_t_array_handle *h,
- size_t *lenp,
- ssize_t *incp);
-SCM_API uint16_t *scm_u16vector_writable_elements (SCM uvec,
- scm_t_array_handle *h,
- size_t *lenp,
- ssize_t *incp);
-
-SCM_API SCM scm_s16vector_p (SCM obj);
-SCM_API SCM scm_make_s16vector (SCM n, SCM fill);
-SCM_API SCM scm_take_s16vector (int16_t *data, size_t n);
-SCM_API SCM scm_s16vector (SCM l);
-SCM_API SCM scm_s16vector_length (SCM uvec);
-SCM_API SCM scm_s16vector_ref (SCM uvec, SCM index);
-SCM_API SCM scm_s16vector_set_x (SCM uvec, SCM index, SCM value);
-SCM_API SCM scm_s16vector_to_list (SCM uvec);
-SCM_API SCM scm_list_to_s16vector (SCM l);
-SCM_API SCM scm_any_to_s16vector (SCM obj);
-SCM_API const int16_t *scm_array_handle_s16_elements (scm_t_array_handle *h);
-SCM_API int16_t *scm_array_handle_s16_writable_elements (scm_t_array_handle *h);
-SCM_API const int16_t *scm_s16vector_elements (SCM uvec,
- scm_t_array_handle *h,
- size_t *lenp, ssize_t *incp);
-SCM_API int16_t *scm_s16vector_writable_elements (SCM uvec,
- scm_t_array_handle *h,
- size_t *lenp,
- ssize_t *incp);
-
-SCM_API SCM scm_u32vector_p (SCM obj);
-SCM_API SCM scm_make_u32vector (SCM n, SCM fill);
-SCM_API SCM scm_take_u32vector (uint32_t *data, size_t n);
-SCM_API SCM scm_u32vector (SCM l);
-SCM_API SCM scm_u32vector_length (SCM uvec);
-SCM_API SCM scm_u32vector_ref (SCM uvec, SCM index);
-SCM_API SCM scm_u32vector_set_x (SCM uvec, SCM index, SCM value);
-SCM_API SCM scm_u32vector_to_list (SCM uvec);
-SCM_API SCM scm_list_to_u32vector (SCM l);
-SCM_API SCM scm_any_to_u32vector (SCM obj);
-SCM_API const uint32_t *scm_array_handle_u32_elements (scm_t_array_handle *h);
-SCM_API uint32_t *scm_array_handle_u32_writable_elements (scm_t_array_handle *h);
-SCM_API const uint32_t *scm_u32vector_elements (SCM uvec,
- scm_t_array_handle *h,
- size_t *lenp,
- ssize_t *incp);
-SCM_API uint32_t *scm_u32vector_writable_elements (SCM uvec,
- scm_t_array_handle *h,
- size_t *lenp,
- ssize_t *incp);
-
-SCM_API SCM scm_s32vector_p (SCM obj);
-SCM_API SCM scm_make_s32vector (SCM n, SCM fill);
-SCM_API SCM scm_take_s32vector (int32_t *data, size_t n);
-SCM_API SCM scm_s32vector (SCM l);
-SCM_API SCM scm_s32vector_length (SCM uvec);
-SCM_API SCM scm_s32vector_ref (SCM uvec, SCM index);
-SCM_API SCM scm_s32vector_set_x (SCM uvec, SCM index, SCM value);
-SCM_API SCM scm_s32vector_to_list (SCM uvec);
-SCM_API SCM scm_list_to_s32vector (SCM l);
-SCM_API SCM scm_any_to_s32vector (SCM obj);
-SCM_API const int32_t *scm_array_handle_s32_elements (scm_t_array_handle *h);
-SCM_API int32_t *scm_array_handle_s32_writable_elements (scm_t_array_handle *h);
-SCM_API const int32_t *scm_s32vector_elements (SCM uvec,
- scm_t_array_handle *h,
- size_t *lenp, ssize_t *incp);
-SCM_API int32_t *scm_s32vector_writable_elements (SCM uvec,
- scm_t_array_handle *h,
- size_t *lenp,
- ssize_t *incp);
-
-SCM_API SCM scm_u64vector_p (SCM obj);
-SCM_API SCM scm_make_u64vector (SCM n, SCM fill);
-SCM_API SCM scm_u64vector (SCM l);
-SCM_API SCM scm_u64vector_length (SCM uvec);
-SCM_API SCM scm_u64vector_ref (SCM uvec, SCM index);
-SCM_API SCM scm_u64vector_set_x (SCM uvec, SCM index, SCM value);
-SCM_API SCM scm_u64vector_to_list (SCM uvec);
-SCM_API SCM scm_list_to_u64vector (SCM l);
-SCM_API SCM scm_any_to_u64vector (SCM obj);
-
-SCM_API SCM scm_take_u64vector (uint64_t *data, size_t n);
-SCM_API const uint64_t *scm_array_handle_u64_elements (scm_t_array_handle *h);
-SCM_API uint64_t *scm_array_handle_u64_writable_elements (scm_t_array_handle *h);
-SCM_API const uint64_t *scm_u64vector_elements (SCM uvec,
- scm_t_array_handle *h,
- size_t *lenp,
- ssize_t *incp);
-SCM_API uint64_t *scm_u64vector_writable_elements (SCM uvec,
- scm_t_array_handle *h,
- size_t *lenp,
- ssize_t *incp);
-
-SCM_API SCM scm_s64vector_p (SCM obj);
-SCM_API SCM scm_make_s64vector (SCM n, SCM fill);
-SCM_API SCM scm_s64vector (SCM l);
-SCM_API SCM scm_s64vector_length (SCM uvec);
-SCM_API SCM scm_s64vector_ref (SCM uvec, SCM index);
-SCM_API SCM scm_s64vector_set_x (SCM uvec, SCM index, SCM value);
-SCM_API SCM scm_s64vector_to_list (SCM uvec);
-SCM_API SCM scm_list_to_s64vector (SCM l);
-SCM_API SCM scm_any_to_s64vector (SCM obj);
-
-SCM_API SCM scm_take_s64vector (int64_t *data, size_t n);
-SCM_API const int64_t *scm_array_handle_s64_elements (scm_t_array_handle *h);
-SCM_API int64_t *scm_array_handle_s64_writable_elements (scm_t_array_handle *h);
-SCM_API const int64_t *scm_s64vector_elements (SCM uvec,
- scm_t_array_handle *h,
- size_t *lenp, ssize_t *incp);
-SCM_API int64_t *scm_s64vector_writable_elements (SCM uvec,
- scm_t_array_handle *h,
- size_t *lenp,
- ssize_t *incp);
-
-SCM_API SCM scm_f32vector_p (SCM obj);
-SCM_API SCM scm_make_f32vector (SCM n, SCM fill);
-SCM_API SCM scm_take_f32vector (float *data, size_t n);
-SCM_API SCM scm_f32vector (SCM l);
-SCM_API SCM scm_f32vector_length (SCM uvec);
-SCM_API SCM scm_f32vector_ref (SCM uvec, SCM index);
-SCM_API SCM scm_f32vector_set_x (SCM uvec, SCM index, SCM value);
-SCM_API SCM scm_f32vector_to_list (SCM uvec);
-SCM_API SCM scm_list_to_f32vector (SCM l);
-SCM_API SCM scm_any_to_f32vector (SCM obj);
-SCM_API const float *scm_array_handle_f32_elements (scm_t_array_handle *h);
-SCM_API float *scm_array_handle_f32_writable_elements (scm_t_array_handle *h);
-SCM_API const float *scm_f32vector_elements (SCM uvec,
- scm_t_array_handle *h,
- size_t *lenp, ssize_t *incp);
-SCM_API float *scm_f32vector_writable_elements (SCM uvec,
- scm_t_array_handle *h,
- size_t *lenp,
- ssize_t *incp);
-
-SCM_API SCM scm_f64vector_p (SCM obj);
-SCM_API SCM scm_make_f64vector (SCM n, SCM fill);
-SCM_API SCM scm_take_f64vector (double *data, size_t n);
-SCM_API SCM scm_f64vector (SCM l);
-SCM_API SCM scm_f64vector_length (SCM uvec);
-SCM_API SCM scm_f64vector_ref (SCM uvec, SCM index);
-SCM_API SCM scm_f64vector_set_x (SCM uvec, SCM index, SCM value);
-SCM_API SCM scm_f64vector_to_list (SCM uvec);
-SCM_API SCM scm_list_to_f64vector (SCM l);
-SCM_API SCM scm_any_to_f64vector (SCM obj);
-SCM_API const double *scm_array_handle_f64_elements (scm_t_array_handle *h);
-SCM_API double *scm_array_handle_f64_writable_elements (scm_t_array_handle *h);
-SCM_API const double *scm_f64vector_elements (SCM uvec,
- scm_t_array_handle *h,
- size_t *lenp, ssize_t *incp);
-SCM_API double *scm_f64vector_writable_elements (SCM uvec,
- scm_t_array_handle *h,
- size_t *lenp,
- ssize_t *incp);
-
-SCM_API SCM scm_c32vector_p (SCM obj);
-SCM_API SCM scm_make_c32vector (SCM n, SCM fill);
-SCM_API SCM scm_take_c32vector (float *data, size_t n);
-SCM_API SCM scm_c32vector (SCM l);
-SCM_API SCM scm_c32vector_length (SCM uvec);
-SCM_API SCM scm_c32vector_ref (SCM uvec, SCM index);
-SCM_API SCM scm_c32vector_set_x (SCM uvec, SCM index, SCM value);
-SCM_API SCM scm_c32vector_to_list (SCM uvec);
-SCM_API SCM scm_list_to_c32vector (SCM l);
-SCM_API SCM scm_any_to_c32vector (SCM obj);
-SCM_API const float *scm_array_handle_c32_elements (scm_t_array_handle *h);
-SCM_API float *scm_array_handle_c32_writable_elements (scm_t_array_handle *h);
-SCM_API const float *scm_c32vector_elements (SCM uvec,
- scm_t_array_handle *h,
- size_t *lenp, ssize_t *incp);
-SCM_API float *scm_c32vector_writable_elements (SCM uvec,
- scm_t_array_handle *h,
- size_t *lenp,
- ssize_t *incp);
-
-SCM_API SCM scm_c64vector_p (SCM obj);
-SCM_API SCM scm_make_c64vector (SCM n, SCM fill);
-SCM_API SCM scm_take_c64vector (double *data, size_t n);
-SCM_API SCM scm_c64vector (SCM l);
-SCM_API SCM scm_c64vector_length (SCM uvec);
-SCM_API SCM scm_c64vector_ref (SCM uvec, SCM index);
-SCM_API SCM scm_c64vector_set_x (SCM uvec, SCM index, SCM value);
-SCM_API SCM scm_c64vector_to_list (SCM uvec);
-SCM_API SCM scm_list_to_c64vector (SCM l);
-SCM_API SCM scm_any_to_c64vector (SCM obj);
-SCM_API const double *scm_array_handle_c64_elements (scm_t_array_handle *h);
-SCM_API double *scm_array_handle_c64_writable_elements (scm_t_array_handle *h);
-SCM_API const double *scm_c64vector_elements (SCM uvec,
- scm_t_array_handle *h,
- size_t *lenp, ssize_t *incp);
-SCM_API double *scm_c64vector_writable_elements (SCM uvec,
- scm_t_array_handle *h,
- size_t *lenp,
- ssize_t *incp);
+#define SCM_SRFI4_DECL(tag, type) \
+ SCM_API SCM scm_##tag##vector_p (SCM obj); \
+ SCM_API SCM scm_make_##tag##vector (SCM n, SCM fill); \
+ SCM_API SCM scm_take_##tag##vector (type *data, size_t n); \
+ SCM_API SCM scm_##tag##vector (SCM l); \
+ SCM_API SCM scm_##tag##vector_length (SCM uvec); \
+ SCM_API SCM scm_##tag##vector_ref (SCM uvec, SCM index); \
+ SCM_API SCM scm_##tag##vector_set_x (SCM uvec, SCM index, SCM value); \
+ SCM_API SCM scm_##tag##vector_to_list (SCM uvec); \
+ SCM_API SCM scm_list_to_##tag##vector (SCM l); \
+ SCM_API SCM scm_any_to_##tag##vector (SCM obj); \
+ SCM_API const type *scm_array_handle_##tag##_elements (scm_t_array_handle *h); \
+ SCM_API type *scm_array_handle_##tag##_writable_elements (scm_t_array_handle *h); \
+ SCM_API const type *scm_##tag##vector_elements (SCM uvec, scm_t_array_handle *h, size_t *lenp, ssize_t *incp); \
+ SCM_API type *scm_##tag##vector_writable_elements (SCM uvec, scm_t_array_handle *h, size_t *lenp, ssize_t *incp);
+
+SCM_SRFI4_DECL (u8, uint8_t)
+SCM_SRFI4_DECL (s8, int8_t)
+SCM_SRFI4_DECL (u16, uint16_t)
+SCM_SRFI4_DECL (s16, int16_t)
+SCM_SRFI4_DECL (u32, uint32_t)
+SCM_SRFI4_DECL (s32, int32_t)
+SCM_SRFI4_DECL (u64, uint64_t)
+SCM_SRFI4_DECL (s64, int64_t)
+SCM_SRFI4_DECL (f32, float)
+SCM_SRFI4_DECL (f64, double)
+SCM_SRFI4_DECL (c32, float)
+SCM_SRFI4_DECL (c64, double)
+
+#undef SCM_SRFI4_DECL
SCM_INTERNAL void scm_init_srfi_4 (void);