Avoid unpacking symbols in GOOPS
[bpt/guile.git] / libguile / convert.c
1 /* Copyright (C) 2002, 2006 Free Software Foundation, Inc.
2 *
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.
7 *
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.
12 *
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
16 * 02110-1301 USA
17 */
18
19 \f
20 #ifdef HAVE_CONFIG_H
21 # include <config.h>
22 #endif
23
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"
31
32 #include "libguile/convert.h"
33
34 #ifdef HAVE_STRING_H
35 #include <string.h>
36 #endif
37
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);
41 */
42
43 #define CTYPE char
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
48 #if CHAR_MIN == 0
49 /* 'char' is unsigned. */
50 #define UVEC_TAG u8
51 #define UVEC_CTYPE scm_t_uint8
52 #else
53 /* 'char' is signed. */
54 #define UVEC_TAG s8
55 #define UVEC_CTYPE scm_t_int8
56 #endif
57 #include "libguile/convert.i.c"
58
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);
62 */
63
64 #define CTYPE short
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
69 #define UVEC_TAG s16
70 #define UVEC_CTYPE scm_t_int16
71 #include "libguile/convert.i.c"
72
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);
77 */
78
79 #define CTYPE int
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
84 #define UVEC_TAG s32
85 #define UVEC_CTYPE scm_t_int32
86
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
91
92 #include "libguile/convert.i.c"
93
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);
98 */
99
100 #define CTYPE long
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
105 #define UVEC_TAG s32
106 #define UVEC_CTYPE scm_t_int32
107
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
112
113 #include "libguile/convert.i.c"
114
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);
118 */
119
120 #define CTYPE float
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
125 #define UVEC_TAG f32
126 #define UVEC_CTYPE float
127 #include "libguile/convert.i.c"
128
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);
132 */
133
134 #define CTYPE double
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
139 #define UVEC_TAG f64
140 #define UVEC_CTYPE double
141 #include "libguile/convert.i.c"
142
143 /*
144 Local Variables:
145 c-file-style: "gnu"
146 End:
147 */