From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?ISO-8859-1?Q?Eduardo_Acu=F1a?= Newsgroups: gmane.lisp.guile.user Subject: Re: Guile initialization and string evaluation with C++ Date: Tue, 1 Apr 2014 23:38:56 -0700 Message-ID: References: <1395920357.2020.20.camel@Renee-desktop.suse> <1395976370.2020.22.camel@Renee-desktop.suse> <1396348559.6172.7.camel@Renee-desktop.suse> <20140401133450.GA7928@seid-online.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11c2f2d4f0059104f6098981 X-Trace: ger.gmane.org 1396522338 28279 80.91.229.3 (3 Apr 2014 10:52:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 3 Apr 2014 10:52:18 +0000 (UTC) To: Ralf Mattes , guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Thu Apr 03 12:52:14 2014 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WVeLf-0002WE-P5 for guile-user@m.gmane.org; Thu, 03 Apr 2014 11:54:15 +0200 Original-Received: from localhost ([::1]:36304 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WVEpV-0002ew-Qj for guile-user@m.gmane.org; Wed, 02 Apr 2014 02:39:21 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43920) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WVEp8-0002VR-Uf for guile-user@gnu.org; Wed, 02 Apr 2014 02:39:00 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WVEp7-0007uT-8b for guile-user@gnu.org; Wed, 02 Apr 2014 02:38:58 -0400 Original-Received: from mail-oa0-x231.google.com ([2607:f8b0:4003:c02::231]:64503) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WVEp7-0007uJ-1P for guile-user@gnu.org; Wed, 02 Apr 2014 02:38:57 -0400 Original-Received: by mail-oa0-f49.google.com with SMTP id o6so2000117oag.22 for ; Tue, 01 Apr 2014 23:38:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=elV+BblyDbYgHz7HjENyCcB0BWPgj1cXhx5ud7FbY8M=; b=Vz1+tb6rwXe9RHZ3GWyGOeilM0Z5hSnGuXTgQz9uK/iYPhf6Z/qIzB98MAeSFM8Ecn EWAPZwWw7ZWFxHIw0IjTCeYy8A74c10LOTShJhbOU8V0XeeplyUIyhEQKo+zb72hCkAA AcZk6LLN1xMyyxmN+C4+nPbrXh/6evsnyp9h02lTU5Nj3+3tud8/fYDhQSU3edLKibI3 1sz0PUEuI4Fv5kd4tZFFoctuVrOk1zm4GZ0EYsHanAxcLhV22pwl61OHdRDAqp2VIfF6 4yH47mAZBtr/a+tBMNgVh5URx+19HpcFH2S0P370ze3z0rOkOkWwo35setFYsdzH2oBA SQSg== X-Received: by 10.182.246.35 with SMTP id xt3mr16940667obc.39.1396420736188; Tue, 01 Apr 2014 23:38:56 -0700 (PDT) Original-Received: by 10.76.129.142 with HTTP; Tue, 1 Apr 2014 23:38:56 -0700 (PDT) In-Reply-To: <20140401133450.GA7928@seid-online.de> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4003:c02::231 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:11185 Archived-At: --001a11c2f2d4f0059104f6098981 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Thank you very much for your feedback! :D I updated the code ( https://github.com/eduardoacye/GuileCppApplication ). If you have any other suggestions for making a better C++ interface with GNU Guile, i can do my best to put them in the code. Eduardo. On Tue, Apr 1, 2014 at 6:34 AM, Ralf Mattes wrote: > On Tue, Apr 01, 2014 at 06:35:59PM +0800, Nala Ginrut wrote: > > On Thu, 2014-03-27 at 21:03 -0700, Eduardo Acu=F1a wrote: > > > Slightly reordered .... > > > > > Sorry I can't help you on this. IMO, you don't understand why you can't > > cast it as a function pointer. Maybe it's different from C? > > Yes, somehow C++ happens to be different from C ;-) > > > > My program calls scm_boot_guile from the member function init() of th= e > > > GuileApplication class. There is no problem passing the argc and argv > > > to scm_boot_guile, however i want to pass the member function > > > guileMain as the third argument of scm_boot_guile like a void functio= n > > > pointer (i can't cast the member function as a function pointer). The > > > current way i'm avoiding this problem is passing as the third argumen= t > > > a function outside of the GuileApplication class, and passing the > > > address of the instance of the GuileApplication as the fourth argumen= t > > > for dereferencing the object and calling the guileMain member functio= n > > > from there, so i had to make this non-member function a friend of > > > GuileApplication. This method works but it doesn't seem to be a clean > > > way of doing things. > > I'd do this slightly different: instead of using a non-member function > (which > needs to be declared a friend) I'd rather give my object a static functio= n > - > static functions _can_ be used as C callbacks (since they don't expect a > hidden instance as the first parameter). You'd still need to pass down an > instance of your GuileApplication class so it can be handed to > scm_boot_guile > as the data parameter. This is asdmittedly only slightly better than your > solution. > > HTH Ralf Mattes > > --001a11c2f2d4f0059104f6098981 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Thank you very much for your feedback! :D I upda= ted the code ( https://github.com/eduardoacye/GuileCppApplication ).

I= f you have any other suggestions for making a better C++ interface with GNU= Guile, i can do my best to put them in the code.


Eduardo.


On Tue, Apr 1, 2014 at 6:34 AM, Ralf Mattes <rm@seid-on= line.de> wrote:
On Tue, Apr 01, 2014 at 06:3= 5:59PM +0800, Nala Ginrut wrote:
> On Thu, 2014-03-27 at 21:03 -0700, Eduardo Acu=F1a wrote:


Slightly reordered ....

>
> Sorry I can't help you on this. IMO, you don't understand why = you can't
> cast it as a function pointer. Maybe it's different from C?

Yes, somehow C++ happens to be different from C ;-)

> > My program calls scm_boot_guile from the member function init() o= f the
> > GuileApplication class. There is no problem passing the argc and = argv
> > to scm_boot_guile, however i want to pass the member function
> > guileMain as the third argument of scm_boot_guile like a void fun= ction
> > pointer (i can't cast the member function as a function point= er). The
> > current way i'm avoiding this problem is passing as the third= argument
> > a function outside of the GuileApplication class, and passing the=
> > address of the instance of the GuileApplication as the fourth arg= ument
> > for dereferencing the object and calling the guileMain member fun= ction
> > from there, so i had to make this non-member function a friend of=
> > GuileApplication. This method works but it doesn't seem to be= a clean
> > way of doing things.

I'd do this slightly different: instead of using a non-member fun= ction (which
needs to be declared a friend) I'd rather give my object a static funct= ion -
static functions _can_ be used as C callbacks (since they don't expect = a
hidden instance as the first parameter). You'd still need to pass down = an
instance of your GuileApplication class so it can be handed to scm_boot_gui= le
as the data parameter. This is asdmittedly only slightly better than your solution.

HTH Ralf Mattes


--001a11c2f2d4f0059104f6098981--