Skip to content

Commit

Permalink
[fix] better handle readtable-case :preserve and :invert
Browse files Browse the repository at this point in the history
  • Loading branch information
digikar99 committed May 12, 2024
1 parent 1d5332e commit a56e96b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/arg-list.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ If the readtable case is :INVERT, it inverts the case of the name and returns it
(prefinal-string (string-upcase (format nil "~{~A~^-~}" words))))
(ecase (readtable-case *readtable*)
((:upcase :downcase)
;; FIXME: This may not work correctly with :downcase
(remove-if (lambda (ch)
(char= ch #\_))
prefinal-string
Expand Down
19 changes: 18 additions & 1 deletion src/pythonizers.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,24 @@ takes place."))
into python-name
result-type string)
;; Use keywords as if to indicate keyword python argument name
(finally (return python-name))))))
(finally
(return
(ecase (readtable-case *readtable*)
((:upcase :downcase)
;; FIXME: This may not work correctly with :downcase
python-name)
((:perserve)
symbol-name)
((:invert)
;; What is mixed stays mixed.
;; All uppercase becomes lowercase
;; All lowercase becomes uppercase
(cond ((upper-case-string-p symbol-name)
(string-downcase symbol-name))
((lower-case-string-p symbol-name)
(string-upcase symbol-name))
(t
symbol-name))))))))))

(defmethod pythonize ((o symbol))
(if (null o)
Expand Down

0 comments on commit a56e96b

Please sign in to comment.