[lambda-gtk-devel] passing lisp data to signal handlers

Todd Dukes tdukes at austin.rr.com
Sun May 29 03:56:05 UTC 2005


I am trying to port a minesweeper game from C to lisp, just to
learn a little about lambda-gtk. 

The buttons for the game are kept in a two dimensional array of
these structures:

     (defstruct minesweeper-button
                button-state widget bombs-nearby has-bomb row
		column)

I want to connect the button "clicked" signal to a handler like this:

     (g:signal-connect button "clicked" mine-button-clicked
                       (aref *mines* column row))

The problem is that at runtime I get an error complaining that the
data I passed to the signal-handler, ie. the (aref *mines* column row)
is not of type
     (OR NULL SYSTEM-AREA-POINTER (ALIEN (* T)))

I looked through the examples.lisp and downloaded cm-2.6.0 and looked
at all the signal-connect calls, but found no examples of passing lisp
data to the signal handler.

I looked through the sb-alien section in the sbcl manual, but it
doens't seem that converting lisp to a C representation so it could be
accessed by other lisp occurred to them. 

I wanted to avoid having to create a C structure just to pass a couple
of intergers to a signal.

I guess for this particular case I could multiply the column by the
number of rows and then add the row to that and decode it in the
callback, but that seems a little hackish. I wanted to eliminate most
of the globals once I got the program to work. Can anyone suggest a
better way of sending this data to the callback.

I can send the complete code if you would like. It is less than 600
lines without the xpm files.

thanks,
Todd.




More information about the Lambda-gtk-devel mailing list