>From 0c04a368436cb4e8e988ceb4a9946bfc2cf4337b Mon Sep 17 00:00:00 2001
From: Evan Hanson
Date: Wed, 27 Apr 2016 20:47:08 +1200
Subject: [PATCH] Modularise csi
Wraps csi in a module and renames the primitive "csi" module to
"chicken.csi" for consistency with the other core libraries.
Also cleans up some old and unused code from csi.scm.
---
README | 2 +-
chicken-install.scm | 2 +-
chicken.csi.import.scm | 31 +++++++++++++++++++++
csi.import.scm | 29 --------------------
csi.scm | 64 ++++++++++----------------------------------
defaults.make | 2 +-
distribution/manifest | 4 +--
manual/Using the interpreter | 5 ++++
tests/environment-tests.scm | 2 +-
tests/runtests.sh | 3 ++-
10 files changed, 58 insertions(+), 86 deletions(-)
create mode 100644 chicken.csi.import.scm
delete mode 100644 csi.import.scm
diff --git a/README b/README
index 2ae9959..e997947 100644
--- a/README
+++ b/README
@@ -286,6 +286,7 @@
| | |-- chicken.bitwise.import.so
| | |-- chicken.compiler.user-pass.import.so
| | |-- chicken.continuation.import.so
+ | | |-- chicken.csi.import.so
| | |-- chicken.data-structures.import.so
| | |-- chicken.eval.import.so
| | |-- chicken.expand.import.so
@@ -311,7 +312,6 @@
| | |-- chicken.tcp.import.so
| | |-- chicken.time.import.so
| | |-- chicken.utils.import.so
- | | |-- csi.import.so
| | |-- modules.db
| | |-- setup-api.import.so
| | |-- setup-api.so
diff --git a/chicken-install.scm b/chicken-install.scm
index 397c3e9..a4b87ca 100644
--- a/chicken-install.scm
+++ b/chicken-install.scm
@@ -46,6 +46,7 @@
;;XXX keep this up-to-date!
'("chicken.bitwise.import.so"
"chicken.continuation.import.so"
+ "chicken.csi.import.so"
"chicken.data-structures.import.so"
"chicken.eval.import.so"
"chicken.expand.import.so"
@@ -72,7 +73,6 @@
"chicken.tcp.import.so"
"chicken.time.import.so"
"chicken.utils.import.so"
- "csi.import.so"
"setup-api.import.so"
"setup-api.so"
"setup-download.so"
diff --git a/chicken.csi.import.scm b/chicken.csi.import.scm
new file mode 100644
index 0000000..104799d
--- /dev/null
+++ b/chicken.csi.import.scm
@@ -0,0 +1,31 @@
+;;;; chicken.csi.import.scm - import library for "chicken.csi" module
+;
+; Copyright (c) 2008-2015, The CHICKEN Team
+; All rights reserved.
+;
+; Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following
+; conditions are met:
+;
+; Redistributions of source code must retain the above copyright notice, this list of conditions and the following
+; disclaimer.
+; Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
+; disclaimer in the documentation and/or other materials provided with the distribution.
+; Neither the name of the author nor the names of its contributors may be used to endorse or promote
+; products derived from this software without specific prior written permission.
+;
+; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
+; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+; AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+; POSSIBILITY OF SUCH DAMAGE.
+
+
+(##sys#register-primitive-module
+ 'chicken.csi
+ '((editor-command . chicken.csi#editor-command)
+ (set-describer! . chicken.csi#set-describer!)
+ (toplevel-command . chicken.csi#toplevel-command)))
diff --git a/csi.import.scm b/csi.import.scm
deleted file mode 100644
index a1fad2e..0000000
--- a/csi.import.scm
+++ /dev/null
@@ -1,29 +0,0 @@
-;;;; csi.import.scm - import library for "csi" module
-;
-; Copyright (c) 2008-2015, The CHICKEN Team
-; All rights reserved.
-;
-; Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following
-; conditions are met:
-;
-; Redistributions of source code must retain the above copyright notice, this list of conditions and the following
-; disclaimer.
-; Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
-; disclaimer in the documentation and/or other materials provided with the distribution.
-; Neither the name of the author nor the names of its contributors may be used to endorse or promote
-; products derived from this software without specific prior written permission.
-;
-; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
-; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
-; AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
-; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-; POSSIBILITY OF SUCH DAMAGE.
-
-
-(##sys#register-primitive-module
- 'csi
- '(toplevel-command editor-command set-describer!))
diff --git a/csi.scm b/csi.scm
index 5466deb..86755c1 100644
--- a/csi.scm
+++ b/csi.scm
@@ -28,7 +28,8 @@
(declare
(usual-integrations)
(disable-interrupts)
- (compile-syntax)
+ (fixnum-arithmetic)
+ (always-bound ##sys#windows-platform)
(foreign-declare #<
@@ -40,20 +41,11 @@
EOF
) )
-(include "banner")
+(module chicken.csi
+ (editor-command toplevel-command set-describer!)
-(declare
- (always-bound
- ##sys#windows-platform)
- (hide parse-option-string bytevector-data member* canonicalize-args
- describer-table dirseparator? circular-list? improper-pairs?
- show-frameinfo selected-frame select-frame copy-from-frame
- findall command-table default-editor csi-eval print-usage
- print-banner run hexdump chop-separator lookup-script-file report
- describe dump tty-input? history-list history-count
- history-add history-ref history-clear history-show) )
-
-(import chicken.data-structures
+(import chicken scheme
+ chicken.data-structures
chicken.foreign
chicken.format
chicken.gc
@@ -63,6 +55,7 @@ EOF
chicken.pretty-print
chicken.repl)
+(include "banner.scm")
;;; Parameters:
@@ -136,23 +129,6 @@ EOF
(define (print-banner)
(newline)
- ;;UNUSED BECAUSE IT IS STUPID
- #;(when (and (tty-input?) (##sys#fudge 11))
- (let* ((t (string-copy +product+))
- (len (string-length t))
- (c (make-string len #\x08)))
- (do ((i (sub1 (* 2 len)) (sub1 i)))
- ((zero? i))
- (let* ((p (abs (- i len)))
- (o (string-ref t p)))
- (string-set! t p #\@)
- (print* t)
- (string-set! t p o)
- (let ((t0 (+ (current-milliseconds) 20)))
- (let loop () ; crude, but doesn't need srfi-18
- (when (< (current-milliseconds) t0)
- (loop))))
- (print* c) ) ) ) )
(print +product+)
(print +banner+ (chicken-version #t) "\n") )
@@ -160,9 +136,7 @@ EOF
;;; Reader for REPL history:
(set! ##sys#user-read-hook
- (let ([read-char read-char]
- [read read]
- [old-hook ##sys#user-read-hook] )
+ (let ((old-hook ##sys#user-read-hook))
(lambda (char port)
(cond [(or (char=? #\) char) (char-whitespace? char))
`',(history-ref (fx- history-count 1)) ]
@@ -191,8 +165,6 @@ EOF
;;; Find script in PATH (only used for Windows/DOS):
-(define @ #f)
-
(define lookup-script-file
(let* ([buf (make-string 256)]
[_getcwd (foreign-lambda nonnull-c-string "_getcwd" scheme-pointer int)] )
@@ -298,14 +270,11 @@ EOF
(load-noisily load-noisily)
(read read)
(read-line read-line)
- (length length)
(display display)
- (write write)
(string-split string-split)
(printf printf)
(expand expand)
(pretty-print pretty-print)
- (integer? integer?)
(values values) )
(lambda (form)
(cond ((eof-object? form) (exit))
@@ -466,7 +435,6 @@ EOF
(define report
(let ((printf printf)
- (chop chop)
(sort sort)
(with-output-to-port with-output-to-port)
(current-output-port current-output-port)
@@ -811,8 +779,7 @@ EOF
;;; Frame-info operations:
(define show-frameinfo
- (let ((write-char write-char)
- (newline newline)
+ (let ((newline newline)
(display display))
(lambda (fn)
(define (prin1 x)
@@ -1141,11 +1108,8 @@ EOF
(newline ##sys#standard-error)
(eval x)))))
(when (equal? "-ss" scr)
- (call-with-values (cut main (command-line-arguments))
- (lambda results
- (exit
- (if (and (pair? results) (fixnum? (car results)))
- (car results)
- 0) ) ) ) ) ) ) ) ) ) ) ) )
-
-(run)
+ (receive rs ((eval 'main) (command-line-arguments))
+ (let ((r (optional rs)))
+ (exit (if (fixnum? r) r 0)))))))))))))
+
+(run))
diff --git a/defaults.make b/defaults.make
index cf8044d..404fa11 100644
--- a/defaults.make
+++ b/defaults.make
@@ -262,7 +262,7 @@ CHICKEN_PROGRAM_OPTIONS += $(if $(PROFILE_OBJECTS),-profile)
# import libraries
-PRIMITIVE_IMPORT_LIBRARIES = chicken csi chicken.foreign
+PRIMITIVE_IMPORT_LIBRARIES = chicken chicken.csi chicken.foreign
DYNAMIC_IMPORT_LIBRARIES = setup-api setup-download srfi-4
DYNAMIC_CHICKEN_IMPORT_LIBRARIES = bitwise fixnum flonum format gc io \
keyword locative posix pretty-print random time
diff --git a/distribution/manifest b/distribution/manifest
index 5b08865..e9106cb 100644
--- a/distribution/manifest
+++ b/distribution/manifest
@@ -259,6 +259,8 @@ chicken.compiler.user-pass.import.scm
chicken.compiler.user-pass.import.c
chicken.continuation.import.scm
chicken.continuation.import.c
+chicken.csi.import.scm
+chicken.csi.import.c
chicken.data-structures.import.scm
chicken.data-structures.import.c
chicken.eval.import.scm
@@ -309,8 +311,6 @@ chicken.utils.import.scm
chicken.utils.import.c
srfi-4.import.scm
srfi-4.import.c
-csi.import.scm
-csi.import.c
setup-download.scm
setup-api.scm
chicken-status.scm
diff --git a/manual/Using the interpreter b/manual/Using the interpreter
index fc5ba76..2891f09 100644
--- a/manual/Using the interpreter
+++ b/manual/Using the interpreter
@@ -201,6 +201,8 @@ Defines or redefines a toplevel interpreter command which can be invoked by ente
read any required argument via {{read}} (or {{read-line}}). If the optional
argument {{HELPSTRING}} is given, it will be listed by the {{,?}} command.
+This procedure is provided by the {{(chicken csi)}} module.
+
=== Getting error information
@@ -285,6 +287,9 @@ example:
#;3> ,d (make-point 1 2)
a point with x=1 and y=2
+This procedure is provided by the {{(chicken csi)}} module.
+
+
=== Auto-completion and edition
On platforms that support it, it is possible to get auto-completion of
diff --git a/tests/environment-tests.scm b/tests/environment-tests.scm
index 49f53ae..285ad65 100644
--- a/tests/environment-tests.scm
+++ b/tests/environment-tests.scm
@@ -40,7 +40,7 @@
(define (bar) 99))
(define foo-env (module-environment 'foo))
-(define csi-env (module-environment 'csi))
+(define csi-env (module-environment '(chicken csi)))
(define format-env (module-environment 'format))
(test-equal (eval '(bar) foo-env) 99)
diff --git a/tests/runtests.sh b/tests/runtests.sh
index 99dcf87..fbb0b5e 100755
--- a/tests/runtests.sh
+++ b/tests/runtests.sh
@@ -36,11 +36,12 @@ mkdir -p test-repository
# copy files into test-repository (by hand to avoid calling `chicken-install'):
for x in \
- chicken.import.so csi.import.so types.db \
+ chicken.import.so types.db \
setup-api.so setup-api.import.so srfi-4.import.so \
setup-download.so setup-download.import.so \
chicken.bitwise.import.so \
chicken.continuation.import.so \
+ chicken.csi.import.so \
chicken.data-structures.import.so \
chicken.files.import.so \
chicken.flonum.import.so \
--
2.7.0