Changeset 11620


Ignore:
Timestamp:
Jan 16, 2009, 4:44:12 AM (11 years ago)
Author:
rme
Message:

New macros WITH-AUTORELEASED-NSSTRING, WITH-AUTORELEASED-NSSTRINGS.

Delete %make-nsstring-from-utf8-c-string and update %make-nsstring
accordingly.

Move %make-nsstring from objc-runtime.lisp to objc-support.lisp.

In #/reason method on ns-lisp-exception, autorelease returned string.

Location:
trunk/source/objc-bridge
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/objc-bridge/objc-runtime.lisp

    r11589 r11620  
    30293029        (release-autorelease-pool ,pool-temp)))))
    30303030
    3031 
    3032 (defun %make-nsstring (string)
    3033   (with-encoded-cstrs :utf-8 ((s string))
    3034     (%make-nsstring-from-utf8-c-string s)))
    3035 
    3036 
    3037 
    30383031#+apple-objc-2.0
    30393032;;; New!!! Improved!!! At best, half-right!!!
    30403033(defmacro with-ns-exceptions-as-errors (&body body)
    30413034  `(progn ,@body))
    3042                  
    3043              
    3044    
     3035
    30453036#-apple-objc-2.0
    30463037(defmacro with-ns-exceptions-as-errors (&body body)
  • trunk/source/objc-bridge/objc-support.lisp

    r11588 r11620  
    183183(pushnew 'recognize-objc-exception *foreign-error-condition-recognizers*)
    184184
    185 (defun %make-nsstring-from-utf8-c-string (s)
    186   (#/initWithUTF8String: (#/alloc ns:ns-string) s))
    187 
     185(defun %make-nsstring (string)
     186  (with-encoded-cstrs :utf-8 ((s string))
     187    (#/initWithUTF8String: (#/alloc ns:ns-string) s)))
     188
     189(defmacro with-autoreleased-nsstring ((nsstring lisp-string) &body body)
     190  `(let* ((,nsstring (%make-nsstring ,lisp-string)))
     191     (#/autorelease ,nsstring)
     192     ,@body))
     193
     194(defmacro with-autoreleased-nsstrings (speclist &body body)
     195  (with-specs-aux 'with-autoreleased-nsstring speclist body))
    188196
    189197(defun retain-objc-instance (instance)
     
    230238  (with-slots (condition) self
    231239    (if condition
    232       (%make-nsstring (format nil "~A" condition))
     240      (#/autorelease (%make-nsstring (format nil "~A" condition)))
    233241      (call-next-method))))
    234242
Note: See TracChangeset for help on using the changeset viewer.