Mercurial > pub > dyncall > bindings
changeset 44:0f86a5ecfe61
- python: allow None to be passed for 'p'ointers, always passing NULL
author | Tassilo Philipp |
---|---|
date | Tue, 27 Oct 2020 18:44:18 +0100 |
parents | 1086ca649715 |
children | da553362fa7c |
files | python/pydc/README.txt python/pydc/pydcext.c python/pydc/test/types.py |
diffstat | 3 files changed, 5 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/python/pydc/README.txt Wed Apr 15 21:58:13 2020 +0200 +++ b/python/pydc/README.txt Tue Oct 27 18:44:18 2020 +0100 @@ -11,6 +11,7 @@ Apr 12, 2020: breaking change: restrict 'Z' conversions to immutable types and 'p' to mutable types (and handles) Apr 13, 2020: added signature char support to specify calling conventions +Oct 27, 2020: allowing 'None' for 'p' params, always passing NULL BUILD/INSTALLATION @@ -75,6 +76,7 @@ 'p' | bytearray (PyByteArray) & | bytearray (PyByteArray) & | void* | int,long (Py_ssize_t) | int (Py_ssize_t) | int (PyInt) | int (PyLong) | void* | int,long (Py_ssize_t) | int (Py_ssize_t) | long (PyLong) | - | void* | int,long (Py_ssize_t) | int (Py_ssize_t) + | None (Py_None) | None (Py_None) | void* (always NULL) | int,long (Py_ssize_t) | int (Py_ssize_t) 'Z' | str (PyString) ! | str (PyUnicode) ! | const char* (UTF-8 for unicode) | int (PyString) | str (PyUnicode) | unicode (PyUnicode) ! | - | const char* (UTF-8 for unicode) | int (PyString) | str (PyUnicode) | - | bytes (PyBytes) ! | const char* (UTF-8 for unicode) | int (PyString) | str (PyUnicode)
--- a/python/pydc/pydcext.c Wed Apr 15 21:58:13 2020 +0200 +++ b/python/pydc/pydcext.c Tue Oct 27 18:44:18 2020 +0100 @@ -359,6 +359,8 @@ #endif else if ( PyLong_Check(po) ) p = (DCpointer) PyLong_AsVoidPtr(po); + else if ( po == Py_None ) + p = NULL; else return PyErr_Format( PyExc_RuntimeError, "arg %d - expecting a promoting pointer-type (int, bytearray)", pos ); dcArgPointer(gpCall, p);
--- a/python/pydc/test/types.py Wed Apr 15 21:58:13 2020 +0200 +++ b/python/pydc/test/types.py Tue Oct 27 18:44:18 2020 +0100 @@ -132,6 +132,7 @@ t(l, "p)p", "const char*", "ccp_plus_one", "(const char*)", ' "xY" => p+1 (~ odd addr)', bytearray(b'xY')) # bytearray object t(l, "p)p", "const char*", "ccp_plus_one", "(const char*)", ' 0xdeadc0de => 0xdeadc0de+1=3735929055', long_h) # handle (integer interpreted as ptr) t(l, "p)p", "const char*", "ccp_plus_one", "(const char*)", ' 0xdeadc0de => 0xdeadc0de+1=3735929055', long_h) # handle (integer interpreted as ptr, long in Python 2) +t(l, "p)p", "const char*", "ccp_plus_one", "(const char*)", ' NULL => NULL+1=1', None) # NULL, addin gone will result in 0x1 # functions that change buffers theader('TESTS OF IMMUTABLE AND MUTABLE PYTHON BUFFERS:')