Make a `resource' struct so it is identifiable.

(Also, change a `define-struct' to a `struct'.)

original commit: 787f3151de5f803fa5b54e6a4d4d2219c72d0b4c
This commit is contained in:
Eli Barzilay 2011-12-26 13:29:37 -05:00
parent 73784d91d9
commit 65e44be261
2 changed files with 7 additions and 3 deletions

View File

@ -164,7 +164,10 @@
;; `#:exists' determines what happens when the render destination exists, it
;; can be one of: #f (do nothing), 'delete-file (delete if a file exists, error
;; if exists as a directory)
(provide resource)
(provide resource resource?)
;; use a struct to make resources identifiable as such
(struct resource (url) #:constructor-name make-resource
#:property prop:procedure 0 #:omit-define-syntaxes)
(define (resource path0 renderer #:exists [exists 'delete-file])
(define (bad reason) (error 'resource "bad path, ~a: ~e" reason path0))
(unless (string? path0) (bad "must be a string"))
@ -208,7 +211,7 @@
[(#f) (relativize filename dirpathlist (rendered-dirpath))]
[(#t) (force absolute-url)]
[else (error 'resource "bad absolute flag value: ~e" absolute?)]))
url)
(make-resource url))
;; a convenient utility to create renderers from some output function (like
;; `output-xml' or `display') and some content

View File

@ -78,7 +78,8 @@
;; Structs for xml data: elements, literals, entities
(provide make-element)
(define-struct element (tag attrs body [cache #:auto #:mutable])
(struct element (tag attrs body [cache #:auto #:mutable])
#:constructor-name make-element
#:transparent #:omit-define-syntaxes #:auto-value #f
#:property prop:procedure
(lambda (e)