Skip to content

Instantly share code, notes, and snippets.

@AeroNotix
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AeroNotix/ff3d128c16b4abb31efd to your computer and use it in GitHub Desktop.
Save AeroNotix/ff3d128c16b4abb31efd to your computer and use it in GitHub Desktop.
LISPKIT> (macroexpand '(WITH-GDK-EVENT-SLOTS (window) (first (all-events))
(print window)))
(LET ((WINDOW (FUNCALL #'|GDK:GDK-EVENT-KEY-WINDOW| (FIRST (ALL-EVENTS)))))
(PRINT WINDOW))
T
LISPKIT> (eval (macroexpand '(WITH-GDK-EVENT-SLOTS (window) (first (all-events))
(print window))))
; in:
; LET ((WINDOW (FUNCALL #'|GDK:GDK-EVENT-KEY-WINDOW| (FIRST (ALL-EVENTS)))))
; (FUNCALL #'LISPKIT::|GDK:GDK-EVENT-KEY-WINDOW| (FIRST (LISPKIT::ALL-EVENTS)))
; ==>
; (SB-C::%FUNCALL #'LISPKIT::|GDK:GDK-EVENT-KEY-WINDOW|
; (FIRST (LISPKIT::ALL-EVENTS)))
;
; caught STYLE-WARNING:
; undefined function: |GDK:GDK-EVENT-KEY-WINDOW|
;
; compilation unit finished
; Undefined function:
; |GDK:GDK-EVENT-KEY-WINDOW|
; caught 1 STYLE-WARNING condition
; Evaluation aborted on #<UNDEFINED-FUNCTION GDK:GDK-EVENT-KEY-WINDOW {100862F1E3}>.
LISPKIT> (LET ((WINDOW (FUNCALL #'GDK:GDK-EVENT-KEY-WINDOW (FIRST (ALL-EVENTS)))))
(PRINT WINDOW))
#<GDK-WINDOW {1009F60043}>
#<GDK-WINDOW {1009F60043}>
(defun gdk-event-slot (slot)
(intern (format nil "GDK:GDK-EVENT-KEY-~a" slot)))
(defmacro with-gdk-event-slots (slots gdk-event &body body)
`(let (,@(mapcar #'(lambda (slot)
(let ((slot-name (gdk-event-slot slot)))
`(,slot (funcall #',slot-name ,gdk-event))))
slots))
,@body))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment