Ignore:
Timestamp:
04/15/10 14:54:55 (13 years ago)
Author:
Mark Evenson
Message:

Move pathname functions to EXT; implement DEFSETF for URL pathnames.

Implemented DEFSETF functions for HOST, AUTHORITY, QUERY, and FRAGMENT
sections of URL pathname.

Moved PATHNAME-JAR-P and PATHNAME-URL-P to EXT.

EXT::%INVALIDATE-NAMESTRING resets the namestring after changing the
internal structure. Having to monkey around with the internal
structure of Pathname is just wrong: we should implement the get/set
accessor pattern in Java even though it would make the code more
verbose.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/pathnames.lisp

    r12607 r12617  
    434434            :format-control "~S cannot be converted to a pathname."
    435435            :format-arguments (list thing)))))
     436
     437
     438;;; Functions for dealing with URL Pathnames
     439
     440(in-package :extensions)
     441
     442(defun url-pathname-scheme (p)
     443  (unless (pathname-url-p p)
     444    (error "~A is not a URL pathname." p))
     445  (getf (pathname-host p) :scheme))
     446
     447(defun set-url-pathname-scheme (p v)
     448  (unless (pathname-url-p p)
     449    (error "~A is not a URL pathname." p))
     450  (let ((host (pathname-host p)))
     451    (setf (getf host :scheme) v))
     452  (%invalidate-namestring p))
     453
     454(defsetf url-pathname-scheme set-url-pathname-scheme)
     455
     456(defun url-pathname-authority (p)
     457  (unless (pathname-url-p p)
     458    (error "~A is not a URL pathname." p))
     459  (getf (pathname-host p) :authority))
     460
     461(defun set-url-pathname-authority (p v)
     462  (unless (pathname-url-p p)
     463    (error "~A is not a URL pathname." p))
     464  (let ((host (pathname-host p)))
     465    (setf (getf host :authority) v))
     466  (%invalidate-namestring p))
     467
     468(defsetf url-pathname-authority set-url-pathname-authority)
     469
     470(defun url-pathname-query (p)
     471  (unless (pathname-url-p p)
     472    (error "~A is not a URL pathname." p))
     473  (getf (pathname-host p) :query))
     474
     475(defun set-url-pathname-query (p v)
     476  (unless (pathname-url-p p)
     477    (error "~A is not a URL pathname." p))
     478  (let ((host (pathname-host p)))
     479    (setf (getf host :query) v))
     480  (%invalidate-namestring p))
     481
     482(defsetf url-pathname-query set-url-pathname-query)
     483
     484(defun url-pathname-fragment (p)
     485  (unless (pathname-url-p p)
     486    (error "~A is not a URL pathname." p))
     487  (getf (pathname-host p) :fragment))
     488
     489(defun set-url-pathname-fragment (p v)
     490  (unless (pathname-url-p p)
     491    (error "~A is not a URL pathname." p))
     492  (let ((host (pathname-host p)))
     493    (setf (getf host :fragment) v))
     494  (%invalidate-namestring p))
     495
     496(defsetf url-pathname-query set-url-pathname-fragment)
     497
     498(export '(url-pathname-scheme
     499          url-pathname-authority
     500          url-pathname-query
     501          url-pathname-fragment)
     502        'ext)
Note: See TracChangeset for help on using the changeset viewer.