;; Inputs is of the form ;; k => name provided by user for input ;; v => the code generated to make an instance ;; ex: (:scale pony 0 10 1) creates an entry ;; where pony=>(make-instance 'scale ...) (defparameter *inputs* (make-hash-table)) ;; The parameters passed to the action function. (defparameter *params* nil) ;; Resets the model (defun reset-inputs () (setf *inputs* (make-hash-table)) (setf *params* '())) ;; Converts a keyworded form to the ;;appropriate LTK make-instance. ;; Side-effect: Adds the instance to *inputs* (defun convert-to-instance (keyword) (let ((key (first keyword)) ; eg: :scale (name (second keyword)) ; (vals (cddr keyword)) ; all additional parameters (special (eql 'special (first (last keyword)))) tmp) (cond ((equal key :scale) (progn (setf tmp `(make-instance 'scale :master main-label :label ,(format nil "~A" name) :from ,(first vals) :to ,(second vals) :digits 5 :resolution ,(or (third vals) 1) :troughcolor ,(if special :red :black) :orientation 'horizontal)) (setf (gethash name *inputs*) tmp)))) tmp)) (defmacro defmodel (name inputs model importance &body action) (reset-inputs) (let ( letz ; all LTK forms packer ;;generated from letz, a sequence of (pack NAME) ui-name model-name function-name function-parameters importance-name ) ; Generates two symbols: NAME-MODEL and NAME-PROCESSOR (setf model-name (intern (format nil "~A-MODEL" name))) (setf function-name (intern (format nil "~A-PROCESSOR" name))) (setf ui-name (intern (format nil "~A-UI" name))) (setf importance-name (intern (format nil "~A-IMPORTANCE" name)))