Changeset 8896

Mar 26, 2008, 3:40:50 PM (14 years ago)

working on objective-c bridge docs

2 edited


  • trunk/source/doc/src/ffi.xml

    r8894 r8896  
    26742674  <sect1>
    26752675    <title>The Foreign-Function-Interface Dictionary</title>
     2676    <anchor id="anchor_Foreign-Function-Interface-Dictionary"/>
    26772677    <!-- ====================================  -->
    26782678    <refentry id="rm_sharpsign-underscore">
  • trunk/source/doc/src/objc-bridge.xml

    r8895 r8896  
    2929    also provides some convenience facilities for working with
    3030    Cocoa.</para>
     32  <sect1 id="Objective-C-Changes-1.2">
     33    <title>Changes in 1.2</title>
     35    <para>Version 1.2 of &CCL; exports most of the useful symbols
     36    described in this chapter; in previous releases, most of them were
     37    private in the <code>CCL</code> package.</para>
     39    <para>There are several new reader macros that make it much more
     40    conveinent than before to refer to several classes of symbols used
     41    with the Objective-C bridge. For a full description of these
     42    reader-macros, see
     43    the <link linkend="anchor_Foreign-Function-Interface-Dictionary">Foreign-Function-Interface
     44    Dictionary</link>, especially the entries at the beginning,
     45    describing reader macros.</para>
     47    <para>As in previous releases, 32-bit versions of &CCL; use 32-bit
     48    floats and integers in data structures that describe geometry,
     49    font sizes and metrics, and so on. 64-bit versions of &CCL; use
     50    64-bit values where appropriate.</para>
     52    <para>The Objective-C bridge defines the
     53      type <code>NS:CGFLOAT</code> as the Lisp type of the preferred
     54      floating-point type on the current platform, and defines the
     55      constant <code>NS:+CGFLOAT+</code>.  On DarwinPPC32, the foreign
     56      types <code>:cgfloat</code>, <code>:&lt;NSUI&gt;nteger</code>,
     57      and
     58      <code>:&lt;NSI&gt;nteger</code> are defined by the Objective-C
     59      bridge (as 32-bit float, 32-bit unsigned integer, and 32-bit
     60      signed integer, respectively); these types are defined as 64-bit
     61      variants in the 64-bit interfaces.</para>
     63    <para>Every Objective-C class is now properly named, either with a
     64      name exported from the <code>NS</code> package (in the case of a
     65      predefined class declared in the interface files) or with the
     66      name provided in the <code>DEFCLASS</code> form (with <code>:METACLASS</code>
     67      <code>NS:+NS-OBJECT</code>) which defines the class from Lisp.
     68      The class's Lisp name is now proclaimed to be a "static"
     69      variable (as if by <code>DEFSTATIC</code>, as described in the
     70      <link linkend="Static_Variables">"Static Variables"
     71      section</link>) and given the class object as its value.  In
     72      other words:</para>
     74    <programlisting>
     75(send (find-class 'ns:ns-application) 'shared-application)
     76    </programlisting>
     78  <para>and</para>
     80    <programlisting>
     81(send ns:ns-application 'shared-application)
     82    </programlisting>
     84  <para>are equivalent.  (Since it's not legal to bind a "static"
     85  variable, it may be necessary to rename some things so that
     86  unrelated variables whose names coincidentally conflict with
     87  Objective-C class names don't do so.)</para>
     89  </sect1>
    3291  <sect1 id="Using-Objective-C-Classes">
    329388  (send c 'white-color))
    330389      </programlisting>
    331       <para>The other case that alllows optimization is when only
     390      <para>The other case that allows optimization is when only
    332391        the message is known at compile-time, but its type signature
    333392        is unique. Of the more-than-6000 messages currently provided
    463522      belonging to Objective-C classes which have been defined in
    464523      Lisp.</para>
    465     <para>The macro <literal>define-objc-method</literal> is used
    466       for this.  As described in , the names of Objective-C methods are
     524    <para>The macro <literal>define-objc-method</literal> is used for
     525      this.  As described in the
     526      section <link linkend="Calling-Objective-C-Methods">Calling
     527      Objective-C Methods</link>, the names of Objective-C methods are
    467528      broken into pieces, each piece followed by a parameter.  The
    468529      types of all parameters must be explicitly declared.</para>
    481542      world; and <literal>data</literal> is an ordinary slot, stored
    482543      in the Lisp world.</para>
    483     <para>Here is an example of how to define a method which takes
    484       no arguments.  It happens to be an initialization method, but
    485       that's not important:</para>
     544    <para>Here is an example of how to define a method which takes no
     545      arguments:</para>
    486546    <programlisting>
    487547(define-objc-method ((:id get-window)
    502562(define-objc-method ((:id :init-with-multiplier (:int multiplier))
    503563                     data-window-controller)
    504     (setf (data self) (make-array 100))
     564  (setf (data self) (make-array 100))
    505565  (dotimes (i 100)
    506566    (setf (aref (data self) i)
    519579                          :and-addend (:int addend))
    520580                     data-window-controller)
    521     (setf (data self) (make-array size))
     581  (setf (data self) (make-array size))
    522582  (dotimes (i 100)
    523583    (setf (aref (data self) i)
    537597(define-objc-method ((:void :take-action (:id sender))
    538598                     data-window-controller)
    539     (declare (ignore sender))
     599  (declare (ignore sender))
    540600  (dotimes (i 100)
    541601    (setf (aref (data self) i)
    555615                     "LispApplicationDelegate")
    556616    (:id sender :&lt;BOOL>)
    557          (declare (ignore sender))
    558          nil)
     617    (declare (ignore sender))
     618    nil)
    560   (define-objc-method ((:&lt;BOOL>
     620(define-objc-method ((:&lt;BOOL>
    561621                        :application-should-terminate sender)
    562622                       lisp-application-delegate)
    563       (declare (ignore sender))
     623    (declare (ignore sender))
    564624    nil)
    565625    </programlisting>
Note: See TracChangeset for help on using the changeset viewer.