From a4e6154d961ff4b606aa534bd4e1570565cab351 Mon Sep 17 00:00:00 2001 From: Drew Crampsie Date: Tue, 21 Mar 2006 11:13:06 -0800 Subject: [PATCH] massive refactoring in preparation of release. darcs-hash:20060321191306-5417e-444c1795d0a41eb2c9e15dcdb43a87536dc446ce.gz --- lisp-on-lines.asd | 4 ++ patches/yaclml.lisp | 15 +++++ src/attributes/numbers.lisp | 33 +++++++++-- src/defdisplay.lisp | 7 ++- src/dojo-attributes.lisp | 33 ++++++----- src/lines.lisp | 33 +++++++++++ src/mewa.lisp | 6 +- src/packages.lisp | 1 + src/relational-attributes.lisp | 31 +++++++++- src/slot-presentations/date.lisp | 28 ++++----- src/standard-attributes.lisp | 94 ++++++++++++++++--------------- src/standard-display.lisp | 32 +++++++---- src/standard-wrappers.lisp | 44 +++++++++++---- src/ucw-test-component.lisp | 39 +++++++------ src/validate-email-address.lisp | 2 +- src/validation.lisp | 6 +- src/validation/email-address.lisp | 2 +- 17 files changed, 278 insertions(+), 132 deletions(-) create mode 100644 patches/yaclml.lisp create mode 100644 src/lines.lisp diff --git a/lisp-on-lines.asd b/lisp-on-lines.asd index 9629103..5f2637b 100644 --- a/lisp-on-lines.asd +++ b/lisp-on-lines.asd @@ -11,6 +11,8 @@ (defsystem :lisp-on-lines :components ((:static-file "lisp-on-lines.asd") (:file "src/packages") + (:module :patches + :components ((:file "yaclml"))) (:module :src :components ((:file "special-initargs") (:file "properties") @@ -32,6 +34,8 @@ (:file "standard-wrappers") (:file "relational-attributes") + (:file "lines") + (:file "backwards-compat")) :serial t) (:module :attributes diff --git a/patches/yaclml.lisp b/patches/yaclml.lisp new file mode 100644 index 0000000..6a7b26c --- /dev/null +++ b/patches/yaclml.lisp @@ -0,0 +1,15 @@ +(in-package :yaclml) + +(defun funcall-with-tag (tag-spec thunk) + (let ((%yaclml-code% nil) + (%yaclml-indentation-depth% 0)) + (declare (special %yaclml-code%)) + ;; build tag's body + (dolist (i (fold-strings + (nreverse + (funcall (gethash (car (ensure-list tag-spec)) *expanders*) + (append (cdr tag-spec) (list + thunk)))))) + (if (functionp i) + (funcall i) + (write-string i *yaclml-stream*))))) \ No newline at end of file diff --git a/src/attributes/numbers.lisp b/src/attributes/numbers.lisp index 8eeff63..6fb0460 100644 --- a/src/attributes/numbers.lisp +++ b/src/attributes/numbers.lisp @@ -5,22 +5,47 @@ (:type-name number)) ;;;; INTEGER -(defattribute integer-attribute (base-attribute) +(defattribute integer-attribute (number-attribute) () (:type-name integer)) + +(define-layered-method (setf attribute-value) ((value string) object (attribute integer-attribute)) + (let ((*read-eval* nil)) + (unless (string= "" value) + (let ((value (read-from-string value))) + (when (numberp value) + (setf (attribute-value object attribute) value)))))) + ;;;; REALS -(defattribute real-attribute (base-attribute) +(defattribute real-attribute (number-attribute) () (:type-name real)) +(define-layered-method (setf attribute-value) ((value string) object (attribute real-attribute)) + (let ((*read-eval* nil)) + (unless (string= "" value) + (let ((value (read-from-string value))) + (when (numberp value) + (setf (attribute-value object attribute) value)))))) + ;;;; Currency -(defattribute currency-attribute (base-attribute) +(defattribute currency-attribute (real-attribute) () (:type-name currency)) (defdisplay ((currency currency-attribute) object) - (<:as-html (format nil "$~$" (attribute-value object currency)))) + (<:as-html "$") + (call-next-method)) + +(defdisplay :in-layer editor + ((currency currency-attribute) object) + (<:as-html "$") + (<:input + :type "text" + :id (id currency) + :name (callback currency) + :value (format nil "~$" (or (attribute-value object currency) "")))) diff --git a/src/defdisplay.lisp b/src/defdisplay.lisp index 89f6987..9b4cb79 100644 --- a/src/defdisplay.lisp +++ b/src/defdisplay.lisp @@ -1,6 +1,7 @@ (in-package :lisp-on-lines) (define-layered-function display-using-description (description object component) +; (:argument-precedence-order ) (:documentation "Render the object in component, using DESCRIPTION, which is an occurence, an attribute, or something else entirely.")) @@ -46,7 +47,7 @@ (error "no description for ~A" object)))) ;;;;; Macros -;;;; TODO: " should really be a funcall-with function with a small wrapper." + (defun funcall-with-description (description properties function &rest args) (if description @@ -61,8 +62,8 @@ (funcall-with-layers (description.layers description) #'(lambda () - (funcall-with-special-initargs - description properties + (contextl::funcall-with-special-initargs + (list (cons description properties)) #'(lambda () (apply function args)))))) (apply function args))) diff --git a/src/dojo-attributes.lisp b/src/dojo-attributes.lisp index 862ee11..8cb5447 100644 --- a/src/dojo-attributes.lisp +++ b/src/dojo-attributes.lisp @@ -3,39 +3,38 @@ (deflayer dojo) (define-layered-class - attribute :in-layer dojo () + description :in-layer dojo () ((dojo-type :accessor dojo-type :initarg :dojo-type :initform nil :special t))) - -(defgeneric display-as-dojo-type (type attribute object component)) +(define-layered-function display-as-dojo-type (type description object component)) (defdisplay - :in-layer dojo :after ((attribute standard-attribute) object) - (when (dojo-type attribute) - (display-as-dojo-type (dojo-type attribute) attribute object self))) + :in-layer dojo :after (description object) + (when (dojo-type description) + (display-as-dojo-type (dojo-type description) description object self))) -(defcomponent dojo-test (window-component) - ( - (results :accessor results :initarg :results))) +(defcomponent combo-results () + ()) -(defmethod render ((self dojo-test)) +(defmethod render ((self combo-results)) (<:as-is (js:js* `(array ,@(loop for r in (results self) for n upfrom 0 collect `(array , (with-output-to-string (s) (yaclml:with-yaclml-stream s - (display self r :type 'as-string))) ,n)))))) + (display self r :type 'as-string))) + ,n)))))) -(defmethod display-as-dojo-type ((type (eql 'combo-box)) attribute object component) +(define-layered-method display-as-dojo-type ((type (eql 'combo-box)) attribute object component) (let* ((search-function (search-function attribute)) (select-function (select-function attribute)) - (select-callback (ucw::make-new-callback (lambda (x) - (warn "setting index to ~A" (parse-integer x)) - (funcall select-function - (parse-integer x)))))) + (select-callback (ucw::make-new-callback + (lambda (x) + (funcall select-function + (parse-integer x)))))) "The combo box widget" (