Changeset 532
- Timestamp:
- Feb 13, 2004, 10:17:27 AM (21 years ago)
- File:
-
- 1 edited
-
trunk/ccl/examples/name-translation.lisp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ccl/examples/name-translation.lisp
r186 r532 44 44 (define-special-objc-word "CF") 45 45 (define-special-objc-word "CMYK") 46 (define-special-objc-word "MIME") 46 47 (define-special-objc-word "DR") 47 48 (define-special-objc-word "EPS") … … 52 53 (define-special-objc-word "HTML") 53 54 (define-special-objc-word "HTTP") 55 (define-special-objc-word "HTTPS") 54 56 (define-special-objc-word "ID") 55 57 (define-special-objc-word "NS") 58 (define-special-objc-word "MIME") 56 59 (define-special-objc-word "PDF") 57 60 (define-special-objc-word "PNG") 61 (define-special-objc-word "QD") 58 62 (define-special-objc-word "RGB") 59 63 (define-special-objc-word "RTFD") … … 166 170 167 171 168 #|169 ;;; Convert an ObjC message to a corresponding Lisp generic function name170 ;;; Example: "nextEventMatchingMask:untilDate:inMode:dequeue:" ==>171 ;;; next-event-matching-mask$until-date$in-mode$dequeue$172 173 (defun compute-objc-to-lisp-method (str)174 (symbol-concatenate175 (mapcar #'string176 (mapcar #'compute-lisp-name177 (split-if-char #\$178 (substitute #\$ #\: str)179 :after)))))180 181 182 ;;; Convert a Lisp generic function name to an ObjC message183 ;;; Example: next-event-matching-mask$until-date$in-mode$dequeue$ ==>184 ;;; "nextEventMatchingMask:untilDate:inMode:dequeue:"185 186 (defun compute-lisp-to-objc-method (sym)187 (apply #'cstring-cat188 (mapcar #'(lambda (s)189 (nstring-downcase (compute-objc-class-name s)190 :start 0 :end 1))191 (split-if-char #\: (substitute #\: #\$ (string sym)) :after))))192 |#193 194 195 172 ;;; Convert an ObjC method selector to a set of Lisp keywords 196 173 ;;; Example: "nextEventMatchingMask:untilDate:inMode:dequeue:" ==> … … 302 279 303 280 304 #|305 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;306 ;;;; Generic Function / Message Name Translation ;;;;307 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;308 309 ;;; Hash tables for caching method name translations310 311 (defvar *lisp-method-table* (make-hash-table :test 'equal))312 (defvar *objc-method-table* (make-hash-table :test 'equal))313 314 315 ;;; Define a hard-wired method translation (if the automatic316 ;;; translation doesn't apply)317 318 (defmacro define-method-translation (method-name gf-name)319 (let ((method-name-temp (gensym))320 (gf-name-temp (gensym))321 (old-method-name-temp (gensym))322 (old-gf-name-temp (gensym)))323 `(let* ((,method-name-temp ',method-name)324 (,gf-name-temp ',gf-name)325 (,old-method-name-temp326 (gethash ,method-name-temp *lisp-method-table*))327 (,old-gf-name-temp328 (gethash ,gf-name-temp *objc-method-table*)))329 (remhash ,old-method-name-temp *lisp-method-table*)330 (remhash ,old-gf-name-temp *objc-method-table*)331 (setf (gethash ,gf-name-temp *objc-method-table*) ,method-name-temp)332 (setf (gethash ,method-name-temp *lisp-method-table*) ,gf-name-temp)333 (values))))334 335 336 ;;; Translate an ObjC method into a Lisp generic function name337 338 (defun objc-to-lisp-gf-name (method-name)339 (let ((gf-name340 (or (gethash method-name *lisp-method-table*)341 (compute-objc-to-lisp-method method-name))))342 (setf (gethash gf-name *objc-method-table*) method-name)343 (setf (gethash method-name *lisp-method-table*) gf-name)))344 345 346 ;;; Translate a Lisp generic function name into an ObjC method347 348 (defun lisp-to-objc-message (gf-name)349 (let ((method-name350 (or (gethash gf-name *objc-method-table*)351 (compute-lisp-to-objc-method gf-name))))352 (setf (gethash method-name *lisp-method-table*) gf-name)353 (setf (gethash gf-name *objc-method-table*) method-name)))354 355 |#356 357 281 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 358 282 ;;;; Message Keyword Translation ;;;;
Note:
See TracChangeset
for help on using the changeset viewer.
