comparison python/pydc/README.txt @ 37:8c8f848131c6

- version bump - better doc - made calling convention mode reset by default, as only way to specify convention used is via signature string
author Tassilo Philipp
date Mon, 13 Apr 2020 20:08:54 +0200
parents 75fe1dec0eb4
children 0f86a5ecfe61
comparison
equal deleted inserted replaced
36:b84064293541 37:8c8f848131c6
8 Apr 7, 2020: update to dyncall 1.1, Python 3 support, using the Capsule 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 9 API, as well as support for python unicode strings
10 Apr 11, 2020: support for getting loaded library path 10 Apr 11, 2020: support for getting loaded library path
11 Apr 12, 2020: breaking change: restrict 'Z' conversions to immutable types 11 Apr 12, 2020: breaking change: restrict 'Z' conversions to immutable types
12 and 'p' to mutable types (and handles) 12 and 'p' to mutable types (and handles)
13 Apr 13, 2020: added signature char support to specify calling conventions
13 14
14 15
15 BUILD/INSTALLATION 16 BUILD/INSTALLATION
16 ================== 17 ==================
17 18
26 27
27 28
28 API 29 API
29 === 30 ===
30 31
31 libhandle = load(libpath) 32 libhandle = load(libpath) # if path == None => handle to running process
33 libpath = get_path(libhandle) # if handle == None => path to executable
32 funcptr = find(libhandle, symbolname) 34 funcptr = find(libhandle, symbolname)
33 call(funcptr, signature, ...) 35 call(funcptr, signature, ...)
34 free(libhandle) 36 free(libhandle)
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.
35 42
36 43
37 SIGNATURE FORMAT 44 SIGNATURE FORMAT
38 ================ 45 ================
39 46
71 'Z' | str (PyString) ! | str (PyUnicode) ! | const char* (UTF-8 for unicode) | int (PyString) | str (PyUnicode) 78 '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) 79 | 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) 80 | - | 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) 81 | bytearray (PyByteArray) ! | bytearray (PyByteArray) ! | const char* (UTF-8 for unicode) | int (PyString) | str (PyUnicode)
75 82
83 Annotations:
76 # converted to 1 if True and 0 otherwise 84 # converted to 1 if True and 0 otherwise
77 @ converted to False if 0 and True otherwise 85 @ converted to False if 0 and True otherwise
78 % range/length checked 86 % range/length checked
79 $ cast to single precision 87 $ cast to single precision
80 ^ cast to double precision 88 ^ cast to double precision
81 & mutable buffer when passed to C 89 & mutable buffer when passed to C
82 ! immutable buffer when passed to C, as strings (in any form) are considered objects, not buffers 90 ! immutable buffer when passed to C, as strings (in any form) are considered objects, not buffers
83 91
84 92
85 also supported are specifying calling convention mode switches using 93 Also supported are specifying calling convention switches using '_'-prefixed
86 '_'-prefixed signature characters; consult the dyncall docs for a list 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
87 111
88 112
89 TODO 113 TODO
90 ==== 114 ====
91 115