Do not use records to aid with serialization in the future.
This commit is contained in:
parent
c13db943b5
commit
9107d33eac
2 changed files with 38 additions and 14 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -8,3 +8,4 @@ bbstool-static
|
||||||
*.c
|
*.c
|
||||||
output/
|
output/
|
||||||
members/
|
members/
|
||||||
|
hackerbase
|
||||||
|
|
|
@ -51,7 +51,11 @@
|
||||||
|
|
||||||
(import scheme
|
(import scheme
|
||||||
(chicken base)
|
(chicken base)
|
||||||
(chicken format))
|
(chicken format)
|
||||||
|
util-tag)
|
||||||
|
|
||||||
|
;; Unique tag
|
||||||
|
(define TAG-BANK-TRANSACTION (make-tag bank-transaction))
|
||||||
|
|
||||||
;; Bank account is represented as a list with list with the following
|
;; Bank account is represented as a list with list with the following
|
||||||
;; elements: list of transactions, account number, bank code. This
|
;; elements: list of transactions, account number, bank code. This
|
||||||
|
@ -74,20 +78,39 @@
|
||||||
(cons (cons transaction (car account))
|
(cons (cons transaction (car account))
|
||||||
(cdr account)))
|
(cdr account)))
|
||||||
|
|
||||||
;; Creates a new bank transaction.
|
;; Creates new record
|
||||||
(define-record bank-transaction id date amount currency varsym message type account bank specsym)
|
(define (make-bank-transaction . args)
|
||||||
|
(apply vector (cons TAG-BANK-TRANSACTION args)))
|
||||||
|
|
||||||
(set-record-printer! bank-transaction
|
;; Defines one accessor
|
||||||
(lambda (tr out)
|
(define-syntax define-accessor
|
||||||
(fprintf out "#<transaction ~A ~A ~A ~A ~A ~A ~A ~A>"
|
(syntax-rules ()
|
||||||
(bank-transaction-id tr)
|
((_ num)
|
||||||
(bank-transaction-date tr)
|
(void))
|
||||||
(bank-transaction-amount tr)
|
((_ num acc accs ...)
|
||||||
(bank-transaction-currency tr)
|
(begin
|
||||||
(bank-transaction-varsym tr)
|
(define (acc t)
|
||||||
(bank-transaction-message tr)
|
(vector-ref t num))
|
||||||
(bank-transaction-type tr)
|
(define-accessor (add1 num) accs ...)))))
|
||||||
(bank-transaction-specsym tr))))
|
|
||||||
|
;; Defines all accessors
|
||||||
|
(define-syntax define-accessors
|
||||||
|
(syntax-rules ()
|
||||||
|
((_ accs ...)
|
||||||
|
(define-accessor 1 accs ...))))
|
||||||
|
|
||||||
|
;; Define accessors for bank-transaction
|
||||||
|
(define-accessors
|
||||||
|
bank-transaction-id
|
||||||
|
bank-transaction-date
|
||||||
|
bank-transaction-amount
|
||||||
|
bank-transaction-currency
|
||||||
|
bank-transaction-varsym
|
||||||
|
bank-transaction-message
|
||||||
|
bank-transaction-type
|
||||||
|
bank-transaction-account
|
||||||
|
bank-transaction-bank
|
||||||
|
bank-transaction-specsym)
|
||||||
|
|
||||||
;; Returns true if given acc/bc is in the list of accounts
|
;; Returns true if given acc/bc is in the list of accounts
|
||||||
(define (bank-accounts-member? bas acc bc)
|
(define (bank-accounts-member? bas acc bc)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue