我需要將碳方法轉化爲可可,並且我無法找到有關碳方法getPtrSize真正做什麼的任何文檔。從我翻譯的代碼看來,它返回的是一個圖像的字節表示,但並不真正與該名稱匹配。有人能給我一個關於這種方法的很好的解釋,或者將我鏈接到描述它的一些文檔。我正在翻譯的代碼是在一個叫做MCL的通用lisp實現中,它有一個通向碳的橋樑(我正在翻譯成CCL,這是一個Cocoa橋的常見lisp實現)。下面是MCL代碼(#_before方法調用意味着它是一個碳法):Carbon方法的可可等價物getPtrSize
(defmethod COPY-CONTENT-INTO ((Source inflatable-icon)
(Destination inflatable-icon))
;; check for size compatibility to avoid disaster
(unless (and (= (rows Source) (rows Destination))
(= (columns Source) (columns Destination))
(= (#_getPtrSize (image Source))
(#_getPtrSize (image Destination))))
(error "cannot copy content of source into destination
inflatable icon: incompatible sizes"))
;; given that they are the same size only copy content
(setf (is-upright Destination) (is-upright Source))
(setf (height Destination) (height Source))
(setf (dz Destination) (dz Source))
(setf (surfaces Destination) (surfaces Source))
(setf (distance Destination) (distance Source))
;; arrays
(noise-map Source) ;; accessor makes array if needed
(noise-map Destination) ;; ;; accessor makes array if needed
(dotimes (Row (rows Source))
(dotimes (Column (columns Source))
(setf (aref (noise-map Destination) Row Column)
(aref (noise-map Source) Row Column))
(setf (aref (altitudes Destination) Row Column)
(aref (altitudes Source) Row Column))))
(setf (connectors Destination)
(mapcar #'copy-instance (connectors Source)))
(setf (visible-alpha-threshold Destination)
(visible-alpha-threshold Source))
;; copy Image: slow byte copy
(dotimes (I (#_getPtrSize (image Source)))
(%put-byte (image Destination) (%get-byte (image Source) i) i))
;; flat texture optimization:
;; do not copy texture-id
;; -> destination should get its own texture id from OpenGL
(setf (is-flat Destination) (is-flat Source))
;; do not compile flat textures: the display list overhead
;; slows things down by about 2x
(setf (auto-compile Destination) (not (is-flat Source)))
;; to make change visible we have to reset the compiled flag
(setf (is-compiled Destination) nil))
這是真的嗎? +1因爲吹我的頭腦。 – 2010-03-08 17:53:53