diff --git a/pitfall/pitfall/page-test.rkt b/pitfall/pitfall/page-test.rkt index e50f057b..d4390a0c 100644 --- a/pitfall/pitfall/page-test.rkt +++ b/pitfall/pitfall/page-test.rkt @@ -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)) \ No newline at end of file +(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)) \ No newline at end of file diff --git a/pitfall/pitfall/reference.rkt b/pitfall/pitfall/reference.rkt index 2118b996..c002b7de 100644 --- a/pitfall/pitfall/reference.rkt +++ b/pitfall/pitfall/reference.rkt @@ -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)])