unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* calling define-class function from C++ source file
@ 2003-10-17  9:52 Laurent Marzullo
  2003-10-17 12:12 ` Andreas Rottmann
  0 siblings, 1 reply; 2+ messages in thread
From: Laurent Marzullo @ 2003-10-17  9:52 UTC (permalink / raw)


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++ ???

Thank you very much.
-- 
Laurent Marzullo <marzullo@la-defense.oilfield.slb.com>



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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: calling define-class function from C++ source file
  2003-10-17  9:52 calling define-class function from C++ source file Laurent Marzullo
@ 2003-10-17 12:12 ` Andreas Rottmann
  0 siblings, 0 replies; 2+ messages in thread
From: Andreas Rottmann @ 2003-10-17 12:12 UTC (permalink / raw)
  Cc: Guile (Devel)

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-10-17 12:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-10-17  9:52 calling define-class function from C++ source file Laurent Marzullo
2003-10-17 12:12 ` Andreas Rottmann

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).