Add tag util module.
This commit is contained in:
parent
41080d06c7
commit
79aab17731
3 changed files with 78 additions and 21 deletions
16
src/Makefile
16
src/Makefile
|
@ -43,7 +43,7 @@ BBSTOOL-DEPS=bbstool.scm testing.import.scm listing.import.scm \
|
|||
bank-fio.import.scm members-payments.import.scm \
|
||||
web-static.import.scm environment.import.scm \
|
||||
mailman.import.scm util-set-list.import.scm \
|
||||
util-time.import.scm
|
||||
util-time.import.scm util-tag.import.scm
|
||||
|
||||
BBSTOOL-OBJS=bbstool.o testing.o listing.o month.o period.o ansi.o \
|
||||
dictionary.o command-line.o members-base.o utils.o primes.o \
|
||||
|
@ -51,7 +51,7 @@ BBSTOOL-OBJS=bbstool.o testing.o listing.o month.o period.o ansi.o \
|
|||
members-print.o member-fees.o members-dir.o csv-simple.o \
|
||||
bank-account.o bank-fio.o members-payments.o member-parser.o \
|
||||
web-static.o environment.o mailman.o util-set-list.o \
|
||||
util-time.o
|
||||
util-time.o util-tag.o
|
||||
|
||||
.PHONY: imports
|
||||
imports: $(BBSTOOL-DEPS)
|
||||
|
@ -217,7 +217,7 @@ bank-fio.import.scm: $(BANK-FIO-SOURCES)
|
|||
MEMBERS-PAYMENTS-SOURCES=members-payments.scm bank-account.import.scm \
|
||||
dictionary.import.scm member-fees.import.scm \
|
||||
period.import.scm configuration.import.scm utils.import.scm \
|
||||
progress.import.scm
|
||||
progress.import.scm bank-fio.import.scm
|
||||
|
||||
members-payments.o: members-payments.import.scm
|
||||
members-payments.import.scm: $(MEMBERS-PAYMENTS-SOURCES)
|
||||
|
@ -235,12 +235,13 @@ environment.o: environment.import.scm
|
|||
environment.import.scm: $(ENVIRONMENT-SOURCES)
|
||||
|
||||
MAILMAN-SOURCES=mailman.scm utils.import.scm progress.import.scm \
|
||||
util-set-list.scm
|
||||
util-set-list.import.scm
|
||||
|
||||
mailman.o: mailman.import.scm
|
||||
mailman.import.scm: $(MAILMAN-SOURCES)
|
||||
|
||||
UTIL-SET-LIST-SOURCES=util-set-list.scm testing.import.scm
|
||||
UTIL-SET-LIST-SOURCES=util-set-list.scm testing.import.scm \
|
||||
util-tag.import.scm
|
||||
|
||||
util-set-list.o: util-set-list.import.scm
|
||||
util-set-list.import.scm: $(UTIL-SET-LIST-SOURCES)
|
||||
|
@ -249,3 +250,8 @@ UTIL-TIME-SOURCES=util-time.scm
|
|||
|
||||
util-time.o: util-time.import.scm
|
||||
util-time.import.scm: $(UTIL-TIME-SOURCES)
|
||||
|
||||
UTIL-TAG-SOURCES=util-tag.scm
|
||||
|
||||
util-tag.o: util-tag.import.scm
|
||||
util-tag.import.scm: $(UTIL-TAG-SOURCES)
|
||||
|
|
|
@ -53,24 +53,11 @@
|
|||
|
||||
(import scheme
|
||||
(chicken base)
|
||||
(chicken string)
|
||||
(chicken random)
|
||||
testing)
|
||||
testing
|
||||
util-tag)
|
||||
|
||||
;; Tag used for identifying list sets from this module
|
||||
(define TAG-LSET
|
||||
(string-intersperse
|
||||
(cons "LSET-"
|
||||
(map (lambda (n)
|
||||
(substring
|
||||
(number->string
|
||||
(+ 256 (char->integer n))
|
||||
16)
|
||||
1))
|
||||
(string->list
|
||||
(random-bytes
|
||||
(make-string 8)))))
|
||||
""))
|
||||
(define TAG-LSET (make-tag LSET))
|
||||
|
||||
;; Creates new list set using given equality procedure
|
||||
(define (make-lset . equality?)
|
||||
|
|
64
src/util-tag.scm
Normal file
64
src/util-tag.scm
Normal file
|
@ -0,0 +1,64 @@
|
|||
;;
|
||||
;; util-tag.scm
|
||||
;;
|
||||
;; Implementation of data structure tags.
|
||||
;;
|
||||
;; ISC License
|
||||
;;
|
||||
;; Copyright 2023 Brmlab, z.s.
|
||||
;; Dominik Pantůček <dominik.pantucek@trustica.cz>
|
||||
;;
|
||||
;; Permission to use, copy, modify, and/or distribute this software
|
||||
;; for any purpose with or without fee is hereby granted, provided
|
||||
;; that the above copyright notice and this permission notice appear
|
||||
;; in all copies.
|
||||
;;
|
||||
;; THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
||||
;; WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
||||
;; WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
|
||||
;; AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
|
||||
;; CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
;; OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
;; NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
;; CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
;;
|
||||
|
||||
(declare (unit util-tag))
|
||||
|
||||
(module
|
||||
util-tag
|
||||
(
|
||||
make-tag
|
||||
util-tag-make
|
||||
)
|
||||
|
||||
(import scheme
|
||||
(chicken string)
|
||||
(chicken random))
|
||||
|
||||
;; Syntactic wrapper to allow easy tag creation
|
||||
(define-syntax make-tag
|
||||
(syntax-rules ()
|
||||
((_ tag)
|
||||
(util-tag-make 'tag))))
|
||||
|
||||
;; Creates a tag symbol based on symbol
|
||||
(define (util-tag-make sym)
|
||||
(string->symbol
|
||||
(string-intersperse
|
||||
(cons
|
||||
(symbol->string sym)
|
||||
(cons
|
||||
"-"
|
||||
(map (lambda (n)
|
||||
(substring
|
||||
(number->string
|
||||
(+ 256 (char->integer n))
|
||||
16)
|
||||
1))
|
||||
(string->list
|
||||
(random-bytes
|
||||
(make-string 8))))))
|
||||
"")))
|
||||
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue