summaryrefslogtreecommitdiff
path: root/doc/example-smob
diff options
context:
space:
mode:
authorNeil Jerram <neil@ossau.uklinux.net>2001-04-26 18:26:28 +0000
committerNeil Jerram <neil@ossau.uklinux.net>2001-04-26 18:26:28 +0000
commitbd5e6840910070de8d50e26b968146252841d188 (patch)
tree390a9756d74e27f937a222181321f1a5754ee7b9 /doc/example-smob
parentac667929bcebd842677537ff8472dd71c0171981 (diff)
downloadguile-bd5e6840910070de8d50e26b968146252841d188.tar.gz
* Update SMOB example and associated documentation.
Diffstat (limited to 'doc/example-smob')
-rw-r--r--doc/example-smob/ChangeLog8
-rw-r--r--doc/example-smob/image-type.c17
2 files changed, 16 insertions, 9 deletions
diff --git a/doc/example-smob/ChangeLog b/doc/example-smob/ChangeLog
index 316d0b0ec..12afa8813 100644
--- a/doc/example-smob/ChangeLog
+++ b/doc/example-smob/ChangeLog
@@ -1,3 +1,11 @@
+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.
diff --git a/doc/example-smob/image-type.c b/doc/example-smob/image-type.c
index 3c49e592e..fe0a9b802 100644
--- a/doc/example-smob/image-type.c
+++ b/doc/example-smob/image-type.c
@@ -42,8 +42,7 @@ make_image (SCM name, SCM s_width, SCM s_height)
struct image *image;
int width, height;
- SCM_ASSERT (SCM_NIMP (name) && SCM_STRINGP (name), name,
- SCM_ARG1, "make-image");
+ SCM_ASSERT (SCM_STRINGP (name), name, SCM_ARG1, "make-image");
SCM_ASSERT (SCM_INUMP (s_width), s_width, SCM_ARG2, "make-image");
SCM_ASSERT (SCM_INUMP (s_height), s_height, SCM_ARG3, "make-image");
@@ -66,11 +65,10 @@ clear_image (SCM image_smob)
int area;
struct image *image;
- SCM_ASSERT ((SCM_NIMP (image_smob)
- && SCM_CAR (image_smob) == image_tag),
- image_smob, SCM_ARG1, "clear-image");
+ SCM_ASSERT (SCM_SMOB_PREDICATE (image_tag, image_smob),
+ image_smob, SCM_ARG1, "clear-image");
- image = (struct image *) SCM_CDR (image_smob);
+ image = (struct image *) SCM_SMOB_DATA (image_smob);
area = image->width * image->height;
memset (image->pixels, 0, area);
@@ -84,7 +82,8 @@ clear_image (SCM image_smob)
static SCM
mark_image (SCM image_smob)
{
- struct image *image = (struct image *) SCM_CDR (image_smob);
+ /* Mark the image's name and update function. */
+ struct image *image = (struct image *) SCM_SMOB_DATA (image_smob);
scm_gc_mark (image->name);
return image->update_func;
@@ -93,7 +92,7 @@ mark_image (SCM image_smob)
static scm_sizet
free_image (SCM image_smob)
{
- struct image *image = (struct image *) SCM_CDR (image_smob);
+ struct image *image = (struct image *) SCM_SMOB_DATA (image_smob);
scm_sizet size = image->width * image->height + sizeof (struct image);
free (image->pixels);
@@ -105,7 +104,7 @@ free_image (SCM image_smob)
static int
print_image (SCM image_smob, SCM port, scm_print_state *pstate)
{
- struct image *image = (struct image *) SCM_CDR (image_smob);
+ struct image *image = (struct image *) SCM_SMOB_DATA (image_smob);
scm_puts ("#<image ", port);
scm_display (image->name, port);