From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Hilaire Fernandes Newsgroups: gmane.lisp.guile.user Subject: C++ application linked with guile dos not quite Date: 17 Jun 2002 15:24:57 +0200 Sender: guile-user-admin@gnu.org Message-ID: <1024320297.17552.141.camel@tice> NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Trace: main.gmane.org 1024320097 25147 127.0.0.1 (17 Jun 2002 13:21:37 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 17 Jun 2002 13:21:37 +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 17JwRs-0006XU-00 for ; Mon, 17 Jun 2002 15:21:36 +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 17JwRM-0004Ad-00; Mon, 17 Jun 2002 09:21:04 -0400 Original-Received: from smtp-out-2.wanadoo.fr ([193.252.19.254] helo=mel-rto2.wanadoo.fr) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 17JwOe-0003zG-00 for ; Mon, 17 Jun 2002 09:18:16 -0400 Original-Received: from mel-rta9.wanadoo.fr (193.252.19.69) by mel-rto2.wanadoo.fr (6.5.007) id 3D0DC46B00012EFC for guile-user@gnu.org; Mon, 17 Jun 2002 15:18:15 +0200 Original-Received: from localhost.localdomain (80.14.155.118) by mel-rta9.wanadoo.fr (6.5.007) id 3CFB286C008858CF for guile-user@gnu.org; Mon, 17 Jun 2002 15:18:15 +0200 Original-To: Guile user 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:600 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.user:600 Hi, In DrGenius (guile aware), when I quite, all the application is hanging. This happens when there is a user defined guile procedure. If the user does not define procedure this does not happen. If I run it under GDB then the application quite normaly. I am not very confortable with guile, so there is probably something wrong in my code. I use Libguile 1.4 Hilaire For information, the related piece of code are: I initialise the guile interprertor as: int main(int argc, char* argv[]) { gh_enter(argc, argv, main_prog); return 0; } In main_prog, I record some procedures: /* 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); [...] gtk_main(); } The GTK+ application is started with gtk_main() User script are recorded in the guile interpreter as: void script:: setScript (gchar *scriptCode) { gchar *tmpScript, *tmp1, *tmp2; gint nb; g_free (this->scriptCode); this->scriptCode = g_strdup (scriptCode); /* define a scm procedure to hold the user script */ tmpScript = g_strdup_printf ("(define (script%d",this); for (nb = 1; nb <= g_list_length (parentList); nb++) { tmp1 = g_strdup_printf (" a%d", nb); tmp2 = g_strconcat (tmpScript, tmp1, NULL); g_free (tmp1); g_free (tmpScript); tmpScript = tmp2; } tmp1 = 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); } 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 ) Then in the geometric engine, this procedure is called as: /* build the call sequence */ tmpScript = g_strdup_printf ("(script%d", this); for (nb = 0; nb < g_list_length (parentList); nb++) { tmp1 = g_strdup_printf (" %d", g_list_nth_data (parentList, nb)); tmp2 = g_strconcat (tmpScript, tmp1, NULL); g_free (tmpScript); g_free (tmp1); tmpScript = tmp2; } tmp1 = g_strconcat (tmpScript, ")", NULL); g_free (tmpScript); ret = gh_eval_str_with_catch(tmp1, standard_handler); g_free (tmp1); if (gh_number_p (ret)) { val = gh_scm2double (ret); str = g_strdup_printf ("%.2f", val); } else if (gh_string_p (ret)) { str = gh_scm2newstr (ret, NULL); } else str = g_strdup (_("Unprintable result")); } When the script object is deleted I undefine the function. -- http://www.ofset.org Organization for Free Software in Education and Teaching _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://mail.gnu.org/mailman/listinfo/guile-user