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

Re: X bindings in Scheme?

In article <6599@ubc-cs.UUCP> manis@cs.ubc.ca (Vincent Manis) writes:

>Actually, what I'd like is Xt (or, even better, Motif) from Scheme. It
>would be even better to be able to write widgets in Scheme!  The problem
>is that the architecture of Xt involves a lot of callbacks, and,
>generally (unless you're using the DECWRL compiler) you can't call
>Scheme from C.

I have found a way to get around the problem. The trick is:
- use a vector to store the Scheme callback functions and client_data.
- use the index to the vector to communicate between Scheme and C.
- use a "standard_callback" function (written in C). standard_callback's
  client data will always be the index to the vector. If this callback
  is called by Xt it simply set a few flags which indicates information
  about widget-id, client_data (the index), and call_data.
- XtMainloop need to be written in Scheme which simply polls the flags
  while looping. (if callback occured, use the index to find the Schems
  callback function and call it with the desired data.)

Simon Tung
Department of Computer Science
Indiana University