[Openmcl-devel] pref with vriable field name

Taoufik Dachraoui taoufik at mazeboard.com
Mon Jan 25 08:25:24 UTC 2010


Hi

I have the following code:

(defmacro defonevent (onevent eventtype xstruct)
  `(defmacro ,onevent (&rest body)
     `(progn
(if (null (gethash (window *context*) %event-handlers%))
    (setf (gethash (window *context*) %event-handlers%) (make-hash-table)))
(setf (gethash ,',eventtype (gethash (window *context*) %event-handlers%))
      #'(lambda (event)
  (macrolet ((this (var) `(xpref event ',',',xstruct ,var)))
    (this window) ; to avoid the warning if the event is not used in the
body
    , at body))))))

(defonevent on-expose #$Expose :<XE>xpose<E>vent)
(defonevent on-buttonpress #$ButtonPress :<XB>utton<E>vent)
(defonevent on-buttonrelease #$ButtonRelease :<XB>utton<E>vent)
(defonevent on-keypress #$KeyPress :<XK>ey<E>vent)
(defonevent on-keyrelease #$KeyRelease :<XK>ey<E>vent)
(defonevent on-clientmessage #$ClientMessage :<XC>lient<M>essage<E>vent)
(defonevent on-mapnotify #$MappingNotify :<XM>ap<E>vent)


; usage
(cell ....
  (on-expose
     (drawline 0 0 (this width) (this height)))
  ...
 )


The issue is that I do not know how to implement xpref. The pref macro takes
an accessor of the form
type.field but I need a macro that takes the type of the structure and the
field name separately.

Thank you for your help

Taoufik
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.clozure.com/pipermail/openmcl-devel/attachments/20100125/ca8eeb96/attachment.html>


More information about the Openmcl-devel mailing list