summaryrefslogtreecommitdiff
path: root/ebus-racket/3rdparty/bzlib/base/version-case.ss
diff options
context:
space:
mode:
authorYves Fischer <yvesf-git@xapek.org>2016-08-14 19:25:26 +0200
committerYves Fischer <yvesf-git@xapek.org>2016-08-14 19:25:26 +0200
commitcaae83f445935c06cd6aef36f283a4688675278a (patch)
tree5e63cbfd2877195430a8657dcd75f42b6a4d7110 /ebus-racket/3rdparty/bzlib/base/version-case.ss
downloadebus-caae83f445935c06cd6aef36f283a4688675278a.tar.gz
ebus-caae83f445935c06cd6aef36f283a4688675278a.zip
refactored ebus code
Diffstat (limited to 'ebus-racket/3rdparty/bzlib/base/version-case.ss')
-rw-r--r--ebus-racket/3rdparty/bzlib/base/version-case.ss118
1 files changed, 118 insertions, 0 deletions
diff --git a/ebus-racket/3rdparty/bzlib/base/version-case.ss b/ebus-racket/3rdparty/bzlib/base/version-case.ss
new file mode 100644
index 0000000..a9f60d7
--- /dev/null
+++ b/ebus-racket/3rdparty/bzlib/base/version-case.ss
@@ -0,0 +1,118 @@
+#lang scheme/base
+;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; BASE.plt - common routines that are shared by all other bzlib modules
+;;
+;; in a way, base.plt is the most fundamental module of the whole bzlib stack
+;; and as such it also is the lowest level code. We are not likely to
+;; fix the code any time soon, and hence any of the functions here are
+;; explicitly likely to be obsoleted or moved elsewhere.
+;;
+;; Proceed with caution.
+;;
+;;
+;; Bonzai Lab, LLC. All rights reserved.
+;;
+;; Licensed under LGPL.
+;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; version-case.ss - version-based macros
+;; yc 1/18/2010 - first version
+(require (for-syntax scheme/base
+ "version.ss"
+ )
+ "version.ss"
+ )
+
+(define-syntax (+:version stx)
+ (syntax-case stx (between > >= < <= = != else)
+ ((~) #'(void))
+ ((~ (else exp)) #'exp)
+ ((~ ((between min max) exp) rest ...)
+ (version<=? (syntax->datum #'min)
+ (version)
+ (syntax->datum #'max))
+ #'exp)
+ ((~ ((between min max) exp) rest ...)
+ #'(~ rest ...))
+ ((~ ((> v) exp) rest ...)
+ (version>? (version) (syntax->datum #'v))
+ #'exp)
+ ((~ ((> v) exp) rest ...)
+ #'(~ rest ...))
+ ((~ ((>= v) exp) rest ...)
+ (version>=? (version) (syntax->datum #'v))
+ #'exp)
+ ((~ ((>= v) exp) rest ...)
+ #'(~ rest ...))
+ ((~ ((< v) exp) rest ...)
+ (version<? (version) (syntax->datum #'v))
+ #'exp)
+ ((~ ((< v) exp) rest ...)
+ #'(~ rest ...))
+ ((~ ((<= v) exp) rest ...)
+ (version<=? (version) (syntax->datum #'v))
+ #'exp)
+ ((~ ((<= v) exp) rest ...)
+ #'(~ rest ...))
+ ((~ ((= v) exp) rest ...)
+ (version=? (version) (syntax->datum #'v))
+ #'exp)
+ ((~ ((= v) exp) rest ...)
+ #'(~ rest ...))
+ ((~ ((!= v) exp) rest ...)
+ (version!=? (version) (syntax->datum #'v))
+ #'exp)
+ ((~ ((!= v) exp) rest ...)
+ #'(~ rest ...))
+ ))
+
+(define-syntax +:version-between
+ (syntax-rules ()
+ ((~ min max exp otherwise)
+ (+:version ((between min max) exp) (else otherwise)))
+ ))
+
+(define-syntax define-version-if
+ (syntax-rules ()
+ ((~ name comp)
+ (define-syntax name
+ (syntax-rules ()
+ ((~ v exp otherwise)
+ (+:version ((comp v) exp) (else otherwise))))))
+ ))
+
+(define-version-if +:version> >)
+
+(define-version-if +:version>= >=)
+
+(define-version-if +:version< <)
+
+(define-version-if +:version<= <=)
+
+(define-version-if +:version= =)
+
+(define-version-if +:version!= !=)
+
+(define-syntax require/v
+ (syntax-rules ()
+ ((~ (test s1 ...) ...)
+ (+:version (test (require s1 ...)) ...))
+ ))
+
+(define-syntax provide/v
+ (syntax-rules ()
+ ((~ (test s1 ...) ...)
+ (+:version (test (provide s1 ...)) ...))
+ ))
+
+(provide +:version
+ +:version-between
+ +:version>
+ +:version>=
+ +:version<
+ +:version<=
+ +:version=
+ +:version!=
+ require/v
+ provide/v
+ )
+