Skip to content

Commit a56e96b

Browse files
committed
[fix] better handle readtable-case :preserve and :invert
1 parent 1d5332e commit a56e96b

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/arg-list.lisp

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ If the readtable case is :INVERT, it inverts the case of the name and returns it
5858
(prefinal-string (string-upcase (format nil "~{~A~^-~}" words))))
5959
(ecase (readtable-case *readtable*)
6060
((:upcase :downcase)
61+
;; FIXME: This may not work correctly with :downcase
6162
(remove-if (lambda (ch)
6263
(char= ch #\_))
6364
prefinal-string

src/pythonizers.lisp

+18-1
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,24 @@ takes place."))
382382
into python-name
383383
result-type string)
384384
;; Use keywords as if to indicate keyword python argument name
385-
(finally (return python-name))))))
385+
(finally
386+
(return
387+
(ecase (readtable-case *readtable*)
388+
((:upcase :downcase)
389+
;; FIXME: This may not work correctly with :downcase
390+
python-name)
391+
((:perserve)
392+
symbol-name)
393+
((:invert)
394+
;; What is mixed stays mixed.
395+
;; All uppercase becomes lowercase
396+
;; All lowercase becomes uppercase
397+
(cond ((upper-case-string-p symbol-name)
398+
(string-downcase symbol-name))
399+
((lower-case-string-p symbol-name)
400+
(string-upcase symbol-name))
401+
(t
402+
symbol-name))))))))))
386403

387404
(defmethod pythonize ((o symbol))
388405
(if (null o)

0 commit comments

Comments
 (0)