Changeset 6149


Ignore:
Timestamp:
Apr 7, 2007, 12:41:56 PM (13 years ago)
Author:
gb
Message:

Define NS:WITH-... macros for typed foreign structs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/objc-gf/ccl/examples/bridge.lisp

    r6130 r6149  
    102102          ,struct)))))
    103103
     104(defun define-typed-foreign-struct-class-with-form (with-form-name foreign-type init-function-name)
     105  (declare (ignorable init-function-name))
     106  (when with-form-name
     107  `(defmacro ,with-form-name ((instance &rest inits) &body body)
     108    (multiple-value-bind (body decls) (parse-body body nil)
     109      `(rlet ((,instance ,,foreign-type))
     110        ,@decls
     111        ,@(when inits
     112                `((,',init-function-name ,instance ,@inits)))
     113        ,@body)))))
    104114         
    105115
    106 (defmacro define-typed-foreign-struct-class (class-name (foreign-type predicate-name init-function-name creation-function-name) &rest accessors)
     116(defmacro define-typed-foreign-struct-class (class-name (foreign-type predicate-name init-function-name creation-function-name with-form-name) &rest accessors)
    107117  (let* ((arg (gensym)))
    108118    `(progn
     
    119129      ,(define-typed-foreign-struct-initializer init-function-name accessors)
    120130      ,(define-typed-foreign-struct-creation-function creation-function-name init-function-name foreign-type accessors)
     131      ,(define-typed-foreign-struct-class-with-form with-form-name foreign-type init-function-name)
    121132      ,(define-typed-foreign-struct-accessors class-name accessors)
    122133      ',class-name)))
     
    130141;;; AEDesc (Apple Event Descriptor)
    131142
    132 (define-typed-foreign-struct-class ns::aedesc (:<AED>esc ns::aedesc-p ns::init-aedesc ns::make-aedesc)
     143(define-typed-foreign-struct-class ns::aedesc (:<AED>esc ns::aedesc-p ns::init-aedesc ns::make-aedesc ns::with-aedesc)
    133144  (descriptor-type ns::aedesc-descriptor-type :<AED>esc.descriptor<T>ype)
    134145  (data-handle ns::aedesc-data-handle :<AED>esc.data<H>andle))
     
    145156;;; part of the ObjC 2.0 extensible iteration stuff ("foreach").
    146157#+apple-objc-2.0
    147 (define-typed-foreign-struct-class ns::ns-fast-enumeration-state (:<NSF>ast<E>numeration<S>tate ns::ns-fast-enumeration-state-p ns::init-fast-enumeration-state ns::make-fast-enumeration-state))
     158(define-typed-foreign-struct-class ns::ns-fast-enumeration-state (:<NSF>ast<E>numeration<S>tate ns::ns-fast-enumeration-state-p ns::init-ns-fast-enumeration-state ns::make-ns-fast-enumeration-state ns::with-ns-fast-enumeration-state))
    148159
    149160;;; NSAffineTransformStruct CGAffineTransform
    150 (define-typed-foreign-struct-class ns::ns-affine-transform-struct (:<NSA>ffine<T>ransform<S>truct ns::ns-affine-transform-struct-p ns::init-ns-affine-transform-struct ns::make-ns-affine-transform-struct)
     161(define-typed-foreign-struct-class ns::ns-affine-transform-struct (:<NSA>ffine<T>ransform<S>truct ns::ns-affine-transform-struct-p ns::init-ns-affine-transform-struct ns::make-ns-affine-transform-struct ns::wint-ns-affine-transform-struct)
    151162    (m11 ns::ns-affine-transform-struct-m11 :<NSA>ffine<T>ransform<S>truct.m11 wrap-cg-float)
    152163    (m12 ns::ns-affine-transform-struct-m12 :<NSA>ffine<T>ransform<S>truct.m12 wrap-cg-float)
     
    187198
    188199;;; NSDecimal
    189 (define-typed-foreign-struct-class ns::ns-decimal (:<NSD>ecimal ns::ns-decimal-p nil nil)
     200(define-typed-foreign-struct-class ns::ns-decimal (:<NSD>ecimal ns::ns-decimal-p nil nil nil)
    190201  (nil ns::ns-decimal-exponent :<NSD>ecimal._exponent)
    191202  (nil ns::ns-decimal-length :<NSD>ecimal._length)
     
    240251;;; NSRect
    241252
    242 (define-typed-foreign-struct-class ns::ns-rect (:<NSR>ect ns::ns-rect-p ns::init-ns-rect ns::make-ns-rect)
     253(define-typed-foreign-struct-class ns::ns-rect (:<NSR>ect ns::ns-rect-p ns::init-ns-rect ns::make-ns-rect ns::with-ns-rect)
    243254  (x ns::ns-rect-x :<NSR>ect.origin.x wrap-cg-float)
    244255  (y ns::ns-rect-y :<NSR>ect.origin.y wrap-cg-float)
     
    262273
    263274;;; NSSize
    264 (define-typed-foreign-struct-class ns::ns-size (:<NSS>ize ns::ns-size-p ns::init-ns-size ns::make-ns-size)
     275(define-typed-foreign-struct-class ns::ns-size (:<NSS>ize ns::ns-size-p ns::init-ns-size ns::make-ns-size ns::with-ns-size)
    265276  (width ns::ns-size-width :<NSS>ize.width wrap-cg-float)
    266277  (height ns::ns-size-height :<NSS>ize.height wrap-cg-float))
     
    279290
    280291;;; NSPoint
    281 (define-typed-foreign-struct-class ns::ns-point (:<NSP>oint ns::ns-point-p ns::init-ns-point ns::make-ns-point)
     292(define-typed-foreign-struct-class ns::ns-point (:<NSP>oint ns::ns-point-p ns::init-ns-point ns::make-ns-point ns::with-ns-point)
    282293  (x ns::ns-point-x :<NSP>oint.x wrap-cg-float)
    283294  (y ns::ns-point-y :<NSP>oint.y wrap-cg-float))
     
    295306
    296307;;; NSRange
    297 (define-typed-foreign-struct-class ns::ns-range (:<NSR>ange ns::ns-range-p ns::init-ns-range ns::make-ns-range)
     308(define-typed-foreign-struct-class ns::ns-range (:<NSR>ange ns::ns-range-p ns::init-ns-range ns::make-ns-range ns::with-ns-range)
    298309  (location ns::ns-range-location :<NSR>ange.location)
    299310  (length ns::ns-range-length :<NSR>ange.length ))
Note: See TracChangeset for help on using the changeset viewer.