1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 03:30:27 +02:00

Move string-related snarfers to strings.h

* libguile/snarf.h:
* libguile/strings.h (SCM_IMMUTABLE_STRINGBUF, SCM_IMMUTABLE_STRING):
  Move here.
This commit is contained in:
Andy Wingo 2018-06-20 09:22:18 +02:00
parent 8f8e450a60
commit 93dcc55761
2 changed files with 35 additions and 25 deletions

View file

@ -195,33 +195,9 @@ SCM_SNARF_INIT(scm_set_smob_apply((tag), (c_name), (req), (opt), (rest));)
{ SCM_PACK (ccr), SCM_PACK (cdr) } \
}; \
static SCM_UNUSED const SCM c_name = SCM_PACK (& c_name ## _raw_cell)
#define SCM_IMMUTABLE_STRINGBUF(c_name, contents) \
static SCM_UNUSED const \
struct \
{ \
scm_t_bits word_0; \
scm_t_bits word_1; \
const char buffer[sizeof (contents)]; \
} \
c_name = \
{ \
scm_tc7_stringbuf, \
sizeof (contents) - 1, \
contents \
}
#define SCM_IMMUTABLE_STRING(c_name, contents) \
SCM_IMMUTABLE_STRINGBUF (scm_i_paste (c_name, _stringbuf), contents); \
SCM_IMMUTABLE_DOUBLE_CELL (c_name, \
scm_tc7_ro_string, \
(scm_t_bits) &scm_i_paste (c_name, \
_stringbuf), \
(scm_t_bits) 0, \
(scm_t_bits) (sizeof (contents) - 1))
#endif /* SCM_SUPPORT_STATIC_ALLOCATION */
/* Documentation. */

View file

@ -26,6 +26,7 @@
#include "libguile/__scm.h"
#include <libguile/error.h>
#include <libguile/snarf.h>
@ -176,6 +177,39 @@ SCM_API SCM scm_string_normalize_nfkc (SCM str);
SCM_API SCM scm_makfromstrs (int argc, char **argv);
/* Snarfing support. See snarf.h. */
#ifdef SCM_SUPPORT_STATIC_ALLOCATION
#define SCM_IMMUTABLE_STRINGBUF(c_name, contents) \
static SCM_UNUSED const \
struct \
{ \
scm_t_bits word_0; \
scm_t_bits word_1; \
const char buffer[sizeof (contents)]; \
} \
c_name = \
{ \
scm_tc7_stringbuf, \
sizeof (contents) - 1, \
contents \
}
#define SCM_IMMUTABLE_STRING(c_name, contents) \
SCM_IMMUTABLE_STRINGBUF (scm_i_paste (c_name, _stringbuf), contents); \
SCM_IMMUTABLE_DOUBLE_CELL (c_name, \
scm_tc7_ro_string, \
(scm_t_bits) &scm_i_paste (c_name, \
_stringbuf), \
(scm_t_bits) 0, \
(scm_t_bits) (sizeof (contents) - 1))
#endif /* SCM_SUPPORT_STATIC_ALLOCATION */
/* internal constants */