From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: CDDP 40 - TICE Newsgroups: gmane.lisp.guile.user Subject: Re: C++ application linked with guile dos not quite Date: 18 Jun 2002 10:25:07 +0200 Sender: guile-user-admin@gnu.org Message-ID: <1024388708.23129.28.camel@tice> References: <1024320297.17552.141.camel@tice> NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: main.gmane.org 1024388544 25135 127.0.0.1 (18 Jun 2002 08:22:24 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 18 Jun 2002 08:22:24 +0000 (UTC) Return-path: Original-Received: from fencepost.gnu.org ([199.232.76.164]) by main.gmane.org with esmtp (Exim 3.33 #1 (Debian)) id 17KEFs-0006XH-00 for ; Tue, 18 Jun 2002 10:22:24 +0200 Original-Received: from localhost ([127.0.0.1] helo=fencepost.gnu.org) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 17KEEm-0005PD-00; Tue, 18 Jun 2002 04:21:16 -0400 Original-Received: from smtp-out-3.wanadoo.fr ([193.252.19.233] helo=mel-rto3.wanadoo.fr) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 17KEC0-0005JW-00 for ; Tue, 18 Jun 2002 04:18:24 -0400 Original-Received: from mel-rta8.wanadoo.fr (193.252.19.79) by mel-rto3.wanadoo.fr (6.5.007) id 3D09BEC800216AF1 for guile-user@gnu.org; Tue, 18 Jun 2002 10:18:23 +0200 Original-Received: from localhost.localdomain (80.14.155.118) by mel-rta8.wanadoo.fr (6.5.007) id 3CFB23D9008B2644 for guile-user@gnu.org; Tue, 18 Jun 2002 10:18:23 +0200 Original-To: Guile user In-Reply-To: <1024320297.17552.141.camel@tice> X-Mailer: Ximian Evolution 1.0.5 Errors-To: guile-user-admin@gnu.org X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.0.9 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.lisp.guile.user:605 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.user:605 When guile is embedded in a C++ aplication, is there any garbage collection to take care of ? Hilaire Le lun 17/06/2002 =E0 15:24, Hilaire Fernandes a =E9crit : > Hi, >=20 > In DrGenius (guile aware), when I quite, all the application is hanging. >=20 > This happens when there is a user defined guile procedure. If the user > does not define procedure this does not happen. >=20 > If I run it under GDB then the application quite normaly. >=20 > I am not very confortable with guile, so there is probably something > wrong in my code. >=20 > I use Libguile 1.4 >=20 > Hilaire >=20 >=20 > For information, the related piece of code are: >=20 > I initialise the guile interprertor as: >=20 > int main(int argc, char* argv[]) > { > gh_enter(argc, argv, main_prog); > return 0; > } >=20 >=20 > In main_prog, I record some procedures: >=20 > /* declare drgeo interface in guile */ > gh_new_procedure ("move", drgeo_scm_move, 2, 0, 0); > gh_new_procedure ("getAbscissa", drgeo_scm_getAbscissa, 1, 0, 0); > gh_new_procedure ("getCoordinates", drgeo_scm_getCoordinates, 1, 0, > 0); > gh_new_procedure ("getValue", drgeo_scm_getValue, 1, 0, 0); >=20 > [...] >=20 > gtk_main(); > } >=20 > The GTK+ application is started with gtk_main() >=20 > User script are recorded in the guile interpreter as: >=20 > void script:: > setScript (gchar *scriptCode) > { > gchar *tmpScript, *tmp1, *tmp2; > gint nb; >=20 > g_free (this->scriptCode); > this->scriptCode =3D g_strdup (scriptCode); >=20 > /* define a scm procedure to hold the user script */ > tmpScript =3D g_strdup_printf ("(define (script%d",this); > for (nb =3D 1; nb <=3D g_list_length (parentList); nb++) > { > tmp1 =3D g_strdup_printf (" a%d", nb); > tmp2 =3D g_strconcat (tmpScript, tmp1, NULL); > g_free (tmp1); > g_free (tmpScript); > tmpScript =3D tmp2; > } > tmp1 =3D g_strconcat (tmpScript, ")", scriptCode, ")", NULL); > g_free(tmpScript); > /* define the procedure in the Guile interpretor */ > gh_eval_str_with_catch(tmp1, standard_handler); > g_free (tmp1); > } >=20 > Basicly the user script is embedded in a procedure so the code is > looking like: > (define (scriptOBJECT_ADRESS a1 a2 ...) > CODE PROVIDED BY THE USER > ) >=20 >=20 > Then in the geometric engine, this procedure is called as: >=20 > /* build the call sequence */ > tmpScript =3D g_strdup_printf ("(script%d", this); > for (nb =3D 0; nb < g_list_length (parentList); nb++) > { > tmp1 =3D g_strdup_printf (" %d", g_list_nth_data > (parentList, nb)); > tmp2 =3D g_strconcat (tmpScript, tmp1, NULL); > g_free (tmpScript); > g_free (tmp1); > tmpScript =3D tmp2; > } > tmp1 =3D g_strconcat (tmpScript, ")", NULL); > g_free (tmpScript); =20 > ret =3D gh_eval_str_with_catch(tmp1, standard_handler); > g_free (tmp1); > if (gh_number_p (ret)) > { > val =3D gh_scm2double (ret); > str =3D g_strdup_printf ("%.2f", val); > } > else if (gh_string_p (ret)) > { > str =3D gh_scm2newstr (ret, NULL); > } > else > str =3D g_strdup (_("Unprintable result")); > } >=20 > When the script object is deleted I undefine the function. >=20 >=20 > --=20 > http://www.ofset.org > Organization for Free Software in > Education and Teaching >=20 >=20 > _______________________________________________ > Guile-user mailing list > Guile-user@gnu.org > http://mail.gnu.org/mailman/listinfo/guile-user >=20 --=20 Ing=E9nierie =C9ducative CDDP des Landes _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://mail.gnu.org/mailman/listinfo/guile-user