[engine-utilities] deprecate split utility functions

These functions are obsolete with srfi-1
This commit is contained in:
Christopher Lam 2019-02-14 20:59:27 +08:00
parent 9ba0d9658d
commit 972562421e
3 changed files with 16 additions and 17 deletions

View File

@ -93,33 +93,34 @@
(hashx-set! account-hash account-assoc table account value)) (hashx-set! account-hash account-assoc table account value))
;; Splits ;; Splits
(export split-same?) (export split-same?) ;deprecated
(export split-in-list?) (export split-in-list?) ;deprecated
(define (split-same? s1 s2) (define (split-same? s1 s2)
(issue-deprecation-warning "split-same? is deprecated. use equal? instead.")
(or (eq? s1 s2) (or (eq? s1 s2)
(string=? (gncSplitGetGUID s1) (gncSplitGetGUID s2)))) (string=? (gncSplitGetGUID s1) (gncSplitGetGUID s2))))
(define split-in-list? (define split-in-list?
(lambda (split splits) (lambda (split splits)
(issue-deprecation-warning "split-in-list? is deprecated. use member instead.")
(cond (cond
((null? splits) #f) ((null? splits) #f)
((split-same? (car splits) split) #t) ((split-same? (car splits) split) #t)
(else (split-in-list? split (cdr splits)))))) (else (split-in-list? split (cdr splits))))))
;; Split hashtable. Because we do gncSplitGetGUID so often, it
;; turns out to be a bit quicker to store a (hash, split) pair
;; instead of just the split.
(define (split-assoc split alist) (define (split-assoc split alist)
(issue-deprecation-warning "split-assoc is deprecated. use assoc instead")
(find (lambda (pair) (split-same? (cdr split) (cdr (car pair)))) alist)) (find (lambda (pair) (split-same? (cdr split) (cdr (car pair)))) alist))
(define (split-hash split size) (define (split-hash split size)
(issue-deprecation-warning "split-hash is deprecated. \
internal function -- no srfi-1 equivalent")
(remainder (car split) size)) (remainder (car split) size))
(define (split-hashtable-ref table split) (define (split-hashtable-ref table split)
(issue-deprecation-warning "split-hashtable-ref is deprecated. \
use assoc-ref instead.")
(hashx-ref split-hash split-assoc table (hashx-ref split-hash split-assoc table
(cons (string-hash (gncSplitGetGUID split)) split))) (cons (string-hash (gncSplitGetGUID split)) split)))
(define (split-hashtable-set! table split value) (define (split-hashtable-set! table split value)
(issue-deprecation-warning "split-hashtable-set! is deprecated. \
use assoc-set! instead")
(hashx-set! split-hash split-assoc table (hashx-set! split-hash split-assoc table
(cons (string-hash (gncSplitGetGUID split)) split) value)) (cons (string-hash (gncSplitGetGUID split)) split) value))

View File

@ -73,13 +73,10 @@
(export account-hashtable-ref) (export account-hashtable-ref)
(export account-hashtable-set!) (export account-hashtable-set!)
(export split-same?) (export split-same?) ;deprecated
(export split-in-list?) (export split-in-list?) ;deprecated
(export split-hashtable-ref) ;deprecated
(export split-same?) (export split-hashtable-set!) ;deprecated
(export split-in-list?)
(export split-hashtable-ref)
(export split-hashtable-set!)
(export gnc:split-structure) (export gnc:split-structure)
(export gnc:make-split-scm) (export gnc:make-split-scm)

View File

@ -11,6 +11,7 @@
(test test-split-in-list?)) (test test-split-in-list?))
(define (test-split-in-list?) (define (test-split-in-list?)
;; this test suite tests deprecated functions.
(let* ((env (create-test-env)) (let* ((env (create-test-env))
(today (current-time)) (today (current-time))
(account-alist (env-create-test-accounts env)) (account-alist (env-create-test-accounts env))