summaryrefslogtreecommitdiff
path: root/Lisp/name-conversion.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'Lisp/name-conversion.lisp')
-rw-r--r--Lisp/name-conversion.lisp24
1 files changed, 24 insertions, 0 deletions
diff --git a/Lisp/name-conversion.lisp b/Lisp/name-conversion.lisp
index 2386bfb..e51aa14 100644
--- a/Lisp/name-conversion.lisp
+++ b/Lisp/name-conversion.lisp
@@ -120,6 +120,17 @@
(name-hyphened->mixed-case (symbol-name slot-name) case-convention))
+(defun foreign-slot-name->slot-name (foreign-slot-name)
+ (let ((*package* (find-package '#:objective-c-classes)))
+ (export-and-return (read-from-string (name-underscored->hyphened
+ (name-camel-case->hyphened
+ foreign-slot-name))))))
+
+
+(defun name-underscored->hyphened (string)
+ (substitute #\- #\_ string))
+
+
(defun name-hyphened->underscored (string)
(substitute #\_ #\- string))
@@ -164,5 +175,18 @@
(subseq (string-capitalise-lower-case string) 1))))
+(defun name-camel-case->hyphened (string)
+ (with-output-to-string (out)
+ (loop for previous-position = 0 then word-start
+ for word-start = (position-if #'upper-case-p
+ string
+ :start (1+ previous-position))
+ do (format out "~(~A~)" (subseq string
+ previous-position
+ (or word-start (length string))))
+ while word-start
+ do (format out "-"))))
+
+
(defun name-hyphened->nerd-caps (string)
(remove #\- (string-capitalise-lower-case string)))