guile-gtk-general
[Top][All Lists]
Advanced

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

Re: making a SCM from a GObject *


From: Peter Gavin
Subject: Re: making a SCM from a GObject *
Date: Tue, 10 May 2005 23:36:48 -0400

Ok, so maybe I'm completely missing the point here :b

What I really initially meant was much simpler than that, but I'm sure
I'll end up wrapping my objects entirely anyways. (Thanks for pointing
out where I can find info on that btw.) Essentially, what I am
initially trying to do is this:

GObject *obj = g_object_new (SOME_TYPE, ...);
SCM obj_scm = some_unknown_function (obj); /* wrap the GObject in a SCM */
scm_c_define ("obj", obj_scm);
scm_primitive_load (scm_makfrom0str ("user-scheme-code.scm");

Then the user's scheme code can access obj's properties with get and
set. Right now I'm not interested in wrapping any subclass's methods,
only accessing properties -- but its probable that I will be later.

Again, I'm not sure if this is even possible, or the right way to do it anyways.

On 5/10/05, gregory benison <address@hidden> wrote:
> Peter Gavin wrote:
> 
> >Ok, so, I'm a bit new to guile, but I've been playing around w/ trying
> >to embed guile in my app, and one thing I've been wanting to do is
> >create a GObject subtype in C and pass it to some scheme code
> >
> I am a bit new to guile-gnome as well.
> I am also interested in doing what you are trying to do.
> I think this is likely to be a common desire among people trying out
> guile-gnome.
> 
> > I
> >couldn't find any docs concerning this, and google gave me no hits,
> >
> >
> I have had success using this method:
> 1) Create a .defs file which describes your gobject - based header
> file.  It describes all of your functions and custom types.  Look in the
> guile-gnome distribution in the 'defs' directory for examples.  You can
> use the 'h2defs.py' program (found in the guile-gnome distribution) to
> generate this file automatically from your headers, if you have followed
> normal conventions in writing your headers.
> 2) Process your .defs file to automatically create C-to-guile glue code
> for your gobject types.  Look at any "*-spec.scm" file in the
> guile-gnome distribution to see how this works.
> 3) Compile the resulting C file into a shared library.  Load it from a
> scheme interpreter, and your gobject type will be available to use from
> scheme.
> 
> ( guile-gnome experts: is this the right approach?? )
> 
> I admit that the above method looks intimidating at first but it really
> does work,
> and it allows you to use your C code from scheme with very little extra
> coding.
> If you use the above method, you can use your gobjects seamlessly in
> scheme (subclassing from them, connecting signals to them, etc.)
> I would be interested in writing some additional documentation for this...
> in my opinion the guile-gtk and guile-gnome teams have made a really
> great programming environment here, and new users could benefit from
> some additional documentation, especially regarding C/guile
> interoperability issues.
> 
> >get back an error when I use it:
> ><gtype> #<gtype GObject> already has a GOOPS class, use gtype->class
> >Am I using the wrong function, or using it in the wrong way?
> >
> >
> I don't understand this approach very well, but I suspect it is not what
> you want.
> 
> Greg
> 
>




reply via email to

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