1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-10 14:00:21 +02:00

* gh_init.c (gh_standard_handler): Return SCM_BOOL_F, not garbage.

Merge GH interface library into libguile.
* gh.h, gh_data.c, gh_eval.c, gh_funcs.c, gh_init.c, gh_io.c,
gh_list.c, gh_predicates.c, gh_test_c, gh_test_c.c, gh_test_repl,
gh_test_repl.c: New files.
* Makefile.am (libguile_la_SOURCES): Add gh_data.c, gh_eval.c,
gh_funcs.c, gh_init.c, gh_io.c, gh_list.c, gh_predicates.c.  Move
_scm.h to ...
(EXTRA_libguile_la_SOURCES): ... here.
(pkginclude_HEADERS): Add variable, to get gh.h installed.
(THREAD_LIBS, check_ldadd, check_PROGRAMS, gh_test_c_SOURCES,
gh_test_c_LDADD, gh_test_repl_SOURCES, gh_test_repl_LDADD):
New variables, describing how to build the gh test programs.
* configure.in: Check for -lm, -lsocket, -lnsl; we need this to
build the test programs, and we probably should have been linking
libguile.la against them all along, to support AIX shared libs.
Add cflags for threads to CFLAGS; add libs for threads to new
variable THREAD_LIBS, used in Makefile.am.
* ChangeLog-gh: log from old `gh' subdirectory.
* Makefile.in, configure, scmconfig.h.in: Rebuilt.
This commit is contained in:
Jim Blandy 1997-04-14 06:42:27 +00:00
parent f4d7dfb69d
commit ee2a8b9bdd
17 changed files with 2306 additions and 184 deletions

View file

@ -1,12 +1,28 @@
Sun Apr 13 23:03:55 1997 Jim Blandy <jimb@floss.cyclic.com>
Mon Apr 14 01:32:57 1997 Jim Blandy <jimb@floss.cyclic.com>
* gh_init.c (gh_standard_handler): Return SCM_BOOL_F, not garbage.
Merge GH interface library into libguile.
* gh.h, gh_data.c, gh_eval.c, gh_funcs.c, gh_init.c, gh_io.c,
gh_list.c, gh_predicates.c, gh_test_c, gh_test_c.c, gh_test_repl,
gh_test_repl.c: New files.
* Makefile.am (libguile_la_SOURCES): Add gh_data.c, gh_eval.c,
gh_funcs.c, gh_init.c, gh_io.c, gh_list.c, gh_predicates.c.
* Makefile.am (libguile_la_SOURCES): Move _scm.h to...
gh_funcs.c, gh_init.c, gh_io.c, gh_list.c, gh_predicates.c. Move
_scm.h to ...
(EXTRA_libguile_la_SOURCES): ... here.
(pkginclude_HEADERS): Add variable, to get gh.h installed.
(THREAD_LIBS, check_ldadd, check_PROGRAMS, gh_test_c_SOURCES,
gh_test_c_LDADD, gh_test_repl_SOURCES, gh_test_repl_LDADD):
New variables, describing how to build the gh test programs.
* configure.in: Check for -lm, -lsocket, -lnsl; we need this to
build the test programs, and we probably should have been linking
libguile.la against them all along, to support AIX shared libs.
Add cflags for threads to CFLAGS; add libs for threads to new
variable THREAD_LIBS, used in Makefile.am.
* ChangeLog-gh: log from old `gh' subdirectory.
* Makefile.in, configure, scmconfig.h.in: Rebuilt.
Sun Apr 13 23:03:55 1997 Jim Blandy <jimb@floss.cyclic.com>
* acconfig.h: Undo change of Apr 9; including the definition of
PACKAGE in the guile headers conflicts with applications' own

250
libguile/ChangeLog-gh Normal file
View file

@ -0,0 +1,250 @@
Thu Apr 10 16:14:43 1997 Jim Blandy <jimb@floss.cyclic.com>
Let the test programs build even when we're not using threads.
* configure.in: Use CY_AC_WITH_THREADS to decide whether to build
with threads.
* Makefile.am (check_PROGRAMS_LDADD): Remove -lthreads -lqt. The
configure script will stick them in LIBS if they're needed.
* Makefile.in, aclocal.m4, configure: Rebuilt.
* gh_funcs.c (gh_apply, gh_call0, gh_call1, gh_call2, gh_call3):
New functions.
* gh.h: Prototypes for above.
* gh_test_c.c (main_prog): Added test cases for above.
* gh.h (gh_display, gh_newline): Added prototypes.
* gh_test_c.c (main_prog): Remove bizarre single quote from test
of gh_symbol2scm, and from "test" of (display "hello world").
* gh.c: Removed; its guts have been redistributed to the other
gh-mumble.c files.
* gh.c, gh_data.c, gh_eval.c, gh_funcs.c, gh_init.c, gh_io.c,
gh_list.c, gh_predicates.c, gh_test_c.c, gh_test_repl.c:
Re-indented, according to the GNU coding standards. (Put function
names at beginning of lines, basically.)
Wed Apr 9 17:56:34 1997 Jim Blandy <jimb@floss.cyclic.com>
Changes to work with automake-1.1n, which has better libtool support.
* Makefile.am: Use lib_LTLIBRARIES, not lib_PROGRAMS.
* Makefile.in: Regenerated.
Sat Mar 8 06:37:23 1997 Gary Houston <ghouston@actrix.gen.nz>
* gh_eval.c (gh_eval_file): remove case_i, sharp arguments from
scm_primitive_load call.
Mon Feb 24 21:45:32 1997 Mikael Djurfeldt <mdj@mdj.nada.kth.se>
* configure.in: Added AM_MAINTAINER_MODE
Wed Feb 12 16:34:42 1997 Mark Galassi <rosalia@sarastro.lanl.gov>
* gh_data.c (gh_symbol2newstr): added this conversion from SCM
symbol to C string.
(gh_set_substr): more data conversion: from part of a (possibly
large) C string to an existing SCM string.
(gh_get_substr): more data conversion: from part of a (possibly
large) SCM string to an existing C char array.
Mon Feb 10 14:03:09 1997 Mark Galassi <rosalia@sarastro.lanl.gov>
* gh_funcs.c (gh_define): added this function.
* gh_init.c (gh_catch): fixed stupid bug, gh_catch() was not
returning anything.
* gh_data.c (gh_scm2newstr): Renamed gh_scm2str0() to
gh_scm2newstr(), and did away with the str0 convention (it doesn't
seem to belong in gh_).
(gh_scm2str): this function now copies Scheme data to a
pre-allocated C string.
Fri Feb 7 15:12:30 1997 Mark Galassi <rosalia@sarastro.lanl.gov>
* gh_data.c (gh_scm2str0): On Sascha Ziemann and Jim Blandy's
suggestion I changed gh_scm2str0() so that it returns a malloc-ed
string, rather than taking a pre-allocated string with a maximum
length...
Fri Jan 24 08:18:28 1997 Mark Galassi <rosalia@sarastro.lanl.gov>
* gh_eval.c (gh_eval_str): gh_eval_str() now returns an SCM object
with the result of the evaluation. It has also been simplified to
just call scm_eval_0str(). gh_eval_file() has been similarly
altered.
Sat Jan 11 14:40:17 1997 Marius Vollmer <mvo@zagadka.ping.de>
* ltconfig, ltmain.sh: New files for libtool support. libguile,
rx, gh and gtcltk-lib can now be build as shared libraries.
* Makefile.am (EXTRA_DIST): Added ltconfig and ltmain.sh
Sun Jan 5 16:57:10 1997 Jim Blandy <jimb@floss.cyclic.com>
* Guile 1.0 released. This is the first release by the Free
Software Foundation; Cygnus has also released earlier versions of
Guile.
* GUILE-VERSION: Updated version number.
* NEWS: Added comments for all the user-visible changes marked in
the ChangeLogs.
* README: Updated for release.
Thu Dec 12 00:14:32 1996 Gary Houston <ghouston@actrix.gen.nz>
* scsh: new directory.
Mon Dec 2 17:33:04 1996 Tom Tromey <tromey@cygnus.com>
* configure.in: Generate doc/guile-programmer/Makefile and
doc/guile-user/Makefile.
Sat Nov 30 23:45:54 1996 Tom Tromey <tromey@cygnus.com>
* aclocal.m4: Now automatically generated by aclocal.
* threads.m4: New file.
* guile.m4: New file.
* Makefile.am, doc/Makefile.am: New files.
* configure.in: Updated for Automake. Avoid excessively verbose
"greet" messages.
Wed Oct 16 07:32:14 1996 Mark Galassi <rosalia@sarastro.lanl.gov>
* lgh: directory renamed to gh, along with all prefixes of the
high level library procedures.
Thu Oct 10 14:37:43 1996 Jim Blandy <jimb@floss.cyclic.com>
* Makefile.in (TAGS tags): Find the source files in $srcdir.
Wed Oct 9 19:37:14 1996 Jim Blandy <jimb@floss.cyclic.com>
* Makefile.in (DISTFILES): Add AUTHORS and aclocal.m4.
Tue Oct 1 00:13:55 1996 Mikael Djurfeldt <mdj@woody.nada.kth.se>
* configure.in: Added some configuration magic from the Cygnus
distribution.
* aclocal.m4: New file. For now used for thread support
configuration.
Fri Sep 13 14:39:30 1996 Mark Galassi <rosalia@sarastro.lanl.gov>
* Makefile.in (DISTFILES): added mkinstalldirs to the DISTFILES
* PLUGIN: changed the PLUGIN/REQ files in the ice-9 and lgh
directories, to arrange for lgh to the last thing
configured/built.
Wed Sep 11 21:11:33 1996 Mark Galassi <rosalia@nis.lanl.gov>
* lgh/: added the directory in which I implement the high level
libguile library (lgh_) for this release of Guile. See the
ChangeLog in there for further details.
Wed Sep 11 16:12:53 1996 Mark Galassi <rosalia@sarastro.lanl.gov>
* doc/ (guile-user and guile-programmer): added the guile-user and
guile-programmer directories which contain the user and programmer
manuals. See the ChangeLog entries there for detail.
Wed Sep 11 14:33:49 1996 Jim Blandy <jimb@floss.cyclic.com>
* Makefile.in (distclean): Don't forget to delete doc/Makefile.
* Makefile.in (distclean): Don't forget to delete
config.build-subdirs.
Thu Sep 5 17:36:15 1996 Jim Blandy <jimb@floss.cyclic.com>
* Makefile.in (tags): New name for `TAGS' target, which will
always run the commands.
Thu Sep 5 09:56:50 1996 Jim Blandy <jimb@totoro.cyclic.com>
* README: Doc fixes.
Fri Aug 30 16:56:27 1996 Jim Blandy <jimb@floss.cyclic.com>
* Makefile.in (TAGS): Produce a single tags file for all of Guile.
Thu Aug 15 19:03:03 1996 Jim Blandy <jimb@floss.cyclic.com>
* configure.in: Check for -ldl, so the check for Tcl won't fail
spuriously.
Thu Aug 15 01:29:29 1996 Jim Blandy <jimb@totoro.cyclic.com>
Change the way we decide whether to build gtcltk-lib, so that it's
omitted from the build process when appropriate, but never from
the dist process.
* configure.in: Don't edit all_subdirs depending on the
availability of Tk; let that be the list of all PLUGIN
subdirectories present, as it used to be. Instead, edit a new
variable, build_subdirs; write its final value, the list of
subdirs we do want to compile in, to config.build-subdirs.
Substitute that into the top-level Makefile too.
* Makefile.in (subdirs): Set this to @build_subdirs@, so we only
recurse on the subdirectories we should build.
(distdirs): Set this to @existingdirs@, so it includes the subdirs
we decided not to build.
* doc/gtcltk.texi: File resurrected from old Guile releases.
* doc/Makefile.in (info): Build the gtcltk documentation.
(DIST_FILES): Include it in the distribution.
* configure.in: If we can find the library for tcl7.5, build
gtcltk-lib. Call AC_PROG_CC, to help run that test with the right
compiler (not sure this is necessary).
Mon Aug 12 15:09:37 1996 Jim Blandy <jimb@totoro.cyclic.com>
* NEWS: Fix bug reporting address.
Fri Aug 9 15:58:42 1996 Jim Blandy <jimb@totoro.cyclic.com>
* AUTHORS: New file, in accordance with the GNU maintainers'
standards.
Tue Aug 6 14:40:44 1996 Jim Blandy <jimb@totoro.cyclic.com>
* README: Renamed from ANNOUNCE; include bug report address,
description, and short tour.
* INSTALL: Renamed from BUILDING.
* NEWS: New file.
* Makefile.in (DISTFILES): Update appropriately.
Thu Aug 1 02:31:53 1996 Jim Blandy <jimb@totoro.cyclic.com>
* doc/Makefile.in: Added pattern targets for creating DVI and
PostScript files.
(%.ps, %.dvi, %.txt): New targets.
(DVIPS, TEXI2DVI): New variables.
* GUILE-VERSION: Updated to 1.0b3.
Rehashed distribution system, in preparation for nightly
snapshots. Other changes in subdirectories.
* Makefile.in (dist): Rewritten --- the old target was out of
date, dependent on files that we don't have, and relied on GNU
tar. The new target is simpler.
(VERSION, srcdir, dist_dirs): New variables.
(DISTFILES): Renamed from localfiles. Added GUILE-VERSION and
TODO.
(localtreats): Variable removed. We don't have this file.
(info): cd to doc and make info there; don't make info in every
${subdir}; those Makefiles don't know what to do.
(distname, distdir, treats, announcefile): Variables removed.
(manifest-file): Target removed.
(dist-dir): New target, responsible for distributable files in
this directory.
(GZIP, GZIP_EXT, TAR_VERBOSE, DIST_NAME): New variables,
controlling the 'dist' target.
* configure.in: Substitute GUILE-VERSION into the top-level
Makefile. Build doc/Makefile from doc/Makefile.in.
* doc/Makefile.in: New file.

View file

@ -8,18 +8,20 @@ AUTOMAKE_OPTIONS = foreign
INCLUDES = -I.. -I$(srcdir)/..
lib_LTLIBRARIES = libguile.la
libguile_la_SOURCES = alist.c append.c appinit.c arbiters.c async.c \
boolean.c chars.c continuations.c dynl.c dynwind.c eq.c \
error.c eval.c extchrs.c feature.c filesys.c fports.c gc.c \
gdbint.c genio.c gsubr.c hash.c hashtab.c init.c ioext.c \
kw.c list.c load.c mallocs.c markers.c mbstrings.c net_db.c \
numbers.c objprop.c \
options.c pairs.c ports.c posix.c print.c procprop.c procs.c ramap.c \
read.c root.c scmsigs.c sequences.c simpos.c smob.c socket.c \
stackchk.c stime.c strings.c strop.c strorder.c \
strports.c struct.c symbols.c tag.c throw.c unif.c variable.c \
vectors.c version.c vports.c weaks.c _scm.h
EXTRA_libguile_la_SOURCES = backtrace.c stacks.c debug.c srcprop.c \
libguile_la_SOURCES = \
alist.c append.c appinit.c arbiters.c async.c boolean.c chars.c \
continuations.c dynl.c dynwind.c eq.c error.c eval.c extchrs.c \
feature.c filesys.c fports.c gc.c gdbint.c genio.c gh_data.c gh_eval.c \
gh_funcs.c gh_init.c gh_io.c gh_list.c gh_predicates.c gsubr.c hash.c \
hashtab.c init.c ioext.c kw.c list.c load.c mallocs.c markers.c \
mbstrings.c net_db.c numbers.c objprop.c options.c pairs.c ports.c \
posix.c print.c procprop.c procs.c ramap.c read.c root.c scmsigs.c \
sequences.c simpos.c smob.c socket.c stackchk.c stime.c strings.c \
strop.c strorder.c strports.c struct.c symbols.c tag.c throw.c unif.c \
variable.c vectors.c version.c vports.c weaks.c
EXTRA_libguile_la_SOURCES = _scm.h \
backtrace.c stacks.c debug.c srcprop.c \
strerror.c inet_aton.c putenv.c
libguile_la_DEPENDENCIES = @LIBLOBJS@
libguile_la_LIBADD = @LIBLOBJS@
@ -27,6 +29,9 @@ libguile_la_LDFLAGS = -version-info 0:0 -rpath $(libdir)
include_HEADERS = libguile.h
# These are headers visible as <guile/mumble.h>
pkginclude_HEADERS = gh.h
# These are headers visible as <libguile/mumble.h>.
modincludedir = $(includedir)/@module@
modinclude_HEADERS = __scm.h alist.h append.h arbiters.h async.h \
@ -47,6 +52,14 @@ modinclude_DATA = scmconfig.h
bin_SCRIPTS = guile-snarf
THREAD_LIBS = @THREAD_LIBS@
check_ldadd = libguile.la ${THREAD_LIBS}
check_PROGRAMS = gh_test_c gh_test_repl
gh_test_c_SOURCES = gh_test_c.c
gh_test_c_LDADD = ${check_ldadd}
gh_test_repl_SOURCES = gh_test_repl.c
gh_test_repl_LDADD = ${check_ldadd}
EXTRA_DIST = gscm.c gscm.h ChangeLog-scm dynl-dl.c dynl-dld.c dynl-shl.c \
dynl-vms.c DYNAMIC-LINKING PLUGIN/REQ PLUGIN/guile.config \
PLUGIN/guile.libs.in cpp_signal.c cpp_errno.c cpp_err_symbols.in \

View file

@ -67,18 +67,20 @@ AUTOMAKE_OPTIONS = foreign
INCLUDES = -I.. -I$(srcdir)/..
lib_LTLIBRARIES = libguile.la
libguile_la_SOURCES = alist.c append.c appinit.c arbiters.c async.c \
boolean.c chars.c continuations.c dynl.c dynwind.c eq.c \
error.c eval.c extchrs.c feature.c filesys.c fports.c gc.c \
gdbint.c genio.c gsubr.c hash.c hashtab.c init.c ioext.c \
kw.c list.c load.c mallocs.c markers.c mbstrings.c net_db.c \
numbers.c objprop.c \
options.c pairs.c ports.c posix.c print.c procprop.c procs.c ramap.c \
read.c root.c scmsigs.c sequences.c simpos.c smob.c socket.c \
stackchk.c stime.c strings.c strop.c strorder.c \
strports.c struct.c symbols.c tag.c throw.c unif.c variable.c \
vectors.c version.c vports.c weaks.c _scm.h
EXTRA_libguile_la_SOURCES = backtrace.c stacks.c debug.c srcprop.c \
libguile_la_SOURCES = \
alist.c append.c appinit.c arbiters.c async.c boolean.c chars.c \
continuations.c dynl.c dynwind.c eq.c error.c eval.c extchrs.c \
feature.c filesys.c fports.c gc.c gdbint.c genio.c gh_data.c gh_eval.c \
gh_funcs.c gh_init.c gh_io.c gh_list.c gh_predicates.c gsubr.c hash.c \
hashtab.c init.c ioext.c kw.c list.c load.c mallocs.c markers.c \
mbstrings.c net_db.c numbers.c objprop.c options.c pairs.c ports.c \
posix.c print.c procprop.c procs.c ramap.c read.c root.c scmsigs.c \
sequences.c simpos.c smob.c socket.c stackchk.c stime.c strings.c \
strop.c strorder.c strports.c struct.c symbols.c tag.c throw.c unif.c \
variable.c vectors.c version.c vports.c weaks.c
EXTRA_libguile_la_SOURCES = _scm.h \
backtrace.c stacks.c debug.c srcprop.c \
strerror.c inet_aton.c putenv.c
libguile_la_DEPENDENCIES = @LIBLOBJS@
libguile_la_LIBADD = @LIBLOBJS@
@ -86,6 +88,9 @@ libguile_la_LDFLAGS = -version-info 0:0 -rpath $(libdir)
include_HEADERS = libguile.h
# These are headers visible as <guile/mumble.h>
pkginclude_HEADERS = gh.h
# These are headers visible as <libguile/mumble.h>.
modincludedir = $(includedir)/@module@
modinclude_HEADERS = __scm.h alist.h append.h arbiters.h async.h \
@ -104,6 +109,14 @@ modinclude_DATA = scmconfig.h
bin_SCRIPTS = guile-snarf
THREAD_LIBS = @THREAD_LIBS@
check_ldadd = libguile.la ${THREAD_LIBS}
check_PROGRAMS = gh_test_c gh_test_repl
gh_test_c_SOURCES = gh_test_c.c
gh_test_c_LDADD = ${check_ldadd}
gh_test_repl_SOURCES = gh_test_repl.c
gh_test_repl_LDADD = ${check_ldadd}
EXTRA_DIST = gscm.c gscm.h ChangeLog-scm dynl-dl.c dynl-dld.c dynl-shl.c \
dynl-vms.c DYNAMIC-LINKING PLUGIN/REQ PLUGIN/guile.config \
PLUGIN/guile.libs.in cpp_signal.c cpp_errno.c cpp_err_symbols.in \
@ -131,13 +144,21 @@ LIBS = @LIBS@
libguile_la_OBJECTS = alist.lo append.lo appinit.lo arbiters.lo \
async.lo boolean.lo chars.lo continuations.lo dynl.lo dynwind.lo eq.lo \
error.lo eval.lo extchrs.lo feature.lo filesys.lo fports.lo gc.lo \
gdbint.lo genio.lo gsubr.lo hash.lo hashtab.lo init.lo ioext.lo kw.lo \
list.lo load.lo mallocs.lo markers.lo mbstrings.lo net_db.lo numbers.lo \
objprop.lo options.lo pairs.lo ports.lo posix.lo print.lo procprop.lo \
procs.lo ramap.lo read.lo root.lo scmsigs.lo sequences.lo simpos.lo \
smob.lo socket.lo stackchk.lo stime.lo strings.lo strop.lo strorder.lo \
strports.lo struct.lo symbols.lo tag.lo throw.lo unif.lo variable.lo \
vectors.lo version.lo vports.lo weaks.lo
gdbint.lo genio.lo gh_data.lo gh_eval.lo gh_funcs.lo gh_init.lo \
gh_io.lo gh_list.lo gh_predicates.lo gsubr.lo hash.lo hashtab.lo \
init.lo ioext.lo kw.lo list.lo load.lo mallocs.lo markers.lo \
mbstrings.lo net_db.lo numbers.lo objprop.lo options.lo pairs.lo \
ports.lo posix.lo print.lo procprop.lo procs.lo ramap.lo read.lo \
root.lo scmsigs.lo sequences.lo simpos.lo smob.lo socket.lo stackchk.lo \
stime.lo strings.lo strop.lo strorder.lo strports.lo struct.lo \
symbols.lo tag.lo throw.lo unif.lo variable.lo vectors.lo version.lo \
vports.lo weaks.lo
gh_test_c_OBJECTS = gh_test_c.o
gh_test_c_DEPENDENCIES = libguile.la
gh_test_c_LDFLAGS =
gh_test_repl_OBJECTS = gh_test_repl.o
gh_test_repl_DEPENDENCIES = libguile.la
gh_test_repl_LDFLAGS =
SCRIPTS = $(bin_SCRIPTS)
CFLAGS = @CFLAGS@
@ -146,7 +167,8 @@ LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CF
LINK = $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@
DATA = $(modinclude_DATA)
HEADERS = $(include_HEADERS) $(modinclude_HEADERS)
HEADERS = $(include_HEADERS) $(modinclude_HEADERS) \
$(pkginclude_HEADERS)
DIST_COMMON = COPYING ChangeLog Makefile.am Makefile.in acconfig.h \
acinclude.m4 aclocal.m4 configure configure.in guile-snarf.in \
@ -162,21 +184,23 @@ DEP_FILES = .deps/alist.P .deps/append.P .deps/appinit.P \
.deps/chars.P .deps/continuations.P .deps/debug.P .deps/dynl.P \
.deps/dynwind.P .deps/eq.P .deps/error.P .deps/eval.P .deps/extchrs.P \
.deps/feature.P .deps/filesys.P .deps/fports.P .deps/gc.P \
.deps/gdbint.P .deps/genio.P .deps/gsubr.P .deps/hash.P .deps/hashtab.P \
.deps/inet_aton.P .deps/init.P .deps/ioext.P .deps/kw.P .deps/list.P \
.deps/load.P .deps/mallocs.P .deps/markers.P .deps/mbstrings.P \
.deps/net_db.P .deps/numbers.P .deps/objprop.P .deps/options.P \
.deps/pairs.P .deps/ports.P .deps/posix.P .deps/print.P \
.deps/procprop.P .deps/procs.P .deps/putenv.P .deps/ramap.P \
.deps/read.P .deps/root.P .deps/scmsigs.P .deps/sequences.P \
.deps/simpos.P .deps/smob.P .deps/socket.P .deps/srcprop.P \
.deps/stackchk.P .deps/stacks.P .deps/stime.P .deps/strerror.P \
.deps/strings.P .deps/strop.P .deps/strorder.P .deps/strports.P \
.deps/struct.P .deps/symbols.P .deps/tag.P .deps/throw.P .deps/unif.P \
.deps/variable.P .deps/vectors.P .deps/version.P .deps/vports.P \
.deps/weaks.P
SOURCES = $(libguile_la_SOURCES) $(EXTRA_libguile_la_SOURCES)
OBJECTS = $(libguile_la_OBJECTS)
.deps/gdbint.P .deps/genio.P .deps/gh_data.P .deps/gh_eval.P \
.deps/gh_funcs.P .deps/gh_init.P .deps/gh_io.P .deps/gh_list.P \
.deps/gh_predicates.P .deps/gh_test_c.P .deps/gh_test_repl.P \
.deps/gsubr.P .deps/hash.P .deps/hashtab.P .deps/inet_aton.P \
.deps/init.P .deps/ioext.P .deps/kw.P .deps/list.P .deps/load.P \
.deps/mallocs.P .deps/markers.P .deps/mbstrings.P .deps/net_db.P \
.deps/numbers.P .deps/objprop.P .deps/options.P .deps/pairs.P \
.deps/ports.P .deps/posix.P .deps/print.P .deps/procprop.P \
.deps/procs.P .deps/putenv.P .deps/ramap.P .deps/read.P .deps/root.P \
.deps/scmsigs.P .deps/sequences.P .deps/simpos.P .deps/smob.P \
.deps/socket.P .deps/srcprop.P .deps/stackchk.P .deps/stacks.P \
.deps/stime.P .deps/strerror.P .deps/strings.P .deps/strop.P \
.deps/strorder.P .deps/strports.P .deps/struct.P .deps/symbols.P \
.deps/tag.P .deps/throw.P .deps/unif.P .deps/variable.P .deps/vectors.P \
.deps/version.P .deps/vports.P .deps/weaks.P
SOURCES = $(libguile_la_SOURCES) $(EXTRA_libguile_la_SOURCES) $(gh_test_c_SOURCES) $(gh_test_repl_SOURCES)
OBJECTS = $(libguile_la_OBJECTS) $(gh_test_c_OBJECTS) $(gh_test_repl_OBJECTS)
default: all
@ -271,7 +295,24 @@ distclean-libtool:
maintainer-clean-libtool:
libguile.la: $(libguile_la_OBJECTS) $(libguile_la_DEPENDENCIES)
$(LINK) -rpath lib $(libguile_la_LDFLAGS) $(libguile_la_OBJECTS) $(libguile_la_LIBADD) $(LIBS)
$(LINK) -rpath $(libdir) $(libguile_la_LDFLAGS) $(libguile_la_OBJECTS) $(libguile_la_LIBADD) $(LIBS)
mostlyclean-checkPROGRAMS:
clean-checkPROGRAMS:
test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS)
distclean-checkPROGRAMS:
maintainer-clean-checkPROGRAMS:
gh_test_c: $(gh_test_c_OBJECTS) $(gh_test_c_DEPENDENCIES)
@rm -f gh_test_c
$(LINK) $(gh_test_c_LDFLAGS) $(gh_test_c_OBJECTS) $(gh_test_c_LDADD) $(LIBS)
gh_test_repl: $(gh_test_repl_OBJECTS) $(gh_test_repl_DEPENDENCIES)
@rm -f gh_test_repl
$(LINK) $(gh_test_repl_LDFLAGS) $(gh_test_repl_OBJECTS) $(gh_test_repl_LDADD) $(LIBS)
install-binSCRIPTS: $(bin_SCRIPTS)
@$(NORMAL_INSTALL)
@ -339,6 +380,20 @@ uninstall-modincludeHEADERS:
rm -f $(modincludedir)/$$p; \
done
install-pkgincludeHEADERS: $(pkginclude_HEADERS)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(pkgincludedir)
@list='$(pkginclude_HEADERS)'; for p in $$list; do \
echo " $(INSTALL_DATA) $(srcdir)/$$p $(pkgincludedir)/$$p"; \
$(INSTALL_DATA) $(srcdir)/$$p $(pkgincludedir)/$$p; \
done
uninstall-pkgincludeHEADERS:
$(NORMAL_UNINSTALL)
list='$(pkginclude_HEADERS)'; for p in $$list; do \
rm -f $(pkgincludedir)/$$p; \
done
tags: TAGS
ID: $(HEADERS) $(SOURCES)
@ -429,19 +484,19 @@ maintainer-clean-depend:
$(MKDEP) $< | sed "s,^\(.*\)\.o:,\1.$$o \1.l$$o $@:," > $@
info:
dvi:
check: all
check: all $(check_PROGRAMS)
$(MAKE)
installcheck:
install-exec: install-libLTLIBRARIES install-binSCRIPTS
@$(NORMAL_INSTALL)
install-data: install-modincludeDATA install-includeHEADERS install-modincludeHEADERS
install-data: install-modincludeDATA install-includeHEADERS install-modincludeHEADERS install-pkgincludeHEADERS
@$(NORMAL_INSTALL)
install: install-exec install-data all
@:
uninstall: uninstall-libLTLIBRARIES uninstall-binSCRIPTS uninstall-modincludeDATA uninstall-includeHEADERS uninstall-modincludeHEADERS
uninstall: uninstall-libLTLIBRARIES uninstall-binSCRIPTS uninstall-modincludeDATA uninstall-includeHEADERS uninstall-modincludeHEADERS uninstall-pkgincludeHEADERS
all: $(LTLIBRARIES) $(SCRIPTS) $(DATA) $(HEADERS) Makefile scmconfig.h
@ -449,7 +504,7 @@ install-strip:
$(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install
installdirs:
$(mkinstalldirs) $(libdir) $(bindir) $(modincludedir) $(includedir) \
$(modincludedir)
$(modincludedir) $(pkgincludedir)
mostlyclean-generic:
@ -468,21 +523,24 @@ maintainer-clean-generic:
test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
mostlyclean: mostlyclean-hdr mostlyclean-libLTLIBRARIES \
mostlyclean-compile mostlyclean-libtool \
mostlyclean-tags mostlyclean-depend mostlyclean-generic
mostlyclean-checkPROGRAMS mostlyclean-tags \
mostlyclean-depend mostlyclean-generic
clean: clean-hdr clean-libLTLIBRARIES clean-compile clean-libtool \
clean-tags clean-depend clean-generic mostlyclean
clean-checkPROGRAMS clean-tags clean-depend \
clean-generic mostlyclean
distclean: distclean-hdr distclean-libLTLIBRARIES distclean-compile \
distclean-libtool distclean-tags distclean-depend \
distclean-generic clean
distclean-libtool distclean-checkPROGRAMS \
distclean-tags distclean-depend distclean-generic clean
rm -f config.status
rm -f libtool
maintainer-clean: maintainer-clean-hdr maintainer-clean-libLTLIBRARIES \
maintainer-clean-compile maintainer-clean-libtool \
maintainer-clean-tags maintainer-clean-depend \
maintainer-clean-generic distclean
maintainer-clean-checkPROGRAMS maintainer-clean-tags \
maintainer-clean-depend maintainer-clean-generic \
distclean
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
rm -f config.status
@ -494,9 +552,12 @@ maintainer-clean-libLTLIBRARIES uninstall-libLTLIBRARIES \
install-libLTLIBRARIES mostlyclean-compile distclean-compile \
clean-compile maintainer-clean-compile mostlyclean-libtool \
distclean-libtool clean-libtool maintainer-clean-libtool \
uninstall-binSCRIPTS install-binSCRIPTS uninstall-modincludeDATA \
install-modincludeDATA uninstall-includeHEADERS install-includeHEADERS \
uninstall-modincludeHEADERS install-modincludeHEADERS tags \
mostlyclean-checkPROGRAMS distclean-checkPROGRAMS clean-checkPROGRAMS \
maintainer-clean-checkPROGRAMS uninstall-binSCRIPTS install-binSCRIPTS \
uninstall-modincludeDATA install-modincludeDATA \
uninstall-includeHEADERS install-includeHEADERS \
uninstall-modincludeHEADERS install-modincludeHEADERS \
uninstall-pkgincludeHEADERS install-pkgincludeHEADERS tags \
mostlyclean-tags distclean-tags clean-tags maintainer-clean-tags \
distdir mostlyclean-depend distclean-depend clean-depend \
maintainer-clean-depend info dvi installcheck install-exec install-data \

371
libguile/configure vendored

File diff suppressed because it is too large Load diff

View file

@ -37,6 +37,9 @@ AC_ISC_POSIX
AC_MINIX
CY_AC_WITH_THREADS
CFLAGS="$CFLAGS $cy_cv_threads_cflags"
THREAD_LIBS="$cy_cv_threads_libs"
AC_SUBST(THREAD_LIBS)
AC_C_CONST
@ -80,6 +83,9 @@ if test "$ac_cv_lib_dld_dld_link" = "yes"; then
xtra_PLUGIN_guile_libs="-lguile -ldld"
AC_DEFINE(DYNAMIC_LINKING)
else
AC_CHECK_LIB(m, main)
AC_CHECK_LIB(socket, main)
AC_CHECK_LIB(nsl, main)
AC_CHECK_FUNCS(shl_load)
if test "$ac_cv_func_shl_load" = "yes"; then
AC_DEFINE(DYNAMIC_LINKING)

195
libguile/gh.h Normal file
View file

@ -0,0 +1,195 @@
/* Copyright (C) 1995,1996,1997 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, 675 Mass Ave, Cambridge, MA 02139, USA.
*
* As a special exception, the Free Software Foundation gives permission
* for additional uses of the text contained in its release of GUILE.
*
* The exception is that, if you link the GUILE library with other files
* to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the GUILE library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the
* Free Software Foundation under the name GUILE. If you copy
* code from other Free Software Foundation releases into a copy of
* GUILE, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for GUILE, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*/
#ifndef __GH_H
#define __GH_H
#include <stdio.h>
#include <libguile.h>
/* gcc has extern inline functions that are basically as fast as macros */
#ifdef __GNUC__
# define INL inline
# define EXTINL extern inline
#else
# define INL
#define EXTINL
#endif /* __GNUC__ */
void gh_enter(int argc, char *argv[], void (*c_main_prog)());
void gh_repl();
SCM gh_catch(SCM tag, scm_catch_body_t body, void *body_data,
scm_catch_handler_t handler, void *handler_data);
/* SCM gh_catch_with_saved_stack (SCM tag, scm_catch_body_t body, */
/* void *body_data, scm_catch_handler_t handler, */
/* void *handler_data); */
SCM gh_standard_handler(void *data, SCM tag, SCM throw_args);
#if 0
SCM gh_repl_handler(void *data, SCM tag, SCM throw_args);
void gh_enter_repl(int argc, char *argv[], void (*init_proc)());
#endif /* 0 */
SCM gh_eval_str(char *scheme_code);
SCM gh_eval_str_with_catch(char *scheme_code, scm_catch_handler_t handler);
SCM gh_eval_str_with_standard_handler(char *scheme_code);
SCM gh_eval_str_with_stack_saving_handler(char *scheme_code);
SCM gh_eval_file(char *fname);
SCM gh_eval_file_with_catch(char *scheme_code, scm_catch_handler_t handler);
SCM gh_eval_file_with_standard_handler(char *scheme_code);
#define gh_defer_ints() SCM_DEFER_INTS
#define gh_allow_ints() SCM_ALLOW_INTS
SCM gh_new_procedure(char *proc_name, SCM (*fn)(),
int n_required_args, int n_optional_args, int varp);
SCM gh_new_procedure0_0(char *proc_name, SCM (*fn)());
SCM gh_new_procedure0_1(char *proc_name, SCM (*fn)());
SCM gh_new_procedure0_2(char *proc_name, SCM (*fn)());
SCM gh_new_procedure1_0(char *proc_name, SCM (*fn)());
SCM gh_new_procedure1_1(char *proc_name, SCM (*fn)());
SCM gh_new_procedure1_2(char *proc_name, SCM (*fn)());
SCM gh_new_procedure2_0(char *proc_name, SCM (*fn)());
SCM gh_new_procedure2_1(char *proc_name, SCM (*fn)());
SCM gh_new_procedure2_2(char *proc_name, SCM (*fn)());
SCM gh_new_procedure3_0(char *proc_name, SCM (*fn)());
SCM gh_new_procedure4_0(char *proc_name, SCM (*fn)());
SCM gh_new_procedure5_0(char *proc_name, SCM (*fn)());
/* C to Scheme conversion */
SCM gh_bool2scm(int x);
SCM gh_int2scm(int x);
SCM gh_ulong2scm(unsigned long x);
SCM gh_long2scm(long x);
SCM gh_double2scm(double x);
SCM gh_char2scm(char c);
SCM gh_str2scm(char *s, int len);
SCM gh_str02scm(char *s);
void gh_set_substr(char *src, SCM dst, int start, int len);
SCM gh_symbol2scm(char *symbol_str);
/* Scheme to C conversion */
int gh_scm2bool(SCM obj);
int gh_scm2int(SCM obj);
unsigned long gh_scm2ulong(SCM obj);
long gh_scm2long(SCM obj);
char gh_scm2char(SCM obj);
double gh_scm2double(SCM obj);
char *gh_scm2newstr(SCM str, int *lenp);
void gh_get_substr(SCM src, char *dst, int start, int len);
char *gh_symbol2newstr(SCM sym, int *lenp);
/* type predicates: tell you if an SCM object has a given type */
int gh_boolean_p(SCM val);
int gh_symbol_p(SCM val);
int gh_char_p(SCM val);
int gh_vector_p(SCM val);
int gh_pair_p(SCM val);
int gh_number_p(SCM val);
int gh_string_p(SCM val);
int gh_procedure_p(SCM val);
int gh_list_p(SCM val);
int gh_inexact_p(SCM val);
int gh_exact_p(SCM val);
/* more predicates */
int gh_eq_p(SCM x, SCM y);
int gh_eqv_p(SCM x, SCM y);
int gh_equal_p(SCM x, SCM y);
/* standard Scheme procedures available from C */
SCM gh_define(char *name, SCM val);
SCM gh_vector(SCM length, SCM val);
SCM gh_vset(SCM vec, SCM pos, SCM val);
SCM gh_vref(SCM vec, SCM pos);
unsigned long gh_vector_length(SCM v);
SCM gh_cons(SCM x, SCM y);
#define gh_list scm_listify
unsigned long gh_list_length(SCM l);
SCM gh_car(SCM x);
SCM gh_cdr(SCM x);
SCM gh_caar(SCM x);
SCM gh_cadr(SCM x);
SCM gh_cdar(SCM x);
SCM gh_cddr(SCM x);
SCM gh_caaar(SCM x);
SCM gh_caadr(SCM x);
SCM gh_cadar(SCM x);
SCM gh_caddr(SCM x);
SCM gh_cdaar(SCM x);
SCM gh_cdadr(SCM x);
SCM gh_cddar(SCM x);
SCM gh_cdddr(SCM x);
/* Calling Scheme functions from C. */
SCM gh_apply (SCM proc, SCM ls);
SCM gh_call0 (SCM proc);
SCM gh_call1 (SCM proc, SCM arg);
SCM gh_call2 (SCM proc, SCM arg1, SCM arg2);
SCM gh_call3 (SCM proc, SCM arg1, SCM arg2, SCM arg3);
/* reading and writing Scheme objects. */
void gh_display (SCM x);
void gh_newline (void);
/* void gh_gc_mark(SCM) : mark an SCM as in use. */
/* void gh_defer_ints() : don't interrupt code section. */
/* void gh_allow_ints() : see gh_defer_ints(). */
/* void gh_new_cell(SCM, int tag) : initialize SCM to be of type 'tag' */
/* int gh_type_p(SCM, tag) : test if SCM is of type 'tag' */
/* SCM gh_intern(char*) : get symbol corresponding to c-string.*/
/* void gh_set_ext_data(SCM, void*) : set extension data on SCM */
/* void *gh_get_ext_data(SCM) : return extension data from SCM. */
/* void gh_assert(int cond, char *msg, SCM obj); */
#endif /* __GH_H */

286
libguile/gh_data.c Normal file
View file

@ -0,0 +1,286 @@
/* Copyright (C) 1995,1996,1987 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, 675 Mass Ave, Cambridge, MA 02139, USA.
*
* As a special exception, the Free Software Foundation gives permission
* for additional uses of the text contained in its release of GUILE.
*
* The exception is that, if you link the GUILE library with other files
* to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the GUILE library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the
* Free Software Foundation under the name GUILE. If you copy
* code from other Free Software Foundation releases into a copy of
* GUILE, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for GUILE, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*/
/* data initialization and C<->Scheme data conversion */
#include <stdio.h>
#include <gh.h>
/* data conversion C->scheme */
SCM
gh_int2scmb (int x)
{
return (x ? SCM_BOOL_T : SCM_BOOL_F);
}
SCM
gh_int2scm (int x)
{
return scm_long2num ((long) x);
}
SCM
gh_ulong2scm (unsigned long x)
{
return scm_ulong2num (x);
}
SCM
gh_long2scm (long x)
{
return scm_long2num (x);
}
SCM
gh_double2scm (double x)
{
return scm_makdbl (x, 0.0);
}
SCM
gh_char2scm (char c)
{
return SCM_MAKICHR (c);
}
SCM
gh_str2scm (char *s, int len)
{
return scm_makfromstr (s, len, 0);
}
SCM
gh_str02scm (char *s)
{
return scm_makfrom0str (s);
}
/* Copy LEN characters at SRC into the *existing* Scheme string DST,
starting at START. START is an index into DST; zero means the
beginning of the string.
If START + LEN is off the end of DST, signal an out-of-range
error. */
void
gh_set_substr (char *src, SCM dst, int start, int len)
{
char *dst_ptr, dst_len, effective_length;
SCM_ASSERT (SCM_NIMP (dst) && SCM_STRINGP (dst), dst, SCM_ARG3,
"gh_set_substr");
scm_protect_object (dst);
dst_ptr = SCM_CHARS (dst);
dst_len = SCM_LENGTH (dst);
effective_length = (len < dst_len) ? len : dst_len;
memcpy (dst_ptr + start, src, effective_length);
/* FIXME: must signal an error if len > dst_len */
scm_unprotect_object (dst);
}
/* Return the symbol named SYMBOL_STR. */
SCM
gh_symbol2scm (char *symbol_str)
{
return SCM_CAR (scm_intern (symbol_str, strlen (symbol_str)));
}
/* data conversion scheme->C */
int
gh_scm2bool (SCM obj)
{
return ((obj) == SCM_BOOL_F) ? 0 : 1;
}
unsigned long
gh_scm2ulong (SCM obj)
{
return scm_num2ulong (obj, (char *) SCM_ARG1, "gh_scm2ulong");
}
long
gh_scm2long (SCM obj)
{
return scm_num2long (obj, (char *) SCM_ARG1, "gh_scm2long");
}
int
gh_scm2int (SCM obj)
{
/* NOTE: possible loss of precision here */
return (int) scm_num2long (obj, (char *) SCM_ARG1, "gh_scm2int");
}
double
gh_scm2double (SCM obj)
{
return scm_num2dbl (obj, "gh_scm2double");
}
char
gh_scm2char (SCM obj)
{
return SCM_ICHR (obj);
}
/* string conversions between C and Scheme */
/* gh_scm2newstr() -- Given a Scheme string STR, return a pointer to a
new copy of its contents, followed by a null byte. If lenp is
non-null, set *lenp to the string's length.
This function uses malloc to obtain storage for the copy; the
caller is responsible for freeing it.
Note that Scheme strings may contain arbitrary data, including null
characters. This means that null termination is not a reliable way
to determine the length of the returned value. However, the
function always copies the complete contents of STR, and sets
*LEN_P to the true length of the string (when LEN_P is non-null). */
char *
gh_scm2newstr (SCM str, int *lenp)
{
char *ret_str;
int len;
SCM_ASSERT (SCM_NIMP (str) && SCM_STRINGP (str), str, SCM_ARG3,
"gh_scm2newstr");
/* protect str from GC while we copy off its data */
scm_protect_object (str);
len = SCM_LENGTH (str);
ret_str = (char *) malloc ((len + 1) * sizeof (char));
/* so we copy tmp_str to ret_str, which is what we will allocate */
memcpy (ret_str, SCM_CHARS (str), len);
/* now make sure we null-terminate it */
ret_str[len] = '\0';
scm_unprotect_object (str);
if (lenp != NULL)
{
*lenp = len;
}
return ret_str;
}
/* Copy LEN characters at START from the Scheme string SRC to memory
at DST. START is an index into SRC; zero means the beginning of
the string. DST has already been allocated by the caller.
If START + LEN is off the end of SRC, silently truncate the source
region to fit the string. If truncation occurs, the corresponding
area of DST is left unchanged. */
void
gh_get_substr (SCM src, char *dst, int start, int len)
{
int src_len, effective_length;
SCM_ASSERT (SCM_NIMP (src) && SCM_STRINGP (src), src, SCM_ARG3,
"gh_get_substr");
scm_protect_object (src);
src_len = SCM_LENGTH (src);
effective_length = (len < src_len) ? len : src_len;
memcpy (dst + start, SCM_CHARS (src), effective_length * sizeof (char));
/* FIXME: must signal an error if len > src_len */
scm_unprotect_object (src);
}
/* gh_scm2newsymbol() -- Given a Scheme symbol 'identifier, return a
pointer to a string with the symbol characters "identifier",
followed by a null byte. If lenp is non-null, set *lenp to the
string's length.
This function uses malloc to obtain storage for the copy; the
caller is responsible for freeing it. */
char *
gh_symbol2newstr (SCM sym, int *lenp)
{
char *ret_str;
int len;
SCM_ASSERT (SCM_NIMP (sym) && SCM_SYMBOLP (sym), sym, SCM_ARG3,
"gh_scm2newsymbol");
/* protect str from GC while we copy off its data */
scm_protect_object (sym);
len = SCM_LENGTH (sym);
ret_str = (char *) malloc ((len + 1) * sizeof (char));
/* so we copy tmp_str to ret_str, which is what we will allocate */
memcpy (ret_str, SCM_CHARS (sym), len);
/* now make sure we null-terminate it */
ret_str[len] = '\0';
scm_unprotect_object (sym);
if (lenp != NULL)
{
*lenp = len;
}
return ret_str;
}
/* create a new vector of the given length, all initialized to the
given value */
SCM
gh_vector (SCM length, SCM val)
{
return scm_make_vector (length, val, SCM_UNDEFINED);
}
/* set the given element of the given vector to the given value */
SCM
gh_vset (SCM vec, SCM pos, SCM val)
{
return scm_vector_set_x (vec, pos, val);
}
/* retrieve the given element of the given vector */
SCM
gh_vref (SCM vec, SCM pos)
{
return scm_vector_ref (vec, pos);
}
/* returns the length of the given vector */
unsigned long
gh_vector_length (SCM v)
{
return gh_scm2ulong (scm_vector_length (v));
}

180
libguile/gh_eval.c Normal file
View file

@ -0,0 +1,180 @@
/* Copyright (C) 1995,1996,1997 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, 675 Mass Ave, Cambridge, MA 02139, USA.
*
* As a special exception, the Free Software Foundation gives permission
* for additional uses of the text contained in its release of GUILE.
*
* The exception is that, if you link the GUILE library with other files
* to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the GUILE library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the
* Free Software Foundation under the name GUILE. If you copy
* code from other Free Software Foundation releases into a copy of
* GUILE, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for GUILE, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*/
/* routines to evaluate Scheme code */
#include <stdio.h>
#include <gh.h>
typedef SCM (*gh_eval_t) (void *data, SCM jmpbuf);
struct cwss_data
{
SCM tag;
scm_catch_body_t body;
void *data;
};
/* Evaluate the string; toss the value. */
#if 0
void
gh_eval_str (char *scheme_code)
{
/* Create a port that reads characters from SCHEME_CODE. */
SCM port = scm_mkstrport (SCM_MAKINUM (0),
scm_makfrom0str (scheme_code),
SCM_OPN | SCM_RDNG,
"guile_main");
SCM form;
/* Read expressions from that port; ignore the values. */
while ((form = scm_read (port, SCM_BOOL_F, SCM_BOOL_F)) != SCM_EOF_VAL)
scm_eval_x (form);
/* Dispose of the port when done. (Oh icky.) */
scm_close_port (port);
}
#endif /* 0 */
SCM
gh_eval_str (char *scheme_code)
{
return scm_eval_0str (scheme_code);
}
/* evaluate the file by passing it to the lower level scm_primitive_load() */
SCM
gh_eval_file (char *fname)
{
return scm_primitive_load (gh_str02scm (fname));
}
static SCM
eval_str_wrapper (void *data, SCM jmpbuf)
{
/* gh_eval_t real_eval_proc = (gh_eval_t) (* ((gh_eval_t *) data)); */
char *scheme_code = (char *) data;
return gh_eval_str (scheme_code);
}
SCM
gh_eval_str_with_catch (char *scheme_code, scm_catch_handler_t handler)
{
/* FIXME: not there yet */
return gh_catch (SCM_BOOL_T, (scm_catch_body_t) eval_str_wrapper, scheme_code,
(scm_catch_handler_t) gh_standard_handler, scheme_code);
}
SCM
gh_eval_str_with_standard_handler (char *scheme_code)
{
return gh_eval_str_with_catch (scheme_code, gh_standard_handler);
}
SCM
ss_handler (void *data, SCM tag, SCM throw_args)
{
/* Save the stack */
SCM_SETCDR (scm_the_last_stack_var,
scm_make_stack (scm_cons (SCM_BOOL_T, SCM_EOL)));
/* Throw the error */
return scm_throw (tag, throw_args);
}
static SCM
cwss_body (void *data, SCM jmpbuf)
{
struct cwss_data *d = data;
return scm_internal_lazy_catch (d->tag, d->body, d->data, ss_handler, NULL);
}
/* FIXME: should catch_with_saved_stack() be in the gh_ API? */
static SCM
catch_with_saved_stack (SCM tag,
scm_catch_body_t body,
void *body_data,
scm_catch_handler_t handler,
void *handler_data)
{
struct cwss_data d;
d.tag = tag;
d.body = body;
d.data = body_data;
return scm_internal_catch (tag, cwss_body, &d, handler, handler_data);
}
SCM
gh_eval_str_with_stack_saving_handler (char *scheme_code)
{
return catch_with_saved_stack (SCM_BOOL_T,
(scm_catch_body_t) eval_str_wrapper,
scheme_code,
(scm_catch_handler_t)
gh_standard_handler,
scheme_code);
}
static SCM
eval_file_wrapper (void *data, SCM jmpbuf)
{
/* gh_eval_t real_eval_proc = (gh_eval_t) (* ((gh_eval_t *) data)); */
char *scheme_code = (char *) data;
return gh_eval_file (scheme_code);
}
SCM
gh_eval_file_with_catch (char *scheme_code, scm_catch_handler_t handler)
{
/* FIXME: not there yet */
return gh_catch (SCM_BOOL_T, (scm_catch_body_t) eval_file_wrapper,
scheme_code, (scm_catch_handler_t) gh_standard_handler,
scheme_code);
}
SCM
gh_eval_file_with_standard_handler (char *scheme_code)
{
return gh_eval_file_with_catch (scheme_code, gh_standard_handler);
}

169
libguile/gh_funcs.c Normal file
View file

@ -0,0 +1,169 @@
/* Copyright (C) 1995,1996,1997 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, 675 Mass Ave, Cambridge, MA 02139, USA.
*
* As a special exception, the Free Software Foundation gives permission
* for additional uses of the text contained in its release of GUILE.
*
* The exception is that, if you link the GUILE library with other files
* to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the GUILE library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the
* Free Software Foundation under the name GUILE. If you copy
* code from other Free Software Foundation releases into a copy of
* GUILE, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for GUILE, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*/
/* Defining Scheme functions implemented by C functions --- subrs. */
#include <stdio.h>
#include <gh.h>
/* allows you to define new scheme primitives written in C */
SCM
gh_new_procedure (char *proc_name, SCM (*fn) (),
int n_required_args, int n_optional_args, int varp)
{
return scm_make_gsubr (proc_name, n_required_args, n_optional_args,
varp, fn);
}
SCM
gh_new_procedure0_0 (char *proc_name, SCM (*fn) ())
{
return gh_new_procedure (proc_name, fn, 0, 0, 0);
}
SCM
gh_new_procedure0_1 (char *proc_name, SCM (*fn) ())
{
return gh_new_procedure (proc_name, fn, 0, 1, 0);
}
SCM
gh_new_procedure0_2 (char *proc_name, SCM (*fn) ())
{
return gh_new_procedure (proc_name, fn, 0, 2, 0);
}
SCM
gh_new_procedure1_0 (char *proc_name, SCM (*fn) ())
{
return gh_new_procedure (proc_name, fn, 1, 0, 0);
}
SCM
gh_new_procedure1_1 (char *proc_name, SCM (*fn) ())
{
return gh_new_procedure (proc_name, fn, 1, 1, 0);
}
SCM
gh_new_procedure1_2 (char *proc_name, SCM (*fn) ())
{
return gh_new_procedure (proc_name, fn, 1, 2, 0);
}
SCM
gh_new_procedure2_0 (char *proc_name, SCM (*fn) ())
{
return gh_new_procedure (proc_name, fn, 2, 0, 0);
}
SCM
gh_new_procedure2_1 (char *proc_name, SCM (*fn) ())
{
return gh_new_procedure (proc_name, fn, 2, 1, 0);
}
SCM
gh_new_procedure2_2 (char *proc_name, SCM (*fn) ())
{
return gh_new_procedure (proc_name, fn, 2, 2, 0);
}
SCM
gh_new_procedure3_0 (char *proc_name, SCM (*fn) ())
{
return gh_new_procedure (proc_name, fn, 3, 0, 0);
}
SCM
gh_new_procedure4_0 (char *proc_name, SCM (*fn) ())
{
return gh_new_procedure (proc_name, fn, 4, 0, 0);
}
SCM
gh_new_procedure5_0 (char *proc_name, SCM (*fn) ())
{
return gh_new_procedure (proc_name, fn, 5, 0, 0);
}
/* some (possibly most) Scheme functions available from C */
SCM
gh_define (char *name, SCM val)
{
return scm_sysintern (name, val);
}
/* Calling Scheme functions from C. */
SCM
gh_apply (SCM proc, SCM args)
{
return scm_apply (proc, args, SCM_EOL);
}
SCM
gh_call0 (SCM proc)
{
return scm_apply (proc, SCM_EOL, SCM_EOL);
}
SCM
gh_call1 (SCM proc, SCM arg)
{
return scm_apply (proc, arg, scm_listofnull);
}
SCM
gh_call2 (SCM proc, SCM arg1, SCM arg2)
{
return scm_apply (proc, arg1, scm_cons (arg2, scm_listofnull));
}
SCM
gh_call3 (SCM proc, SCM arg1, SCM arg2, SCM arg3)
{
return scm_apply (proc, arg1, scm_cons2 (arg2, arg3, scm_listofnull));
}

107
libguile/gh_init.c Normal file
View file

@ -0,0 +1,107 @@
/* Copyright (C) 1995,1996 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, 675 Mass Ave, Cambridge, MA 02139, USA.
*
* As a special exception, the Free Software Foundation gives permission
* for additional uses of the text contained in its release of GUILE.
*
* The exception is that, if you link the GUILE library with other files
* to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the GUILE library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the
* Free Software Foundation under the name GUILE. If you copy
* code from other Free Software Foundation releases into a copy of
* GUILE, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for GUILE, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*/
/* Guile high level (gh_) interface, initialization-related stuff */
#include <stdio.h>
#include <gh.h>
typedef void (*main_prog_t) (int argc, char **argv);
typedef void (*repl_prog_t) (int argc, char **argv);
/* This function takes care of all real GH initialization. Since it's
called by scm_boot_guile, it can safely work with heap objects, or
call functions that do so. */
static void
gh_launch_pad (void *closure, int argc, char **argv)
{
main_prog_t c_main_prog = (main_prog_t) closure;
gh_eval_str ("(primitive-load-path \"ice-9/boot-9.scm\")");
c_main_prog (argc, argv);
exit (0);
}
/* starts up the Scheme interpreter, and stays in it. c_main_prog()
is the address of the user's main program, since gh_enter() never
returns. */
void
gh_enter (int argc, char *argv[], main_prog_t c_main_prog)
{
scm_boot_guile (argc, argv, gh_launch_pad, c_main_prog);
/* never returns */
}
/* offer a REPL to the C programmer; for now I just invoke the ice-9
REPL that is written in Scheme */
void
gh_repl ()
{
/* gh_eval_str("(primitive-load-path \"ice-9/boot-9.scm\")"); */
gh_eval_str ("(top-repl)");
}
/* libguile programmers need exception handling mechanisms; here is
the recommended way of doing it with the gh_ interface */
/* gh_catch() -- set up an exception handler for a particular type of
error (or any thrown error if tag is SCM_BOOL_T); see
../libguile/throw.c for the comments explaining scm_internal_catch */
SCM
gh_catch (SCM tag, scm_catch_body_t body, void *body_data,
scm_catch_handler_t handler, void *handler_data)
{
return scm_internal_catch (tag, body, body_data, handler, handler_data);
}
SCM
gh_standard_handler (void *data, SCM tag, SCM throw_args)
{
fprintf (stderr, "\nJust got an error; tag is\n ");
scm_display (tag, scm_current_output_port ());
scm_newline (scm_current_output_port ());
scm_newline (scm_current_output_port ());
return SCM_BOOL_F;
}

57
libguile/gh_io.c Normal file
View file

@ -0,0 +1,57 @@
/* Copyright (C) 1995,1996 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, 675 Mass Ave, Cambridge, MA 02139, USA.
*
* As a special exception, the Free Software Foundation gives permission
* for additional uses of the text contained in its release of GUILE.
*
* The exception is that, if you link the GUILE library with other files
* to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the GUILE library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the
* Free Software Foundation under the name GUILE. If you copy
* code from other Free Software Foundation releases into a copy of
* GUILE, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for GUILE, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*/
#include <stdio.h>
#include <gh.h>
void
gh_display (SCM x)
{
scm_display (x, scm_current_output_port ());
}
void
gh_newline ()
{
scm_newline (scm_current_output_port ());
}

142
libguile/gh_list.c Normal file
View file

@ -0,0 +1,142 @@
/* Copyright (C) 1995,1996 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, 675 Mass Ave, Cambridge, MA 02139, USA.
*
* As a special exception, the Free Software Foundation gives permission
* for additional uses of the text contained in its release of GUILE.
*
* The exception is that, if you link the GUILE library with other files
* to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the GUILE library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the
* Free Software Foundation under the name GUILE. If you copy
* code from other Free Software Foundation releases into a copy of
* GUILE, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for GUILE, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*/
/* list manipulation */
#include <stdio.h>
#include <gh.h>
/* returns the length of a list */
unsigned long
gh_list_length (SCM l)
{
return gh_scm2ulong (scm_list_length (l));
}
/* list operations */
/* analogous to the Scheme cons operator */
SCM
gh_cons (SCM x, SCM y)
{
return scm_cons (x, y);
}
/* gh_list(SCM elt, ...) is implemented as a macro in gh.h. */
/* analogous to the Scheme car operator */
SCM
gh_car (SCM x)
{
return SCM_CAR (x);
}
/* analogous to the Scheme cdr operator */
SCM
gh_cdr (SCM x)
{
return SCM_CDR (x);
}
/* now for the multiple car/cdr utility procedures */
SCM
gh_caar (SCM x)
{
return SCM_CAAR (x);
}
SCM
gh_cadr (SCM x)
{
return SCM_CADR (x);
}
SCM
gh_cdar (SCM x)
{
return SCM_CDAR (x);
}
SCM
gh_cddr (SCM x)
{
return SCM_CDDR (x);
}
SCM
gh_caaar (SCM x)
{
return SCM_CAAAR (x);
}
SCM
gh_caadr (SCM x)
{
return SCM_CAADR (x);
}
SCM
gh_cadar (SCM x)
{
return SCM_CADAR (x);
}
SCM
gh_caddr (SCM x)
{
return SCM_CADDR (x);
}
SCM
gh_cdaar (SCM x)
{
return SCM_CDAAR (x);
}
SCM
gh_cdadr (SCM x)
{
return SCM_CDADR (x);
}
SCM
gh_cddar (SCM x)
{
return SCM_CDDAR (x);
}
SCM
gh_cdddr (SCM x)
{
return SCM_CDDDR (x);
}

121
libguile/gh_predicates.c Normal file
View file

@ -0,0 +1,121 @@
/* Copyright (C) 1995,1996 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, 675 Mass Ave, Cambridge, MA 02139, USA.
*
* As a special exception, the Free Software Foundation gives permission
* for additional uses of the text contained in its release of GUILE.
*
* The exception is that, if you link the GUILE library with other files
* to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the GUILE library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the
* Free Software Foundation under the name GUILE. If you copy
* code from other Free Software Foundation releases into a copy of
* GUILE, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for GUILE, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*/
/* type predicates and equality predicates */
#include <stdio.h>
#include <gh.h>
/* type predicates: tell you if an SCM object has a given type */
int
gh_boolean_p (SCM val)
{
return (scm_boolean_p (val) == SCM_BOOL_T) ? 1 : 0;
}
int
gh_symbol_p (SCM val)
{
return (scm_symbol_p (val) == SCM_BOOL_T) ? 1 : 0;
}
int
gh_char_p (SCM val)
{
return (scm_char_p (val) == SCM_BOOL_T) ? 1 : 0;
}
int
gh_vector_p (SCM val)
{
return (scm_vector_p (val) == SCM_BOOL_T) ? 1 : 0;
}
int
gh_pair_p (SCM val)
{
return (scm_pair_p (val) == SCM_BOOL_T) ? 1 : 0;
}
int
gh_number_p (SCM val)
{
return (scm_number_p (val) == SCM_BOOL_T) ? 1 : 0;
}
int
gh_string_p (SCM val)
{
return (scm_string_p (val) == SCM_BOOL_T) ? 1 : 0;
}
int
gh_procedure_p (SCM val)
{
return (scm_procedure_p (val) == SCM_BOOL_T) ? 1 : 0;
}
int
gh_list_p (SCM val)
{
return (scm_list_p (val) == SCM_BOOL_T) ? 1 : 0;
}
int
gh_inexact_p (SCM val)
{
return (scm_inexact_p (val) == SCM_BOOL_T) ? 1 : 0;
}
int
gh_exact_p (SCM val)
{
return (scm_exact_p (val) == SCM_BOOL_T) ? 1 : 0;
}
/* the three types of equality */
int
gh_eq_p (SCM x, SCM y)
{
return (scm_eq_p (x, y) == SCM_BOOL_T) ? 1 : 0;
}
int
gh_eqv_p (SCM x, SCM y)
{
return (scm_eqv_p (x, y) != SCM_BOOL_T) ? 1 : 0;
}
int
gh_equal_p (SCM x, SCM y)
{
return (scm_equal_p (x, y) != SCM_BOOL_T) ? 1 : 0;
}

221
libguile/gh_test_c.c Normal file
View file

@ -0,0 +1,221 @@
/* Copyright (C) 1995,1996,1987 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, 675 Mass Ave, Cambridge, MA 02139, USA.
*
* As a special exception, the Free Software Foundation gives permission
* for additional uses of the text contained in its release of GUILE.
*
* The exception is that, if you link the GUILE library with other files
* to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the GUILE library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the
* Free Software Foundation under the name GUILE. If you copy
* code from other Free Software Foundation releases into a copy of
* GUILE, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for GUILE, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*/
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <gh.h>
SCM c_factorial (SCM s_n);
SCM c_sin (SCM s_x);
SCM c_vector_test (SCM s_length);
/* the gh_enter() routine, the standard entryp point for the gh_
interface, makes you use a separate main function */
void
main_prog (int argc, char *argv[])
{
int done;
char input_str[1000];
SCM cf;
SCM result_dummy;
result_dummy = gh_eval_str ("(display \"hello guile\n\")");
gh_display (result_dummy);
printf ("\ntesting gh_define\n");
gh_define ("test_symbol", gh_double2scm (2.5));
gh_eval_str ("(display test_symbol) (newline)");
/* test playing with symbols */
{
SCM sym;
char *sym_string;
sym = gh_symbol2scm ("a-test-symbol");
sym_string = gh_symbol2newstr (sym, NULL);
printf ("the symbol was <%s>; after converting to Scheme and back to\n",
"a-test-symbol");
printf ("a C string it is now <%s>\n", sym_string);
free (sym_string);
}
/* here result dummy should be a string object */
result_dummy = gh_eval_str ("\"test_string\"");
assert (gh_string_p (result_dummy));
{
char *s;
s = gh_scm2newstr (result_dummy, NULL);
printf ("result of converting \"test_string\" from SCM to C is <%s>\n", s);
free (s); /* remember to free s!! */
}
gh_eval_str ("(define (square x) (* x x))");
gh_eval_str ("(define (fact n) (if (= n 1) 1 (* n (fact (- n 1)))))");
gh_eval_str ("(display (square 9)) (newline)");
gh_eval_str ("(display (fact 100)) (newline)");
gh_eval_str_with_standard_handler ("(display \"dude!\n\")");
/* in this next line I have a wilful typo: dosplay is not a defined
procedure, so it should throw an error */
gh_eval_str_with_standard_handler ("(dosplay \"dude!\n\")");
/* now define some new primitives in C */
cf = gh_new_procedure1_0 ("c_factorial", c_factorial);
gh_new_procedure1_0 ("c_sin", c_sin);
gh_new_procedure1_0 ("c_vector_test", c_vector_test);
/* now try some (eval ...) action from C */
{
SCM l = SCM_EOL;
l = gh_cons (gh_str02scm ("hello world"), l);
l = gh_cons (gh_symbol2scm ("display"), l);
printf ("expression is: ");
gh_display (l);
gh_newline ();
/* Don't have a function for evaluating sexps yet. */
}
printf ("testing the predicates for procedure? and vector?\n");
printf ("gh_procedure_p(c_factorial) is %d, gh_vector_p(c_factorial) is %d\n",
gh_procedure_p (cf), gh_vector_p (cf));
/* Test calling procedures. */
{
SCM list = gh_eval_str ("list");
printf ("testing gh_apply\n");
printf ("gh_apply (list, '(1 2)) => ");
gh_display (gh_apply (list, gh_cons (gh_int2scm (1),
gh_cons (gh_int2scm (2),
SCM_EOL))));
gh_newline ();
printf ("gh_call0 (list) => ");
gh_display (gh_call0 (list));
gh_newline ();
printf ("gh_call1 (list, 1) => ");
gh_display (gh_call1 (list, gh_int2scm (1)));
gh_newline ();
printf ("gh_call2 (list, 1, 2) => ");
gh_display (gh_call2 (list, gh_int2scm (1), gh_int2scm (2)));
gh_newline ();
printf ("gh_call3 (list, 1, 2, 3) => ");
gh_display (gh_call3 (list,
gh_int2scm (1), gh_int2scm (2), gh_int2scm (3)));
gh_newline ();
}
/* now sit in a scheme eval loop: I input the expressions, have
guile evaluate them, and then get another expression. */
done = 0;
while (!done)
{
printf ("\n%s> ", argv[0]);
if (gets (input_str) == NULL)
{
done = 1;
}
else
{
/* gh_display(gh_eval_str_with_standard_handler(input_str)); */
gh_display (gh_eval_str_with_stack_saving_handler (input_str));
}
}
}
int
main (int argc, char *argv[])
{
gh_enter (argc, argv, main_prog);
return 0;
}
SCM
c_factorial (SCM s_n)
{
int i, n;
unsigned long result = 1;
n = gh_scm2ulong (s_n);
for (i = 1; i <= n; ++i)
{
result = result * i;
}
return gh_ulong2scm (result);
}
/* a sin routine in C, callable from scheme. it is named c_sin() to
distinguish it from the default scheme sin function */
SCM
c_sin (SCM s_x)
{
double x = gh_scm2double (s_x);
return gh_double2scm (sin (x));
}
/* play around with vectors in guile: this routine creates a vector of
the given length, initializes it all to zero except element 2 which
is set to 1.9. */
SCM
c_vector_test (SCM s_length)
{
SCM xvec;
unsigned long c_length;
c_length = gh_scm2ulong (s_length);
printf ("requested length for vector: %ld\n", c_length);
/* create a vector filled witth 0.0 entries */
xvec = gh_vector (c_length, gh_double2scm (0.0));
/* set the second element in it to some floating point value */
gh_vset (xvec, 2, gh_double2scm (1.9));
return xvec;
}

156
libguile/gh_test_repl.c Normal file
View file

@ -0,0 +1,156 @@
/* Copyright (C) 1995,1996 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, 675 Mass Ave, Cambridge, MA 02139, USA.
*
* As a special exception, the Free Software Foundation gives permission
* for additional uses of the text contained in its release of GUILE.
*
* The exception is that, if you link the GUILE library with other files
* to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the GUILE library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the
* Free Software Foundation under the name GUILE. If you copy
* code from other Free Software Foundation releases into a copy of
* GUILE, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for GUILE, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*/
/* gh_test_repl -- a program that demonstrates starting Guile, adding
some privmitive procedures and entering a REPL form C */
#include <stdio.h>
#include <math.h>
#include <gh.h>
SCM c_factorial (SCM s_n);
SCM c_sin (SCM s_x);
SCM c_vector_test (SCM s_length);
/* the gh_enter() routine, the standard entryp point for the gh_
interface, makes you use a separate main function */
void
main_prog (int argc, char *argv[])
{
SCM cf;
gh_eval_str ("(display \"hello guile\n\")");
gh_eval_str ("(define (square x) (* x x))");
gh_eval_str ("(define (fact n) (if (= n 1) 1 (* n (fact (- n 1)))))");
gh_eval_str ("(display (square 9)) (newline)");
gh_eval_str ("(display (fact 100)) (newline)");
gh_eval_str ("(define s \"A string\")");
gh_eval_str ("(define p '(A . pair))");
gh_eval_str ("(display s)");
gh_eval_str ("(display p)");
gh_eval_str ("(display (string? s))");
gh_eval_str ("(display (pair? s))");
/* now define some new primitives in C */
cf = gh_new_procedure1_0 ("c_factorial", c_factorial);
gh_new_procedure1_0 ("c_sin", c_sin);
gh_new_procedure1_0 ("c_vector_test", c_vector_test);
/* now try some (eval ...) action from C */
{
SCM l = SCM_EOL;
l = gh_cons (gh_str02scm ("hello world"), l);
l = gh_cons (gh_symbol2scm ("'display"), l);
gh_display (l);
}
{
SCM a_string;
a_string = gh_str02scm ("A string");
printf ("testing the predicates for pair? and string?\n");
printf ("gh_pair_p(a_string) is %d, gh_string_p(a_string) is %d\n",
gh_pair_p (a_string), gh_string_p (a_string));
}
printf ("testing the predicates for procedure? and vector?\n");
printf ("gh_procedure_p(c_factorial) is %d, gh_vector_p(c_factorial) is %d\n",
gh_procedure_p (cf), gh_vector_p (cf));
gh_repl ();
}
int
main (int argc, char *argv[])
{
gh_enter (argc, argv, main_prog);
return 0;
}
SCM
c_factorial (SCM s_n)
{
int i, n;
unsigned long result = 1;
n = gh_scm2ulong (s_n);
for (i = 1; i <= n; ++i)
{
result = result * i;
}
return gh_ulong2scm (result);
}
/* a sin routine in C, callable from scheme. it is named c_sin() to
distinguish it from the default scheme sin function */
SCM
c_sin (SCM s_x)
{
double x = gh_scm2double (s_x);
return gh_double2scm (sin (x));
}
/* play around with vectors in guile: this routine creates a vector of
the given length, initializes it all to zero except element 2 which
is set to 1.9. */
SCM
c_vector_test (SCM s_length)
{
SCM xvec;
unsigned long c_length;
c_length = gh_scm2ulong (s_length);
printf ("requested length for vector: %ld\n", c_length);
/* create a vector filled witth 0.0 entries */
xvec = gh_vector (c_length, gh_double2scm (0.0));
/* set the second element in it to some floating point value */
gh_vset (xvec, 2, gh_double2scm (1.9));
return xvec;
}

View file

@ -313,3 +313,12 @@
/* Define if you have the dld library (-ldld). */
#undef HAVE_LIBDLD
/* Define if you have the m library (-lm). */
#undef HAVE_LIBM
/* Define if you have the nsl library (-lnsl). */
#undef HAVE_LIBNSL
/* Define if you have the socket library (-lsocket). */
#undef HAVE_LIBSOCKET