1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-07-04 00:30:30 +02:00

Add srfi-14-internal.h

* libguile/srfi-14-internal.h: New file.
* libguile/Makefile.am (noinst_HEADERS): Add file.
* libguile/srfi-14.h: Remove internal definitions.
* libguile/init.c:
* libguile/srfi-14.c:
* libguile/eq.c:
* libguile/print.c: Use internal file.
This commit is contained in:
Andy Wingo 2025-06-30 15:43:56 +02:00
parent c66668a87a
commit 7c13e983b3
7 changed files with 84 additions and 56 deletions

View file

@ -43,39 +43,12 @@
#include "values.h"
#include "version.h"
#include "srfi-14.h"
#include "srfi-14-internal.h"
typedef struct scm_char_range
{
scm_t_wchar lo;
scm_t_wchar hi;
} scm_t_char_range;
/* Include the pre-computed standard charset data. */
#include "srfi-14.i.c"
/* We call this "charset" instead of "char_set" to avoid confusion with
"set" as a verb. */
struct scm_charset
{
scm_t_bits tag_and_flags;
struct scm_bytevector *ranges;
};
static inline struct scm_charset*
scm_to_charset (SCM scm)
{
if (!scm_is_char_set (scm)) abort();
return (struct scm_charset *) SCM_UNPACK_POINTER (scm);
}
static inline SCM
scm_from_charset (struct scm_charset *s)
{
return SCM_PACK_POINTER (s);
}
static inline scm_t_char_range*
char_ranges (struct scm_bytevector *bv)
{
@ -131,25 +104,6 @@ charset_range_contains (struct scm_charset *s, size_t idx, scm_t_wchar c)
return range->lo <= c && c <= range->hi;
}
static const scm_t_bits SCM_CHARSET_F_IMMUTABLE = 1 << 16;
static inline int
charset_is_immutable (SCM charset)
{
return scm_to_charset (charset)->tag_and_flags & SCM_CHARSET_F_IMMUTABLE;
}
#define SCM_VALIDATE_CHARSET(pos, x) \
do { \
SCM_ASSERT_TYPE (SCM_CHARSETP (x), x, pos, FUNC_NAME, "charset"); \
} while (0)
#define SCM_VALIDATE_MUTABLE_CHARSET(pos, x) \
do { \
SCM_ASSERT_TYPE (SCM_CHARSETP (x) && !charset_is_immutable (x), \
x, pos, FUNC_NAME, "mutable charset"); \
} while (0)
static const scm_t_char_range cs_full_ranges[] = {
{0x0000, SCM_CODEPOINT_SURROGATE_START - 1},
{SCM_CODEPOINT_SURROGATE_END + 1, SCM_CODEPOINT_MAX}
@ -691,7 +645,7 @@ SCM_DEFINE_STATIC (scm_charset_mutable_p, "charset-mutable?", 1, 0, 0,
#define FUNC_NAME s_scm_char_set_p
{
SCM_VALIDATE_CHARSET (1, cs);
return scm_from_bool (!charset_is_immutable (cs));
return scm_from_bool (!scm_charset_is_immutable (cs));
}
#undef FUNC_NAME