@@ -1025,6 +1025,22 @@ As we can easily check, our array is sorted now::
10251025 1 5 7 33 99
10261026 >>>
10271027
1028+ The function factories can be used as decorator factories, so we may as well
1029+ write::
1030+
1031+ >>> @CFUNCTYPE(c_int, POINTER(c_int), POINTER(c_int))
1032+ ... def py_cmp_func(a, b):
1033+ ... print("py_cmp_func", a[0], b[0])
1034+ ... return a[0] - b[0]
1035+ ...
1036+ >>> qsort(ia, len(ia), sizeof(c_int), py_cmp_func)
1037+ py_cmp_func 5 1
1038+ py_cmp_func 33 99
1039+ py_cmp_func 7 33
1040+ py_cmp_func 1 7
1041+ py_cmp_func 5 7
1042+ >>>
1043+
10281044.. note ::
10291045
10301046 Make sure you keep references to :func: `CFUNCTYPE ` objects as long as they
@@ -1577,7 +1593,9 @@ Foreign functions can also be created by instantiating function prototypes.
15771593Function prototypes are similar to function prototypes in C; they describe a
15781594function (return type, argument types, calling convention) without defining an
15791595implementation. The factory functions must be called with the desired result
1580- type and the argument types of the function.
1596+ type and the argument types of the function, and can be used as decorator
1597+ factories, and as such, be applied to functions through the ``@wrapper `` syntax.
1598+ See :ref: `ctypes-callback-functions ` for examples.
15811599
15821600
15831601.. function :: CFUNCTYPE(restype, *argtypes, use_errno=False, use_last_error=False)
0 commit comments