convert.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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
  5. * License as published by the Free Software Foundation; either
  6. * version 2.1 of the License, or (at your option) any later version.
  7. *
  8. * This library is distributed in the hope that it will be useful,
  9. * but 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 02110-1301 USA
  16. */
  17. #ifdef HAVE_CONFIG_H
  18. # include <config.h>
  19. #endif
  20. #include "libguile/_scm.h"
  21. #include "libguile/validate.h"
  22. #include "libguile/strings.h"
  23. #include "libguile/vectors.h"
  24. #include "libguile/pairs.h"
  25. #include "libguile/unif.h"
  26. #include "libguile/srfi-4.h"
  27. #include "libguile/convert.h"
  28. #ifdef HAVE_STRING_H
  29. #include <string.h>
  30. #endif
  31. /* char *scm_c_scm2chars (SCM obj, char *dst);
  32. SCM scm_c_chars2scm (const char *src, long n);
  33. SCM scm_c_chars2byvect (const char *src, long n);
  34. */
  35. #define CTYPE char
  36. #define FROM_CTYPE scm_from_char
  37. #define SCM2CTYPES scm_c_scm2chars
  38. #define CTYPES2SCM scm_c_chars2scm
  39. #define CTYPES2UVECT scm_c_chars2byvect
  40. #if CHAR_MIN == 0
  41. /* 'char' is unsigned. */
  42. #define UVEC_TAG u8
  43. #define UVEC_CTYPE scm_t_uint8
  44. #else
  45. /* 'char' is signed. */
  46. #define UVEC_TAG s8
  47. #define UVEC_CTYPE scm_t_int8
  48. #endif
  49. #include "libguile/convert.i.c"
  50. /* short *scm_c_scm2shorts (SCM obj, short *dst);
  51. SCM scm_c_shorts2scm (const short *src, long n);
  52. SCM scm_c_shorts2svect (const short *src, long n);
  53. */
  54. #define CTYPE short
  55. #define FROM_CTYPE scm_from_short
  56. #define SCM2CTYPES scm_c_scm2shorts
  57. #define CTYPES2SCM scm_c_shorts2scm
  58. #define CTYPES2UVECT scm_c_shorts2svect
  59. #define UVEC_TAG s16
  60. #define UVEC_CTYPE scm_t_int16
  61. #include "libguile/convert.i.c"
  62. /* int *scm_c_scm2ints (SCM obj, int *dst);
  63. SCM scm_c_ints2scm (const int *src, long n);
  64. SCM scm_c_ints2ivect (const int *src, long n);
  65. SCM scm_c_uints2uvect (const unsigned int *src, long n);
  66. */
  67. #define CTYPE int
  68. #define FROM_CTYPE scm_from_int
  69. #define SCM2CTYPES scm_c_scm2ints
  70. #define CTYPES2SCM scm_c_ints2scm
  71. #define CTYPES2UVECT scm_c_ints2ivect
  72. #define UVEC_TAG s32
  73. #define UVEC_CTYPE scm_t_int32
  74. #define CTYPES2UVECT_2 scm_c_uints2uvect
  75. #define CTYPE_2 unsigned int
  76. #define UVEC_TAG_2 u32
  77. #define UVEC_CTYPE_2 scm_t_uint32
  78. #include "libguile/convert.i.c"
  79. /* long *scm_c_scm2longs (SCM obj, long *dst);
  80. SCM scm_c_longs2scm (const long *src, long n);
  81. SCM scm_c_longs2ivect (const long *src, long n);
  82. SCM scm_c_ulongs2uvect (const unsigned long *src, long n);
  83. */
  84. #define CTYPE long
  85. #define FROM_CTYPE scm_from_long
  86. #define SCM2CTYPES scm_c_scm2longs
  87. #define CTYPES2SCM scm_c_longs2scm
  88. #define CTYPES2UVECT scm_c_longs2ivect
  89. #define UVEC_TAG s32
  90. #define UVEC_CTYPE scm_t_int32
  91. #define CTYPES2UVECT_2 scm_c_ulongs2uvect
  92. #define CTYPE_2 unsigned int
  93. #define UVEC_TAG_2 u32
  94. #define UVEC_CTYPE_2 scm_t_uint32
  95. #include "libguile/convert.i.c"
  96. /* float *scm_c_scm2floats (SCM obj, float *dst);
  97. SCM scm_c_floats2scm (const float *src, long n);
  98. SCM scm_c_floats2fvect (const float *src, long n);
  99. */
  100. #define CTYPE float
  101. #define FROM_CTYPE scm_from_double
  102. #define SCM2CTYPES scm_c_scm2floats
  103. #define CTYPES2SCM scm_c_floats2scm
  104. #define CTYPES2UVECT scm_c_floats2fvect
  105. #define UVEC_TAG f32
  106. #define UVEC_CTYPE float
  107. #include "libguile/convert.i.c"
  108. /* double *scm_c_scm2doubles (SCM obj, double *dst);
  109. SCM scm_c_doubles2scm (const double *src, long n);
  110. SCM scm_c_doubles2dvect (const double *src, long n);
  111. */
  112. #define CTYPE double
  113. #define FROM_CTYPE scm_from_double
  114. #define SCM2CTYPES scm_c_scm2doubles
  115. #define CTYPES2SCM scm_c_doubles2scm
  116. #define CTYPES2UVECT scm_c_doubles2dvect
  117. #define UVEC_TAG f64
  118. #define UVEC_CTYPE double
  119. #include "libguile/convert.i.c"
  120. /*
  121. Local Variables:
  122. c-file-style: "gnu"
  123. End:
  124. */