2004-01-30 Thomas Heller * (Repository): Added STATUS.txt, which describes the state of the libffi integration. Added bench.bat, a batch file using the timeit module to make it easier to check the speed of some simple operations. 2004-01-20 Thomas Heller * source\_ctypes.c: Moved the test functions into a separate Python extension module _ctypes_test.c. Setup-script and unittests updated. 2003-10-30 Thomas Heller * source\_ctypes.c: Finally added cycle GC support for all the base-types implemented in this module, without breaking the test-suite. 2003-10-24 Thomas Heller * win32\com\__init__.py: Changes to prevent crashes when the interpreter exits, and COM pointers are to be cleaned up. The problem was that CoUninitialize was registered by the atexit module, and this runs *before* all the modules are cleared out and the final Release() call on the COM pointers is done. The solution is to create an object in the com\__init__.py module which will call CoUninitialize when it's refcount reaches zero. Even better would probably be to make this an attribute of the sys module, because sys is cleaned last, only __builtins__ is cleaned later. 2003-07-18 Thomas Heller * ctypes\__init__.py (c_buffer): Accept int as well as long integers as the size argment for c_buffer. 2003-07-09 Thomas Heller * source\_ctypes.c: Prevent crashes on pointer(IUnknown()) call. 2003-07-08 Thomas Heller * source\_ctypes.c: Finally fixed this nasty pointer bug. The incomplete pointer sample from the tutorial now works. 2003-07-03 Thomas Heller * ctypes\__init__.py: Use __getitem__ to load libaries or get functions. gpib = cdll["gpib-32.dll"], and gpib["Function-With-A-Strange_Name@@@"]. Suggested by Chuck Esterbrook. 2003-06-24 Thomas Heller * source\_callbacks.c: Callback functions can now return simple data types like floats, doubles, long long and so on. Before, only integers were returned. 2003-06-12 Thomas Heller * source\*.c: On Windows, structures and unions can now be passed *by value* to function calls. 2003-06-03 Thomas Heller * source\_ctypes.c: Raise AttributeError instead of ValueError when a function is not found in a dll. Suggested by Chuck Esterbrook. 2003-05-16 Thomas Heller * source\_ctypes.c: Fix some (but not all) problems with pointer instance and types. * source\_ctypes.c: Make the restype atribute of functions readable. VisualPython's debugger had problems if it was not. Contributed by Nick Adams. * ctypes\__init__.py: Fix the name of the void pointer type, it's c_void_p not c_voidp (but leave the old name intact) * source\cfield.c: The c_wchar_p.from_param method did not accept None (NULL pointer as parameter). Unittests updated. * source\_ctypes.c: ctypes' types now have a in_dll() class method. It allows to access values exported from dlls. Also added a unittest. Often requested feature. 2003-05-14 Thomas Heller * win32\com\register.py: Register the script with the absolute pathname. 2003-03-11 Thomas Heller * ctypes/source: CFuncPtr changes: The _argtypes_ attribute is now optional (but required if you want to construct callbacks). CFuncPtr now has two contructors: CFuncPtr(callable), and CFuncPtr(funcname, dll). So CFuncPtr can now completely replace both CFunction (for callbacks) and DynFunction (for dll functions). 2003-03-07 Thomas Heller * ctypes: The CFuncPtr type now supports cyclic garbage collection, it is especially useful here, but GC support for other types is not far away. * ctypes: The CFunction subclass _types_ attribute does not accept format characters any more, types like c_int, c_char_p and so on must now be used. The same change has been made for the argtypes and restype attribute of dll functions. A new base type CFuncPtr was added. This will soon make CFunction and DynFunction obsolete. Subclass creation requires an _argtype_ attribute mush must be a sequence of types like c_int or c_charp, a _flags_attribute which must be a bitwise or of FUNCFLAG_CDECL, FUNCFLAG_STDCALL and FUNCFLAG_HRESULT (the latter two only on Windows) to specify the calling convention, and an optional _restype_ attribute which defaults to c_int. The plan is to create some factory functions like STDCALL() and CDECL() which return CFuncPtr subclasses, this is useful to define these subclasses in an expression instead of a class statement, also it probably makes it easier to use. Obscure change: If the CFunction instance uses c_int in the _types_ sequence, it will now receive a standard Python integer and no longer a c_int instance if it is called. (CFuncPtr instances behave in the same way). 2003-03-04 Thomas Heller * ctypes.py (cdll): Changed the __getattr__ implementations for all *DLL classes to raise an attribute error if the requested name both starts and ends with a double underscore. Thanks to Wolfgang Strobl for pointing at this. 2003-02-26 Thomas Heller * source\_ctypes.c: Removed the unused from_bytes stuff. * source\_ctypes.c (CString_new): The buffer is only initialized to the bytes from the string is passed in, if any. The terminating NUL byte is always set. This allows large c_string instances to be created with minimum overhead. * source: Moved code from _ctypes.c into the new files cfield.c (field accessors) and stgdict.c (storage info dict). 2003-02-25 Thomas Heller * source\callproc.c: Added call_cdeclfunction. * source\_ctypes.c: addressof() now accepts CFunction instances. 2003-02-24 Thomas Heller * source\_ctypes.c: c_string() and c_wstring() signatures changed. If the first parameter is a string, an optional positive integer can be used as second parameter to specify the size of the internal buffer. This size does NOT include the terminating NUL byte. Since sizeof() does now support c_string and c_wstring, len() is no longer supported (c_string and c_wstring have never really been sequences). * source\_ctypes.c: Made sizeof() and addressof() work with c_string and c_wstring objects. * source\callproc.c: PyCArgObjects now have a readonly _obj attribute, this is the object passed to the byref() call. Useful for implmenting custom argument type checking in Python. 2003-02-20 Thomas Heller * unittests\test_strings.py (StringTestCase.test_sized_strings): Added tests for the new c_string constructor. * source\_ctypes.c (CString_new): The c_string constructor can now be called with a positive integer, this will create an empty string buffer of the specified length (+ 1 for a terminating NUL character). * source\_ctypes.c (CString_new): It's no longer possible to call c_string with None as argument. It created a string of zero size, but this doesn't seem to make sense. 2003-02-19 Thomas Heller * source/_ctypes.c, ctypes.py: Add a c_voidp data type, which represents (void) pointers to memory locations. The value attribute is a Python integer (or a long). 2003-02-18 Thomas Heller * (Repository): Added a packages directory, and created a ctcom package. See separate changelog. 2003-02-11 Thomas Heller * source/_ctypes.c: The .from_parameter method of POINTER classes now accept Array instances containing elements of exactly the same type. * source/callproc.c: Make sure call_comproc checks for valid number of arguments before calling _CallProc. 2003-02-07 Thomas Heller * Version 0.4.0 released and uploaded. * source/_ctypes.c: PointerType_new, ArrayType_new, SimpleType_new, and CFunctionType_new did not check for NULL result from PyType_Type.tp_new() call. This call will fail in Python 2.3 when 'object' is listed as the first base class with a TypeError: MRO conflict among bases. Spotted by Greg Chapman. 2003-02-05 Thomas Heller * The 'raw' and 'value' properties of c_wstring are back, also fixed some severe bugs (it seems c_wstring never worked correctly). Added unittests. * Fixed a problem in c_string: The NUL byte at the buffer end could be overwritten. Added unittests for c_strings. Per suggestion from Niki Spahiev, CFieldObjects now have a readonly size and offset property. Added short docs for them. 2003-01-31 Thomas Heller * Item deletion on Array or Pointer instances did crash with a NULL pointer access. Added unittest for this, and also for Arrays. 2003-01-28 Thomas Heller * source\_ctypes.c: Dangerous code checked in. Pointer instances can point to a single data item, or they can point to an array of values. Back in the distant past ;-), I had a SetSize() method, which would enable indexes != 0. Don't know when and why I removed it, but I need it again. Should it have to be enabled explicitely? Would be better, it seems. Note that there's no corresponding ass_item implementation with indexes != 0. This means, we can get and change the items the pointer points to, if they are mutable, but not replace the items by different ones. 2003-01-24 Thomas Heller * (several): Fixed the alignment and size of the compound datatypes Structure, Union, and hopefully also Array. 2003-01-23 Thomas Heller * source/_ctypes.c: Raise a TypeError if a SimpleCData type or a CDataType is specified as a CFunction's restype. * source/_ctypes.c: CFunction now has a from_param class method. This means that CFunction subclasses can now be used in the argtypes attribute, and so typechecking is done. * unittests: Rewrote the tests from doctest to pyunit. 2003-01-21 Thomas Heller * source/: Merged in these changes from the C_FAST_CARGS branch: ConvParam returns PyCArgObject instances now. Fixed the _as_parameter_ properties of Array, CString, and CFunction so that they 'return' PyCArgObject instances instead of magic tuples. Added a public 'P' fielddescriptor, which is mostly for internal use. The 's' rettype value for functions is probably useless, because functions return *pointers* to strings (char *), not strings. Adapted all the unittests to work, and also changed the samples. 2003-01-20 Thomas Heller * source/*.[ch]: Introduced PyCArgObject objects, which contain a Python object itself and also the data converted to C. This replaces the magic 3-tuples, and should be somewhat faster because no two conversions take place. This is now used by SimpleType_from_param(), byref(), and Pointer_as_parameter(), and is understood by ConvParam(). In the long run this should be the only thing (besides primitive Python data types with trivial conversions) used by ConvParam(). Also ConvParam should probably *return* these things. 2003-01-17 Thomas Heller * source/_ctypes.c: Rewrite of SimpleType_from_param complete. unittests/test_parameters.py shows that it does the right things in most cases. * (Repository): Moved everything from local CVS to the SF repository, and restructured the directories.