unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Andreas Rottmann <a.rottmann@gmx.at>
Cc: "Guile \(Devel\)" <guile-devel@gnu.org>
Subject: Re: calling define-class function from C++ source file
Date: Fri, 17 Oct 2003 14:12:46 +0200	[thread overview]
Message-ID: <87vfqot64h.fsf@alice.rotty.yi.org> (raw)
In-Reply-To: <1066384323.28107.40.camel@MARZULLO-MIS> (Laurent Marzullo's message of "Fri, 17 Oct 2003 11:52:04 +0200")

Laurent Marzullo <marzullo@la-defense.oilfield.slb.com> writes:

> Hello,
>
> Could anyone give me an example of how to call the function 
> define-class from C++ once the goop module has been loaded.
>
> // C++
> scm_load_goops();
> scm_apply( ??????? );
>
> In fact I would like to write in C++ the following statment
> (define-class <MyClass> ()
>     (r #:init-value 0))
>
> Could someone show me how to write this Scheme statment from
> C/C++ ???
>
As I already told you, my Yehia code does this. From http://cvs.sourceforge.net/viewcvs.py/ucxx/yehia/plugins/guile/guile-script.cc?rev=1.3&view=auto:

---------------------------
Object& guileObjectFactory::create_class(const Signature& supers)
{
  Signature::const_iterator it;
  int i;
  SCM ssupers = SCM_EOL;
  
  for (i = supers.size() - 1, it = supers.end(); i >= 0; i--)
    ssupers = scm_cons(dynamic_cast<guileObject *>(find_class(**--it))->sobj(),
                       ssupers);
  
  if (supers.size() == 0)
    ssupers = scm_cons(scm_class_object, ssupers);
  
  // We need to create a new metaclass for the class, so we can
  // implement static methods

#if 0 // this seems to cause infinite loops in goops
  SCM ensure_meta = SCM_VARIABLE_REF(scm_c_module_lookup(scm_module_goops, 
                                                         "ensure-metaclass"));
  SCM meta = scm_apply(ensure_meta, scm_list_2(ssupers, SCM_BOOL_F), 
                       SCM_EOL);
#else
  SCM meta = scm_class_class;
#endif
  meta = scm_basic_make_class(scm_class_class,
                              scm_str2symbol("yehia:meta:<unknown>"),
                              scm_list_1(meta), SCM_EOL);
  SCM slots = scm_list_1(scm_list_3(scm_str2symbol("%yehia-instance"),
                                    scm_c_make_keyword("init-value"),
                                    SCM_BOOL_F));
  SCM sclass = scm_basic_make_class(meta, scm_str2symbol("<unknown>"), 
                                    ssupers, slots);
  return create_object(sclass);
}
-----------------------------

Regards, Andy
-- 
Andreas Rottmann         | Rotty@ICQ      | 118634484@ICQ | a.rottmann@gmx.at
http://www.8ung.at/rotty | GnuPG Key: http://www.8ung.at/rotty/gpg.asc
Fingerprint              | DFB4 4EB4 78A4 5EEE 6219  F228 F92F CFC5 01FD 5B62

This reality is really just a fucked-up dream -- Papa Roach


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


      reply	other threads:[~2003-10-17 12:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-17  9:52 calling define-class function from C++ source file Laurent Marzullo
2003-10-17 12:12 ` Andreas Rottmann [this message]

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=87vfqot64h.fsf@alice.rotty.yi.org \
    --to=a.rottmann@gmx.at \
    --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).