Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
379e9d63
Kaydet (Commit)
379e9d63
authored
Tem 13, 2018
tarafından
Andrés Delfino
Kaydeden (comit)
Berker Peksag
Tem 13, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-4260: Document that ctypes.xFUNCTYPE are decorators (GH-7924)
üst
d6345def
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
1 deletion
+19
-1
ctypes.rst
Doc/library/ctypes.rst
+19
-1
No files found.
Doc/library/ctypes.rst
Dosyayı görüntüle @
379e9d63
...
...
@@ -1025,6 +1025,22 @@ As we can easily check, our array is sorted now::
1 5 7 33 99
>>>
The function factories can be used as decorator factories, so we may as well
write::
>>> @CFUNCTYPE(c_int, POINTER(c_int), POINTER(c_int))
... def py_cmp_func(a, b):
... print("py_cmp_func", a[0], b[0])
... return a[0] - b[0]
...
>>> qsort(ia, len(ia), sizeof(c_int), py_cmp_func)
py_cmp_func 5 1
py_cmp_func 33 99
py_cmp_func 7 33
py_cmp_func 1 7
py_cmp_func 5 7
>>>
.. note::
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.
Function prototypes are similar to function prototypes in C; they describe a
function (return type, argument types, calling convention) without defining an
implementation. The factory functions must be called with the desired result
type and the argument types of the function.
type and the argument types of the function, and can be used as decorator
factories, and as such, be applied to functions through the ``@wrapper`` syntax.
See :ref:`ctypes-callback-functions` for examples.
.. function:: CFUNCTYPE(restype, *argtypes, use_errno=False, use_last_error=False)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment