Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added struct table. Needed to avoid using spanned cells as it breaks …

…the latex output.
  • Loading branch information...
commit cc3b4267c188e829add532df0d52b54978e02fce 1 parent eb39c41
authored May 04, 2008

Showing 1 changed file with 32 additions and 12 deletions. Show diff stats Hide diff stats

  1. 44  docs/external_C_code.rst
44  docs/external_C_code.rst
Source Rendered
@@ -159,18 +159,38 @@ header file, and the corresponding Cython declaration that you should put in
159 159
 the ``cdef extern`` from block. Struct declarations are used as an example; the
160 160
 same applies equally to union and enum declarations.
161 161
 
162  
-.. TODO: put table here...
163  
-
164  
-+-----------------+--------------------+
165  
-| C code          | Cython             |
166  
-+-----------------+--------------------+
167  
-| ::              | ::                 |
168  
-|                 |                    |
169  
-|   struct Foo {  |   cdef struct Foo: |
170  
-|     ...         |     ...            |
171  
-|   };            |                    |
172  
-+-----------------+--------------------+
173  
-
  162
++-------------------------+---------------------------------------------+-----------------------------------------------------------------------+
  163
+| C code                  | Possibilities for corresponding Cython Code | Comments                                                              |
  164
++=========================+=============================================+=======================================================================+
  165
+| ::                      | ::                                          | Cython will refer to the as ``struct Foo`` in the generated C code.   |
  166
+|                         |                                             |                                                                       |
  167
+|   struct Foo {          |   cdef struct Foo:                          |                                                                       |
  168
+|     ...                 |     ...                                     |                                                                       |
  169
+|   };                    |                                             |                                                                       |
  170
++-------------------------+---------------------------------------------+-----------------------------------------------------------------------+
  171
+| ::                      | ::                                          | Cython will refer to the type simply as ``Foo`` in                    |
  172
+|                         |                                             | the generated C code.                                                 |
  173
+|   typedef struct {      |   ctypedef struct Foo:                      |                                                                       |
  174
+|     ...                 |     ...                                     |                                                                       |
  175
+|   } Foo;                |                                             |                                                                       |
  176
++-------------------------+---------------------------------------------+-----------------------------------------------------------------------+
  177
+| ::                      | ::                                          | If the C header uses both a tag and a typedef with *different*        |
  178
+|                         |                                             | names, you can use either form of declaration in Cython               |
  179
+|   typedef struct foo {  |   cdef struct foo:                          | (although if you need to forward reference the type,                  |
  180
+|     ...                 |     ...                                     | you'll have to use the first form).                                   |
  181
+|   } Foo;                |   ctypedef foo Foo #optional                |                                                                       |
  182
+|                         |                                             |                                                                       |
  183
+|                         | or::                                        |                                                                       |
  184
+|                         |                                             |                                                                       |
  185
+|                         |   ctypedef struct Foo:                      |                                                                       |
  186
+|                         |     ...                                     |                                                                       |
  187
++-------------------------+---------------------------------------------+-----------------------------------------------------------------------+
  188
+| ::                      | ::                                          | If the header uses the *same* name for the tag and typedef, you       |
  189
+|                         |                                             | won't be able to include a :keyword:`ctypedef` for it -- but then,    |
  190
+|   typedef struct Foo {  |   cdef struct Foo:                          | it's not necessary.                                                   |
  191
+|     ...                 |     ...                                     |                                                                       |
  192
+|   } Foo;                |                                             |                                                                       |
  193
++-------------------------+---------------------------------------------+-----------------------------------------------------------------------+
174 194
 
175 195
 Note that in all the cases below, you refer to the type in Cython code simply
176 196
 as :ctype:`Foo`, not ``struct Foo``.

0 notes on commit cc3b426

Please sign in to comment.
Something went wrong with that request. Please try again.