-
Notifications
You must be signed in to change notification settings - Fork 0
/
lispify.lisp
81 lines (75 loc) · 3.76 KB
/
lispify.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
;;; Copyright (c) 2022 Max-Gerd Retzlaff <mgr@matroid.org>, Datagraph GmbH.
;;; Copyright (c) 2016 Fernando Borretti <eudoxiahp@gmail.com>.
;;; Distributed under the terms of the GNU General Public License, Version 2.0,
;;; see file LICENSE in the top level directory of this repository.
;;; This file was automatically generated by SWIG (http://www.swig.org).
;;; Version 3.0.12
;;;
;;; Do not make changes to this file unless you know what you are doing--modify
;;; the SWIG interface file instead.
(cl:in-package :ndbapi.ffi)
;;; SWIG wrapper code starts here
(cl:defmacro defanonenum (cl:&body enums)
"Converts anonymous enums to defconstants."
`(cl:progn ,@(cl:loop for value in enums
for index = 0 then (cl:1+ index)
when (cl:listp value) do (cl:setf index (cl:second value)
value (cl:first value))
collect `(cl:defconstant ,value ,index))))
;; This is the default swig-lispify but with strip-prefix added,
;; which is used to strip the mdb_/MDB_ prefixes. (20220914 mgr)
;; This modification was written by Fernando Borretti as part
;; of liblmdb, available at https://github.com/antimer/liblmdb.
;; It was further modified by Max-Gerd Retzlaff to support more characters.
(cl:eval-when (:compile-toplevel :load-toplevel)
(cl:unless (cl:fboundp 'swig-lispify)
(cl:defun swig-lispify (name flag cl:&optional (package cl:*package*))
(cl:labels ((helper (lst last rest cl:&aux (c (cl:car lst)))
(cl:cond
((cl:null lst)
rest)
((cl:upper-case-p c)
(helper (cl:cdr lst) 'upper
(cl:case last
((lower digit) (cl:list* c #\- rest))
(cl:t (cl:cons c rest)))))
((cl:lower-case-p c)
(helper (cl:cdr lst) 'lower (cl:cons (cl:char-upcase c) rest)))
((cl:digit-char-p c)
(helper (cl:cdr lst) 'digit
(cl:case last
((upper lower) (cl:list* c #\- rest))
(cl:t (cl:cons c rest)))))
((cl:char-equal c #\_)
(helper (cl:cdr lst) '() (cl:cons #\- rest)))
((cl:char-equal c #\-)
(helper (cl:cdr lst) '() (cl:cons c rest)))
((cl:char-equal c #\:)
(helper (cl:cdr lst) '() (cl:cons c rest)))
((cl:char-equal c #\=)
(helper (cl:cdr lst) '() (cl:cons c rest)))
((cl:char-equal c #\/)
(helper (cl:cdr lst) '() (cl:cons c rest)))
((cl:char-equal c #\%)
(helper (cl:cdr lst) '() (cl:cons c rest)))
(cl:t
(cl:error "Invalid character: ~A" c))))
(strip-prefix (prefix string)
(cl:if (cl:search prefix string)
(cl:subseq string (cl:length prefix))
string)))
(cl:let ((fix (cl:case flag
((constant enumvalue) "+")
(variable "*")
(cl:t ""))))
(cl:intern
(cl:concatenate
'cl:string
fix
(cl:nreverse (helper (cl:concatenate 'cl:list
(strip-prefix "mdb_"
(strip-prefix "MDB_" name)))
cl:nil cl:nil))
fix)
package))))))
;;; SWIG wrapper code ends here