[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Inheriting from foreign objects

From: Thien-Thi Nguyen
Subject: Re: Inheriting from foreign objects
Date: Tue, 23 Apr 2002 13:43:56 -0700

   From: Neil Jerram <address@hidden>
   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!]


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;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]