Mercurial > pub > dyncall > bindings
annotate python/pydc/README.txt @ 36:b84064293541
- bugfix
author | Tassilo Philipp |
---|---|
date | Mon, 13 Apr 2020 16:28:47 +0200 |
parents | 75fe1dec0eb4 |
children | 8c8f848131c6 |
rev | line source |
---|---|
0 | 1 dyncall python bindings |
28 | 2 Copyright 2007-2016 Daniel Adler |
3 2018-2020 Tassilo Philipp | |
4 | |
5 Dec 4, 2007: initial | |
6 Mar 22, 2016: update to dyncall 0.9, includes breaking sig char changes | |
7 Apr 19, 2018: update to dyncall 1.0 | |
8 Apr 7, 2020: update to dyncall 1.1, Python 3 support, using the Capsule | |
9 API, as well as support for python unicode strings | |
34 | 10 Apr 11, 2020: support for getting loaded library path |
11 Apr 12, 2020: breaking change: restrict 'Z' conversions to immutable types | |
12 and 'p' to mutable types (and handles) | |
5 | 13 |
0 | 14 |
7 | 15 BUILD/INSTALLATION |
16
a40084782546
- added support for more return values to python binding
cslag
parents:
10
diff
changeset
|
16 ================== |
4 | 17 |
18 1) make sure dyncall is built and libraries/headers are in include paths or | |
19 CFLAGS points to them, etc. | |
20 | |
10 | 21 2) Build and install this extension with: |
16
a40084782546
- added support for more return values to python binding
cslag
parents:
10
diff
changeset
|
22 |
a40084782546
- added support for more return values to python binding
cslag
parents:
10
diff
changeset
|
23 python setup.py install |
a40084782546
- added support for more return values to python binding
cslag
parents:
10
diff
changeset
|
24 |
28 | 25 Building a wheel package isn't supported, currently. |
4 | 26 |
27 | |
0 | 28 API |
16
a40084782546
- added support for more return values to python binding
cslag
parents:
10
diff
changeset
|
29 === |
0 | 30 |
31 libhandle = load(libpath) | |
5 | 32 funcptr = find(libhandle, symbolname) |
33 call(funcptr, signature, ...) | |
29 | 34 free(libhandle) |
0 | 35 |
7 | 36 |
0 | 37 SIGNATURE FORMAT |
16
a40084782546
- added support for more return values to python binding
cslag
parents:
10
diff
changeset
|
38 ================ |
0 | 39 |
35
75fe1dec0eb4
- added support for signature-based calling convention switch
Tassilo Philipp
parents:
34
diff
changeset
|
40 ignoring calling convention mode switching for simplicity, the signature is |
75fe1dec0eb4
- added support for signature-based calling convention switch
Tassilo Philipp
parents:
34
diff
changeset
|
41 a string with the following format (using * as regex-like repetition): |
0 | 42 |
35
75fe1dec0eb4
- added support for signature-based calling convention switch
Tassilo Philipp
parents:
34
diff
changeset
|
43 "x*)y" |
0 | 44 |
35
75fe1dec0eb4
- added support for signature-based calling convention switch
Tassilo Philipp
parents:
34
diff
changeset
|
45 where x is positional parameter-type charcode (per argument), y is result-type charcode |
75fe1dec0eb4
- added support for signature-based calling convention switch
Tassilo Philipp
parents:
34
diff
changeset
|
46 |
0 | 47 |
34 | 48 SIG | FROM PYTHON 2 | FROM PYTHON 3 | C/C++ | TO PYTHON 2 | TO PYTHON 3 |
49 ----+---------------------------------+---------------------------------+---------------------------------+--------------------------------------+--------------------------------------- | |
50 'v' | | | void | None (Py_None) (e.g. ret of "...)v") | None (Py_None) (e.g. ret of "...)v") | |
51 'B' | bool (PyBool) | bool (PyBool) # | int/bool | bool (PyBool) | bool (PyBool) @ | |
52 'c' | int (PyInt) % | int (PyLong) % | char | int (PyInt) | int (PyLong) | |
53 | str (with only a single char) % | str (with only a single char) % | char | int (PyInt) | int (PyLong) | |
54 'C' | int (PyInt) % | int (PyLong) % | unsigned char | int (PyInt) | int (PyLong) | |
55 | str (with only a single char) % | str (with only a single char) % | unsigned char | int (PyInt) | int (PyLong) | |
56 's' | int (PyInt) % | int (PyLong) % | short | int (PyInt) | int (PyLong) | |
57 'S' | int (PyInt) % | int (PyLong) % | unsigned short | int (PyInt) | int (PyLong) | |
58 'i' | int (PyInt) | int (PyLong) | int | int (PyInt) | int (PyLong) | |
59 'I' | int (PyInt) | int (PyLong) | unsigned int | int (PyInt) | int (PyLong) | |
60 'j' | int (PyInt) | int (PyLong) | long | int (PyInt) | int (PyLong) | |
61 'J' | int (PyInt) | int (PyLong) | unsigned long | int (PyInt) | int (PyLong) | |
62 'l' | int (PyInt) | int (PyLongLong) | long long | long (PyLong) | int (PyLong) | |
63 | long (PyLong) | - | long long | long (PyLong) | int (PyLong) | |
64 'L' | int (PyInt) | int (PyLongLong) | unsigned long long | long (PyLong) | int (PyLong) | |
65 | long (PyLong) | - | unsigned long long | long (PyLong) | int (PyLong) | |
66 'f' | float (PyFloat) $ | float (PyFloat) $ | float | float (PyFloat) ^ | float (PyFloat) ^ | |
67 'd' | float (PyFloat) | float (PyFloat) | double | float (PyFloat) | float (PyFloat) | |
68 'p' | bytearray (PyByteArray) & | bytearray (PyByteArray) & | void* | int,long (Py_ssize_t) | int (Py_ssize_t) | |
69 | int (PyInt) | int (PyLong) | void* | int,long (Py_ssize_t) | int (Py_ssize_t) | |
70 | long (PyLong) | - | void* | int,long (Py_ssize_t) | int (Py_ssize_t) | |
71 'Z' | str (PyString) ! | str (PyUnicode) ! | const char* (UTF-8 for unicode) | int (PyString) | str (PyUnicode) | |
72 | unicode (PyUnicode) ! | - | const char* (UTF-8 for unicode) | int (PyString) | str (PyUnicode) | |
73 | - | bytes (PyBytes) ! | const char* (UTF-8 for unicode) | int (PyString) | str (PyUnicode) | |
74 | bytearray (PyByteArray) ! | bytearray (PyByteArray) ! | const char* (UTF-8 for unicode) | int (PyString) | str (PyUnicode) | |
0 | 75 |
35
75fe1dec0eb4
- added support for signature-based calling convention switch
Tassilo Philipp
parents:
34
diff
changeset
|
76 # converted to 1 if True and 0 otherwise |
75fe1dec0eb4
- added support for signature-based calling convention switch
Tassilo Philipp
parents:
34
diff
changeset
|
77 @ converted to False if 0 and True otherwise |
75fe1dec0eb4
- added support for signature-based calling convention switch
Tassilo Philipp
parents:
34
diff
changeset
|
78 % range/length checked |
75fe1dec0eb4
- added support for signature-based calling convention switch
Tassilo Philipp
parents:
34
diff
changeset
|
79 $ cast to single precision |
75fe1dec0eb4
- added support for signature-based calling convention switch
Tassilo Philipp
parents:
34
diff
changeset
|
80 ^ cast to double precision |
75fe1dec0eb4
- added support for signature-based calling convention switch
Tassilo Philipp
parents:
34
diff
changeset
|
81 & mutable buffer when passed to C |
75fe1dec0eb4
- added support for signature-based calling convention switch
Tassilo Philipp
parents:
34
diff
changeset
|
82 ! immutable buffer when passed to C, as strings (in any form) are considered objects, not buffers |
75fe1dec0eb4
- added support for signature-based calling convention switch
Tassilo Philipp
parents:
34
diff
changeset
|
83 |
75fe1dec0eb4
- added support for signature-based calling convention switch
Tassilo Philipp
parents:
34
diff
changeset
|
84 |
75fe1dec0eb4
- added support for signature-based calling convention switch
Tassilo Philipp
parents:
34
diff
changeset
|
85 also supported are specifying calling convention mode switches using |
75fe1dec0eb4
- added support for signature-based calling convention switch
Tassilo Philipp
parents:
34
diff
changeset
|
86 '_'-prefixed signature characters; consult the dyncall docs for a list |
75fe1dec0eb4
- added support for signature-based calling convention switch
Tassilo Philipp
parents:
34
diff
changeset
|
87 |
16
a40084782546
- added support for more return values to python binding
cslag
parents:
10
diff
changeset
|
88 |
a40084782546
- added support for more return values to python binding
cslag
parents:
10
diff
changeset
|
89 TODO |
a40084782546
- added support for more return values to python binding
cslag
parents:
10
diff
changeset
|
90 ==== |
a40084782546
- added support for more return values to python binding
cslag
parents:
10
diff
changeset
|
91 |
28 | 92 - callback support |
5 | 93 |
35
75fe1dec0eb4
- added support for signature-based calling convention switch
Tassilo Philipp
parents:
34
diff
changeset
|
94 |
30 | 95 BUGS |
96 ==== | |
97 | |
98 - when using Python 2, the dyncall call vm object is never dcFree'd, as there | |
99 is no way to call a "freefunc" as introduced with Python 3 module definitions | |
100 (see PEP 3121 for details) | |
101 |