From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19295 invoked by alias); 7 Aug 2003 08:07:09 -0000 Mailing-List: contact guile-gtk-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: guile-gtk-owner@sources.redhat.com Received: (qmail 19288 invoked from network); 7 Aug 2003 08:07:08 -0000 Received: from unknown (HELO ms-smtp-03.southeast.rr.com) (24.93.67.84) by sources.redhat.com with SMTP; 7 Aug 2003 08:07:08 -0000 Received: from fridge (rdu163-60-178.nc.rr.com [24.163.60.178]) by ms-smtp-03.southeast.rr.com (8.12.5/8.12.2) with ESMTP id h778543M014228 for ; Thu, 7 Aug 2003 04:05:04 -0400 (EDT) Received: from localhost (mantis.schoolnet.na [::ffff:196.44.140.238]) (AUTH: LOGIN wingo) by fridge with esmtp; Thu, 07 Aug 2003 04:06:26 -0400 Received: from wingo by localhost with local (Exim 3.36 #1 (Debian)) id 19kWLM-0004Ft-00; Wed, 06 Aug 2003 23:01:16 +0100 Date: Thu, 07 Aug 2003 08:07:00 -0000 From: Andy Wingo To: guile-gtk@sources.redhat.com, Patrick Bernaud Subject: (fwd) Re: Problem with guile-gobject-0.5.1 Message-ID: <20030806220116.GE16304@lark> Mail-Followup-To: guile-gtk@sources.redhat.com, Patrick Bernaud Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Operating-System: Linux lark 2.4.20-1-686 User-Agent: Mutt/1.5.4i X-SW-Source: 2003-q3/txt/msg00027.txt.bz2 I'm forwarding this, as I think me email was being flaky before and somehow exim lost this one. Argh! ----- Forwarded message from Andy Wingo ----- > From: Andy Wingo > Subject: Re: Problem with guile-gobject-0.5.1 > To: guile-gtk@sources.redhat.com > Cc: Patrick Bernaud > Mail-Followup-To: guile-gtk@sources.redhat.com, > Patrick Bernaud > > Hi Patrick, > > I'm replying to the list, because that's where this sort of question > should go. My apologies for being so late. I live in rural Namibia and > my internet is slow as sap, and I only connect every week or so. > > On Mon, 30 Jun 2003, Patrick Bernaud wrote: > > > I am evaluating the use of your project to wrap around (and extend) > > libraries based on Glib/Gobject/Gtk. > > Great! > > > However I am having a problem: I do not understand how to manipulate > > gboxed types from guile. > > > > Here is an example. Let's consider the following definition of the > > type Point in the .def file: > > > > (define-boxed Point > > (in-module "MyModule") > > (c-name "MyPoint") > > (gtype-id "MY_TYPE_POINT") > > (fields > > '("gint" "x") > > '("gint" "y") > > ) > > ) > > Well yes. Interpreted languages need custom wrappers for boxed types. I > suppose the support could somehow use the field names there to access > the structure members... but boxed types are usually a sign that > something is not convenient to represent as an object, on the C side of > things. > > If it's a refcounting or a speed issue, then there should be C functions > provided to operate on the object. > > If it's represented as a boxed type for convenience and memory usage, > then there's usually a better way to wrap it in scheme. In the case of a > point, I would just have a pair, with the car as x and the cdr as y. > > If the type is more complicated than that, representing it as an object > is usually the right way to go. > > If you're defining a type in a custom project, why not a GObject? > > Indeed, the only thing the defs parser cares about is > > > (define-boxed Point > > (c-name "MyPoint") > > (gtype-id "MY_TYPE_POINT") > > ) > > The other information is superfluous. It's impossible to do at runtime, > although automagic generation of my_module_my_point_set_x () and its > get() counterpart is possible I suppose. It's just a nasty solution. > Gah. I twitch when I think about it. Perhaps someone has thoughts on > this? > > > Firstly I do not know how to create such a point from guile. I added a > > constructor to the library and the following to the .def: > > > > (define-function new_point > > (c-name "new_point") > > (is-constructor-of "MyPoint") > > (return-type "MyPoint*") > > ) > > > > where my_point has the following prototype : > > > > MyPoint *new_point(); > > > > and it works. But is it the right way to create a boxed type? Any > > other way? > > Yes, that's the right way, if you want it to be an opaque type, only > accessible by C functions. Otherwise you'll have to wrap it specially, > either on the g-wrap level or by providing C functions to wrap it. There > are examples of both in gst-guile, although more documentation on this > would be nice. I'd like to write a nice article about the binding > generator, but I don't have the time right now. > > > Sorry if it is obvious, but I did not find the solution in the files > > of the package. There is also few projects around that are using > > guile-gobject, so it is hard to have an example. I know of gstreamer, > > is there any other of interest? > > I guess it's not really obvious, I spend so much time staring at this > code I forget what I was and wasn't born with ;) I don't know of any > other projects that are using the bindings. My soundscrape project > (http://ambient.2y.net/soundscrape/) uses the gstreamer bindings a lot > and the wrapper generator a little bit. Things have been changing quite > a bit on the gst-guile side recently, but they seem to be settling down > > But no, I don't know of any other ones. Anyone out there want to speak > up? It's only been since a couple of months ago that the wrapper > generator even exists, so it's not so surprising. > > > Thank your for your time. > > And thank you for your interest, and apologies again for the delay. > > Andy Wingo. ----- End forwarded message -----