unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* C++ application linked with guile dos not quite
@ 2002-06-17 13:24 Hilaire Fernandes
  2002-06-18  8:25 ` CDDP 40 - TICE
  0 siblings, 1 reply; 12+ messages in thread
From: Hilaire Fernandes @ 2002-06-17 13:24 UTC (permalink / raw)


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


^ permalink raw reply	[flat|nested] 12+ messages in thread
* C++ application linked with guile dos not quite
@ 2002-06-17 13:23 CDDP
  0 siblings, 0 replies; 12+ messages in thread
From: CDDP @ 2002-06-17 13:23 UTC (permalink / raw)


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.






_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2002-06-19 16:42 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-17 13:24 C++ application linked with guile dos not quite Hilaire Fernandes
2002-06-18  8:25 ` CDDP 40 - TICE
2002-06-18 13:43   ` Brett Viren
2002-06-18 14:37     ` Hilaire Fernandes
2002-06-18 14:45       ` Brett Viren
2002-06-18 17:26     ` Marius Vollmer
2002-06-19  8:02       ` CDDP 40 - TICE
2002-06-19 11:14         ` Marius Vollmer
2002-06-19 13:19           ` CDDP 40 - TICE
2002-06-19 14:09             ` Brett Viren
2002-06-19 16:42               ` CDDP 40 - TICE
  -- strict thread matches above, loose matches on Subject: below --
2002-06-17 13:23 CDDP

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).