- Timestamp:
- May 20, 2007, 9:10:26 AM (18 years ago)
- File:
-
- 1 edited
-
branches/ide-1.0/ccl/examples/objc-support.lisp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/ide-1.0/ccl/examples/objc-support.lisp
r6566 r6585 153 153 154 154 155 (defun %make-nsstring-from-c-string (s) 156 (#/initWithCString: (#/alloc ns:ns-string) s)) 157 158 (defun %make-nsstring-from-utf32-string (s nbytes) 159 (#/initWithBytes:length:encoding: (#/alloc ns:ns-string) 160 s 161 nbytes 162 #+big-endian-target #x98000100 163 #+little-endian-target #x9c000100)) 155 (defun %make-nsstring-from-utf8-c-string (s) 156 (#/initWithUTF8String: (#/alloc ns:ns-string) s)) 157 164 158 165 159 (defun retain-objc-instance (instance) … … 173 167 (#/release p)) 174 168 175 ;;; This can fail if the nsstring contains non-8-bit characters. 169 170 #-ascii-only 171 (defun lisp-string-from-nsstring (nsstring) 172 ;; The NSData object created here is autoreleased. 173 (let* ((data (#/dataUsingEncoding:allowLossyConversion: 174 nsstring 175 #+little-endian-target #x9c000100 176 #+big-endian-target #x98000100 177 nil))) 178 (unless (%null-ptr-p data) 179 (let* ((nbytes (#/length data)) 180 (string (make-string (ash nbytes -2)))) 181 ;; BLT the 4-byte code-points from the NSData object 182 ;; to the string, return the string. 183 (%copy-ptr-to-ivector (#/bytes data) 0 string 0 nbytes))))) 184 185 186 187 #+ascii-only 176 188 (defun lisp-string-from-nsstring (nsstring) 177 189 (with-macptrs (cstring) … … 206 218 ;;; this condition. 207 219 208 ;;(dbg (format nil "~a" c))220 (dbg (format nil "~a" c)) 209 221 ;;(#_NSLog #@"Lisp exception: %@" :id (%make-nsstring (format nil "~a" c))) 210 222 (make-instance 'ns-lisp-exception :condition c))
Note:
See TracChangeset
for help on using the changeset viewer.
