Fix markup.

Document the new 'offset' parameter for the 'ctypes.byref' function.
This commit is contained in:
Thomas Heller 2008-06-11 07:10:43 +00:00
parent e0b9261a2f
commit 73baefd7fc
1 changed files with 30 additions and 20 deletions

View File

@ -1406,10 +1406,9 @@ GetLastError() and SetLastError() Windows api functions;
to request and change the ctypes private copy of the windows error to request and change the ctypes private copy of the windows error
code. code.
.. versionchanged:: 2.6 .. versionadded:: 2.6
The ``use_last_error`` and ``use_errno`` optional parameters
The `use_errno` and `use_last_error` parameters were added in Python were added.
2.6.
.. data:: RTLD_GLOBAL .. data:: RTLD_GLOBAL
:noindex: :noindex:
@ -1572,22 +1571,23 @@ They are instances of a private class:
Assign a Python function or another callable to this attribute. The Assign a Python function or another callable to this attribute. The
callable will be called with three or more arguments: callable will be called with three or more arguments:
.. function:: callable(result, func, arguments)
:noindex:
.. function:: callable(result, func, arguments) ``result`` is what the foreign function returns, as specified
:noindex: by the :attr:`restype` attribute.
``result`` is what the foreign function returns, as specified by the ``func`` is the foreign function object itself, this allows
:attr:`restype` attribute. to reuse the same callable object to check or post process
the results of several functions.
``func`` is the foreign function object itself, this allows to reuse the same ``arguments`` is a tuple containing the parameters originally
callable object to check or post process the results of several functions. passed to the function call, this allows to specialize the
behavior on the arguments used.
``arguments`` is a tuple containing the parameters originally passed to the The object that this function returns will be returned from the
function call, this allows to specialize the behavior on the arguments used. foreign function call, but it can also check the result value
and raise an exception if the foreign function call failed.
The object that this function returns will be returned from the foreign
function call, but it can also check the result value and raise an exception
if the foreign function call failed.
.. exception:: ArgumentError() .. exception:: ArgumentError()
@ -1805,12 +1805,22 @@ Utility functions
ctypes type or instance. ctypes type or instance.
.. function:: byref(obj) .. function:: byref(obj[, offset])
Returns a light-weight pointer to ``obj``, which must be an instance of a ctypes Returns a light-weight pointer to ``obj``, which must be an
type. The returned object can only be used as a foreign function call parameter. instance of a ctypes type. ``offset`` defaults to zero, it must be
It behaves similar to ``pointer(obj)``, but the construction is a lot faster. an integer which is added to the internal pointer value.
``byref(obj, offset)`` corresponds to this C code::
(((char *)&obj) + offset)
The returned object can only be used as a foreign function call
parameter. It behaves similar to ``pointer(obj)``, but the
construction is a lot faster.
.. versionadded:: 2.6
The ``offset`` optional argument was added.
.. function:: cast(obj, type) .. function:: cast(obj, type)