Changeset 532


Ignore:
Timestamp:
Feb 13, 2004, 10:17:27 AM (21 years ago)
Author:
beer
Message:

Added a few more special ObjC words I've come across
Removed old generic function name-mangling code, since we're no going that route

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ccl/examples/name-translation.lisp

    r186 r532  
    4444(define-special-objc-word "CF")
    4545(define-special-objc-word "CMYK")
     46(define-special-objc-word "MIME")
    4647(define-special-objc-word "DR")
    4748(define-special-objc-word "EPS")
     
    5253(define-special-objc-word "HTML")
    5354(define-special-objc-word "HTTP")
     55(define-special-objc-word "HTTPS")
    5456(define-special-objc-word "ID")
    5557(define-special-objc-word "NS")
     58(define-special-objc-word "MIME")
    5659(define-special-objc-word "PDF")
    5760(define-special-objc-word "PNG")
     61(define-special-objc-word "QD")
    5862(define-special-objc-word "RGB")
    5963(define-special-objc-word "RTFD")
     
    166170
    167171
    168 #|
    169 ;;; Convert an ObjC message to a corresponding Lisp generic function name
    170 ;;; 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-concatenate
    175    (mapcar #'string 
    176            (mapcar #'compute-lisp-name
    177                    (split-if-char #\$
    178                                   (substitute #\$ #\: str)
    179                                   :after)))))
    180 
    181 
    182 ;;; Convert a Lisp generic function name to an ObjC message
    183 ;;; 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-cat
    188          (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 
    195172;;; Convert an ObjC method selector to a set of Lisp keywords
    196173;;; Example: "nextEventMatchingMask:untilDate:inMode:dequeue:" ==>
     
    302279
    303280
    304 #|
    305 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    306 ;;;;              Generic Function / Message Name Translation               ;;;;
    307 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    308 
    309 ;;; Hash tables for caching method name translations
    310 
    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 automatic
    316 ;;; 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-temp
    326              (gethash ,method-name-temp *lisp-method-table*))
    327             (,old-gf-name-temp
    328              (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 name
    337 
    338 (defun objc-to-lisp-gf-name (method-name)
    339   (let ((gf-name
    340          (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 method
    347 
    348 (defun lisp-to-objc-message (gf-name)
    349   (let ((method-name
    350          (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 
    357281;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    358282;;;;                      Message Keyword Translation                       ;;;;
Note: See TracChangeset for help on using the changeset viewer.