guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C++ application linked with guile dos not quite


From: CDDP 40 - TICE
Subject: Re: C++ application linked with guile dos not quite
Date: 18 Jun 2002 10:25:07 +0200

When guile is embedded in a C++ aplication, is there any garbage
collection to take care of ?

Hilaire



Le lun 17/06/2002 à 15:24, Hilaire Fernandes a écrit :
> 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
> address@hidden
> http://mail.gnu.org/mailman/listinfo/guile-user
> 
-- 
Ingénierie Éducative
CDDP des Landes




reply via email to

[Prev in Thread] Current Thread [Next in Thread]