summaryrefslogtreecommitdiff
path: root/libguile/strings.h
diff options
context:
space:
mode:
Diffstat (limited to 'libguile/strings.h')
-rw-r--r--libguile/strings.h106
1 files changed, 79 insertions, 27 deletions
diff --git a/libguile/strings.h b/libguile/strings.h
index fa0c663b8..3f92d8c89 100644
--- a/libguile/strings.h
+++ b/libguile/strings.h
@@ -1,30 +1,31 @@
-/* classes: h_files */
-
#ifndef SCM_STRINGS_H
#define SCM_STRINGS_H
-/* Copyright (C) 1995-1998, 2000, 2001, 2004-2006, 2008-2011, 2013,
- * 2015-2018 Free Software Foundation, Inc.
- *
- * This library 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.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA
- */
+/* Copyright 1995-1998,2000-2001,2004-2006,2008-2011,2013,2015-2019
+ 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/__scm.h"
+#include <libguile/gc.h>
+#include <libguile/error.h>
+#include "libguile/inline.h"
+#include <libguile/snarf.h>
@@ -104,6 +105,7 @@ SCM_INTERNAL SCM scm_nullstr;
SCM_INTERNAL scm_t_string_failed_conversion_handler
scm_i_default_string_failed_conversion_handler (void);
+SCM_INLINE int scm_is_string (SCM x);
SCM_API SCM scm_string_p (SCM x);
SCM_API SCM scm_string (SCM chrs);
SCM_API SCM scm_make_string (SCM k, SCM chr);
@@ -176,6 +178,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 */
/* Type tag for read-only strings. */
@@ -247,13 +282,30 @@ SCM_API SCM scm_sys_stringbuf_hist (void);
#endif
+
+
+#if SCM_CAN_INLINE || defined SCM_INLINE_C_IMPLEMENTING_INLINES
+/* Either inlining, or being included from inline.c. */
+
+SCM_INLINE_IMPLEMENTATION int
+scm_is_string (SCM x)
+{
+ return SCM_HAS_TYP7 (x, scm_tc7_string);
+}
+
+#endif
+
+
+
+
+#define SCM_VALIDATE_STRING(pos, str) \
+ do { \
+ SCM_ASSERT_TYPE (scm_is_string (str), str, pos, FUNC_NAME, "string"); \
+ } while (0)
+
+
+
SCM_INTERNAL void scm_init_strings (void);
#endif /* SCM_STRINGS_H */
-
-/*
- Local Variables:
- c-file-style: "gnu"
- End:
-*/