unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: CDDP <cddp.landes@ac-bordeaux.fr>
Subject: C++ application linked with guile dos not quite
Date: 17 Jun 2002 15:23:39 +0200	[thread overview]
Message-ID: <1024320220.17552.138.camel@tice> (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


             reply	other threads:[~2002-06-17 13:23 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-17 13:23 CDDP [this message]
  -- strict thread matches above, loose matches on Subject: below --
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1024320220.17552.138.camel@tice \
    --to=cddp.landes@ac-bordeaux.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).