From: Kevin Ryde <user42@zip.com.au>
To: guile-devel@gnu.org
Subject: Re: make-vtable
Date: Tue, 06 Mar 2007 11:27:31 +1100 [thread overview]
Message-ID: <87fy8jz05o.fsf@zip.com.au> (raw)
In-Reply-To: <87hcti8rtn.fsf@laas.fr> (Ludovic Courtès's message of "Mon, 19 Feb 2007 09:39:00 +0100")
[-- Attachment #1: Type: text/plain, Size: 181 bytes --]
I'm looking at the code below for my new `make-vtable'. I'm still not
completely convinced it's a great idea, but it does at least find a
use in stacks.c, so it can't be all bad!
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: struct.c.vtable.diff --]
[-- Type: text/x-diff, Size: 1718 bytes --]
--- struct.c.~1.111.2.6.~ 2007-03-06 11:19:49.000000000 +1100
+++ struct.c 2007-03-06 11:20:55.000000000 +1100
@@ -560,6 +560,28 @@
#undef FUNC_NAME
+static SCM scm_i_vtable_vtable_no_extra_fields;
+
+SCM_DEFINE (scm_make_vtable, "make-vtable", 1, 1, 0,
+ (SCM fields, SCM printer),
+ "Create a vtable, for creating structures with the given\n"
+ "@var{fields}.\n"
+ "\n"
+ "The optional @var{printer} argument is a function to be called\n"
+ "@code{(@var{printer} struct port)} on the structures created.\n"
+ "It should look at @var{struct} and write to @var{port}.")
+#define FUNC_NAME s_scm_struct_vtable_tag
+{
+ if (SCM_UNBNDP (printer))
+ printer = SCM_BOOL_F;
+
+ return scm_make_struct (scm_i_vtable_vtable_no_extra_fields, SCM_INUM0,
+ scm_list_2 (scm_make_struct_layout (fields),
+ printer));
+}
+#undef FUNC_NAME
+
+
/* Return true if S1 and S2 are equal structures, i.e., if their vtable and
contents are the same. Field protections are honored. Thus, it is an
error to test the equality of structures that contain opaque fields. */
@@ -879,6 +901,11 @@
= scm_permanent_object (scm_make_weak_key_hash_table (scm_from_int (31)));
required_vtable_fields = scm_from_locale_string ("prsrpw");
scm_permanent_object (required_vtable_fields);
+
+ scm_i_vtable_vtable_no_extra_fields =
+ scm_permanent_object
+ (scm_make_vtable_vtable (scm_nullstr, SCM_INUM0, SCM_EOL));
+
scm_c_define ("vtable-index-layout", scm_from_int (scm_vtable_index_layout));
scm_c_define ("vtable-index-vtable", scm_from_int (scm_vtable_index_vtable));
scm_c_define ("vtable-index-printer",
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: stacks.c.vtable.diff --]
[-- Type: text/x-diff, Size: 1101 bytes --]
--- stacks.c.~1.83.2.1.~ 2006-02-14 08:59:02.000000000 +1100
+++ stacks.c 2007-03-06 11:21:05.000000000 +1100
@@ -1,5 +1,5 @@
/* Representation of stack frame debug information
- * Copyright (C) 1996,1997,2000,2001, 2006 Free Software Foundation
+ * Copyright (C) 1996,1997,2000,2001, 2006, 2007 Free Software Foundation
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -740,14 +740,10 @@
void
scm_init_stacks ()
{
- SCM vtable;
- SCM stack_layout
- = scm_make_struct_layout (scm_from_locale_string (SCM_STACK_LAYOUT));
- vtable = scm_make_vtable_vtable (scm_nullstr, SCM_INUM0, SCM_EOL);
- scm_stack_type
- = scm_permanent_object (scm_make_struct (vtable, SCM_INUM0,
- scm_cons (stack_layout,
- SCM_EOL)));
+ scm_stack_type =
+ scm_permanent_object
+ (scm_make_vtable (scm_from_locale_string (SCM_STACK_LAYOUT),
+ SCM_UNDEFINED));
scm_set_struct_vtable_name_x (scm_stack_type,
scm_from_locale_symbol ("stack"));
#include "libguile/stacks.x"
[-- Attachment #4: Type: text/plain, Size: 143 bytes --]
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
next prev parent reply other threads:[~2007-03-06 0:27 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-12 21:13 make-vtable Kevin Ryde
2007-02-13 8:13 ` make-vtable Ludovic Courtès
2007-02-13 21:26 ` make-vtable Kevin Ryde
2007-02-14 8:01 ` make-vtable Ludovic Courtès
2007-02-14 20:51 ` make-vtable Kevin Ryde
2007-02-15 8:45 ` make-vtable Ludovic Courtès
2007-02-16 0:07 ` make-vtable Kevin Ryde
2007-02-16 8:12 ` make-vtable Ludovic Courtès
2007-02-18 18:10 ` make-vtable Neil Jerram
2007-02-18 20:05 ` make-vtable Ludovic Courtès
2007-02-18 23:56 ` make-vtable Neil Jerram
2007-02-19 0:14 ` make-vtable Kevin Ryde
2007-02-19 0:39 ` make-vtable Neil Jerram
2007-02-19 8:39 ` make-vtable Ludovic Courtès
2007-03-06 0:27 ` Kevin Ryde [this message]
2007-03-06 8:32 ` make-vtable Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87fy8jz05o.fsf@zip.com.au \
--to=user42@zip.com.au \
--cc=guile-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).