From 473d16e99bc4af1144441a604c4c53fa5cb238f2 Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Thu, 24 Nov 2011 10:49:55 +0900 Subject: [PATCH] updating docs for new release --- AUTHORS | 3 ++- README | 11 ++++++----- doc/chibi-scheme.1 | 13 +++++++++++-- doc/chibi.scrbl | 32 ++++++++++++++++++++++---------- examples/echo-server.scm | 38 ++++++++++++++++++++++++++++++++++++++ tests/process-tests.scm | 28 ++++++++++++++++++++++++++++ tests/system-tests.scm | 27 +++++++++++++++++++++++++++ 7 files changed, 134 insertions(+), 18 deletions(-) create mode 100644 examples/echo-server.scm create mode 100644 tests/process-tests.scm create mode 100644 tests/system-tests.scm diff --git a/AUTHORS b/AUTHORS index e245acec..bfd9b4fb 100644 --- a/AUTHORS +++ b/AUTHORS @@ -11,8 +11,9 @@ Thanks to the following people for patches and bug reports: * Andreas Rottman * Bakul Shah * Bruno Deferrari - * Doug Curie + * Doug Currie * Derrick Eddington + * Dmitry Chestnykh * Eduardo Cavazos * Felix Winkelmann * Gregor Klinke diff --git a/README b/README index 981a949e..94da7991 100644 --- a/README +++ b/README @@ -11,11 +11,12 @@ and scripting language in C programs. In addition to support for lightweight VM-based threads, each VM itself runs in an isolated heap allowing multiple VMs to run simultaneously in different OS threads. -The default language is R7RS Scheme with support for additional -languages such as JavaScript to be provided in future releases. -Scheme is chosen as a substrate because its first class continuations -and guaranteed tail-call optimization makes implementing other -languages easy. +The default language is an extended subset of the current draft R7RS +Scheme, with support for all libraries. Support for additional +languages such as JavaScript, Go, Lua and Bash are planned for future +releases. Scheme is chosen as a substrate because its first class +continuations and guaranteed tail-call optimization makes implementing +other languages easy. To build on most platforms just run "make && make test". This will provide a shared library "libchibi-scheme", as well as a sample diff --git a/doc/chibi-scheme.1 b/doc/chibi-scheme.1 index 772b8e10..da879cfb 100644 --- a/doc/chibi-scheme.1 +++ b/doc/chibi-scheme.1 @@ -56,7 +56,8 @@ is given, the script will be loaded with SRFI-22 semantics, calling the procedure .I main (if defined) with a single parameter as a list of the -command-line arguments beginning with the script name. +command-line arguments beginning with the script name. This +works as expected with shell #! semantics. Otherwise, if no script is given and no -e or -p options are given an interactive repl is entered, reading, evaluating, @@ -65,7 +66,15 @@ provided is very minimal - if you want readline completion you may want to wrap it with the .I rlwrap(1) program. Signals aren't caught either - to enable handling keyboard -interrupts you can use the (chibi process) module. +interrupts you can use the (chibi process) module. For a more +sophisticated REPL with readline support, signal handling, module +management and smarter read/write you may want to use the (chibi repl) +module. For example, +.I chibi-scheme -mchibi.repl -e'(repl)' + +The default language is an extended subset of the draft R7RS +(scheme base) module. To get exactly the base module, use +.I chibi-scheme -xscheme.base .SH OPTIONS .TP 5 diff --git a/doc/chibi.scrbl b/doc/chibi.scrbl index 1c5dc301..9ec44360 100755 --- a/doc/chibi.scrbl +++ b/doc/chibi.scrbl @@ -13,13 +13,12 @@ and scripting language in C programs. In addition to support for lightweight VM-based threads, each VM itself runs in an isolated heap allowing multiple VMs to run simultaneously in different OS threads. -@margin-note{Converging with the -R7RS Scheme small language standard when the standard is finalized.} -The default language is R5RS Scheme with support for additional -languages such as JavaScript to be provided in future releases. -Scheme is chosen as a substrate because its first class continuations -and guaranteed tail-call optimization makes implementing other -languages easy. +The default language is an extended subset of the current draft R7RS +Scheme, with support for all libraries. Support for additional +languages such as JavaScript, Go, Lua and Bash are planned for future +releases. Scheme is chosen as a substrate because its first class +continuations and guaranteed tail-call optimization makes implementing +other languages easy. The system is designed in optional layers, beginning with a VM based on a small set of opcodes, a set of primitives implemented in C, a @@ -28,8 +27,8 @@ standard modules. You can choose whichever layer suits your needs best and customize the rest. Adding your own primitives or wrappers around existing C libraries is easy with the C FFI. -Chibi is known to build and run on 32 and 64-bit Linux, OS X, -iOS, Windows (under cygwin) and Plan9. +Chibi is known to build and run on 32 and 64-bit Linux, FreeBSD, OS X, +iOS, Windows (under Cygwin) and Plan9. @section{Installation} @@ -43,7 +42,8 @@ test the build with "make test". To install run "make install". If you want to try the executable out without installing, you will probably need to set LD_LIBRARY_PATH, -depending on your platform. +depending on your platform. If you have an old version installed, +run "make uninstall" first, or manually delete the directory. You can edit the file chibi/features.h for a number of settings, mostly disabling features to make the executable smaller. You can @@ -106,6 +106,18 @@ are listed below. @item{@ccode{SEXP_USE_NO_FEATURES} - disable almost all features} ] +@subsection{Installed Programs} + +The command-line programs @ccode{chibi-scheme}, @ccode{chibi-doc} and +@ccode{chibi-ffi} are installed by default, along with manpages. +@ccode{chibi-scheme} provides a REPL and way to run scripts. In the +interest of size it has no --help option - see the man page for usage. +@ccode{chibi-doc} is the command-line interface to the literate +documentation system described in +@hyperlink["lib/chibi/scribble.html"]{(chibi scribble)}, and used to +build this manual. @ccode{chibi-ffi} is a tool to build wrappers for +C libraries, described in the FFI section below. + @section{Default Language} @subsection{Scheme Standard} diff --git a/examples/echo-server.scm b/examples/echo-server.scm new file mode 100644 index 00000000..88972225 --- /dev/null +++ b/examples/echo-server.scm @@ -0,0 +1,38 @@ + +(import (srfi 18) (chibi net) (chibi io) (chibi filesystem)) + +;; Copy each input line to output. +(define (echo-handler in out) + (let ((line (read-line in))) + (cond + ((not (eof-object? line)) + (display line out) + (newline out) + (flush-output out) + (echo-handler in out))))) + +;; Run a handler in a separate thread on the input and output ports, +;; then cleanup. +(define (run-io-handler sock handler) + (let ((in (open-input-file-descriptor sock)) + (out (open-output-file-descriptor sock))) + (thread-start! + (make-thread + (lambda () + (handler in out) + (close-input-port in) + (close-output-port out) + (close-file-descriptor sock)))))) + +;; Basic server loop - repeatedly call accept, and dispatch the new +;; socket to a handler. +(define (serve host port) + (let* ((addrinfo (get-address-info host port)) + (sock (make-listener-socket addrinfo))) + (do () (#f) + (let ((fd (accept sock + (address-info-address addrinfo) + (address-info-address-length addrinfo)))) + (run-io-handler fd echo-handler))))) + +(serve "localhost" 5556) diff --git a/tests/process-tests.scm b/tests/process-tests.scm new file mode 100644 index 00000000..3f79a568 --- /dev/null +++ b/tests/process-tests.scm @@ -0,0 +1,28 @@ + +(cond-expand + (modules (import (chibi process) (only (chibi test) test-begin test test-end))) + (else #f)) + +(test-begin "processes") + +(test #t (process-running? (current-process-id))) +(test #t (process-running? (parent-process-id))) +(test #f (signal-set-contains? (current-signal-mask) signal/alarm)) + +(test #t (signal-set? (make-signal-set))) +(test #t (signal-set? (current-signal-mask))) +(test #f (signal-set? #f)) +(test #f (signal-set? '(#f))) +(test #f (signal-set-contains? (make-signal-set) signal/interrupt)) +(test #t (let ((sset (make-signal-set))) + (signal-set-fill! sset) + (signal-set-contains? sset signal/interrupt))) +(test #t (let ((sset (make-signal-set))) + (signal-set-add! sset signal/interrupt) + (signal-set-contains? sset signal/interrupt))) +(test #f (let ((sset (make-signal-set))) + (signal-set-fill! sset) + (signal-set-delete! sset signal/interrupt) + (signal-set-contains? sset signal/interrupt))) + +(test-end) diff --git a/tests/system-tests.scm b/tests/system-tests.scm new file mode 100644 index 00000000..a3350f08 --- /dev/null +++ b/tests/system-tests.scm @@ -0,0 +1,27 @@ + +(cond-expand + (modules (import (chibi system) (only (chibi test) test-begin test test-end))) + (else #f)) + +(test-begin "system") + +(test #t (user? (user-information (current-user-id)))) +(test #f (user? #f)) +(test #f (user? (list #f))) +(test #t (string? (user-name (user-information (current-user-id))))) +(test #t (string? (user-password (user-information (current-user-id))))) +(test #t (integer? (user-id (user-information (current-user-id))))) +(test #t (integer? (user-group-id (user-information (current-user-id))))) +(test #t (string? (user-gecos (user-information (current-user-id))))) +(test #t (string? (user-home (user-information (current-user-id))))) +(test #t (string? (user-shell (user-information (current-user-id))))) + +(test (current-user-id) (user-id (user-information (current-user-id)))) +(test (current-group-id) (user-group-id (user-information (current-user-id)))) + +(test (user-id (user-information (current-user-id))) + (user-id (user-information (user-name (user-information (current-user-id)))))) + +(test #t (integer? (current-session-id))) + +(test-end)