luv

Workshop wiki

foundation.lisp

objective-c/foundation.lisp

system luv/objective-c · 14 definitions · on GitHub

Foundation vocabulary needed by the general Objective-C boundary.

in-package#:luv.objective-c
define-objective-c-message%new-autorelease-pool
"new":object:ownership:owned:class"NSAutoreleasePool"
define-objective-c-message%objective-c-string-from-utf8-pointer
"stringWithUTF8String:":object:ownership:borrowed:class"NSString"
pointer:pointer
define-objective-c-message%objective-c-error-localized-description
"localizedDescription":object:ownership:borrowed:class"NSString"
defunretain-objective-c-object
object

Acquire one retain on object and return a distinct owned wrapper for it.

defunrelease-objective-c-object
object

Consume object's one owned retain and make that wrapper unusable.

values
defmacrowith-owned-objective-c-object
&bodybody

Bind variable to FORM's owned object and release it when body leaves.

`
let
,variable,form
unwind-protect
progn,@body
unless
objective-c-object-released-p,variable
defmacrowith-autorelease-pool
&bodybody

Run body inside one explicitly drained Foundation autorelease pool.

let
pool
gensym"POOL"
`
let
unwind-protect
progn,@body
defunobjective-c-string
object

Copy an NSString-compatible object into a Lisp string.

let
unless
cffi:null-pointer-ppointer
cffi:foreign-string-to-lisppointer
defunlisp-string-to-objective-c
string

Return an autoreleased NSString containing string.

The result is borrowed and must remain inside its surrounding autorelease pool. Native APIs which copy an NSString argument may retain it beyond that scope in the ordinary Objective-C way.

check-typestringstring
cffi:with-foreign-string
pointerstring:encoding:utf-8
defunobjective-c-error-description
error

Copy NSError's localized description into a Lisp string.