diff 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
line wrap: on
line diff
--- a/python/pydc/README.txt	Tue Apr 07 21:16:37 2020 +0200
+++ b/python/pydc/README.txt	Wed Apr 08 22:17:43 2020 +0200
@@ -28,6 +28,7 @@
 libhandle = load(libpath)
 funcptr   = find(libhandle, symbolname)
 call(funcptr, signature, ...)
+free(libhandle)
 
 
 SIGNATURE FORMAT
@@ -39,61 +40,34 @@
 
     x is positional parameter-type charcode, y is result-type charcode
 
-  SIG | FROM PYTHON 2                      | FROM PYTHON 3 @@@                  | C/C++                           | TO PYTHON 2                        | TO PYTHON 3 @@@
-  ----+------------------------------------+------------------------------------+---------------------------------+------------------------------------+-----------------------------------
-  'v' |                                    |                                    | void                            |                                    |
-  'B' | PyBool                             | PyBool                             | bool                            | PyBool                             | PyBool
-  'c' | PyInt (range checked)              | PyInt (range checked)              | char                            | PyInt                              | PyInt
-  'C' | PyInt (range checked)              | PyInt (range checked)              | unsigned char                   | PyInt                              | PyInt
-  's' | PyInt (range checked)              | PyInt (range checked)              | short                           | PyInt                              | PyInt
-  'S' | PyInt (range checked)              | PyInt (range checked)              | unsigned short                  | PyInt                              | PyInt
-  'i' | PyInt                              | PyInt                              | int                             | PyInt                              | PyInt
-  'I' | PyInt                              | PyInt                              | unsigned int                    | PyInt                              | PyInt
-  'j' | PyLong                             | PyLong                             | long                            | PyLong                             | PyLong
-  'J' | PyLong                             | PyLong                             | unsigned long                   | PyLong                             | PyLong
-  'l' | PyLongLong                         | PyLongLong                         | long long                       | PyLongLong                         | PyLongLong
-  'L' | PyLongLong                         | PyLongLong                         | unsigned long long              | PyLongLong                         | PyLongLong
-  'f' | PyFloat (cast to single precision) | PyFloat (cast to single precision) | float                           | PyFloat (cast to double precision) | PyFloat (cast to double precision)
-  'd' | PyFloat                            | PyFloat                            | double                          | PyFloat                            | PyFloat
-  'p' | PyUnicode/PyString/PyLong          | PyUnicode/PyBytes/PyLong           | void*                           | Py_ssize_t                         | Py_ssize_t
-  'Z' | PyUnicode/PyString                 | PyUnicode/PyBytes                  | const char* (UTF-8 for unicode) | PyString                           | PyUnicode
+  SIG | FROM PYTHON 2                                        | FROM PYTHON 3                            | C/C++                           | TO PYTHON 2                          | TO PYTHON 3
+  ----+------------------------------------------------------+------------------------------------------+---------------------------------+--------------------------------------+-------------------------------------
+  'v' |                                                      |                                          | void                            | None (Py_None) (e.g. ret of "...)v") | None (Py_None) (e.g. ret of "...)v")
+  'B' | bool (PyBool)                                        | bool (PyBool)#                           | int/bool                        | bool (PyBool)                        | bool (PyBool)@
+  'c' | int (PyLong)%, str (single char)%                    | int (PyLong)%, str (single char)%        | char                            | int (PyInt)                          | int (PyLong)
+  'C' | int (PyLong)%, str (single char)%                    | int (PyLong)%, str (single char)%        | unsigned char                   | int (PyInt)                          | int (PyLong)
+  's' | int (PyInt)%                                         | int (PyLong)%                            | short                           | int (PyInt)                          | int (PyLong)
+  'S' | int (PyInt)%                                         | int (PyLong)%                            | unsigned short                  | int (PyInt)                          | int (PyLong)
+  'i' | int (PyInt)                                          | int (PyLong)                             | int                             | int (PyInt)                          | int (PyLong)
+  'I' | int (PyInt)                                          | int (PyLong)                             | unsigned int                    | int (PyInt)                          | int (PyLong)
+  'j' | int (PyInt)                                          | int (PyLong)                             | long                            | int (PyInt)                          | int (PyLong)
+  'J' | int (PyInt)                                          | int (PyLong)                             | unsigned long                   | int (PyInt)                          | int (PyLong)
+  'l' | int (PyInt), long (PyLong)                           | int (PyLongLong)                         | long long                       | long (PyLong)                        | int (PyLong)
+  'L' | int (PyInt), long (PyLong)                           | int (PyLongLong)                         | unsigned long long              | long (PyLong)                        | int (PyLong)
+  'f' | float (PyFloat)$                                     | float (PyFloat)$                         | float                           | float (PyFloat)^                     | float (PyFloat)^
+  'd' | float (PyFloat)                                      | float (PyFloat)                          | double                          | float (PyFloat)                      | float (PyFloat)
+  'p' | str (PyUnicode/PyString), int (PyInt), long (PyLong) | str (PyUnicode), int (PyLong), (PyBytes) | void*                           | int,long (Py_ssize_t)                | int (Py_ssize_t)
+  'Z' | str (PyUnicode/PyString)                             | str (PyUnicode), (PyBytes)               | const char* (UTF-8 for unicode) | int (PyString)                       | str (PyUnicode)
 
+# converted to 1 if True and 0 otherwise
+@ converted to False if 0 and True otherwise
+% range checked
+$ cast to single precision
+^ cast to double precision
 
 TODO
 ====
 
 - signature suffixes used to indicate calling conventions are not supported yet!
-- not sure if returning 'p' is working, creating PyCObject, check and write test code @@@
 - callback support
 
-
-BUGS
-====
-
-* build on osx/ppc - link error i386 something...  [MacPython 2.4]
-
-  solution:
-  installation of latest python for os x (MacPython 2.5)  
-
-
-EXAMPLE BUILD
-=============
-
-  $ python setup.py install
-  running install
-  running build
-  running build_py
-  creating build
-  creating build/lib.macosx-10.3-fat-2.4
-  copying pydc.py -> build/lib.macosx-10.3-fat-2.4
-  running build_ext
-  building 'pydcext' extension
-  creating build/temp.macosx-10.3-fat-2.4
-  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
-  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
-  /usr/bin/ld: for architecture i386
-  /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)
-  /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)
-  running install_lib
-  copying build/lib.macosx-10.3-fat-2.4/pydcext.so -> /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages
-