Armin Rigo avatar Armin Rigo committed 7aaba88

Document ffi.addressof().

Comments (0)

Files changed (1)

doc/source/index.rst

    now it returns a regular ``<cdata 'type *' NULL>``, which you can
    check for e.g. by comparing it with ``ffi.NULL``.
 
-There is no equivalent to the ``&`` operator in C (because it would not
-fit nicely in the model, and it does not seem to be needed here).
+There is no general equivalent to the ``&`` operator in C (because it
+would not fit nicely in the model, and it does not seem to be needed
+here).  But see ``ffi.addressof()`` below__.
+
+__ Miscellaneous_
 
 Any operation that would in C return a pointer or array or struct type
 gives you a fresh cdata object.  Unlike the "original" one, these fresh
 
 .. "versionadded:: 0.3" --- inlined in the previous paragraph
 
+``ffi.addressof(cdata)``: from a cdata whose type is ``struct foo_s``,
+return its "address", as a cdata whose type is ``struct foo_s *``.  Also
+works on unions, but not on any other type.  (It would be difficult
+because only structs and unions are internally stored as an indirect
+pointer to the data.)  The returned pointer is only valid as long as
+the original object is.  *New in version 0.4.*
+
+.. "versionadded:: 0.4" --- inlined in the previous paragraph
+
 
 Unimplemented features
 ----------------------
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.