From b69d3fe38a90001475a3217ee22ef8cd8b4175fb Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Sun, 12 Jul 2020 00:12:44 +0800 Subject: [PATCH] [html-style-info] use srfi-9 records for --- gnucash/report/html-style-info.scm | 56 ++++++++++++------------------ 1 file changed, 22 insertions(+), 34 deletions(-) diff --git a/gnucash/report/html-style-info.scm b/gnucash/report/html-style-info.scm index 8c6da4aff1..0da74ca2d9 100644 --- a/gnucash/report/html-style-info.scm +++ b/gnucash/report/html-style-info.scm @@ -22,6 +22,7 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (use-modules (ice-9 match)) +(use-modules (srfi srfi-9)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; class @@ -38,31 +39,36 @@ ;; attribute : single attribute-value pair in a list ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(define-record-type + (make-html-markup-style-info-internal tag attributes inheritable?) + html-markup-style-info? + (tag style-info-tag style-info-set-tag) + (attributes style-info-attributes style-info-set-attributes) + (inheritable? style-info-inheritable? style-info-set-inheritable?)) -(define - (make-record-type "" - '(tag - attributes - inheritable?))) - -(define gnc:html-markup-style-info? - (record-predicate )) - -(define gnc:make-html-markup-style-info-internal - (record-constructor )) +(define gnc:make-html-markup-style-info-internal make-html-markup-style-info-internal) +(define gnc:html-markup-style-info? html-markup-style-info?) +(define gnc:html-markup-style-info-tag style-info-tag) +(define gnc:html-markup-style-info-set-tag! style-info-set-tag) +(define gnc:html-markup-style-info-attributes style-info-attributes) +(define gnc:html-markup-style-info-set-attributes! style-info-set-attributes) +(define gnc:html-markup-style-info-inheritable? style-info-inheritable?) +(define gnc:html-markup-style-info-set-inheritable?! style-info-set-inheritable?) (define (gnc:make-html-markup-style-info . rest) - (let ((retval (gnc:make-html-markup-style-info-internal - #f (make-hash-table) #t))) + (let ((retval (gnc:make-html-markup-style-info-internal #f (make-hash-table) #t))) (apply gnc:html-markup-style-info-set! retval rest) retval)) (define (gnc:html-markup-style-info-set! style . rest) (let loop ((arglist rest)) (match arglist - (('attribute (key . val) . rest) - (gnc:html-markup-style-info-set-attribute! - style key (and (pair? val) (car val))) + (('attribute (key val) . rest) + (gnc:html-markup-style-info-set-attribute! style key val) + (loop rest)) + + (('attribute (key) . rest) + (gnc:html-markup-style-info-set-attribute! style key #f) (loop rest)) ((field value . rest) @@ -71,24 +77,6 @@ (else style)))) -(define gnc:html-markup-style-info-tag - (record-accessor 'tag)) - -(define gnc:html-markup-style-info-set-tag! - (record-modifier 'tag)) - -(define gnc:html-markup-style-info-attributes - (record-accessor 'attributes)) - -(define gnc:html-markup-style-info-set-attributes! - (record-modifier 'attributes)) - -(define gnc:html-markup-style-info-inheritable? - (record-accessor 'inheritable?)) - -(define gnc:html-markup-style-info-set-inheritable?! - (record-modifier 'inheritable?)) - (define (gnc:html-markup-style-info-set-attribute! info attr val) (hash-set! (gnc:html-markup-style-info-attributes info) attr val))