A basic interface to Objective-C
This extension allows to interact with Objective-C code with a minumum of fuss (sort of).
Locates the ObjC classes NAME ... and defines variables holding pointers to the class objects. NAME may be a symbol or a list of the form (VARIABLE CLASSNAME). For example, (define-objc-classes NSTextView NSTask) is equivalent to
(begin (define NSTextView (objc:string->class "NSTextView")) (define NSTask (objc:string->class "NSTask")))
Creates an instance of NSString with the given characters as its contents. Currently assumes UTF8 encoding.
An abbreviation for (objc:send RECEIVER KEYWORD ARGUMENT ...). If the receiver is prefixed with the safe: keyword, then this form expands into a (objc:send/safe ...) expression.
Invokes the method named by KEYWORD1 ... for the given receiver, which may be either an Objc instance or a class. The keywords should follow the normal ObjC syntax.
Equivalent to (objc:send ...) but allows callbacks into Scheme from Objective-C code.
Returns #t if X is an object representing an ObjC instance or #f otherwise.
Returns #t if X is an object representing an ObjC class or #f otherwise.
Returns #t if X is an object representing an ObjC selector or #f otherwise.
Returns the raw pointer for an ObjC instance object.
Converts a raw pointer to an ObjC instance into an instance-object.
Converts a raw pointer to an ObjC clas into a class-object.
Allocates an instance of NSString with the contents of STRING. Currently assumes UTF8 encoding.
Returns a class object representing the ObjC class with the name STRING.
Returns a selector object representing the message selector with the name STRING.
Returns an instance of NSMethodSignature for the given instance and selector.
The cocoa extension provides some basic stuff for using Cocoa. To use these definitions, execute (use cocoa).
Beeps.
Invokes NSApplicationMain() with the appropriate arguments for argc and argv.
(use objc) (define-objc-classes NSObject NSString) (print "NNSObject: " NSObject) (define sel (objc:string->selector "cancelPreviousPerformRequestsWithTarget:selector:object:")) (print "hairy selector: " sel) (define sig (objc:selector->signature NSObject sel)) (print "hairy signature: " sig) (print "nice signature: " (objc:method-signature NSObject sel)) (define x (objc:send (objc:send/safe NSObject alloc) init)) (pp x) @[x release] (define s1 @[NSString stringWithCString: "Oink!"]) (pp s1) (define s0 @"this is a test") (pp s0) (pp @[s0 length])
Copyright (c) 2005, Felix Winkelmann. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED ASIS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.