From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Kjetil S. Matheussen" Newsgroups: gmane.lisp.guile.devel Subject: Re: Passing C pointers through guile Date: Thu, 10 Jul 2008 14:49:50 +0200 (CEST) Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7BIT X-Trace: ger.gmane.org 1215694279 22080 80.91.229.12 (10 Jul 2008 12:51:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 10 Jul 2008 12:51:19 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Thu Jul 10 14:52:06 2008 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KGvcw-0006Wq-1Z for guile-devel@m.gmane.org; Thu, 10 Jul 2008 14:52:02 +0200 Original-Received: from localhost ([127.0.0.1]:41573 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KGvc4-0000Qm-AM for guile-devel@m.gmane.org; Thu, 10 Jul 2008 08:51:08 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KGvbw-0000Nk-Md for guile-devel@gnu.org; Thu, 10 Jul 2008 08:51:00 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KGvbt-0000JT-V6 for guile-devel@gnu.org; Thu, 10 Jul 2008 08:50:59 -0400 Original-Received: from [199.232.76.173] (port=33538 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KGvbt-0000JE-PJ for guile-devel@gnu.org; Thu, 10 Jul 2008 08:50:57 -0400 Original-Received: from smtp.getmail.no ([84.208.20.33]:63135) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KGvbs-0000k9-HX for guile-devel@gnu.org; Thu, 10 Jul 2008 08:50:56 -0400 Original-Received: from pmxchannel-daemon.no-osl-m323-srv-004-z2.isp.get.no by no-osl-m323-srv-004-z2.isp.get.no (Sun Java System Messaging Server 6.2-7.05 (built Sep 5 2006)) id <0K3S00I0NJOK9000@no-osl-m323-srv-004-z2.isp.get.no> for guile-devel@gnu.org; Thu, 10 Jul 2008 14:50:45 +0200 (CEST) Original-Received: from smtp.getmail.no ([10.5.16.1]) by no-osl-m323-srv-004-z2.isp.get.no (Sun Java System Messaging Server 6.2-7.05 (built Sep 5 2006)) with ESMTP id <0K3S005C0JN3TRA0@no-osl-m323-srv-004-z2.isp.get.no> for guile-devel@gnu.org; Thu, 10 Jul 2008 14:49:51 +0200 (CEST) Original-Received: from cm-84.215.136.96.getinternet.no ([84.215.136.96]) by no-osl-m323-srv-004-z1.isp.get.no (Sun Java System Messaging Server 6.2-7.05 (built Sep 5 2006)) with ESMTP id <0K3S00FXNJN365F0@no-osl-m323-srv-004-z1.isp.get.no> for guile-devel@gnu.org; Thu, 10 Jul 2008 14:49:51 +0200 (CEST) X-X-Sender: kjetil@ttleush X-detected-kernel: by monty-python.gnu.org: Solaris 10 (beta) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:7364 Archived-At: Ludovic Court?s: > > Well, `configure.in' has an `AC_PREREQ' call, 1.10(.1) is the latest > Automake, and 1.5.26 is the latest Libtool of the 1.x series, it's > easy. Thanks, I didn't know that. >No. `configure' checks the size of a number of (integer) types. The >idea here would be to have a check for `void *' (if there isn't one >already); then in `numbers.h', you'd add something along the lines of: > > #if SCM_SIZEOF_VOID_P == 4 > #define scm_to_uintptr scm_to_uint32 > [...] > #elif SCM_SIZEOF_VOID_P == 8 > #define scm_to_uintptr scm_to_uint64 > [...] > #else > #error "strange `void *'" > #endif > > IOW, don't rely on or . Good idea. Much better. I'll do that. >> That's true. But at least my experience is that using guardians >> is cleaner than smurf's. > >Smurf? Smurf's what? Oops. :-) I ment SMOB. >If so, the deallocation routine that's called from the guardian (which >is necessarily written in C) is roughly the same as the one you'd pass >to `scm_set_smob_free ()'. Point is that you very often don't need any kind of free functionality. For example, if you create a gui widget, you probably have a callback function which is called if the gui is closed. That callback function can free any allocated memory. Another example from snd is creating ladspa plugins (audio plugins in linux). Handlers from those, plus variuos configuration stuff, is alive througout the whole session and will be automatically freed when the program closes.