[Openmcl-devel] pref with vriable field name

Ron Garret ron at flownet.com
Mon Jan 25 01:30:19 PST 2010


Try something like:

(defmacro xpref (thing type slotname)
  `(pref ,thing ,(intern (format nil "~A.~A" type slotname))))

rg

On Jan 25, 2010, at 12:25 AM, Taoufik Dachraoui wrote:

> 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
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel




More information about the Openmcl-devel mailing list