diff options
author | Andy Wingo <wingo@pobox.com> | 2017-09-23 15:16:04 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2017-09-23 15:33:02 +0200 |
commit | 5870188eb4b6c4246569a1aaaf358bc8a9e6a65d (patch) | |
tree | 239d2b31275520a409576073b67a8cd952a87fc8 /test-suite | |
parent | 0f14a9e59826c1c304d1f50c741e91d99760ff43 (diff) | |
download | guile-5870188eb4b6c4246569a1aaaf358bc8a9e6a65d.tar.gz |
Replace "pr" struct fields with "pw" fields
* libguile/struct.h (SCM_VTABLE_BASE_LAYOUT): Layout is a "pr" field.
* module/ice-9/boot-9.scm (record-type-vtable): Record vtable fields are
writable.
(<parameter>): "pw" fields.
* module/oop/goops.scm (<class>, %compute-layout): <read-only> fields
are "pw" underneath.
* module/rnrs/records/procedural.scm (record-type-vtable)
(record-constructor-vtable, make-record-type-descriptor): Use "pw"
fields in vtables.
* module/srfi/srfi-35.scm (%condition-type-vtable)
(struct-layout-for-condition): "pw" fields in vtables.
* test-suite/tests/goops.test:
* test-suite/tests/structs.test: Use "pw" fields only.
* benchmark-suite/benchmarks/structs.bm: Update for make-struct/no-tail,
to use pw fields, and also to remove useless tests that the compiler
would optimize away.
* doc/ref/api-data.texi (Vtables): Add a note about the now-vestigial
permissions character and update documentation.
(Structure Basics, Meta-Vtables): Update examples.
* libguile/hash.c (scm_i_struct_hash): Remove code that would handle
opaque/self fields.
* libguile/print.h (SCM_PRINT_STATE_LAYOUT): Use "pw" fields.
* libguile/struct.c (scm_struct_init): Simplify check for hidden
fields.
* libguile/values.c (scm_init_values): Field is "pw".
Diffstat (limited to 'test-suite')
-rw-r--r-- | test-suite/tests/goops.test | 6 | ||||
-rw-r--r-- | test-suite/tests/structs.test | 28 |
2 files changed, 14 insertions, 20 deletions
diff --git a/test-suite/tests/goops.test b/test-suite/tests/goops.test index 390cd8c74..4536a468d 100644 --- a/test-suite/tests/goops.test +++ b/test-suite/tests/goops.test @@ -1,6 +1,6 @@ ;;;; goops.test --- test suite for GOOPS -*- scheme -*- ;;;; -;;;; Copyright (C) 2001,2003,2004, 2006, 2008, 2009, 2011, 2012, 2014, 2015 Free Software Foundation, Inc. +;;;; Copyright (C) 2001,2003,2004, 2006, 2008, 2009, 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 @@ -148,7 +148,7 @@ ;; Previously, `class-of' would fail for nameless structs, i.e., structs ;; for which `struct-vtable-name' is #f. (is-a? (class-of (make-vtable - (string-append standard-vtable-fields "prprpr"))) + (string-append standard-vtable-fields "pwpwpw"))) <class>)) ;; Two cases: one for structs created before goops, one after. @@ -157,7 +157,7 @@ (class-of (current-module)))) (pass-if "late vtable class cached" (let ((vtable (make-vtable - (string-append standard-vtable-fields "prprpr")))) + (string-append standard-vtable-fields "pwpwpw")))) (eq? (class-of vtable) (class-of vtable))))) diff --git a/test-suite/tests/structs.test b/test-suite/tests/structs.test index c18e42194..3cbc67db3 100644 --- a/test-suite/tests/structs.test +++ b/test-suite/tests/structs.test @@ -27,7 +27,7 @@ ;;; (define ball-root - (make-vtable (string-append standard-vtable-fields "pr") 0)) + (make-vtable (string-append standard-vtable-fields "pw") 0)) (define (make-ball-type ball-color) (make-struct/no-tail ball-root @@ -69,13 +69,7 @@ ;; end of the vtable tower (eq? (struct-vtable <standard-vtable>) <standard-vtable>))) - (pass-if-exception "write-access denied" - exception:struct-set!-denied - - ;; The first field of instances of BALL-ROOT is read-only. - (struct-set! red vtable-offset-user "blue")) - - (pass-if "write-access granted" + (pass-if "write" (set-owner! (make-ball red "Bob") "Fred") #t) @@ -98,7 +92,7 @@ (pass-if-exception "struct-ref out-of-range" exception:out-of-range - (let* ((v (make-vtable "prpr")) + (let* ((v (make-vtable "pwpw")) (s (make-struct/no-tail v 'a 'b))) (struct-ref s 2))) @@ -112,7 +106,7 @@ (with-test-prefix "equal?" (pass-if "simple structs" - (let* ((vtable (make-vtable "pr")) + (let* ((vtable (make-vtable "pw")) (s1 (make-struct/no-tail vtable "hello")) (s2 (make-struct/no-tail vtable "hello"))) (equal? s1 s2))) @@ -130,21 +124,21 @@ (with-test-prefix "hash" (pass-if "simple structs" - (let* ((v (make-vtable "pr")) + (let* ((v (make-vtable "pw")) (s1 (make-struct/no-tail v "hello")) (s2 (make-struct/no-tail v "hello"))) (= (hash s1 7777) (hash s2 7777)))) (pass-if "different structs" - (let* ((v (make-vtable "pr")) + (let* ((v (make-vtable "pw")) (s1 (make-struct/no-tail v "hello")) (s2 (make-struct/no-tail v "world"))) (or (not (= (hash s1 7777) (hash s2 7777))) (throw 'unresolved)))) (pass-if "different struct types" - (let* ((v1 (make-vtable "pr")) - (v2 (make-vtable "pr")) + (let* ((v1 (make-vtable "pw")) + (v2 (make-vtable "pw")) (s1 (make-struct/no-tail v1 "hello")) (s2 (make-struct/no-tail v2 "hello"))) (or (not (= (hash s1 7777) (hash s2 7777))) @@ -156,7 +150,7 @@ (= (hash s1 7777) (hash s2 7777)))) (pass-if "struct with weird fields" - (let* ((v (make-vtable "prurph")) + (let* ((v (make-vtable "pwuwph")) (s1 (make-struct/no-tail v "hello" 123 "invisible-secret1")) (s2 (make-struct/no-tail v "hello" 123 "invisible-secret2"))) (= (hash s1 7777) (hash s2 7777)))) @@ -191,7 +185,7 @@ (with-test-prefix "make-vtable" (pass-if "without printer" - (let* ((vtable (make-vtable "pwpr")) + (let* ((vtable (make-vtable "pwpw")) (struct (make-struct/no-tail vtable 'x 'y))) (and (eq? 'x (struct-ref struct 0)) (eq? 'y (struct-ref struct 1))))) @@ -201,7 +195,7 @@ (define (print struct port) (display "hello" port)) - (let* ((vtable (make-vtable "pwpr" print)) + (let* ((vtable (make-vtable "pwpw" print)) (struct (make-struct/no-tail vtable 'x 'y)) (str (call-with-output-string (lambda (port) |