1 /* Copyright (C) 2002, 2006 Free Software Foundation, Inc.
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public License
5 * as published by the Free Software Foundation; either version 3 of
6 * the License, or (at your option) any later version.
8 * This library is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 #include "libguile/_scm.h"
25 #include "libguile/validate.h"
26 #include "libguile/strings.h"
27 #include "libguile/vectors.h"
28 #include "libguile/pairs.h"
29 #include "libguile/unif.h"
30 #include "libguile/srfi-4.h"
32 #include "libguile/convert.h"
38 /* char *scm_c_scm2chars (SCM obj, char *dst);
39 SCM scm_c_chars2scm (const char *src, long n);
40 SCM scm_c_chars2byvect (const char *src, long n);
44 #define FROM_CTYPE scm_from_char
45 #define SCM2CTYPES scm_c_scm2chars
46 #define CTYPES2SCM scm_c_chars2scm
47 #define CTYPES2UVECT scm_c_chars2byvect
49 /* 'char' is unsigned. */
51 #define UVEC_CTYPE scm_t_uint8
53 /* 'char' is signed. */
55 #define UVEC_CTYPE scm_t_int8
57 #include "libguile/convert.i.c"
59 /* short *scm_c_scm2shorts (SCM obj, short *dst);
60 SCM scm_c_shorts2scm (const short *src, long n);
61 SCM scm_c_shorts2svect (const short *src, long n);
65 #define FROM_CTYPE scm_from_short
66 #define SCM2CTYPES scm_c_scm2shorts
67 #define CTYPES2SCM scm_c_shorts2scm
68 #define CTYPES2UVECT scm_c_shorts2svect
70 #define UVEC_CTYPE scm_t_int16
71 #include "libguile/convert.i.c"
73 /* int *scm_c_scm2ints (SCM obj, int *dst);
74 SCM scm_c_ints2scm (const int *src, long n);
75 SCM scm_c_ints2ivect (const int *src, long n);
76 SCM scm_c_uints2uvect (const unsigned int *src, long n);
80 #define FROM_CTYPE scm_from_int
81 #define SCM2CTYPES scm_c_scm2ints
82 #define CTYPES2SCM scm_c_ints2scm
83 #define CTYPES2UVECT scm_c_ints2ivect
85 #define UVEC_CTYPE scm_t_int32
87 #define CTYPES2UVECT_2 scm_c_uints2uvect
88 #define CTYPE_2 unsigned int
89 #define UVEC_TAG_2 u32
90 #define UVEC_CTYPE_2 scm_t_uint32
92 #include "libguile/convert.i.c"
94 /* long *scm_c_scm2longs (SCM obj, long *dst);
95 SCM scm_c_longs2scm (const long *src, long n);
96 SCM scm_c_longs2ivect (const long *src, long n);
97 SCM scm_c_ulongs2uvect (const unsigned long *src, long n);
101 #define FROM_CTYPE scm_from_long
102 #define SCM2CTYPES scm_c_scm2longs
103 #define CTYPES2SCM scm_c_longs2scm
104 #define CTYPES2UVECT scm_c_longs2ivect
106 #define UVEC_CTYPE scm_t_int32
108 #define CTYPES2UVECT_2 scm_c_ulongs2uvect
109 #define CTYPE_2 unsigned int
110 #define UVEC_TAG_2 u32
111 #define UVEC_CTYPE_2 scm_t_uint32
113 #include "libguile/convert.i.c"
115 /* float *scm_c_scm2floats (SCM obj, float *dst);
116 SCM scm_c_floats2scm (const float *src, long n);
117 SCM scm_c_floats2fvect (const float *src, long n);
121 #define FROM_CTYPE scm_from_double
122 #define SCM2CTYPES scm_c_scm2floats
123 #define CTYPES2SCM scm_c_floats2scm
124 #define CTYPES2UVECT scm_c_floats2fvect
126 #define UVEC_CTYPE float
127 #include "libguile/convert.i.c"
129 /* double *scm_c_scm2doubles (SCM obj, double *dst);
130 SCM scm_c_doubles2scm (const double *src, long n);
131 SCM scm_c_doubles2dvect (const double *src, long n);
135 #define FROM_CTYPE scm_from_double
136 #define SCM2CTYPES scm_c_scm2doubles
137 #define CTYPES2SCM scm_c_doubles2scm
138 #define CTYPES2UVECT scm_c_doubles2dvect
140 #define UVEC_CTYPE double
141 #include "libguile/convert.i.c"