NextPrevUpTopContentsIndex

1.4.3.2 Defining a method that returns a structure

When a the return type of a method is a structure type such as ns-rect then the conversion specified in Special result conversion for define-objc-method can be used. Alternatively, and for any other structure defined with define-objc-struct, the method can specify a variable as its result-style . This variable is bound to a pointer to a foreign structure of the appropriate type and the method should set the slots in this structure to specify the result. For example, the following definitions show a method that returns a stucture:

(define-objc-struct (pair
                     (:foreign-name "_Pair"))
  (:first :float)
  (:second :float))
 
(define-objc-method ("pair" (:struct pair) result-pair)
    ((this my-object))
  (setf (fli:foreign-slot-value result-pair :first) 1f0
        (fli:foreign-slot-value result-pair :second) 2f0))

LispWorks Objective-C and Cocoa Interface User Guide and Reference Manual - 29 Feb 2008

NextPrevUpTopContentsIndex