Mercurial > pub > dyncall > bindings
annotate python/pydc/README.txt @ 38:9943c30ee2aa
- typo fix
author | Tassilo Philipp |
---|---|
date | Mon, 13 Apr 2020 21:41:59 +0200 |
parents | 8c8f848131c6 |
children | 0f86a5ecfe61 |
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) | |
37 | 13 Apr 13, 2020: added signature char support to specify calling conventions |
5 | 14 |
0 | 15 |
7 | 16 BUILD/INSTALLATION |
16
a40084782546
- added support for more return values to python binding
cslag
parents:
10
diff
changeset
|
17 ================== |
4 | 18 |
19 1) make sure dyncall is built and libraries/headers are in include paths or | |
20 CFLAGS points to them, etc. | |
21 | |
10 | 22 2) Build and install this extension with: |
16
a40084782546
- added support for more return values to python binding
cslag
parents:
10
diff
changeset
|
23 |
a40084782546
- added support for more return values to python binding
cslag
parents:
10
diff
changeset
|
24 python setup.py install |
a40084782546
- added support for more return values to python binding
cslag
parents:
10
diff
changeset
|
25 |
28 | 26 Building a wheel package isn't supported, currently. |
4 | 27 |
28 | |
0 | 29 API |
16
a40084782546
- added support for more return values to python binding
cslag
parents:
10
diff
changeset
|
30 === |
0 | 31 |
37 | 32 libhandle = load(libpath) # if path == None => handle to running process |
33 libpath = get_path(libhandle) # if handle == None => path to executable | |
5 | 34 funcptr = find(libhandle, symbolname) |
35 call(funcptr, signature, ...) | |
29 | 36 free(libhandle) |
0 | 37 |
37 | 38 Note that there are no functions to set the calling convention mode. However, |
39 it can be set using the signature. | |
40 Not specifying any calling convention in the signature string will use the | |
41 platform's default one. | |
42 | |
7 | 43 |
0 | 44 SIGNATURE FORMAT |
16
a40084782546
- added support for more return values to python binding
cslag
parents:
10
diff
changeset
|
45 ================ |
0 | 46 |
35
75fe1dec0eb4
- added support for signature-based calling convention switch
Tassilo Philipp
parents:
34
diff
changeset
|
47 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
|
48 a string with the following format (using * as regex-like repetition): |
0 | 49 |
35
75fe1dec0eb4
- added support for signature-based calling convention switch
Tassilo Philipp
parents:
34
diff
changeset
|
50 "x*)y" |
0 | 51 |
35
75fe1dec0eb4
- added support for signature-based calling convention switch
Tassilo Philipp
parents:
34
diff
changeset
|
52 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
|
53 |
0 | 54 |
34 | 55 SIG | FROM PYTHON 2 | FROM PYTHON 3 | C/C++ | TO PYTHON 2 | TO PYTHON 3 |
56 ----+---------------------------------+---------------------------------+---------------------------------+--------------------------------------+--------------------------------------- | |
57 'v' | | | void | None (Py_None) (e.g. ret of "...)v") | None (Py_None) (e.g. ret of "...)v") | |
58 'B' | bool (PyBool) | bool (PyBool) # | int/bool | bool (PyBool) | bool (PyBool) @ | |
59 'c' | int (PyInt) % | int (PyLong) % | char | int (PyInt) | int (PyLong) | |
60 | str (with only a single char) % | str (with only a single char) % | char | int (PyInt) | int (PyLong) | |
61 'C' | int (PyInt) % | int (PyLong) % | unsigned char | int (PyInt) | int (PyLong) | |
62 | str (with only a single char) % | str (with only a single char) % | unsigned char | int (PyInt) | int (PyLong) | |
63 's' | int (PyInt) % | int (PyLong) % | short | int (PyInt) | int (PyLong) | |
64 'S' | int (PyInt) % | int (PyLong) % | unsigned short | int (PyInt) | int (PyLong) | |
65 'i' | int (PyInt) | int (PyLong) | int | int (PyInt) | int (PyLong) | |
66 'I' | int (PyInt) | int (PyLong) | unsigned int | int (PyInt) | int (PyLong) | |
67 'j' | int (PyInt) | int (PyLong) | long | int (PyInt) | int (PyLong) | |
68 'J' | int (PyInt) | int (PyLong) | unsigned long | int (PyInt) | int (PyLong) | |
69 'l' | int (PyInt) | int (PyLongLong) | long long | long (PyLong) | int (PyLong) | |
70 | long (PyLong) | - | long long | long (PyLong) | int (PyLong) | |
71 'L' | int (PyInt) | int (PyLongLong) | unsigned long long | long (PyLong) | int (PyLong) | |
72 | long (PyLong) | - | unsigned long long | long (PyLong) | int (PyLong) | |
73 'f' | float (PyFloat) $ | float (PyFloat) $ | float | float (PyFloat) ^ | float (PyFloat) ^ | |
74 'd' | float (PyFloat) | float (PyFloat) | double | float (PyFloat) | float (PyFloat) | |
75 'p' | bytearray (PyByteArray) & | bytearray (PyByteArray) & | void* | int,long (Py_ssize_t) | int (Py_ssize_t) | |
76 | int (PyInt) | int (PyLong) | void* | int,long (Py_ssize_t) | int (Py_ssize_t) | |
77 | long (PyLong) | - | void* | int,long (Py_ssize_t) | int (Py_ssize_t) | |
78 'Z' | str (PyString) ! | str (PyUnicode) ! | const char* (UTF-8 for unicode) | int (PyString) | str (PyUnicode) | |
79 | unicode (PyUnicode) ! | - | const char* (UTF-8 for unicode) | int (PyString) | str (PyUnicode) | |
80 | - | bytes (PyBytes) ! | const char* (UTF-8 for unicode) | int (PyString) | str (PyUnicode) | |
81 | bytearray (PyByteArray) ! | bytearray (PyByteArray) ! | const char* (UTF-8 for unicode) | int (PyString) | str (PyUnicode) | |
0 | 82 |
37 | 83 Annotations: |
35
75fe1dec0eb4
- added support for signature-based calling convention switch
Tassilo Philipp
parents:
34
diff
changeset
|
84 # converted to 1 if True and 0 otherwise |
75fe1dec0eb4
- added support for signature-based calling convention switch
Tassilo Philipp
parents:
34
diff
changeset
|
85 @ converted to False if 0 and True otherwise |
75fe1dec0eb4
- added support for signature-based calling convention switch
Tassilo Philipp
parents:
34
diff
changeset
|
86 % range/length checked |
75fe1dec0eb4
- added support for signature-based calling convention switch
Tassilo Philipp
parents:
34
diff
changeset
|
87 $ cast to single precision |
75fe1dec0eb4
- added support for signature-based calling convention switch
Tassilo Philipp
parents:
34
diff
changeset
|
88 ^ cast to double precision |
75fe1dec0eb4
- added support for signature-based calling convention switch
Tassilo Philipp
parents:
34
diff
changeset
|
89 & mutable buffer when passed to C |
75fe1dec0eb4
- added support for signature-based calling convention switch
Tassilo Philipp
parents:
34
diff
changeset
|
90 ! 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
|
91 |
75fe1dec0eb4
- added support for signature-based calling convention switch
Tassilo Philipp
parents:
34
diff
changeset
|
92 |
37 | 93 Also supported are specifying calling convention switches using '_'-prefixed |
94 signature characters: | |
95 | |
96 SIG | DESCRIPTION | |
97 ----+----------------------------------------------------------------------------------------------------------- | |
98 '_' | prefix indicating that next signature character specifies calling convention; char is one of the following | |
99 ':' | platform's default calling convention | |
100 'e' | vararg function | |
101 '.' | vararg function's variadic/ellipsis part (...), to be specified before first vararg | |
102 'c' | only on x86: cdecl | |
103 's' | only on x86: stdcall | |
104 'F' | only on x86: fastcall (MS) | |
105 'f' | only on x86: fastcall (GNU) | |
106 '+' | only on x86: thiscall (MS) | |
107 '#' | only on x86: thiscall (GNU) | |
108 'A' | only on ARM: ARM mode | |
109 'a' | only on ARM: THUMB mode | |
110 '$' | syscall | |
35
75fe1dec0eb4
- added support for signature-based calling convention switch
Tassilo Philipp
parents:
34
diff
changeset
|
111 |
16
a40084782546
- added support for more return values to python binding
cslag
parents:
10
diff
changeset
|
112 |
a40084782546
- added support for more return values to python binding
cslag
parents:
10
diff
changeset
|
113 TODO |
a40084782546
- added support for more return values to python binding
cslag
parents:
10
diff
changeset
|
114 ==== |
a40084782546
- added support for more return values to python binding
cslag
parents:
10
diff
changeset
|
115 |
28 | 116 - callback support |
5 | 117 |
35
75fe1dec0eb4
- added support for signature-based calling convention switch
Tassilo Philipp
parents:
34
diff
changeset
|
118 |
30 | 119 BUGS |
120 ==== | |
121 | |
122 - when using Python 2, the dyncall call vm object is never dcFree'd, as there | |
123 is no way to call a "freefunc" as introduced with Python 3 module definitions | |
124 (see PEP 3121 for details) | |
125 |