1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-07-01 07:20:20 +02:00
guile/libguile/strings-internal.h
Andy Wingo b25a743cf9 Get strings, symbols, stringbufs off scm_double_cell
* libguile/symbols.h (scm_is_symbol, scm_to_symbol, scm_from_symbol):
Define some helpers and a "struct scm_symbol".
* libguile/strings-internal.h (scm_i_string_data): Remove.
* libguile/print.c (write_char_in_string, write_narrow_string)
(write_wide_string): Refactor to avoid per-char narrow checks.
(write_character): Move up.
(iprin1): Adapt to call write_narrow_string / write_wide_string.
* libguile/srfi-13.c (scm_string_eq): Avoid scm_i_string_data.
* libguile/strings.c (scm_is_stringbuf, scm_to_stringbuf)
(scm_from_stringbuf, stringbuf_is_wide, stringbuf_is_narrow)
(stringbuf_is_mutable, stringbuf_set_mutable, stringbuf_length)
(as_narrow_stringbuf, as_wide_stringbuf, narrow_stringbuf_chars)
(wide_stringbuf_chars, scm_to_string, scm_from_string, string_is_read_only)
(string_is_shared, string_stringbuf, string_aliased_string, string_start)
(string_length): New inline function helpers, to replace a pile of
macros.  Adapt all users.
2025-06-23 15:00:09 +02:00

83 lines
3.3 KiB
C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef SCM_STRINGS_INTERNAL_H
#define SCM_STRINGS_INTERNAL_H
/* Copyright 1995-1998,2000-2001,2004-2006,2008-2011,2013,2015-2019,2022,2025
Free Software Foundation, Inc.
This file is part of Guile.
Guile is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Guile is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public
License along with Guile. If not, see
<https://www.gnu.org/licenses/>. */
#include <libguile/strings.h>
SCM_INTERNAL SCM scm_nullstr;
SCM_INTERNAL scm_t_string_failed_conversion_handler
scm_i_default_string_failed_conversion_handler (void);
/* Flags for shared and wide strings. */
#define SCM_I_STRINGBUF_F_WIDE 0x400
#define SCM_I_STRINGBUF_F_MUTABLE 0x800
SCM_INTERNAL void scm_i_print_stringbuf (SCM exp, SCM port,
scm_print_state *pstate);
/* internal accessor functions. Arguments must be valid. */
SCM_INTERNAL SCM scm_i_make_string (size_t len, char **datap,
int read_only_p);
SCM_INTERNAL SCM scm_i_make_wide_string (size_t len, scm_t_wchar **datap,
int read_only_p);
SCM_INTERNAL SCM scm_i_substring (SCM str, size_t start, size_t end);
SCM_INTERNAL SCM scm_i_substring_read_only (SCM str, size_t start, size_t end);
SCM_INTERNAL SCM scm_i_substring_shared (SCM str, size_t start, size_t end);
SCM_INTERNAL SCM scm_i_substring_copy (SCM str, size_t start, size_t end);
SCM_INTERNAL size_t scm_i_string_length (SCM str);
SCM_INTERNAL int scm_i_string_is_mutable (SCM str);
SCM_INTERNAL const scm_t_wchar *scm_i_string_wide_chars (SCM str);
SCM_INTERNAL SCM scm_i_string_start_writing (SCM str);
SCM_INTERNAL void scm_i_string_stop_writing (void);
SCM_INTERNAL int scm_i_is_narrow_string (SCM str);
SCM_INTERNAL scm_t_wchar scm_i_string_ref (SCM str, size_t x);
SCM_INTERNAL int scm_i_string_contains_char (SCM str, char c);
SCM_INTERNAL int scm_i_string_strcmp (SCM sstr, size_t start_x, const char *cstr);
SCM_INTERNAL void scm_i_string_set_x (SCM str, size_t p, scm_t_wchar chr);
SCM_INTERNAL SCM scm_i_make_symbol (SCM name, scm_t_bits flags,
unsigned long hash);
SCM_INTERNAL const char *scm_i_symbol_chars (SCM sym);
SCM_INTERNAL const scm_t_wchar *scm_i_symbol_wide_chars (SCM sym);
SCM_INTERNAL size_t scm_i_symbol_length (SCM sym);
SCM_INTERNAL int scm_i_is_narrow_symbol (SCM str);
SCM_INTERNAL int scm_i_try_narrow_string (SCM str);
SCM_INTERNAL SCM scm_i_symbol_substring (SCM sym, size_t start, size_t end);
SCM_INTERNAL scm_t_wchar scm_i_symbol_ref (SCM sym, size_t x);
SCM_INTERNAL void scm_encoding_error (const char *subr, int err,
const char *message, SCM port, SCM chr);
SCM_INTERNAL void scm_decoding_error (const char *subr, int err,
const char *message, SCM port);
SCM_INTERNAL void scm_i_get_substring_spec (size_t len,
SCM start, size_t *cstart,
SCM end, size_t *cend);
SCM_INTERNAL void scm_init_strings (void);
#endif /* SCM_STRINGS_INTERNAL_H */