summaryrefslogtreecommitdiff
path: root/libguile
diff options
context:
space:
mode:
Diffstat (limited to 'libguile')
-rw-r--r--libguile/hash.c32
-rw-r--r--libguile/print.h2
-rw-r--r--libguile/struct.c25
-rw-r--r--libguile/struct.h2
-rw-r--r--libguile/values.c4
5 files changed, 29 insertions, 36 deletions
diff --git a/libguile/hash.c b/libguile/hash.c
index 604708438..84285aa11 100644
--- a/libguile/hash.c
+++ b/libguile/hash.c
@@ -1,5 +1,5 @@
/* Copyright (C) 1995, 1996, 1997, 2000, 2001, 2003, 2004, 2006, 2008,
- * 2009, 2010, 2011, 2012, 2014, 2015 Free Software Foundation, Inc.
+ * 2009, 2010, 2011, 2012, 2014, 2015, 2017 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
@@ -240,25 +240,19 @@ scm_i_struct_hash (SCM obj, size_t depth)
if (depth > 0)
for (field_num = 0; field_num < struct_size; field_num++)
{
- int protection;
-
- protection = scm_i_symbol_ref (layout, field_num * 2 + 1);
- if (protection != 'h' && protection != 'o')
+ int type;
+ type = scm_i_symbol_ref (layout, field_num * 2);
+ switch (type)
{
- int type;
- type = scm_i_symbol_ref (layout, field_num * 2);
- switch (type)
- {
- case 'p':
- hash ^= scm_raw_ihash (SCM_PACK (data[field_num]),
- depth / 2);
- break;
- case 'u':
- hash ^= scm_raw_ihashq (data[field_num]);
- break;
- default:
- /* Ignore 's' fields. */;
- }
+ case 'p':
+ hash ^= scm_raw_ihash (SCM_PACK (data[field_num]),
+ depth / 2);
+ break;
+ case 'u':
+ hash ^= scm_raw_ihashq (data[field_num]);
+ break;
+ default:
+ abort ();
}
}
diff --git a/libguile/print.h b/libguile/print.h
index 11f533c79..2cfc39273 100644
--- a/libguile/print.h
+++ b/libguile/print.h
@@ -53,7 +53,7 @@ do { \
#define SCM_COERCE_OUTPORT(p) \
(SCM_PORT_WITH_PS_P (p) ? SCM_PORT_WITH_PS_PORT (p) : p)
-#define SCM_PRINT_STATE_LAYOUT "pruwuwuwuwuwpwuwuwurprpw"
+#define SCM_PRINT_STATE_LAYOUT "pwuwuwuwuwuwpwuwuwuwpwpw"
typedef struct scm_print_state {
SCM handle; /* Struct handle */
int revealed; /* Has the state escaped to Scheme? */
diff --git a/libguile/struct.c b/libguile/struct.c
index 4ee5a81ba..eb2bfbb56 100644
--- a/libguile/struct.c
+++ b/libguile/struct.c
@@ -67,9 +67,8 @@ SCM_DEFINE (scm_make_struct_layout, "make-struct-layout", 1, 0, 0,
"strung together. The first character of each pair describes a field\n"
"type, the second a field protection. Allowed types are 'p' for\n"
"GC-protected Scheme data, 'u' for unprotected binary data. \n"
- "Allowed protections\n"
- "are 'w' for mutable fields, 'h' for hidden fields, and\n"
- "'r' for read-only fields.\n\n"
+ "Allowed protections are 'w' for normal fields or 'h' for \n"
+ "hidden fields.\n\n"
"Hidden fields are writable, but they will not consume an initializer arg\n"
"passed to @code{make-struct}. They are useful to add slots to a struct\n"
"in a way that preserves backward-compatibility with existing calls to\n"
@@ -188,7 +187,12 @@ scm_is_valid_vtable_layout (SCM layout)
{
case 'w':
case 'h':
+ break;
case 'r':
+ scm_c_issue_deprecation_warning
+ ("Read-only struct fields are deprecated. Implement access "
+ "control at a higher level instead, as structs no longer "
+ "enforce field permissions.");
break;
default:
return 0;
@@ -293,7 +297,7 @@ scm_struct_init (SCM handle, SCM layout, size_t n_inits, scm_t_bits *inits)
switch (scm_i_symbol_ref (layout, i))
{
case 'u':
- if ((prot != 'r' && prot != 'w') || inits_idx == n_inits)
+ if (prot == 'h' || inits_idx == n_inits)
*mem = 0;
else
{
@@ -303,7 +307,7 @@ scm_struct_init (SCM handle, SCM layout, size_t n_inits, scm_t_bits *inits)
break;
case 'p':
- if ((prot != 'r' && prot != 'w') || inits_idx == n_inits)
+ if (prot == 'h' || inits_idx == n_inits)
*mem = SCM_UNPACK (SCM_BOOL_F);
else
{
@@ -470,9 +474,8 @@ SCM_DEFINE (scm_make_struct_no_tail, "make-struct/no-tail", 1, 0, 1,
"@var{vtable} must be a vtable structure (@pxref{Vtables}).\n\n"
"The @var{init1}, @dots{} are optional arguments describing how\n"
"successive fields of the structure should be initialized.\n"
- "Only fields with protection 'r' or 'w' can be initialized.\n"
- "Hidden fields (those with protection 'h') have to be manually\n"
- "set.\n\n"
+ "Note that hidden fields (those with protection 'h') have to be\n"
+ "manually set.\n\n"
"If fewer optional arguments than initializable fields are supplied,\n"
"fields of type 'p' get default value #f while fields of type 'u' are\n"
"initialized to 0.")
@@ -677,14 +680,10 @@ SCM_DEFINE (scm_struct_set_x, "struct-set!", 3, 0, 0,
else
{
SCM layout;
- scm_t_wchar field_type, protection;
+ scm_t_wchar field_type;
layout = SCM_STRUCT_LAYOUT (handle);
field_type = scm_i_symbol_ref (layout, p * 2);
- protection = scm_i_symbol_ref (layout, p * 2 + 1);
-
- if (protection == 'r')
- SCM_MISC_ERROR ("set! denied for field ~A", scm_list_1 (pos));
if (field_type == 'p')
SCM_STRUCT_SLOT_SET (handle, p, val);
diff --git a/libguile/struct.h b/libguile/struct.h
index 32af8ab5a..58228daa1 100644
--- a/libguile/struct.h
+++ b/libguile/struct.h
@@ -55,7 +55,7 @@
/* All vtables have the following fields. */
#define SCM_VTABLE_BASE_LAYOUT \
- "pr" /* layout */ \
+ "pw" /* layout */ \
"uh" /* flags */ \
"uh" /* finalizer */ \
"pw" /* printer */ \
diff --git a/libguile/values.c b/libguile/values.c
index 2b2ec3f51..f77a977c9 100644
--- a/libguile/values.c
+++ b/libguile/values.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000, 2001, 2006, 2008, 2009, 2011, 2012 Free Software Foundation, Inc.
+/* Copyright (C) 2000, 2001, 2006, 2008, 2009, 2011, 2012, 2017 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
@@ -141,7 +141,7 @@ scm_init_values (void)
{
SCM print = scm_c_define_gsubr ("%print-values", 2, 0, 0, print_values);
- scm_values_vtable = scm_make_vtable (scm_from_locale_string ("pr"), print);
+ scm_values_vtable = scm_make_vtable (scm_from_locale_string ("pw"), print);
scm_add_feature ("values");