mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 03:40:34 +02:00
Remove doc/example-smob/
* doc/example-smob/: Remove example. It's smaller than it used to be in Guile 1.8, and with foreign objects there's practically nothing interesting to test. * doc/oldfmt.c: Remove this hoary thing. * doc/README: * doc/Makefile.am: Update.
This commit is contained in:
parent
d9a4a1cde1
commit
9720934f3a
9 changed files with 1 additions and 440 deletions
|
@ -1,6 +1,6 @@
|
||||||
## Process this file with Automake to create Makefile.in
|
## Process this file with Automake to create Makefile.in
|
||||||
##
|
##
|
||||||
## Copyright (C) 1998, 2002, 2006, 2008, 2009, 2010 Free Software Foundation, Inc.
|
## Copyright (C) 1998, 2002, 2006, 2008, 2009, 2010, 2014 Free Software Foundation, Inc.
|
||||||
##
|
##
|
||||||
## This file is part of GUILE.
|
## This file is part of GUILE.
|
||||||
##
|
##
|
||||||
|
@ -25,18 +25,6 @@ SUBDIRS = ref r5rs
|
||||||
|
|
||||||
dist_man1_MANS = guile.1
|
dist_man1_MANS = guile.1
|
||||||
|
|
||||||
EXAMPLE_SMOB_FILES = \
|
|
||||||
ChangeLog-2008 Makefile README image-type.c image-type.h myguile.c
|
|
||||||
|
|
||||||
OLDFMT = oldfmt.c
|
|
||||||
|
|
||||||
dist-hook:
|
|
||||||
cp $(srcdir)/$(OLDFMT) $(distdir)/
|
|
||||||
mkdir $(distdir)/example-smob
|
|
||||||
for f in $(EXAMPLE_SMOB_FILES); do \
|
|
||||||
cp $(srcdir)/example-smob/$$f $(distdir)/example-smob/; \
|
|
||||||
done
|
|
||||||
|
|
||||||
EXTRA_DIST = groupings.alist ChangeLog-2008 # guile-api.alist
|
EXTRA_DIST = groupings.alist ChangeLog-2008 # guile-api.alist
|
||||||
|
|
||||||
include $(top_srcdir)/am/maintainer-dirs
|
include $(top_srcdir)/am/maintainer-dirs
|
||||||
|
|
|
@ -14,10 +14,6 @@ Please be aware that this is all very much work in progress (apart
|
||||||
from the Revised^5 Report). Bug reports and contributions are
|
from the Revised^5 Report). Bug reports and contributions are
|
||||||
welcome!
|
welcome!
|
||||||
|
|
||||||
The file `oldfmt.c' contains a function which can be used by
|
|
||||||
application writers to support both old-style and new-style error
|
|
||||||
format strings.
|
|
||||||
|
|
||||||
The `sources' directory includes some stuff relevant to the Guile
|
The `sources' directory includes some stuff relevant to the Guile
|
||||||
reference manual, and which may eventually be folded in to it. It's
|
reference manual, and which may eventually be folded in to it. It's
|
||||||
not immediately relevant, however, which is why it's not in this
|
not immediately relevant, however, which is why it's not in this
|
||||||
|
|
|
@ -1,56 +0,0 @@
|
||||||
2008-01-22 Neil Jerram <neil@ossau.uklinux.net>
|
|
||||||
|
|
||||||
* COPYING: Removed.
|
|
||||||
|
|
||||||
2004-09-24 Marius Vollmer <mvo@zagadka.de>
|
|
||||||
|
|
||||||
* image-type.c: Updated from manual.
|
|
||||||
|
|
||||||
2002-02-28 Marius Vollmer <mvo@zagadka.ping.de>
|
|
||||||
|
|
||||||
* image-type.c (image_tag): Changed type to scm_t_bits.
|
|
||||||
(make_image): Use scm_gc_malloc instead of scm_must_malloc.
|
|
||||||
(free_image): Use scm_gc_free instead of free. Return zero.
|
|
||||||
|
|
||||||
2001-05-30 Martin Grabmueller <mgrabmue@cs.tu-berlin.de>
|
|
||||||
|
|
||||||
* image-type.c: Adapted to new typing and naming convention.
|
|
||||||
|
|
||||||
2001-04-26 Neil Jerram <neil@ossau.uklinux.net>
|
|
||||||
|
|
||||||
* image-type.c (make_image): Don't need to use SCM_NIMP before
|
|
||||||
SCM_STRINGP.
|
|
||||||
(clear_image): Use SCM_SMOB_PREDICATE.
|
|
||||||
(clear_image, mark_image, free_image, print_image): Use
|
|
||||||
SCM_SMOB_DATA rather than SCM_CDR.
|
|
||||||
|
|
||||||
2000-06-20 Mikael Djurfeldt <mdj@thalamus.nada.kth.se>
|
|
||||||
|
|
||||||
* image-type.c: Removed unused scm_smobfuns structure.
|
|
||||||
(init_image_type): Use standard smob type interface.
|
|
||||||
|
|
||||||
Fri Jun 25 22:21:04 1999 Greg Badros <gjb@cs.washington.edu>
|
|
||||||
|
|
||||||
* image-type.c: Updated example to use scm_make_smob_type_mfpe,
|
|
||||||
SCM_RETURN_NEWSMOB, SCM_NEWSMOB function and macros.
|
|
||||||
|
|
||||||
1998-10-19 Jim Blandy <jimb@zwingli.cygnus.com>
|
|
||||||
|
|
||||||
* image-type.c, myguile.c: Terminate copyright comments.
|
|
||||||
|
|
||||||
* COPYING: New file.
|
|
||||||
* image-type.c myguile.c: Add copyright notice.
|
|
||||||
|
|
||||||
1998-10-16 Jim Blandy <jimb@zwingli.cygnus.com>
|
|
||||||
|
|
||||||
* Makefile (myguile): Fix link command, to put the Guile libraries
|
|
||||||
after the object files. The old command worked on my machine, but
|
|
||||||
I don't see how.
|
|
||||||
|
|
||||||
1998-10-15 Jim Blandy <jimb@zwingli.cygnus.com>
|
|
||||||
|
|
||||||
Created this directory for the Guile 1.3 release. Thanks to Jay
|
|
||||||
Glascoe for suggesting that we provide a complete, buildable
|
|
||||||
example!
|
|
||||||
* ChangeLog, Makefile, README, image-type.c, image-type.h,
|
|
||||||
myguile: New files.
|
|
|
@ -1,12 +0,0 @@
|
||||||
CFLAGS = `pkg-config guile-2.0 --cflags`
|
|
||||||
LIBS = `pkg-config guile-2.0 --libs`
|
|
||||||
|
|
||||||
O_FILES = image-type.o myguile.o
|
|
||||||
|
|
||||||
all: myguile
|
|
||||||
|
|
||||||
myguile: $(O_FILES)
|
|
||||||
$(CC) $(O_FILES) $(LIBS) -o myguile
|
|
||||||
|
|
||||||
clean:
|
|
||||||
-rm -rf myguile $(O_FILES)
|
|
|
@ -1,6 +0,0 @@
|
||||||
This is the example code for the ``Defining New Types (Smobs)''
|
|
||||||
chapter of the Guile manual.
|
|
||||||
|
|
||||||
When you try to execute the code, if the system complains that it
|
|
||||||
can't find libguile.so, you need to add the directory containing the
|
|
||||||
installed Guile libraries to your LD_LIBRARY_PATH environment variable.
|
|
|
@ -1,115 +0,0 @@
|
||||||
/* image-type.c
|
|
||||||
*
|
|
||||||
* Copyright (C) 1998, 2000, 2004, 2006, 2011 Free Software Foundation, Inc.
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 3, 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
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this software; see the file COPYING.LESSER. If
|
|
||||||
* not, write to the Free Software Foundation, Inc., 51 Franklin
|
|
||||||
* Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <libguile.h>
|
|
||||||
|
|
||||||
static scm_t_bits image_tag;
|
|
||||||
|
|
||||||
struct image
|
|
||||||
{
|
|
||||||
int width, height;
|
|
||||||
char *pixels;
|
|
||||||
|
|
||||||
/* The name of this image */
|
|
||||||
SCM name;
|
|
||||||
|
|
||||||
/* A function to call when this image is
|
|
||||||
modified, e.g., to update the screen,
|
|
||||||
or SCM_BOOL_F if no action necessary */
|
|
||||||
SCM update_func;
|
|
||||||
};
|
|
||||||
|
|
||||||
static SCM
|
|
||||||
make_image (SCM name, SCM s_width, SCM s_height)
|
|
||||||
{
|
|
||||||
SCM smob;
|
|
||||||
struct image *image;
|
|
||||||
int width = scm_to_int (s_width);
|
|
||||||
int height = scm_to_int (s_height);
|
|
||||||
|
|
||||||
/* Step 1: Allocate the memory block.
|
|
||||||
*/
|
|
||||||
image = (struct image *) scm_gc_malloc (sizeof (struct image), "image");
|
|
||||||
|
|
||||||
/* Step 2: Initialize it with straight code.
|
|
||||||
*/
|
|
||||||
image->width = width;
|
|
||||||
image->height = height;
|
|
||||||
image->pixels = NULL;
|
|
||||||
image->name = SCM_BOOL_F;
|
|
||||||
image->update_func = SCM_BOOL_F;
|
|
||||||
|
|
||||||
/* Step 3: Create the smob.
|
|
||||||
*/
|
|
||||||
SCM_NEWSMOB (smob, image_tag, image);
|
|
||||||
|
|
||||||
/* Step 4: Finish the initialization.
|
|
||||||
*/
|
|
||||||
image->name = name;
|
|
||||||
image->pixels = scm_gc_malloc_pointerless (width * height, "image pixels");
|
|
||||||
|
|
||||||
return smob;
|
|
||||||
}
|
|
||||||
|
|
||||||
SCM
|
|
||||||
clear_image (SCM image_smob)
|
|
||||||
{
|
|
||||||
int area;
|
|
||||||
struct image *image;
|
|
||||||
|
|
||||||
scm_assert_smob_type (image_tag, image_smob);
|
|
||||||
|
|
||||||
image = (struct image *) SCM_SMOB_DATA (image_smob);
|
|
||||||
area = image->width * image->height;
|
|
||||||
memset (image->pixels, 0, area);
|
|
||||||
|
|
||||||
/* Invoke the image's update function.
|
|
||||||
*/
|
|
||||||
if (scm_is_true (image->update_func))
|
|
||||||
scm_call_0 (image->update_func);
|
|
||||||
|
|
||||||
scm_remember_upto_here_1 (image_smob);
|
|
||||||
|
|
||||||
return SCM_UNSPECIFIED;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
print_image (SCM image_smob, SCM port, scm_print_state *pstate)
|
|
||||||
{
|
|
||||||
struct image *image = (struct image *) SCM_SMOB_DATA (image_smob);
|
|
||||||
|
|
||||||
scm_puts ("#<image ", port);
|
|
||||||
scm_display (image->name, port);
|
|
||||||
scm_puts (">", port);
|
|
||||||
|
|
||||||
/* non-zero means success */
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
init_image_type (void)
|
|
||||||
{
|
|
||||||
image_tag = scm_make_smob_type ("image", sizeof (struct image));
|
|
||||||
scm_set_smob_print (image_tag, print_image);
|
|
||||||
|
|
||||||
scm_c_define_gsubr ("clear-image", 1, 0, 0, clear_image);
|
|
||||||
scm_c_define_gsubr ("make-image", 3, 0, 0, make_image);
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
/* file "image-type.h" */
|
|
||||||
|
|
||||||
void init_image_type (void);
|
|
|
@ -1,37 +0,0 @@
|
||||||
/* myguile.c
|
|
||||||
*
|
|
||||||
* Copyright (C) 1998, 2006 Free Software Foundation, Inc.
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 3, 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
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this software; see the file COPYING.LESSER. If
|
|
||||||
* not, write to the Free Software Foundation, Inc., 51 Franklin
|
|
||||||
* Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <libguile.h>
|
|
||||||
#include "image-type.h"
|
|
||||||
|
|
||||||
static void
|
|
||||||
inner_main (void *closure, int argc, char **argv)
|
|
||||||
{
|
|
||||||
/* module initializations would go here */
|
|
||||||
init_image_type();
|
|
||||||
scm_shell (argc, argv);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
main (int argc, char **argv)
|
|
||||||
{
|
|
||||||
scm_boot_guile (argc, argv, inner_main, 0);
|
|
||||||
return 0; /* never reached */
|
|
||||||
}
|
|
194
doc/oldfmt.c
194
doc/oldfmt.c
|
@ -1,194 +0,0 @@
|
||||||
/* Copyright (C) 2000,2001, 2006, 2008 Free Software Foundation, Inc.
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 3, 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
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this software; see the file COPYING.LESSER. If
|
|
||||||
* not, write to the Free Software Foundation, Inc., 51 Franklin
|
|
||||||
* Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* From NEWS:
|
|
||||||
*
|
|
||||||
* * New primitive: `simple-format', affects `scm-error', scm_display_error, & scm_error message strings
|
|
||||||
*
|
|
||||||
* (ice-9 boot) makes `format' an alias for `simple-format' until possibly
|
|
||||||
* extended by the more sophisticated version in (ice-9 format)
|
|
||||||
*
|
|
||||||
* (simple-format port message . args)
|
|
||||||
* Write MESSAGE to DESTINATION, defaulting to `current-output-port'.
|
|
||||||
* MESSAGE can contain ~A (was %s) and ~S (was %S) escapes. When printed,
|
|
||||||
* the escapes are replaced with corresponding members of ARGS:
|
|
||||||
* ~A formats using `display' and ~S formats using `write'.
|
|
||||||
* If DESTINATION is #t, then use the `current-output-port',
|
|
||||||
* if DESTINATION is #f, then return a string containing the formatted text.
|
|
||||||
* Does not add a trailing newline."
|
|
||||||
*
|
|
||||||
* The two C procedures: scm_display_error and scm_error, as well as the
|
|
||||||
* primitive `scm-error', now use scm_format to do their work. This means
|
|
||||||
* that the message strings of all code must be updated to use ~A where %s
|
|
||||||
* was used before, and ~S where %S was used before.
|
|
||||||
*
|
|
||||||
* During the period when there still are a lot of old Guiles out there,
|
|
||||||
* you might want to support both old and new versions of Guile.
|
|
||||||
*
|
|
||||||
* There are basically two methods to achieve this. Both methods use
|
|
||||||
* autoconf. Put
|
|
||||||
*
|
|
||||||
* AC_CHECK_FUNCS(scm_simple_format)
|
|
||||||
*
|
|
||||||
* in your configure.in.
|
|
||||||
*
|
|
||||||
* Method 1: Use the string concatenation features of ANSI C's
|
|
||||||
* preprocessor.
|
|
||||||
*
|
|
||||||
* In C:
|
|
||||||
*
|
|
||||||
* #ifdef HAVE_SCM_SIMPLE_FORMAT
|
|
||||||
* #define FMT_S "~S"
|
|
||||||
* #else
|
|
||||||
* #define FMT_S "%S"
|
|
||||||
* #endif
|
|
||||||
*
|
|
||||||
* Then represent each of your error messages using a preprocessor macro:
|
|
||||||
*
|
|
||||||
* #define E_SPIDER_ERROR "There's a spider in your " ## FMT_S ## "!!!"
|
|
||||||
*
|
|
||||||
* In Scheme:
|
|
||||||
*
|
|
||||||
* (define fmt-s (if (defined? 'simple-format) "~S" "%S"))
|
|
||||||
* (define make-message string-append)
|
|
||||||
*
|
|
||||||
* (define e-spider-error
|
|
||||||
* (make-message "There's a spider in your " fmt-s "!!!"))
|
|
||||||
*
|
|
||||||
* Method 2: Use the oldfmt function found in doc/oldfmt.c.
|
|
||||||
*
|
|
||||||
* In C:
|
|
||||||
*
|
|
||||||
* scm_misc_error ("picnic", scm_c_oldfmt0 ("There's a spider in your ~S!!!"),
|
|
||||||
* ...);
|
|
||||||
*
|
|
||||||
* In Scheme:
|
|
||||||
*
|
|
||||||
* (scm-error 'misc-error "picnic" (oldfmt "There's a spider in your ~S!!!")
|
|
||||||
* ...)
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Take a format string FROM adhering to the new standard format (~A and ~S
|
|
||||||
* as placeholders) of length N and return a string which is adapted
|
|
||||||
* to the format used by the Guile interpreter which you are running.
|
|
||||||
*
|
|
||||||
* On successive calls with similar strings but different storage, the
|
|
||||||
* same string with same storage is returned. This is necessary since
|
|
||||||
* the existence of a garbage collector in the system may cause the same
|
|
||||||
* format string to be represented with different storage at different
|
|
||||||
* calls.
|
|
||||||
*/
|
|
||||||
|
|
||||||
char *
|
|
||||||
scm_c_oldfmt (char *from, int n)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_SCM_SIMPLE_FORMAT
|
|
||||||
return from;
|
|
||||||
#else
|
|
||||||
static struct { int n; char *from; char *to; } *strings;
|
|
||||||
static int size = 0;
|
|
||||||
static int n_strings = 0;
|
|
||||||
char *to;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < n_strings; ++i)
|
|
||||||
if (n == strings[i].n && strncmp (from, strings[i].from, n) == 0)
|
|
||||||
return strings[i].to;
|
|
||||||
|
|
||||||
if (n_strings == size)
|
|
||||||
{
|
|
||||||
if (size == 0)
|
|
||||||
{
|
|
||||||
size = 10;
|
|
||||||
strings = scm_must_malloc (size * sizeof (*strings), s_oldfmt);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int oldsize = size;
|
|
||||||
size = 3 * oldsize / 2;
|
|
||||||
strings = scm_must_realloc (strings,
|
|
||||||
oldsize * sizeof (*strings),
|
|
||||||
size * sizeof (*strings),
|
|
||||||
s_oldfmt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
strings[n_strings].n = n;
|
|
||||||
strings[n_strings].from = strncpy (scm_must_malloc (n, s_oldfmt), from, n);
|
|
||||||
to = strings[n_strings].to = scm_must_malloc (n + 1, s_oldfmt);
|
|
||||||
n_strings++;
|
|
||||||
|
|
||||||
for (i = 0; i < n; ++i)
|
|
||||||
{
|
|
||||||
if (from[i] == '~' && ++i < n)
|
|
||||||
{
|
|
||||||
if (from[i] == 'A')
|
|
||||||
{
|
|
||||||
to[i - 1] = '%';
|
|
||||||
to[i] = 's';
|
|
||||||
}
|
|
||||||
else if (from[i] == 'S')
|
|
||||||
{
|
|
||||||
to[i - 1] = '%';
|
|
||||||
to[i] = 'S';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
to[i - 1] = '~';
|
|
||||||
to[i] = from[i];
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
to[i] = from[i];
|
|
||||||
}
|
|
||||||
to[i] = '\0';
|
|
||||||
|
|
||||||
return to;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
char *
|
|
||||||
scm_c_oldfmt0 (char *s)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_SCM_SIMPLE_FORMAT
|
|
||||||
return s;
|
|
||||||
#else
|
|
||||||
return scm_c_oldfmt (s, strlen (s));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
SCM_PROC (s_oldfmt, "oldfmt", 1, 0, 0, scm_oldfmt);
|
|
||||||
|
|
||||||
SCM
|
|
||||||
scm_oldfmt (SCM s)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_SCM_SIMPLE_FORMAT
|
|
||||||
return s;
|
|
||||||
#else
|
|
||||||
int n;
|
|
||||||
SCM_ASSERT (SCM_NIMP (s) && SCM_STRINGP (s), s, 1, s_oldfmt);
|
|
||||||
n = SCM_LENGTH (s);
|
|
||||||
return scm_return_first (scm_mem2string (scm_c_oldfmt (SCM_ROCHARS (s), n),
|
|
||||||
n),
|
|
||||||
s);
|
|
||||||
#endif
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue