From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Andreas Rottmann Newsgroups: gmane.lisp.guile.devel Subject: Re: calling define-class function from C++ source file Date: Fri, 17 Oct 2003 14:12:46 +0200 Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Message-ID: <87vfqot64h.fsf@alice.rotty.yi.org> References: <1066384323.28107.40.camel@MARZULLO-MIS> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1066393675 25815 80.91.224.253 (17 Oct 2003 12:27:55 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 17 Oct 2003 12:27:55 +0000 (UTC) Cc: "Guile \(Devel\)" Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Fri Oct 17 14:27:50 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AAThu-0005VF-00 for ; Fri, 17 Oct 2003 14:27:50 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AAThD-00031e-S2 for guile-devel@m.gmane.org; Fri, 17 Oct 2003 08:27:07 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1AATgm-0002x6-Jr for guile-devel@gnu.org; Fri, 17 Oct 2003 08:26:40 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1AATgF-0002uK-2Y for guile-devel@gnu.org; Fri, 17 Oct 2003 08:26:39 -0400 Original-Received: from [213.165.64.20] (helo=mail.gmx.net) by monty-python.gnu.org with smtp (Exim 4.24) id 1AATR6-0000qr-Dr for guile-devel@gnu.org; Fri, 17 Oct 2003 08:10:28 -0400 Original-Received: (qmail 28479 invoked by uid 65534); 17 Oct 2003 12:10:21 -0000 Original-Received: from chello213047125140.14.univie.teleweb.at (EHLO garibaldi) (213.47.125.140) by mail.gmx.net (mp005) with SMTP; 17 Oct 2003 14:10:21 +0200 X-Authenticated: #3102804 Original-Received: from ivanova.rhinosaur.lan ([192.168.1.9] helo=ivanova) by garibaldi with esmtp (Exim 4.24) id 1AATT7-0004kg-Vx; Fri, 17 Oct 2003 14:12:33 +0200 Original-Received: from andy by ivanova with local (Exim 3.36 #1 (Debian)) id 1AATTK-0000oI-00; Fri, 17 Oct 2003 14:12:46 +0200 Original-To: Laurent Marzullo In-Reply-To: <1066384323.28107.40.camel@MARZULLO-MIS> (Laurent Marzullo's message of "Fri, 17 Oct 2003 11:52:04 +0200") User-Agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (gnu/linux) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Developers list for Guile, the GNU extensibility library List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.devel:2895 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:2895 Laurent Marzullo 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 () > (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(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:"), 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(""), 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