From a1f000d555d1bb8a6b8318e23a92f7e8f000324c Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Wed, 2 Jan 2002 23:57:40 +0000 Subject: [PATCH 1/7] (guile_TEXINFOS): Add autoconf.texi and autoconf-macros.texi. (autoconf.texi, autoconf-macros.texi): New rules. --- doc/ref/Makefile.am | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/ref/Makefile.am b/doc/ref/Makefile.am index 08d73c8a1..9e40bfd0b 100644 --- a/doc/ref/Makefile.am +++ b/doc/ref/Makefile.am @@ -33,10 +33,16 @@ guile_TEXINFOS = preface.texi intro.texi program.texi scheme-intro.texi \ expect.texi scsh.texi tcltk.texi scripts.texi gh.texi scm.texi \ debugging.texi indices.texi script-getopt.texi data-rep.texi \ extend.texi repl-modules.texi srfi-modules.texi misc-modules.texi \ - scheme-compound.texi + scheme-compound.texi autoconf.texi autoconf-macros.texi ETAGS_ARGS = $(info_TEXINFOS) $(guile_TEXINFOS) +# Automated snarfing + +autoconf.texi: autoconf-macros.texi +autoconf-macros.texi: $(top_srcdir)/guile-config/guile.m4 + $(top_srcdir)/scripts/snarf-guile-m4-docs $< > $@ + # Optionally support building an HTML version of the reference manual. if HTMLDOC From dc81cfeb0e392565fcd44c73bbd995b909813852 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Wed, 2 Jan 2002 23:59:00 +0000 Subject: [PATCH 2/7] (Part II): Add "Autoconf Support"; include autoconf.texi. --- doc/ref/guile.texi | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/ref/guile.texi b/doc/ref/guile.texi index 090130c07..171325ec0 100644 --- a/doc/ref/guile.texi +++ b/doc/ref/guile.texi @@ -94,7 +94,7 @@ by the Free Software Foundation. @sp 10 @comment The title is printed in a large font. @title Guile Reference Manual -@subtitle $Id: guile.texi,v 1.10 2001-12-22 12:39:10 ossau Exp $ +@subtitle $Id: guile.texi,v 1.11 2002-01-02 23:59:00 ttn Exp $ @subtitle For use with Guile @value{VERSION} @c AUTHORS @@ -220,6 +220,7 @@ Part II: Programming with Guile * Data Representation:: Data representation in Guile. * GH:: The deprecated GH interface. * Debugger User Interface:: +* Autoconf Support:: Guile-specific configure.in macros. * Further Reading:: Where to find out more about Scheme programming. Part III: Guile API Reference @@ -300,6 +301,7 @@ options available. @include data-rep.texi @include gh.texi @include debugging.texi +@include autoconf.texi @include scheme-reading.texi @page From 4d9678fde4f1d481f3eaf7c86b85b10224089fff Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Thu, 3 Jan 2002 00:00:53 +0000 Subject: [PATCH 3/7] *** empty log message *** --- doc/ref/ChangeLog | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/doc/ref/ChangeLog b/doc/ref/ChangeLog index a3f220184..0bdb77a83 100644 --- a/doc/ref/ChangeLog +++ b/doc/ref/ChangeLog @@ -1,3 +1,14 @@ +2002-01-02 Thien-Thi Nguyen + + * guile.texi (Part II): Add "Autoconf Support"; include + autoconf.texi. + + * Makefile.am (guile_TEXINFOS): Add autoconf.texi and + autoconf-macros.texi. + (autoconf.texi, autoconf-macros.texi): New rules. + + * autoconf.texi: New file. + 2001-12-22 Marius Vollmer * scheme-compound.texi (Alist Example): Changed "Bismarck" to From 7bb16613f4aedd2a72e6db4ff920e02d06b28700 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Sun, 6 Jan 2002 07:45:06 +0000 Subject: [PATCH 4/7] Spell check. --- doc/ref/intro.texi | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/doc/ref/intro.texi b/doc/ref/intro.texi index 8b786fe47..c9cb9900c 100644 --- a/doc/ref/intro.texi +++ b/doc/ref/intro.texi @@ -1,4 +1,4 @@ -@c $Id: intro.texi,v 1.5 2001-12-07 17:08:19 ossau Exp $ +@c $Id: intro.texi,v 1.6 2002-01-06 07:45:06 ttn Exp $ @page @@ -434,7 +434,7 @@ of Guile. If you can, you should use @code{scm_boot_guile} instead. Note that @code{scm_init_guile} does not inform Guile about the command line arguments that should be returned by the Scheme function -@code{comamnd-line}. You can use @code{scm_set_program_arguments} to do +@code{command-line}. You can use @code{scm_set_program_arguments} to do this. @end deftypefun @@ -595,7 +595,7 @@ Scheme programmer. Writing a new version of @code{guile} is inconvenient in this case and it would in fact make the life of the users of your new features needlessly hard. -@c [[ the following is probably a bit longwinded ]] +@c [[ the following is probably a bit long-winded ]] For example, suppose that there is a program @code{guile-db} that is a version of Guile with additional features for accessing a database. @@ -605,7 +605,7 @@ Now suppose that there is also a program @code{guile-gtk} that extends Guile with access to the popular Gtk+ toolkit for graphical user interfaces. People who want to write GUIs in Scheme would have to use @code{guile-gtk}. Now, what happens when you want to write a Scheme -application that uses a GUI to let the user accessa a database? You +application that uses a GUI to let the user access a database? You would have to write a @emph{third} program that incorporates both the database stuff and the GUI stuff. This might not be easy (because @code{guile-gtk} might be a quite obscure program, say) and taking this @@ -620,7 +620,7 @@ possible. You write the new primitive procedures and data types in the normal fashion, and link them into a shared library instead of into a -standalone program. The shared library can then be loaded dynamically +stand-alone program. The shared library can then be loaded dynamically by Guile. @menu @@ -701,7 +701,7 @@ modules, you can group related code together and manage the composition of complete programs from largely independent parts. (Although the module system implementation is in flux, feel free to use it -anyway. Guile will provide reasonable backwards compatability.) +anyway. Guile will provide reasonable backwards compatibility.) Details on the module system beyond this introductory material can be found in @xref{Modules}. @@ -765,7 +765,7 @@ distribute them more easily. Also, explicitly defining the procedures and variables which are exported from a module adds documentation to the source and specifies the interface a module provides. -In Guile, you can create new modules and switch to exisiting modules in +In Guile, you can create new modules and switch to existing modules in order to add bindings to them using the syntactic form @code{define-module}. @@ -862,8 +862,8 @@ Here is the information you will need to get and install Guile and extra packages and documentation you might need or find interesting. @menu -* The Basic Guile Package:: -* Packages not shipped with Guile:: +* The Basic Guile Package:: +* Packages not shipped with Guile:: @end menu @@ -966,7 +966,7 @@ Any problems with the installation should be reported to Whenever you have found a bug in Guile you are encouraged to report it to the Guile developers, so they can fix it. They may also be able to -suggest workarounds when it is not possible for you to apply the bugfix +suggest workarounds when it is not possible for you to apply the bug-fix or install a new version of Guile yourself. Before sending in bug reports, please check with the following list that @@ -974,7 +974,7 @@ you really have found a bug. @itemize @bullet @item -Whenever documentation and actual behaviour differ, you have certainly +Whenever documentation and actual behavior differ, you have certainly found a bug, either in the documentation or in the program. @item @@ -1014,7 +1014,7 @@ You can get the version number by invoking the command $ guile --version Guile 1.4.1 Copyright (c) 1995, 1996, 1997, 2000 Free Software Foundation -Guile may be distributed under the terms of the GNU General Public Licence; +Guile may be distributed under the terms of the GNU General Public License; certain other uses are permitted as well. For details, see the file `COPYING', which is included in the Guile distribution. There is no warranty, to the extent permitted by law. From f159783325e6c12e0b12549bb8f0121559554472 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Sun, 6 Jan 2002 07:46:22 +0000 Subject: [PATCH 5/7] *** empty log message *** --- doc/ref/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/ref/ChangeLog b/doc/ref/ChangeLog index 0bdb77a83..a9f8de15f 100644 --- a/doc/ref/ChangeLog +++ b/doc/ref/ChangeLog @@ -1,3 +1,7 @@ +2002-01-05 Thien-Thi Nguyen + + * intro.texi: Spell check. Thanks to Fabrice Bauzac. + 2002-01-02 Thien-Thi Nguyen * guile.texi (Part II): Add "Autoconf Support"; include From 4902ea64db30647cbece6459813efc73c4e0a84d Mon Sep 17 00:00:00 2001 From: Neil Jerram Date: Mon, 7 Jan 2002 20:48:02 +0000 Subject: [PATCH 6/7] * Fix doc typo. --- THANKS | 1 + doc/ref/ChangeLog | 5 +++++ doc/ref/intro.texi | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/THANKS b/THANKS index 60a6b5398..831b08968 100644 --- a/THANKS +++ b/THANKS @@ -12,6 +12,7 @@ Contributors since the last release: For fixes or providing information which led to a fix: Martin Baulig + Fabrice Bauzac Rob Browning Michael Carmack Brian Crowder diff --git a/doc/ref/ChangeLog b/doc/ref/ChangeLog index a9f8de15f..575c3d8e7 100644 --- a/doc/ref/ChangeLog +++ b/doc/ref/ChangeLog @@ -1,3 +1,8 @@ +2002-01-07 Neil Jerram + + * intro.texi (Linking Programs With Guile): Fix typo (superfluous + `do'). Thanks to Fabrice Bauzac. + 2002-01-05 Thien-Thi Nguyen * intro.texi: Spell check. Thanks to Fabrice Bauzac. diff --git a/doc/ref/intro.texi b/doc/ref/intro.texi index c9cb9900c..e22512af1 100644 --- a/doc/ref/intro.texi +++ b/doc/ref/intro.texi @@ -1,4 +1,4 @@ -@c $Id: intro.texi,v 1.6 2002-01-06 07:45:06 ttn Exp $ +@c $Id: intro.texi,v 1.7 2002-01-07 20:48:02 ossau Exp $ @page @@ -360,7 +360,7 @@ head of any C source file that uses identifiers described in this manual. Once you've compiled your source files, you need to link them against the Guile object code library, @code{libguile}. -On most systems, you should not need to do tell the compiler and linker +On most systems, you should not need to tell the compiler and linker explicitly where they can find @file{libguile.h} and @file{libguile}. When Guile has been installed in a peculiar way, or when you are on a peculiar system, things might not be so easy and you might need to pass From ce5fb40c1d86dfaaf36670ec5cf488a219c68ddb Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Tue, 8 Jan 2002 03:37:57 +0000 Subject: [PATCH 7/7] Initial revision. --- scripts/frisk | 292 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 292 insertions(+) create mode 100755 scripts/frisk diff --git a/scripts/frisk b/scripts/frisk new file mode 100755 index 000000000..6e3f93c07 --- /dev/null +++ b/scripts/frisk @@ -0,0 +1,292 @@ +#!/bin/sh +# aside from this initial boilerplate, this is actually -*- scheme -*- code +main='(module-ref (resolve-module '\''(scripts frisk)) '\'main')' +exec ${GUILE-guile} -l $0 -c "(apply $main (cdr (command-line)))" "$@" +!# +;;; frisk --- Grok the module interfaces of a body of files + +;; Copyright (C) 2002 Free Software Foundation, Inc. +;; +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License as +;; published by the Free Software Foundation; either version 2, or +;; (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this software; see the file COPYING. If not, write to +;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330, +;; Boston, MA 02111-1307 USA + +;;; Author: Thien-Thi Nguyen + +;;; Commentary: + +;; Usage: frisk [options] file ... +;; +;; Analyze FILE... module interfaces in aggregate (as a "body"), +;; and display a summary. Modules that are `define-module'd are +;; considered "internal" (and those not, "external"). When module X +;; uses module Y, X is said to be "(a) downstream of" Y, and Y is +;; "(an) upstream of" X. +;; +;; Normally, the summary displays external modules and their internal +;; downstreams, as this is the usual question asked by a body. There +;; are several options that modify this output. +;; +;; -u, --upstream show upstream edges +;; -d, --downstream show downstream edges (default) +;; -i, --internal show internal modules +;; -x, --external show external modules (default) +;; +;; If given both `upstream' and `downstream' options ("frisk -ud"), the +;; output is formatted: "C MODULE --- UP-LS --- DOWN-LS", where C is +;; either `i' or `x', and each element of UP-LS and DOWN-LS is (TYPE +;; MODULE-NAME ...). +;; +;; In all other cases, the "C MODULE" occupies its own line, and +;; subsequent lines list the up- or downstream edges, respectively, +;; indented by some non-zero amount of whitespace. +;; +;; Top-level `use-modules' (or `load' or 'primitive-load') forms in a +;; file that do not follow a `define-module' result an edge where the +;; downstream is the "default module", normally `(guile-user)'. This +;; can be set to another value by using: +;; +;; -m, --default-module MOD set MOD as the default module + +;; Usage from a Scheme Program: (use-modules (scripts frisk)) +;; +;; Module export list: +;; (frisk . args) +;; (make-frisker . options) => (lambda (files) ...) [see below] +;; (mod-up-ls module) => upstream edges +;; (mod-dn-ls module) => downstream edges +;; (mod-int? module) => is the module internal? +;; (edge-type edge) => symbol: {regular,autoload,computed} +;; (edge-up edge) => upstream module +;; (edge-down edge) => downstream module +;; +;; OPTIONS is an alist. Recognized keys are: +;; default-module +;; +;; `make-frisker' returns a procedure that takes a list of files, the +;; FRISKER. FRISKER returns a closure, REPORT, that takes one of the +;; keys: +;; modules -- entire list of modules +;; internal -- list of internal modules +;; external -- list of external modules +;; i-up -- list of modules upstream of internal modules +;; x-up -- list of modules upstream of external modules +;; i-down -- list of modules downstream of internal modules +;; x-down -- list of modules downstream of external modules +;; edges -- list of edges +;; Note that `x-up' should always be null, since by (lack of!) +;; definition, we only know external modules by reference. +;; +;; The module and edge objects managed by REPORT can be examined in +;; detail by using the other (self-explanatory) procedures. Be careful +;; not to confuse a freshly consed list of symbols, like `(a b c)' with +;; the module `(a b c)'. If you want to find the module by that name, +;; try: (cond ((member '(a b c) (REPORT 'modules)) => car)). + +;; TODO: Make "frisk -ud" output less ugly. +;; Consider default module as internal; add option to invert. +;; Support `edge-misc' data. + +;;; Code: + +(define-module (scripts frisk) + :autoload (ice-9 getopt-long) (getopt-long) + :use-module ((srfi srfi-1) :select (filter remove)) + :export (frisk + make-frisker + mod-up-ls mod-down-ls mod-int? + edge-type edge-up edge-down)) + +(define *default-module* '(guile-user)) + +(define (grok-proc default-module note-use!) + (lambda (filename) + (let* ((p (open-file filename "r")) + (next (lambda () (read p))) + (ferret (lambda (use) ;;; handle "((foo bar) :select ...)" + (let ((maybe (car use))) + (if (list? maybe) + maybe + use)))) + (curmod #f)) + (let loop ((form (next))) + (cond ((eof-object? form)) + ((not (list? form)) (loop (next))) + (else (case (car form) + ((define-module) + (let ((module (cadr form))) + (set! curmod module) + (note-use! 'def module #f) + (let loop ((ls form)) + (or (null? ls) + (case (car ls) + ((:use-module) + (note-use! 'regular module (ferret (cadr ls))) + (loop (cddr ls))) + ((:autoload) + (note-use! 'autoload module (cadr ls)) + (loop (cdddr ls))) + (else (loop (cdr ls)))))))) + ((use-modules) + (for-each (lambda (use) + (note-use! 'regular + (or curmod default-module) + (ferret use))) + (cdr form))) + ((load primitive-load) + (note-use! 'computed + (or curmod default-module) + (let ((file (cadr form))) + (if (string? file) + file + (format #f "[computed in ~A]" + filename)))))) + (loop (next)))))))) + +(define up-ls (make-object-property)) ; list +(define dn-ls (make-object-property)) ; list +(define int? (make-object-property)) ; defined via `define-module' + +(define mod-up-ls up-ls) +(define mod-down-ls dn-ls) +(define mod-int? int?) + +(define (i-or-x module) + (if (int? module) 'i 'x)) + +(define edge-type (make-object-property)) ; symbol + +(define (make-edge type up down) + (let ((new (cons up down))) + (set! (edge-type new) type) + new)) + +(define edge-up car) +(define edge-down cdr) + +(define (up-ls+! m new) (set! (up-ls m) (cons new (up-ls m)))) +(define (dn-ls+! m new) (set! (dn-ls m) (cons new (dn-ls m)))) + +(define (make-body alist) + (lambda (key) + (assq-ref alist key))) + +(define (scan default-module files) + (let* ((modules (list)) + (edges (list)) + (intern (lambda (module) + (cond ((member module modules) => car) + (else (set! (up-ls module) (list)) + (set! (dn-ls module) (list)) + (set! modules (cons module modules)) + module)))) + (grok (grok-proc default-module + (lambda (type d u) + (let ((d (intern d))) + (if (eq? type 'def) + (set! (int? d) #t) + (let* ((u (intern u)) + (edge (make-edge type u d))) + (set! edges (cons edge edges)) + (up-ls+! d edge) + (dn-ls+! u edge)))))))) + (for-each grok files) + (make-body + `((modules . ,modules) + (internal . ,(filter int? modules)) + (external . ,(remove int? modules)) + (i-up . ,(filter int? (map edge-down edges))) + (x-up . ,(remove int? (map edge-down edges))) + (i-down . ,(filter int? (map edge-up edges))) + (x-down . ,(remove int? (map edge-up edges))) + (edges . ,edges))))) + +(define (make-frisker . options) + (let ((default-module (or (assq-ref options 'default-module) + *default-module*))) + (lambda (files) + (scan default-module files)))) + +(define (dump-updown modules) + (for-each (lambda (m) + (format #t "~A ~A --- ~A --- ~A\n" + (i-or-x m) m + (map (lambda (edge) + (cons (edge-type edge) + (edge-up edge))) + (up-ls m)) + (map (lambda (edge) + (cons (edge-type edge) + (edge-down edge))) + (dn-ls m)))) + modules)) + +(define (dump-up modules) + (for-each (lambda (m) + (format #t "~A ~A\n" (i-or-x m) m) + (for-each (lambda (edge) + (format #t "\t\t\t ~A\t~A\n" + (edge-type edge) (edge-up edge))) + (up-ls m))) + modules)) + +(define (dump-down modules) + (for-each (lambda (m) + (format #t "~A ~A\n" (i-or-x m) m) + (for-each (lambda (edge) + (format #t "\t\t\t ~A\t~A\n" + (edge-type edge) (edge-down edge))) + (dn-ls m))) + modules)) + +(define (frisk . args) + (let* ((parsed-opts (getopt-long + (cons "frisk" args) ;;; kludge + '((upstream (single-char #\u)) + (downstream (single-char #\d)) + (internal (single-char #\i)) + (external (single-char #\x)) + (default-module + (single-char #\m) + (value #t))))) + (=u (option-ref parsed-opts 'upstream #f)) + (=d (option-ref parsed-opts 'downstream #f)) + (=i (option-ref parsed-opts 'internal #f)) + (=x (option-ref parsed-opts 'external #f)) + (files (option-ref parsed-opts '() (list))) + (report ((make-frisker + `(default-module + . ,(option-ref parsed-opts 'default-module + *default-module*))) + files)) + (modules (report 'modules)) + (internal (report 'internal)) + (external (report 'external)) + (edges (report 'edges))) + (format #t "~A ~A, ~A ~A (~A ~A, ~A ~A), ~A ~A\n\n" + (length files) "files" + (length modules) "modules" + (length internal) "internal" + (length external) "external" + (length edges) "edges") + ((cond ((and =u =d) dump-updown) + (=u dump-up) + (else dump-down)) + (cond ((and =i =x) modules) + (=i internal) + (else external))))) + +(define main frisk) + +;;; frisk ends here