~ chicken-core (chicken-5) 363f295dc28de04cf50f19f5f7d9a248763b3e3b
commit 363f295dc28de04cf50f19f5f7d9a248763b3e3b
Author: Evan Hanson <evhan@foldling.org>
AuthorDate: Wed Apr 27 20:47:08 2016 +1200
Commit: Peter Bex <peter@more-magic.net>
CommitDate: Thu May 12 20:43:02 2016 +0200
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.
Signed-off-by: Peter Bex <peter@more-magic.net>
diff --git a/README b/README
index 2ae9959d..e997947d 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 397c3e95..a4b87caf 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/csi.import.scm b/chicken.csi.import.scm
similarity index 83%
rename from csi.import.scm
rename to chicken.csi.import.scm
index a1fad2e1..104799d0 100644
--- a/csi.import.scm
+++ b/chicken.csi.import.scm
@@ -1,4 +1,4 @@
-;;;; csi.import.scm - import library for "csi" module
+;;;; chicken.csi.import.scm - import library for "chicken.csi" module
;
; Copyright (c) 2008-2015, The CHICKEN Team
; All rights reserved.
@@ -7,11 +7,11 @@
; conditions are met:
;
; Redistributions of source code must retain the above copyright notice, this list of conditions and the following
-; disclaimer.
+; 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.
+; 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.
+; 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
@@ -25,5 +25,7 @@
(##sys#register-primitive-module
- 'csi
- '(toplevel-command editor-command set-describer!))
+ 'chicken.csi
+ '((editor-command . chicken.csi#editor-command)
+ (set-describer! . chicken.csi#set-describer!)
+ (toplevel-command . chicken.csi#toplevel-command)))
diff --git a/csi.scm b/csi.scm
index 9eabeb65..fee1e83a 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 #<<EOF
#include <signal.h>
@@ -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 cf8044d3..404fa11c 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 5b088655..e9106cbd 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 fc5ba765..2891f090 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 49f53aec..285ad65e 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 99dcf878..fbb0b5e9 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 \
Trap