Commits

Greg Slepak committed 46f9700

updated some outdated code docs

  • Participants
  • Parent commits f74d012

Comments (0)

Files changed (2)

File example-site/dragonfly-framework/dragonfly.lsp

 (constant 'DRAGONFLY_MINOR 50)
 (constant 'DRAGONFLY_VERSION (format "Version %d.%d" DRAGONFLY_MAJOR DRAGONFLY_MINOR))
 
-; This is buffer that contains that content that will get written
-; to STDOUT if no errors are thrown. If you define your own Route
-; then you must write the results to it using 'write-buffer' instead
-; of calling 'println' or 'print' directly!
+; This is the buffer that contains the content that will get written
+; to STDOUT if no errors are thrown. In the Dragonfly context 'print'
+; and 'println' are overridden to write to this buffer.
 (define STDOUT "")
 
 ; you can customize this variable with your own routes, note

File example-site/dragonfly-framework/lib/utils.lsp

 ;; @module Dragonfly
 ;; @author Greg Slepak <greg at taoeffect.com>
 
+;; @syntax (with-wrapped-print <body>)
+;; <p>If you're calling a function outside of the Dragonfly context
+;; that in turn calls 'print' or 'println', make sure to wrap the function
+;; call in this macro to prevent the web headers from being screwed up.</p>
+;; @example
+;; (with-wrapped-print (nldb:show))
+(define-macro (with-wrapped-print)
+	(let (saved-p print saved-pn println)
+		(constant 'print Dragonfly:print 'println Dragonfly:println)
+		(eval (cons 'begin $args))
+		(constant 'print saved-p 'println saved-pn)
+	)
+)
+(global 'with-wrapped-print)
+
+;; @syntax (define-subclass (<sym-subclass> <ctx>) <method-1> ...])
+;; @param <sym-subclass> Symbol representing name of the subclass
+;; @param <ctx> The FOOP class you'll be subclassing
+;; <p>This macro must be called in the MAIN context.</p>
+;; @example
+;; (new Class 'Foo)
+;; (define (Foo:get x) (x 1))
+;; (define (Foo:set x v) (setf (x 1) v) x)
+;; 
+;; (define-subclass (Bar Foo)
+;; 	((get x) (x 2))
+;; 	((set x v) (setf (x 2) v) x)
+;; 	((str x) (string x))
+;; )
+;; 
+;; (:get (Foo 1 2)) => 1
+;; (:get (Bar 1 2)) => 2
+;; (:str (:set (Bar 1 2) 3)) => (Bar 1 3)
+(define-macro (define-subclass)
+	(new (args 0 1) (args 0 0))
+	(dolist (method (rest $args))
+		(setf (method 0 0) (sym $it (args 0 0)))
+		(eval (push 'define method))
+	)
+)
+
 (context 'Dragonfly)
 
 ; protect against situation where one of the load functions is used to
 
 (context 'MAIN)
 
-;; @syntax (define-subclass (<sym-subclass> <ctx>) <method-1> ...])
-;; @param <sym-subclass> Symbol representing name of the subclass
-;; @param <ctx> The FOOP class you'll be subclassing
-;; <p>This macro must be called in the MAIN context.</p>
-;; @example
-;; (new Class 'Foo)
-;; (define (Foo:get x) (x 1))
-;; (define (Foo:set x v) (setf (x 1) v) x)
-;; 
-;; (define-subclass (Bar Foo)
-;; 	((get x) (x 2))
-;; 	((set x v) (setf (x 2) v) x)
-;; 	((str x) (string x))
-;; )
-;; 
-;; (:get (Foo 1 2)) => 1
-;; (:get (Bar 1 2)) => 2
-;; (:str (:set (Bar 1 2) 3)) => (Bar 1 3)
-(define-macro (define-subclass)
-	(new (args 0 1) (args 0 0))
-	(dolist (method (rest $args))
-		(setf (method 0 0) (sym $it (args 0 0)))
-		(eval (push 'define method))
-	)
-)
-
-(define-macro (with-wrapped-print)
-	(let (saved-p print saved-pn println)
-		(constant 'print Dragonfly:print 'println Dragonfly:println)
-		(eval (cons 'begin $args))
-		(constant 'print saved-p 'println saved-pn)
-	)
-)
-(global 'with-wrapped-print)
-
 ; swap the MAIN functions for ours
 (unless Dragonfly:saved-load
 	(def-new 'load 'Dragonfly:saved-load)