dictify reference

main
Matthew Butterick 6 years ago
parent a4802e4203
commit 268c5dacc8

@ -12,10 +12,10 @@
(check-equal? (· p margins) (margin 72 72 72 72))
(check-equal? (· p height) 792.0)
(check-equal? (· p width) 612.0)
(check-equal? (· p resources payload ProcSet) '("PDF" "Text" "ImageB" "ImageC" "ImageI"))
(check-equal? (· p resources ProcSet) '("PDF" "Text" "ImageB" "ImageC" "ImageI"))
(check-equal? (· p dictionary payload Type) "Page")
(check-equal? (· p dictionary payload MediaBox) '(0 0 612.0 792.0))
(check-true (is-a? (· p dictionary payload Contents) PDFReference))
(check-true (is-a? (· p dictionary payload Resources) PDFReference))
#;(check-true (is-a? (· p dictionary payload Parent) PDFReference))
(check-equal? (· p dictionary Type) "Page")
(check-equal? (· p dictionary MediaBox) '(0 0 612.0 792.0))
(check-true (is-a? (· p dictionary Contents) PDFReference))
(check-true (is-a? (· p dictionary Resources) PDFReference))
#;(check-true (is-a? (· p dictionary Parent) PDFReference))

@ -2,14 +2,23 @@
(require racket/class
racket/match
racket/port
racket/dict
racket/private/generic-methods
"core.rkt"
"object.rkt"
"zlib.rkt")
(provide PDFReference)
(define dictable<%>
(interface* ()
([(generic-property gen:dict)
(generic-method-table gen:dict
(define (dict-ref refobj key [thunk #f]) (send refobj get-key key))
(define (dict-set! refobj key val) (send refobj set-key! key))
(define (dict-update! refobj key updater [failure-result #f]) (send refobj update-key! key updater)))])))
(define PDFReference
(class object%
(class* object% (dictable<%>)
(super-new)
(init-field [(@id id)]
[(@payload payload) (make-hasheq)])

Loading…
Cancel
Save