[closure-devel] Re: using closure with cxml

David Lichteblau david at lichteblau.com
Sat Jan 28 22:11:12 UTC 2006


Quoting David Lichteblau (david at lichteblau.com):
> the attached patch removes the rune (and xstream) implementations as
> well as the XML parser from closure.  It adds a dependency to cxml and
> uses the rune implementation shipped with cxml.

Updated for current cxml.


d.
-------------- next part --------------
Index: closure.asd
===================================================================
RCS file: /project/closure/cvsroot/closure/closure.asd,v
retrieving revision 1.7
diff -u -u -r1.7 closure.asd
--- closure.asd	11 Jan 2006 22:05:54 -0000	1.7
+++ closure.asd	28 Jan 2006 22:02:29 -0000
@@ -9,6 +9,11 @@
 (eval-when (compile eval load)
   (pushnew :DEBUG-CLOSURE *features*))
 
+#+rune-is-character
+(error "cxml needs to be compiled with :rune-is-integer for use with closure")
+#-rune-is-character
+(pushnew :rune-is-integer *features*)
+
 ;;;;
 ;;;; Optimization levels:
 ;;;;
@@ -56,11 +61,12 @@
 
 (defpackage :glisp (:use))
 (asdf:defsystem glisp
+    :depends-on (:cxml)
     :pathname (merge-pathnames "src/glisp/"
 			       (make-pathname :name nil :type nil
 					      :defaults *load-truename*))
     :default-component-class closure-source-file
-    :depends-on (:clim #+sbcl :sb-bsd-sockets)
+    :depends-on (:mcclim #+sbcl :sb-bsd-sockets)
     :components
     ((:file dependent
 	    :pathname
@@ -75,12 +81,10 @@
 	    #-(OR sbcl CLISP CMU ALLEGRO GCL OPENMCL) #.(error "Configure!"))
      (:file "package"
 	    :depends-on (dependent))
-     (:file "runes"
-	    :depends-on ("package" dependent))
      (:file "util"
-	    :depends-on ("package" dependent "runes"))
+	    :depends-on ("package" dependent))
      (:file "match"
-	    :depends-on ("package" dependent "runes" "util"))))
+	    :depends-on ("package" dependent "util"))))
 
 
 (asdf:defsystem closure
@@ -121,20 +125,6 @@
 			 (:file "css-support")))
 
 	       ;; Libraries
-	       
-	       (:module xml
-			:components
-			((:file "package")
-			 (:file "encodings"       :depends-on ("package"))
-			 (:file "encodings-data"  :depends-on ("package" "encodings"))
-			 (:file "sax-handler")
-			 (:file "dompack")
-			 (:file "dom-impl"        :depends-on ("dompack"))
-			 (:file "dom-builder"     :depends-on ("dom-impl" "sax-handler"))
-			 (:file "xml-stream"      :depends-on ("package"))
-			 (:file "xml-name-rune-p" :depends-on ("package"))
-			 (:file "xml-parse"       :depends-on ("package" "dompack" "sax-handler"))
-			 (:file "xml-canonic"     :depends-on ("package" "dompack" "xml-parse"))  ))
 
 	       ;; CLEX and LALR
 	       
Index: src/defpack.lisp
===================================================================
RCS file: /project/closure/cvsroot/closure/src/defpack.lisp,v
retrieving revision 1.5
diff -u -u -r1.5 defpack.lisp
--- src/defpack.lisp	17 Jul 2005 09:30:48 -0000	1.5
+++ src/defpack.lisp	28 Jan 2006 22:02:29 -0000
@@ -28,7 +28,7 @@
 
 (defpackage :renderer
   (:nicknames :r2)
-  (:use :glisp)
+  (:use :glisp :runes)
   (:import-from :imagelib 
                 #:aimage
                 #:aimage-width
@@ -94,18 +94,18 @@
    ))
 
 (defpackage :ws/x11
-  (:use :glisp)
+  (:use :glisp :runes)
   (:export
    #:aimage->ximage))
 
 (defpackage :gif
-  (:use :glisp)
+  (:use :glisp :runes)
   (:export #:gif-stream->aimage))
 
 (defpackage :ws/charset
   ;;(:nicknames :charset)
   ;; Arg! CLISP now defines a package called "charset".
-  (:use :glisp)
+  (:use :glisp :runes)
   (:export #:CHARSET
            #:CHARSET-DECODE
            #:CHARSET-ENCODE
@@ -118,7 +118,7 @@
 ;;zzz(defpackage :ws/estk (:use :glisp))     ;should die
 
 (defpackage :gui
-  (:use :glisp)
+  (:use :glisp :runes)
 
   (:import-from #:clim
    #:+nowhere+
@@ -197,7 +197,7 @@
    ))
 
 
-(defpackage :gtk-gui (:use :glisp))
+(defpackage :gtk-gui (:use :glisp :runes))
 
 (defpackage :closure
     (:use)
@@ -234,9 +234,4 @@
                 "DEVICE-FONT-UNDERLINE-THICKNESS"
                 ))
 
-(defpackage :clue-gui2 (:use #||:glue :clue||# :glisp))
-
-
-
-
-
+(defpackage :clue-gui2 (:use #||:glue :clue||# :glisp :runes))
Index: src/css/package.lisp
===================================================================
RCS file: /project/closure/cvsroot/closure/src/css/package.lisp,v
retrieving revision 1.3
diff -u -u -r1.3 package.lisp
--- src/css/package.lisp	13 Mar 2005 18:00:58 -0000	1.3
+++ src/css/package.lisp	28 Jan 2006 22:02:29 -0000
@@ -28,7 +28,7 @@
 
 (in-package :CL-USER)
 (defpackage :css
-  (:use :glisp)
+  (:use :glisp :runes)
   ;;
   (:import-from "CLOSURE-PROTOCOL"
    ;; basic element protocol
Index: src/glisp/package.lisp
===================================================================
RCS file: /project/closure/cvsroot/closure/src/glisp/package.lisp,v
retrieving revision 1.4
diff -u -u -r1.4 package.lisp
--- src/glisp/package.lisp	13 Mar 2005 18:01:15 -0000	1.4
+++ src/glisp/package.lisp	28 Jan 2006 22:02:29 -0000
@@ -285,35 +285,6 @@
       "LREDUCE*"
       "WITH-UNIQUE-NAMES"
     
-      ;; runes.lisp
-      "RUNE"
-      "ROD"
-      "SIMPLE-ROD"
-      "%RUNE"
-      "ROD-CAPITALIZE"
-      "CODE-RUNE"
-      "RUNE-CODE"
-      "RUNE-DOWNCASE"
-      "RUNE-UPCASE"
-      "ROD-DOWNCASE"
-      "ROD-UPCASE"
-      "WHITE-SPACE-RUNE-P"
-      "DIGIT-RUNE-P"
-      "RUNE="
-      "RUNE<="
-      "RUNE>="
-      "RUNE-EQUAL"
-      "RUNEP"
-      "SLOOPY-ROD-P"
-      "ROD="
-      "ROD-EQUAL"
-      "MAKE-ROD"
-      "CHAR-RUNE"
-      "RUNE-CHAR"
-      "ROD-STRING"
-      "STRING-ROD"
-      "ROD-SUBSEQ"
-    
       "G/MAKE-HASH-TABLE"
       "G/HASHGET"
       "G/CLRHASH"
Index: src/glisp/util.lisp
===================================================================
RCS file: /project/closure/cvsroot/closure/src/glisp/util.lisp,v
retrieving revision 1.4
diff -u -u -r1.4 util.lisp
--- src/glisp/util.lisp	13 Mar 2005 18:01:16 -0000	1.4
+++ src/glisp/util.lisp	28 Jan 2006 22:02:30 -0000
@@ -216,14 +216,16 @@
           (t (subseq string start)))))
 
 (defun sanify-rod (string &optional (begin? t) (end? t) (start 0))
-  (let ((i (position-if #'white-space-rune-p string :start start)))
+  (let ((i (position-if #'runes:white-space-rune-p string :start start)))
     (cond (i
-           (let ((j (position-if-not #'white-space-rune-p string :start i)))
+           (let ((j (position-if-not #'runes:white-space-rune-p
+				     string
+				     :start i)))
              (if j
-                 (concatenate 'rod (subseq string start i)
+                 (concatenate 'runes:rod (subseq string start i)
                               (if (and (= i start) begin?) '#() '#(32))
                               (sanify-rod string nil end? j))
-               (concatenate 'rod (subseq string start i)
+               (concatenate 'runes:rod (subseq string start i)
                             (if (not end?) '#(32) '#())))))
           (t (subseq string start)))))
 
Index: src/gui/clue-gui.lisp
===================================================================
RCS file: /project/closure/cvsroot/closure/src/gui/clue-gui.lisp,v
retrieving revision 1.3
diff -u -u -r1.3 clue-gui.lisp
--- src/gui/clue-gui.lisp	13 Mar 2005 18:01:37 -0000	1.3
+++ src/gui/clue-gui.lisp	28 Jan 2006 22:02:30 -0000
@@ -115,7 +115,7 @@
                       ((member mime-type (list (netlib:find-mime-type "text/html")))
                        (sgml::parse-html input charset))
                       ((member mime-type (list (netlib:find-mime-type "text/xml")))
-                       (xml::parse-stream input))
+                       (cxml:parse-stream input (cxml-dom:make-dom-builder) :recode nil))
 
                       ((or t
                            #+NIL
@@ -214,6 +214,10 @@
    (serial       :initarg :serial)
    (dumpee       :initarg :dumpee       :initform nil) ) )
 
+(defmethod runes::figure-encoding ((stream glisp:gstream))
+  ;; For HTML iso-8859-1 is the default
+  (values (cxml::find-encoding :iso-8859-1) nil))
+
 (defmethod g/read-byte ((stream pb-stream)  &optional (eof-error-p t) eof-value)
   (with-slots (nread ntotal proxee dumpee) stream
     (let ((res (g/read-byte proxee eof-error-p eof-value)))
Index: src/imagelib/package.lisp
===================================================================
RCS file: /project/closure/cvsroot/closure/src/imagelib/package.lisp,v
retrieving revision 1.2
diff -u -u -r1.2 package.lisp
--- src/imagelib/package.lisp	13 Mar 2005 18:02:01 -0000	1.2
+++ src/imagelib/package.lisp	28 Jan 2006 22:02:32 -0000
@@ -29,7 +29,7 @@
 (in-package :CL-USER)
 
 (defpackage :imagelib
-  (:use :glisp)
+  (:use :glisp :runes)
   (:export
    #:aimage
    #:aimage-width
Index: src/net/package.lisp
===================================================================
RCS file: /project/closure/cvsroot/closure/src/net/package.lisp,v
retrieving revision 1.2
diff -u -u -r1.2 package.lisp
--- src/net/package.lisp	13 Mar 2005 18:02:19 -0000	1.2
+++ src/net/package.lisp	28 Jan 2006 22:02:32 -0000
@@ -30,7 +30,7 @@
 
 (defpackage :ws/netlib
   (:nicknames :netlib)
-  (:use :glisp :url)
+  (:use :glisp :url :runes)
   (:export #:*options/connection-timeout*
            #:open-document
            #:with-open-document
Index: src/net/url.lisp
===================================================================
RCS file: /project/closure/cvsroot/closure/src/net/url.lisp,v
retrieving revision 1.5
diff -u -u -r1.5 url.lisp
--- src/net/url.lisp	13 Mar 2005 18:02:19 -0000	1.5
+++ src/net/url.lisp	28 Jan 2006 22:02:32 -0000
@@ -41,7 +41,7 @@
 ;(require :glisp)
 
 (defpackage :url
-  (:use :glisp)
+  (:use :glisp :runes)
   (:export
    #:parse-url
    #:unparse-url
Index: src/parse/package.lisp
===================================================================
RCS file: /project/closure/cvsroot/closure/src/parse/package.lisp,v
retrieving revision 1.3
diff -u -u -r1.3 package.lisp
--- src/parse/package.lisp	13 Mar 2005 18:02:40 -0000	1.3
+++ src/parse/package.lisp	28 Jan 2006 22:02:32 -0000
@@ -29,7 +29,7 @@
 (in-package :CL-USER)
 
 (defpackage :sgml
-  (:use :glisp)
+  (:use :glisp :runes)
   (:export #:SGML-PARSE 
            #:PPT 
            #:SGML-UNPARSE 
Index: src/parse/sgml-parse.lisp
===================================================================
RCS file: /project/closure/cvsroot/closure/src/parse/sgml-parse.lisp,v
retrieving revision 1.4
diff -u -u -r1.4 sgml-parse.lisp
--- src/parse/sgml-parse.lisp	13 Mar 2005 18:02:40 -0000	1.4
+++ src/parse/sgml-parse.lisp	28 Jan 2006 22:02:33 -0000
@@ -240,36 +240,36 @@
 
 (defmacro a-read-byte (input)
   (let ((c (gensym)))
-    `(let ((,c (xml:read-rune ,input)))
+    `(let ((,c (runes:read-rune ,input)))
        (if (eq ,c :eof) nil ,c))))
 
 (defmacro a-peek-byte (input)
   (let ((c (gensym)))
-    `(let ((,c (xml:peek-rune ,input)))
+    `(let ((,c (runes:peek-rune ,input)))
        (if (eq ,c :eof) nil ,c))))
 
 (defmacro a-unread-byte (byte input)
-  `(xml:unread-rune ,byte ,input))
+  `(runes:unread-rune ,byte ,input))
 
 (defmacro a-stream-position (input)
-  `(xml:xstream-position ,input))
+  `(runes:xstream-position ,input))
 
 (defun make-a-stream (&key cl-stream)
-  (xml:make-xstream cl-stream :initial-speed 1 :speed 8192))
+  (runes:make-xstream cl-stream :initial-speed 1 :speed 8192))
 
-(defmethod xml::read-octets (sequence (stream glisp:gstream) start end)
+(defmethod runes::read-octets (sequence (stream glisp:gstream) start end)
   (glisp:g/read-byte-sequence sequence stream :start start :end end))
 
-(defmethod xml::xstream/close ((stream glisp:gstream))
+(defmethod runes::xstream/close ((stream glisp:gstream))
   (glisp:g/close stream))
 
 ;; a fake definition -- XXX non-reentrant!
 
 (defun a-stream-scratch (input)
-  (getf (xml::xstream-plist input) 'scratch-pad))
+  (getf (runes::xstream-plist input) 'scratch-pad))
 
 (defun (setf a-stream-scratch) (new-value input)
-  (setf (getf (xml::xstream-plist input) 'scratch-pad) new-value))
+  (setf (getf (runes::xstream-plist input) 'scratch-pad) new-value))
 
 ;;;; -------------------------------------------------------------------------
 ;;;;  Reporting Errors
@@ -295,8 +295,8 @@
     (when (>= level *parse-warn-level*)
       (unless *options/parser-silent-p*
         (let ((preample (format nil ";; Parser warning: ~11@<Line ~D,~> ~11@<column ~D~>: ~5A "
-                                (and input (ignore-errors (xml:xstream-line-number input)))
-                                (and input (ignore-errors (xml:xstream-column-number input)))
+                                (and input (ignore-errors (runes:xstream-line-number input)))
+                                (and input (ignore-errors (runes:xstream-column-number input)))
                                 (make-string level :initial-element #\*))))
           (fresh-line *trace-output*)
           (write-string preample *trace-output*)
@@ -1038,8 +1038,8 @@
                     (handle-meta-tag-in-parser input (caddr ausgabe))))
              ;; when the BODY tag is openend, switch the streams speed to full speed.
              (cond ((and (eq (cadr ausgabe) :body))
-                    (setf (xml::xstream-speed input)
-                      (length (xml::xstream-os-buffer input)))))
+                    (setf (runes::xstream-speed input)
+                      (length (runes::xstream-os-buffer input)))))
              (let ((n (sgml::make-pt/low 
                        :name (cadr ausgabe)
                        :attrs (caddr ausgabe)
@@ -1294,7 +1294,7 @@
 
 (defun parse-html (input &optional (charset :iso-8859-1))
   (let ((dtd cl-user::*html-dtd*))
-    (let ((input (xml:make-xstream input :initial-speed 1 :speed 128)))
+    (let ((input (runes:make-xstream input :initial-speed 1 :speed 128)))
       (setf (a-stream-scratch input)
         (make-array #.(* 2 *buf-size*) :element-type 'rune))
       (setup-code-vector input charset)
@@ -1583,9 +1583,9 @@
 ;;  
 
 (defun setup-code-vector (input charset)
-  (let ((enc (xml::find-encoding charset)))
+  (let ((enc (cxml::find-encoding charset)))
     (cond ((not (null enc))
-           (setf (xml:xstream-encoding input) enc))
+           (setf (runes:xstream-encoding input) enc))
           (t
            (parse-warn input 4 "There is no such encoding: ~S." charset)))))
 
@@ -1795,7 +1795,7 @@
 
 #||
     (format T "~&;; Parse error (line ~D column ~D): [~A] Saw ~A in ~A."
-            (xml:xstream-line-number input)
-            (xml:xstream-column-number input))
+            (runes:xstream-line-number input)
+            (runes:xstream-column-number input))
 
-||#
\ No newline at end of file
+||#
Index: src/protocols/package.lisp
===================================================================
RCS file: /project/closure/cvsroot/closure/src/protocols/package.lisp,v
retrieving revision 1.3
diff -u -u -r1.3 package.lisp
--- src/protocols/package.lisp	13 Mar 2005 18:03:05 -0000	1.3
+++ src/protocols/package.lisp	28 Jan 2006 22:02:33 -0000
@@ -27,7 +27,7 @@
 ;;;  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 (defpackage :CLOSURE-PROTOCOL
-    (:use :glisp)
+    (:use :glisp :runes)
   (:export
    ;; Basic Element Protocol
    #:element-p
Index: src/util/clex.lisp
===================================================================
RCS file: /project/closure/cvsroot/closure/src/util/clex.lisp,v
retrieving revision 1.3
diff -u -u -r1.3 clex.lisp
--- src/util/clex.lisp	13 Mar 2005 18:03:57 -0000	1.3
+++ src/util/clex.lisp	28 Jan 2006 22:02:33 -0000
@@ -27,7 +27,7 @@
 ;;;  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 (defpackage :clex
-  (:use :glisp)
+  (:use :glisp :runes)
   (:export
    #:deflexer #:backup #:begin #:initial #:bag))
 
Index: src/util/lalr.lisp
===================================================================
RCS file: /project/closure/cvsroot/closure/src/util/lalr.lisp,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 lalr.lisp
--- src/util/lalr.lisp	22 Jul 2002 02:27:19 -0000	1.1.1.1
+++ src/util/lalr.lisp	28 Jan 2006 22:02:33 -0000
@@ -7,7 +7,7 @@
 ;;;  (c) 1988 Mark Johnson
 
 (defpackage :lalr
-  (:use :glisp)
+  (:use :glisp :runes)
   (:export #:DEFINE-GRAMMAR))
 
 (in-package :LALR)
Index: src/util/xterm.lisp
===================================================================
RCS file: /project/closure/cvsroot/closure/src/util/xterm.lisp,v
retrieving revision 1.2
diff -u -u -r1.2 xterm.lisp
--- src/util/xterm.lisp	13 Mar 2005 18:03:58 -0000	1.2
+++ src/util/xterm.lisp	28 Jan 2006 22:02:33 -0000
@@ -28,7 +28,7 @@
 
 
 (defpackage :XTERM
-  (:use :glisp)
+  (:use :glisp :runes)
   (:export
    #:open-terminal
    ))


More information about the closure-devel mailing list