[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 03/07: Re-implement (ice-9 gap-buffer) records in terms
From: |
Andy Wingo |
Subject: |
[Guile-commits] 03/07: Re-implement (ice-9 gap-buffer) records in terms of srfi-9 |
Date: |
Tue, 22 Oct 2019 10:23:21 -0400 (EDT) |
wingo pushed a commit to branch master
in repository guile.
commit 0c8d20d2d022e4b990002d7960699af74732409b
Author: Andy Wingo <address@hidden>
Date: Tue Oct 22 13:47:02 2019 +0200
Re-implement (ice-9 gap-buffer) records in terms of srfi-9
* module/ice-9/gap-buffer.scm (gap-buffer): Use srfi-9.
---
module/ice-9/gap-buffer.scm | 62 ++++++++++++++++++---------------------------
1 file changed, 24 insertions(+), 38 deletions(-)
diff --git a/module/ice-9/gap-buffer.scm b/module/ice-9/gap-buffer.scm
index 4533bb5..b2fec4e 100644
--- a/module/ice-9/gap-buffer.scm
+++ b/module/ice-9/gap-buffer.scm
@@ -88,42 +88,30 @@
;;; Code:
(define-module (ice-9 gap-buffer)
- :autoload (srfi srfi-13) (string-join)
- :export (gb?
- make-gap-buffer
- gb-point
- gb-point-min
- gb-point-max
- gb-insert-string!
- gb-insert-char!
- gb-delete-char!
- gb-erase!
- gb-goto-char
- gb->string
- gb-filter!
- gb->lines
- gb-filter-lines!
- make-gap-buffer-port))
-
-(define gap-buffer
- (make-record-type 'gap-buffer
- '(s ; the buffer, a string
- all-sz ; total allocation
- gap-ofs ; GAP starts, aka (1- point)
- aft-ofs ; AFTER starts
- )))
-
-(define gb? (record-predicate gap-buffer))
-
-(define s: (record-accessor gap-buffer 's))
-(define all-sz: (record-accessor gap-buffer 'all-sz))
-(define gap-ofs: (record-accessor gap-buffer 'gap-ofs))
-(define aft-ofs: (record-accessor gap-buffer 'aft-ofs))
-
-(define s! (record-modifier gap-buffer 's))
-(define all-sz! (record-modifier gap-buffer 'all-sz))
-(define gap-ofs! (record-modifier gap-buffer 'gap-ofs))
-(define aft-ofs! (record-modifier gap-buffer 'aft-ofs))
+ #:use-module (srfi srfi-9)
+ #:export (gb?
+ make-gap-buffer
+ gb-point
+ gb-point-min
+ gb-point-max
+ gb-insert-string!
+ gb-insert-char!
+ gb-delete-char!
+ gb-erase!
+ gb-goto-char
+ gb->string
+ gb-filter!
+ gb->lines
+ gb-filter-lines!
+ make-gap-buffer-port))
+
+(define-record-type gap-buffer
+ (new)
+ gb?
+ (s s: s!) ; the buffer, a string
+ (all-sz all-sz: all-sz!) ; total allocation
+ (gap-ofs gap-ofs: gap-ofs!) ; GAP starts, aka (1- point)
+ (aft-ofs aft-ofs: aft-ofs!)) ; AFTER starts
;; todo: expose
(define default-initial-allocation 128)
@@ -133,8 +121,6 @@
(define (round-up n)
(* default-chunk-size (+ 1 (quotient n default-chunk-size))))
-(define new (record-constructor gap-buffer '()))
-
(define (realloc gb inc)
(let* ((old-s (s: gb))
(all-sz (all-sz: gb))
- [Guile-commits] branch master updated (2cca091 -> f060f1a), Andy Wingo, 2019/10/22
- [Guile-commits] 01/07: Refactor PEG records, Andy Wingo, 2019/10/22
- [Guile-commits] 02/07: Remove (ice-9 channel), Andy Wingo, 2019/10/22
- [Guile-commits] 06/07: Allow records to be subtyped, Andy Wingo, 2019/10/22
- [Guile-commits] 04/07: Deprecate two-arg `record-constructor', Andy Wingo, 2019/10/22
- [Guile-commits] 03/07: Re-implement (ice-9 gap-buffer) records in terms of srfi-9,
Andy Wingo <=
- [Guile-commits] 05/07: Fix deprecated 1-arg `make-module' in tests, Andy Wingo, 2019/10/22
- [Guile-commits] 07/07: Record accessors respect subtyping, Andy Wingo, 2019/10/22