Skip to content

Commit

Permalink
Use named-readtables.
Browse files Browse the repository at this point in the history
  • Loading branch information
ruricolist committed Jun 17, 2015
1 parent 5eff3f4 commit fd1ffd9
Show file tree
Hide file tree
Showing 20 changed files with 49 additions and 30 deletions.
7 changes: 3 additions & 4 deletions closure-common/package.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
(in-package :cl-user)

(defpackage :fxml.runes
(:use :cl #-scl :trivial-gray-streams)
(:use :cl #-scl :trivial-gray-streams :named-readtables)
(:export #:definline

;; runes.lisp
Expand Down Expand Up @@ -90,9 +90,8 @@
#:make-octet-input-stream))

(defpackage :fxml.utf8-runes
(:use :cl)
(:export *utf8-runes-readtable*
#:rune #:rod #:simple-rod #:rod-string #:rod= #:make-rod
(:use :cl :named-readtables)
(:export #:rune #:rod #:simple-rod #:rod-string #:rod= #:make-rod
#:string-rod))

(defpackage :fxml.runes-encoding
Expand Down
1 change: 1 addition & 0 deletions closure-common/stream-scl.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
;;; Boston, MA 02111-1307 USA.

(in-package :fxml.runes)
(in-readtable :runes)

(eval-when (:compile-toplevel :load-toplevel :execute)
(defparameter *fast* '(optimize (speed 3) (safety 3))))
Expand Down
9 changes: 6 additions & 3 deletions closure-common/syntax.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@
subchar arg
(values (rune-from-read-name (read-rune-name stream))))

(set-dispatch-macro-character #\# #\/ 'rune-reader)

;;; ROD ext syntax

(defun rod-reader (stream subchar arg)
Expand Down Expand Up @@ -178,4 +176,9 @@
(format stream "\\u~4,'0X" x))))
(princ #\" stream))

(set-dispatch-macro-character #\# #\" 'rod-reader)
;;; Readtable.

(defreadtable :runes
(:merge :standard)
(:dispatch-macro-char #\# #\" 'rod-reader)
(:dispatch-macro-char #\# #\/ 'rune-reader))
9 changes: 4 additions & 5 deletions closure-common/utf8.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
(defun rod-reader (stream subchar arg)
(fxml.runes::rod-string (fxml.runes::rod-reader stream subchar arg)))

(setf closure-common-system:*utf8-runes-readtable*
(let ((rt (copy-readtable)))
(set-dispatch-macro-character #\# #\/ 'rune-reader rt)
(set-dispatch-macro-character #\# #\" 'rod-reader rt)
rt))
(defreadtable :utf8-runes
(:merge :standard)
(:dispatch-macro-char #\# #\/ #'rune-reader)
(:dispatch-macro-char #\# #\" #'rod-reader))
1 change: 1 addition & 0 deletions closure-common/xstream.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
;;; Boston, MA 02111-1307 USA.

(in-package :fxml.runes)
(in-readtable :runes)

;;; API
;;
Expand Down
1 change: 1 addition & 0 deletions closure-common/ystream.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
;;; ystream (for lack of a better name): a rune output "stream"

(in-package :fxml.runes)
(in-readtable :runes)

(defconstant +ystream-bufsize+ 1024)

Expand Down
13 changes: 7 additions & 6 deletions dom/dom-builder.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,24 @@
;;;; Author: David Lichteblau <david@lichteblau.com>
;;;; Author: knowledgeTools Int. GmbH

#-fxml-system::utf8dom-file
#-rune-is-integer
(in-package :fxml.rune-dom)

#+fxml-system::utf8dom-file
#+rune-is-integer
(in-package :fxml.utf8-dom)

#-rune-is-integer
(in-readtable :runes)
#+rune-is-integer
(in-readtable :utf8-runes)


(defclass dom-builder (fxml.sax:content-handler)
((document :initform nil :accessor document)
(element-stack :initform '() :accessor element-stack)
(internal-subset :accessor internal-subset)
(text-buffer :initform nil :accessor text-buffer)))

#+(and rune-is-integer (not fxml-system::utf8dom-file))
(defmethod fxml.hax:%want-strings-p ((handler dom-builder))
nil)

(defun make-dom-builder ()
(make-instance 'dom-builder))

Expand Down
23 changes: 14 additions & 9 deletions dom/dom-impl.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,29 @@
;;;; Author: David Lichteblau <david@lichteblau.com>
;;;; Author: knowledgeTools Int. GmbH

#-fxml-system::utf8dom-file
#-rune-is-integer
(defpackage :fxml.rune-dom
(:use :cl :fxml.runes)
(:use :cl :fxml.runes :named-readtables)
#+rune-is-character (:nicknames :fxml-dom)
(:export #:implementation #:make-dom-builder #:create-document))

#+fxml-system::utf8dom-file
#+rune-is-integer
(defpackage :fxml.utf8-dom
(:use :cl :fxml.utf8-runes)
(:nicknames :fxml-dom)
(:export #:implementation #:make-dom-builder #:create-document))

#-fxml-system::utf8dom-file
#-rune-is-integer
(in-package :fxml.rune-dom)

#+fxml-system::utf8dom-file
#+rune-is-integer
(in-package :fxml.utf8-dom)

#-rune-is-integer
(in-readtable :runes)
#+rune-is-integer
(in-readtable :utf8-runes)


;; Classes

Expand Down Expand Up @@ -157,15 +162,15 @@
(etypecase x
(null x)
(rod x)
#+fxml-system::utf8dom-file (fxml.runes::rod (fxml::rod-to-utf8-string x))
#+rune-is-integer (fxml.runes::rod (fxml::rod-to-utf8-string x))
(string (string-rod x))
(vector x)))

#-fxml-system::utf8dom-file
#-rune-is-integer
(defun real-rod (x)
(%rod x))

#+fxml-system::utf8dom-file
#+rune-is-integer
(defun real-rod (x)
(etypecase x
(null x)
Expand Down Expand Up @@ -1244,7 +1249,7 @@
(when resolver
(setf (document handler) owner)
(push instance (element-stack handler))
#+fxml-system::utf8dom-file
#+rune-is-integer
(setf handler (fxml:make-recoder handler #'fxml:rod-to-utf8-string))
(funcall resolver (real-rod (fxml.dom:name instance)) handler)
(flush-characters handler)))
Expand Down
2 changes: 0 additions & 2 deletions fxml.asd
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
(pushnew :rune-is-utf-16 *features*)
(pushnew :rune-is-character *features*)))))

(defvar *utf8-runes-readtable*)

(defclass closure-source-file (cl-source-file) ())

#+scl
Expand Down
1 change: 1 addition & 0 deletions klacks/klacks-impl.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
;;; Boston, MA 02111-1307 USA.

(in-package :fxml)
(in-readtable :runes)

(defclass fxml-source (fxml.klacks:source)
(;; args to make-source
Expand Down
1 change: 1 addition & 0 deletions klacks/klacks.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
;;; Boston, MA 02111-1307 USA.

(in-package :fxml)
(in-readtable :runes)

(defclass fxml.klacks:source ()
(
Expand Down
1 change: 1 addition & 0 deletions klacks/tap-source.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
;;; Boston, MA 02111-1307 USA.

(in-package :fxml)
(in-readtable :runes)

(defun fxml.klacks:make-tapping-source (upstream-source &optional sax-handler)
(make-instance 'fxml.klacks:tapping-source
Expand Down
1 change: 1 addition & 0 deletions xml/catalog.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
;;;; Copyright: David Lichteblau

(in-package :fxml)
(in-readtable :runes)

;;; http://www.oasis-open.org/committees/entity/spec.html
;;;
Expand Down
1 change: 1 addition & 0 deletions xml/package.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

(defpackage :fxml
(:use :cl :fxml.runes :fxml.runes-encoding #-scl :trivial-gray-streams)
(:import-from #:named-readtables #:in-readtable)
(:export
;; meta
#:xml-character-p
Expand Down
3 changes: 2 additions & 1 deletion xml/sax-handler.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
;; conditions (but isn't yet)

(defpackage :fxml.sax
(:use :common-lisp)
(:use :common-lisp :named-readtables)
(:export #:*namespace-processing*
#:*include-xmlns-attributes*
#:*use-xmlns-namespace*
Expand Down Expand Up @@ -99,6 +99,7 @@
#:standard-attribute))

(in-package :fxml.sax)
(in-readtable :runes)


;;;; SAX-PARSER interface
Expand Down
1 change: 1 addition & 0 deletions xml/sax-tests/tests.lisp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(in-package :fxml.sax.tests)
(named.readtables:in-readtable :runes)

(defun first-start-element-event (string)
(let ((events (fxml:parse-rod string (make-instance 'event-collecting-handler))))
Expand Down
1 change: 1 addition & 0 deletions xml/space-normalizer.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
;;;; Copyright (c) 2005 David Lichteblau

(in-package :fxml)
(in-readtable :runes)

(defclass whitespace-normalizer (sax-proxy)
((attributes :initform '(t) :accessor xml-space-attributes)
Expand Down
1 change: 1 addition & 0 deletions xml/unparse.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
;;; Boston, MA 02111-1307 USA.

(in-package :fxml)
(in-readtable :runes)

;;
;; | Canonical XML
Expand Down
1 change: 1 addition & 0 deletions xml/xml-parse.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@
;;;; we check this VC together with the WFC even in non-validating mode.

(in-package :fxml)
(in-readtable :runes)

#+allegro
(setf (excl:named-readtable :runes) *readtable*)
Expand Down
1 change: 1 addition & 0 deletions xml/xmlns-normalizer.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
;;;; [1] http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/namespaces-algorithms.html#normalizeDocumentAlgo

(in-package :fxml)
(in-readtable :runes)

(defclass namespace-normalizer (sax-proxy)
((xmlns-stack :initarg :xmlns-stack :accessor xmlns-stack)))
Expand Down

0 comments on commit fd1ffd9

Please sign in to comment.