Mercurial > pub > dyncall > bindings
comparison python/pydc/README.txt @ 29:6cc2b7fc7ea2
bigger pydc update:
- cleanups and refactoring
- python 2 fixes in var conversions (especially w/ respect to int vs long)
- fix to pydc.free() which didn't work at all
- fix to return python bool as actual bool
- test lib covering all conversions (manual verification, though :-/)
author | Tassilo Philipp |
---|---|
date | Wed, 08 Apr 2020 22:17:43 +0200 |
parents | edbbd467f50a |
children | baf087cf5971 |
comparison
equal
deleted
inserted
replaced
28:edbbd467f50a | 29:6cc2b7fc7ea2 |
---|---|
26 === | 26 === |
27 | 27 |
28 libhandle = load(libpath) | 28 libhandle = load(libpath) |
29 funcptr = find(libhandle, symbolname) | 29 funcptr = find(libhandle, symbolname) |
30 call(funcptr, signature, ...) | 30 call(funcptr, signature, ...) |
31 free(libhandle) | |
31 | 32 |
32 | 33 |
33 SIGNATURE FORMAT | 34 SIGNATURE FORMAT |
34 ================ | 35 ================ |
35 | 36 |
37 | 38 |
38 format: "xxxxx)y" | 39 format: "xxxxx)y" |
39 | 40 |
40 x is positional parameter-type charcode, y is result-type charcode | 41 x is positional parameter-type charcode, y is result-type charcode |
41 | 42 |
42 SIG | FROM PYTHON 2 | FROM PYTHON 3 @@@ | C/C++ | TO PYTHON 2 | TO PYTHON 3 @@@ | 43 SIG | FROM PYTHON 2 | FROM PYTHON 3 | C/C++ | TO PYTHON 2 | TO PYTHON 3 |
43 ----+------------------------------------+------------------------------------+---------------------------------+------------------------------------+----------------------------------- | 44 ----+------------------------------------------------------+------------------------------------------+---------------------------------+--------------------------------------+------------------------------------- |
44 'v' | | | void | | | 45 'v' | | | void | None (Py_None) (e.g. ret of "...)v") | None (Py_None) (e.g. ret of "...)v") |
45 'B' | PyBool | PyBool | bool | PyBool | PyBool | 46 'B' | bool (PyBool) | bool (PyBool)# | int/bool | bool (PyBool) | bool (PyBool)@ |
46 'c' | PyInt (range checked) | PyInt (range checked) | char | PyInt | PyInt | 47 'c' | int (PyLong)%, str (single char)% | int (PyLong)%, str (single char)% | char | int (PyInt) | int (PyLong) |
47 'C' | PyInt (range checked) | PyInt (range checked) | unsigned char | PyInt | PyInt | 48 'C' | int (PyLong)%, str (single char)% | int (PyLong)%, str (single char)% | unsigned char | int (PyInt) | int (PyLong) |
48 's' | PyInt (range checked) | PyInt (range checked) | short | PyInt | PyInt | 49 's' | int (PyInt)% | int (PyLong)% | short | int (PyInt) | int (PyLong) |
49 'S' | PyInt (range checked) | PyInt (range checked) | unsigned short | PyInt | PyInt | 50 'S' | int (PyInt)% | int (PyLong)% | unsigned short | int (PyInt) | int (PyLong) |
50 'i' | PyInt | PyInt | int | PyInt | PyInt | 51 'i' | int (PyInt) | int (PyLong) | int | int (PyInt) | int (PyLong) |
51 'I' | PyInt | PyInt | unsigned int | PyInt | PyInt | 52 'I' | int (PyInt) | int (PyLong) | unsigned int | int (PyInt) | int (PyLong) |
52 'j' | PyLong | PyLong | long | PyLong | PyLong | 53 'j' | int (PyInt) | int (PyLong) | long | int (PyInt) | int (PyLong) |
53 'J' | PyLong | PyLong | unsigned long | PyLong | PyLong | 54 'J' | int (PyInt) | int (PyLong) | unsigned long | int (PyInt) | int (PyLong) |
54 'l' | PyLongLong | PyLongLong | long long | PyLongLong | PyLongLong | 55 'l' | int (PyInt), long (PyLong) | int (PyLongLong) | long long | long (PyLong) | int (PyLong) |
55 'L' | PyLongLong | PyLongLong | unsigned long long | PyLongLong | PyLongLong | 56 'L' | int (PyInt), long (PyLong) | int (PyLongLong) | unsigned long long | long (PyLong) | int (PyLong) |
56 'f' | PyFloat (cast to single precision) | PyFloat (cast to single precision) | float | PyFloat (cast to double precision) | PyFloat (cast to double precision) | 57 'f' | float (PyFloat)$ | float (PyFloat)$ | float | float (PyFloat)^ | float (PyFloat)^ |
57 'd' | PyFloat | PyFloat | double | PyFloat | PyFloat | 58 'd' | float (PyFloat) | float (PyFloat) | double | float (PyFloat) | float (PyFloat) |
58 'p' | PyUnicode/PyString/PyLong | PyUnicode/PyBytes/PyLong | void* | Py_ssize_t | Py_ssize_t | 59 'p' | str (PyUnicode/PyString), int (PyInt), long (PyLong) | str (PyUnicode), int (PyLong), (PyBytes) | void* | int,long (Py_ssize_t) | int (Py_ssize_t) |
59 'Z' | PyUnicode/PyString | PyUnicode/PyBytes | const char* (UTF-8 for unicode) | PyString | PyUnicode | 60 'Z' | str (PyUnicode/PyString) | str (PyUnicode), (PyBytes) | const char* (UTF-8 for unicode) | int (PyString) | str (PyUnicode) |
60 | 61 |
62 # converted to 1 if True and 0 otherwise | |
63 @ converted to False if 0 and True otherwise | |
64 % range checked | |
65 $ cast to single precision | |
66 ^ cast to double precision | |
61 | 67 |
62 TODO | 68 TODO |
63 ==== | 69 ==== |
64 | 70 |
65 - signature suffixes used to indicate calling conventions are not supported yet! | 71 - signature suffixes used to indicate calling conventions are not supported yet! |
66 - not sure if returning 'p' is working, creating PyCObject, check and write test code @@@ | |
67 - callback support | 72 - callback support |
68 | 73 |
69 | |
70 BUGS | |
71 ==== | |
72 | |
73 * build on osx/ppc - link error i386 something... [MacPython 2.4] | |
74 | |
75 solution: | |
76 installation of latest python for os x (MacPython 2.5) | |
77 | |
78 | |
79 EXAMPLE BUILD | |
80 ============= | |
81 | |
82 $ python setup.py install | |
83 running install | |
84 running build | |
85 running build_py | |
86 creating build | |
87 creating build/lib.macosx-10.3-fat-2.4 | |
88 copying pydc.py -> build/lib.macosx-10.3-fat-2.4 | |
89 running build_ext | |
90 building 'pydcext' extension | |
91 creating build/temp.macosx-10.3-fat-2.4 | |
92 gcc -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd -fno-common -dynamic -DNDEBUG -g -O3 -I../../../dyncall -I../../../dynload -I/Library/Frameworks/Python.framework/Versions/2.4/include/python2.4 -c pydcext.c -o build/temp.macosx-10.3-fat-2.4/pydcext.o | |
93 gcc -arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk -g -bundle -undefined dynamic_lookup build/temp.macosx-10.3-fat-2.4/pydcext.o -L../../../dyncall -L../../../dynload -ldyncall_s -ldynload_s -lstdc++ -o build/lib.macosx-10.3-fat-2.4/pydcext.so | |
94 /usr/bin/ld: for architecture i386 | |
95 /usr/bin/ld: warning ../../../dyncall/libdyncall_s.a archive's cputype (18, architecture ppc) does not match cputype (7) for specified -arch flag: i386 (can't load from it) | |
96 /usr/bin/ld: warning ../../../dynload/libdynload_s.a archive's cputype (18, architecture ppc) does not match cputype (7) for specified -arch flag: i386 (can't load from it) | |
97 running install_lib | |
98 copying build/lib.macosx-10.3-fat-2.4/pydcext.so -> /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages | |
99 |