unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Thien-Thi Nguyen <ttn@giblet.glug.org>
Cc: guile-devel@gnu.org, guile-user@gnu.org
Subject: Re: Inheriting from foreign objects
Date: Tue, 23 Apr 2002 13:43:56 -0700	[thread overview]
Message-ID: <E17078m-000118-00@giblet> (raw)
In-Reply-To: <m3lmbvwd32.fsf@laruns.ossau.uklinux.net> (message from Neil Jerram on 10 Apr 2002 20:47:13 +0100)

   From: Neil Jerram <neil@ossau.uklinux.net>
   Date: 10 Apr 2002 20:47:13 +0100

       Andreas> Is there a way I can cleanly derive from C-created classes?

   I'd say you're in virgin territory here, and that any advice you can
   give on such problems, and on defining a C API for GOOPS, would be
   very useful.

it looks like foreign bit is set when superclass list is empty.  perhaps
a good guideline would be to use at least `(list <object>)' for `supers'
for normal operation.  btw, it doesn't look like user-supplied ctor/dtor
are suppressed based on foreign bit in any case.

[cc guile-user in order to ask survey question: which goops-related C
functions do people use now?  the answer to this helps shape definition
of the C interface to goops -- thanks!]

thi


_______________________________
SCM
scm_make_class (SCM meta, char *s_name, SCM supers, size_t size,
		void * (*constructor) (SCM initargs),
		size_t (*destructor) (void *))
{
  SCM name, class;
  name = scm_str2symbol (s_name);
  if (SCM_NULLP (supers))
    supers = scm_list_1 (scm_class_foreign_object);
  class = scm_basic_basic_make_class (meta, name, supers, SCM_EOL);
  scm_sys_inherit_magic_x (class, supers);

  if (destructor != 0)
    {
      SCM_SET_SLOT (class, scm_si_destructor, (SCM) destructor);
      SCM_SET_CLASS_DESTRUCTOR (class, scm_free_foreign_object);
    }
  else if (size > 0)
    {
      SCM_SET_CLASS_DESTRUCTOR (class, scm_struct_free_light);
      SCM_SET_CLASS_INSTANCE_SIZE (class, size);
    }

  SCM_SET_SLOT (class, scm_si_layout, scm_str2symbol (""));
  SCM_SET_SLOT (class, scm_si_constructor, (SCM) constructor);

  return class;
}

_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


  reply	other threads:[~2002-04-23 20:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-09 18:21 Inheriting from foreign objects Andreas Rottmann
2002-04-10 19:47 ` Neil Jerram
2002-04-23 20:43   ` Thien-Thi Nguyen [this message]
2002-04-30 10:23     ` Andreas Rottmann
2002-05-15 12:30       ` Thien-Thi Nguyen

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=E17078m-000118-00@giblet \
    --to=ttn@giblet.glug.org \
    --cc=guile-devel@gnu.org \
    --cc=guile-user@gnu.org \
    --cc=ttn@glug.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).