ctypes-commit Mailing List for ctypes (Page 4)
Brought to you by:
theller
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
(8) |
May
(90) |
Jun
(143) |
Jul
(106) |
Aug
(94) |
Sep
(84) |
Oct
(163) |
Nov
(60) |
Dec
(58) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(128) |
Feb
(79) |
Mar
(227) |
Apr
(192) |
May
(179) |
Jun
(41) |
Jul
(53) |
Aug
(103) |
Sep
(28) |
Oct
(38) |
Nov
(81) |
Dec
(17) |
2006 |
Jan
(184) |
Feb
(111) |
Mar
(188) |
Apr
(67) |
May
(58) |
Jun
(123) |
Jul
(73) |
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
From: Thomas H. <th...@us...> - 2006-06-30 16:42:33
|
Update of /cvsroot/ctypes/ctypes/source/libffi_msvc In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv14368 Modified Files: ffitarget.h Log Message: MSVC and MINGW32 have the same trampoline size. Index: ffitarget.h =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/libffi_msvc/ffitarget.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ffitarget.h 17 Mar 2006 15:14:44 -0000 1.8 --- ffitarget.h 30 Jun 2006 12:36:09 -0000 1.9 *************** *** 72,80 **** #define FFI_NATIVE_RAW_API 0 #else ! #ifdef _MSC_VER ! # define FFI_TRAMPOLINE_SIZE 15 ! #else ! # define FFI_TRAMPOLINE_SIZE 10 ! #endif #define FFI_NATIVE_RAW_API 1 /* x86 has native raw api support */ #endif --- 72,76 ---- #define FFI_NATIVE_RAW_API 0 #else ! #define FFI_TRAMPOLINE_SIZE 15 #define FFI_NATIVE_RAW_API 1 /* x86 has native raw api support */ #endif |
From: Thomas H. <th...@us...> - 2006-06-30 16:18:41
|
Update of /cvsroot/ctypes/ctypes/source/libffi_msvc In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv29425 Modified Files: ffi.c Log Message: Remove unused code. Index: ffi.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/libffi_msvc/ffi.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** ffi.c 17 Mar 2006 21:10:10 -0000 1.12 --- ffi.c 30 Jun 2006 14:37:09 -0000 1.13 *************** *** 228,236 **** unsigned short rtype; void *resp = (void*)&res; - //#ifdef _MSC_VER void *args = &argp[1]; - //#else - // void *args = __builtin_dwarf_cfa (); - //#endif cif = closure->cif; --- 228,232 ---- *************** *** 354,361 **** /* How to make a trampoline. Derived from gcc/config/i386/i386.c. */ - /* MOV EDX, ESP is 0x8b 0xd4 */ - - //#ifdef _MSC_VER - #define FFI_INIT_TRAMPOLINE(TRAMP,FUN,CTX,BYTES) \ { unsigned char *__tramp = (unsigned char*)(TRAMP); \ --- 350,353 ---- *************** *** 366,370 **** *(unsigned int*) &__tramp[1] = __ctx; /* mov ecx, __ctx */ \ *(unsigned char*) &__tramp[5] = 0x8b; \ ! *(unsigned char*) &__tramp[6] = 0xd4; \ *(unsigned char*) &__tramp[7] = 0xe8; \ *(unsigned int*) &__tramp[8] = __dis; /* call __fun */ \ --- 358,362 ---- *(unsigned int*) &__tramp[1] = __ctx; /* mov ecx, __ctx */ \ *(unsigned char*) &__tramp[5] = 0x8b; \ ! *(unsigned char*) &__tramp[6] = 0xd4; /* mov edx, esp */ \ *(unsigned char*) &__tramp[7] = 0xe8; \ *(unsigned int*) &__tramp[8] = __dis; /* call __fun */ \ *************** *** 373,389 **** } - //#else - //#define FFI_INIT_TRAMPOLINE(TRAMP,FUN,CTX,BYTES) \ - //({ unsigned char *__tramp = (unsigned char*)(TRAMP); \ - // unsigned int __fun = (unsigned int)(FUN); \ - // unsigned int __ctx = (unsigned int)(CTX); \ - // unsigned int __dis = __fun - ((unsigned int) __tramp + FFI_TRAMPOLINE_SIZE); \ - // *(unsigned char*) &__tramp[0] = 0xb8; \ - // *(unsigned int*) &__tramp[1] = __ctx; /* movl __ctx, %eax */ \ - // *(unsigned char *) &__tramp[5] = 0xe9; \ - // *(unsigned int*) &__tramp[6] = __dis; /* jmp __fun */ \ - // }) - //#endif - /* the cif must already be prep'ed */ --- 365,368 ---- |
From: Thomas H. <th...@us...> - 2006-06-30 15:52:48
|
Update of /cvsroot/ctypes/ctypes/ctypes/test In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv29011 Modified Files: test_win32.py Log Message: Implement the _ctypes.uses_seh() function which can be used to determine if SEH is used or not. Index: test_win32.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/test_win32.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test_win32.py 13 Apr 2006 18:42:30 -0000 1.4 --- test_win32.py 30 Jun 2006 14:36:15 -0000 1.5 *************** *** 31,43 **** self.assertRaises(ValueError, IsWindow, None) ! def test_SEH(self): ! # Call functions with invalid arguments, and make sure that access violations ! # are trapped and raise an exception. ! # ! # Normally, in a debug build of the _ctypes extension ! # module, exceptions are not trapped, so we can only run ! # this test in a release build. ! import sys ! if not hasattr(sys, "getobjects"): self.assertRaises(WindowsError, windll.kernel32.GetModuleHandleA, 32) --- 31,39 ---- self.assertRaises(ValueError, IsWindow, None) ! import _ctypes ! if _ctypes.uses_seh(): ! def test_SEH(self): ! # Call functions with invalid arguments, and make sure that access violations ! # are trapped and raise an exception. self.assertRaises(WindowsError, windll.kernel32.GetModuleHandleA, 32) |
From: Thomas H. <th...@us...> - 2006-06-30 15:46:27
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv29027 Modified Files: callproc.c Log Message: Implement the _ctypes.uses_seh() function which can be used to determine if SEH is used or not. Index: callproc.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/callproc.c,v retrieving revision 1.169 retrieving revision 1.170 diff -C2 -d -r1.169 -r1.170 *** callproc.c 22 Jun 2006 19:21:28 -0000 1.169 --- callproc.c 30 Jun 2006 14:36:21 -0000 1.170 *************** *** 1516,1520 **** --- 1516,1534 ---- } + static PyObject * + uses_seh(PyObject *self, PyObject *args) + { + #ifdef DONT_USE_SEH + Py_INCREF(Py_False); + return Py_False; + #else + Py_INCREF(Py_True); + return Py_True; + #endif + } + PyMethodDef module_methods[] = { + {"uses_seh", uses_seh, METH_NOARGS, + "Return whether ctypes uses Windows structured exception handling"}, {"resize", resize, METH_VARARGS, "Resize the memory buffer of a ctypes instance"}, #ifdef CTYPES_UNICODE |
From: Thomas H. <th...@us...> - 2006-06-30 15:46:24
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv31817 Modified Files: ChangeLog Log Message: *** empty log message *** Index: ChangeLog =================================================================== RCS file: /cvsroot/ctypes/ctypes/ChangeLog,v retrieving revision 1.141 retrieving revision 1.142 diff -C2 -d -r1.141 -r1.142 *** ChangeLog 30 Jun 2006 14:36:35 -0000 1.141 --- ChangeLog 30 Jun 2006 14:43:14 -0000 1.142 *************** *** 1,4 **** --- 1,11 ---- 2006-06-30 Thomas Heller <th...@py...> + * source/libffi_msvc/fficonfig.h: #define __attribute__(x) only + for MSVC, not for mingw compilers. This was the main thing that + was missing for building _ctypes with MINGW32. + + Still, 2 tests are failing when compiled with mingw32: + test_bitfields and test_struct_return_8H. + * source/callproc.c: The _ctypes extension module now exports the function "uses_seh()" which will return True when Windows |
From: Thomas H. <th...@us...> - 2006-06-30 15:15:28
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv12167 Modified Files: callproc.c Log Message: Make sure uses_seh() returns False on non-windows platforms. Index: callproc.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/callproc.c,v retrieving revision 1.170 retrieving revision 1.171 diff -C2 -d -r1.170 -r1.171 *** callproc.c 30 Jun 2006 14:36:21 -0000 1.170 --- callproc.c 30 Jun 2006 15:15:20 -0000 1.171 *************** *** 1519,1523 **** uses_seh(PyObject *self, PyObject *args) { ! #ifdef DONT_USE_SEH Py_INCREF(Py_False); return Py_False; --- 1519,1523 ---- uses_seh(PyObject *self, PyObject *args) { ! #if defined(DONT_USE_SEH) || !defined(MS_WIN32) Py_INCREF(Py_False); return Py_False; |
From: Thomas H. <th...@us...> - 2006-06-30 14:56:15
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv29042 Modified Files: ChangeLog Log Message: Index: ChangeLog =================================================================== RCS file: /cvsroot/ctypes/ctypes/ChangeLog,v retrieving revision 1.140 retrieving revision 1.141 diff -C2 -d -r1.140 -r1.141 *** ChangeLog 14 Jun 2006 18:09:11 -0000 1.140 --- ChangeLog 30 Jun 2006 14:36:35 -0000 1.141 *************** *** 1,2 **** --- 1,11 ---- + 2006-06-30 Thomas Heller <th...@py...> + + * source/callproc.c: The _ctypes extension module now exports the + function "uses_seh()" which will return True when Windows + Structured Exception Handling (SEH) is used to catch faults in + foreign functions, False otherwise. SEH is not used when _ctypes + is compiled with the Mingw compiler, or with MSVC in DEBUG mode. + + 2006-06-12 Thomas Heller <th...@py...> |
From: Thomas H. <th...@us...> - 2006-06-30 14:44:55
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv32258 Modified Files: ChangeLog Log Message: Add missing entry. Index: ChangeLog =================================================================== RCS file: /cvsroot/ctypes/ctypes/ChangeLog,v retrieving revision 1.142 retrieving revision 1.143 diff -C2 -d -r1.142 -r1.143 *** ChangeLog 30 Jun 2006 14:43:14 -0000 1.142 --- ChangeLog 30 Jun 2006 14:44:51 -0000 1.143 *************** *** 15,18 **** --- 15,26 ---- + 2006-06-22 Thomas Heller <th...@py...> + + * Merge in changes done in Python SVN for 2.5 beta 1: + - cleanup whitespace + - add Python2.3 compatibility comments + - fix the testsuite for openbsd + + 2006-06-12 Thomas Heller <th...@py...> |
From: Thomas H. <th...@us...> - 2006-06-28 19:55:49
|
Update of /cvsroot/ctypes/ctypes/codegen In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv31105 Modified Files: TODO Log Message: Update todo-list. Index: TODO =================================================================== RCS file: /cvsroot/ctypes/ctypes/codegen/TODO,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TODO 9 Jun 2006 17:38:41 -0000 1.3 --- TODO 28 Jun 2006 19:55:43 -0000 1.4 *************** *** 1,5 **** codegenerator bugs: ! - In ctypes/comtypes: Move GUID and _GUID into ctypes.wintypes. - Import the old docs into cvs. --- 1,9 ---- codegenerator bugs: ! - If -c is given for h2xml.py, we should rerun gccxml as long as ! compiler errors are found. ! ! - Refactor the code so that function generation can be easily adjusted ! in subclasses of the code generator. - Import the old docs into cvs. *************** *** 7,12 **** - Write a README file. - - Don't add 'artificial' structure or union names to the __all__ list. - - Fix code generation for inline functions: <C code> --- 11,14 ---- |
From: Thomas H. <th...@us...> - 2006-06-23 20:05:01
|
Update of /cvsroot/ctypes/ctypes/codegen In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv1731 Modified Files: ChangeLog Log Message: *** empty log message *** Index: ChangeLog =================================================================== RCS file: /cvsroot/ctypes/ctypes/codegen/ChangeLog,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** ChangeLog 23 Jun 2006 20:02:20 -0000 1.10 --- ChangeLog 23 Jun 2006 20:04:58 -0000 1.11 *************** *** 15,19 **** the linker library name instead of the library pathname. I still have to find out which library (on posix systems) really defines a ! function. 2006-06-14 Thomas Heller <th...@py...> --- 15,20 ---- the linker library name instead of the library pathname. I still have to find out which library (on posix systems) really defines a ! function. The generated code that loads the libraries has been ! reworked. 2006-06-14 Thomas Heller <th...@py...> |
From: Thomas H. <th...@us...> - 2006-06-23 20:02:23
|
Update of /cvsroot/ctypes/ctypes/codegen In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv852 Modified Files: ChangeLog Log Message: *** empty log message *** Index: ChangeLog =================================================================== RCS file: /cvsroot/ctypes/ctypes/codegen/ChangeLog,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ChangeLog 23 Jun 2006 19:59:35 -0000 1.9 --- ChangeLog 23 Jun 2006 20:02:20 -0000 1.10 *************** *** 1,22 **** 2006-06-23 Thomas Heller <th...@py...> ! * Remove the use_generators argument and the corresponding command ! line option for xml2py.py, since the code generator does not ! create decorators any more. Add a '-c' command line option which will insert comments in the generated code that will point the the location in the include ! file where the data types are defined. ! 2006-06-13 Thomas Heller <th...@py...> ! * The '-l' option for the xml2py.py script now takes the linker ! library name instead of the library pathname. 2006-06-14 Thomas Heller <th...@py...> ! * The subprocess module is now required, although the code is ! still compatible with Python 2.3. * The '#define' symbols that cause compilation errors are now --- 1,24 ---- 2006-06-23 Thomas Heller <th...@py...> ! * xml2py.py: Remove the use_generators argument and the ! corresponding command line option for xml2py.py, since the code ! generator does not create decorators any more. Add a '-c' command line option which will insert comments in the generated code that will point the the location in the include ! file where the data types are defined. This replaces the ! hardcoded USE_COMMENTS variable. 2006-06-13 Thomas Heller <th...@py...> ! * xml2py.py: The '-l' option for the xml2py.py script now takes ! the linker library name instead of the library pathname. I still ! have to find out which library (on posix systems) really defines a ! function. 2006-06-14 Thomas Heller <th...@py...> ! * h2xml.py: The subprocess module is now required, although the ! code is still compatible with Python 2.3. * The '#define' symbols that cause compilation errors are now *************** *** 34,38 **** longer list symbols that have to be excluded. - 2006-06-13 Thomas Heller <th...@py...> --- 36,39 ---- |
From: Thomas H. <th...@us...> - 2006-06-23 19:59:39
|
Update of /cvsroot/ctypes/ctypes/codegen In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv31972 Modified Files: ChangeLog Log Message: *** empty log message *** Index: ChangeLog =================================================================== RCS file: /cvsroot/ctypes/ctypes/codegen/ChangeLog,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ChangeLog 14 Jun 2006 18:23:48 -0000 1.8 --- ChangeLog 23 Jun 2006 19:59:35 -0000 1.9 *************** *** 1,2 **** --- 1,13 ---- + 2006-06-23 Thomas Heller <th...@py...> + + * Remove the use_generators argument and the corresponding command + line option for xml2py.py, since the code generator does not + create decorators any more. + + Add a '-c' command line option which will insert comments in the + generated code that will point the the location in the include + file where the data types are defined. + + 2006-06-13 Thomas Heller <th...@py...> |
From: Thomas H. <th...@us...> - 2006-06-23 19:58:50
|
Update of /cvsroot/ctypes/ctypes/codegen/ctypes_codegen In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv31543 Modified Files: xml2py_main.py dynmod.py codegenerator.py Log Message: Remove the use_generators argument and the corresponding command line option, since the code generator does not create decorators any more. Add a '-c' command line option which will insert comments in the generated code that will point the the location in the include file where the data types are defined. Index: xml2py_main.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/codegen/ctypes_codegen/xml2py_main.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** xml2py_main.py 14 Jun 2006 18:23:27 -0000 1.4 --- xml2py_main.py 23 Jun 2006 19:58:45 -0000 1.5 *************** *** 44,51 **** parser = OptionParser("usage: %prog xmlfile [options]") ! parser.add_option("-d", action="store_true", ! dest="use_decorators", ! help="use Python 2.4 function decorators", default=False) --- 44,51 ---- parser = OptionParser("usage: %prog xmlfile [options]") ! parser.add_option("-c", action="store_true", ! dest="generate_comments", ! help="include source file location in comments", default=False) *************** *** 127,132 **** options.expressions = map(re.compile, options.expressions) ! stream.write("# generated by 'xml2py'\n") ! stream.write("# flags '%s'\n" % " ".join(argv[1:])) known_symbols = {} --- 127,133 ---- options.expressions = map(re.compile, options.expressions) ! if options.generate_comments: ! stream.write("# generated by 'xml2py'\n") ! stream.write("# flags '%s'\n" % " ".join(argv[1:])) known_symbols = {} *************** *** 169,173 **** expressions=options.expressions, verbose=options.verbose, ! use_decorators=options.use_decorators, known_symbols=known_symbols, searched_dlls=dlls, --- 170,174 ---- expressions=options.expressions, verbose=options.verbose, ! generate_comments=options.generate_comments, known_symbols=known_symbols, searched_dlls=dlls, Index: codegenerator.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/codegen/ctypes_codegen/codegenerator.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** codegenerator.py 16 Jun 2006 18:48:51 -0000 1.5 --- codegenerator.py 23 Jun 2006 19:58:45 -0000 1.6 *************** *** 6,10 **** # This should be configurable - USE_COMMENTS = True ASSUME_STRINGS = True --- 6,9 ---- *************** *** 152,156 **** class Generator(object): def __init__(self, output, ! use_decorators=False, known_symbols=None, searched_dlls=None): --- 151,155 ---- class Generator(object): def __init__(self, output, ! generate_comments=False, known_symbols=None, searched_dlls=None): *************** *** 159,163 **** self.imports = StringIO.StringIO() ## self.stream = self.imports = self.output ! self.use_decorators = use_decorators self.known_symbols = known_symbols or {} self.searched_dlls = searched_dlls or [] --- 158,162 ---- self.imports = StringIO.StringIO() ## self.stream = self.imports = self.output ! self.generate_comments = generate_comments self.known_symbols = known_symbols or {} self.searched_dlls = searched_dlls or [] *************** *** 290,294 **** self.generate(struct.get_head()) self.more.add(struct) ! if USE_COMMENTS and head.struct.location: print >> self.stream, "# %s %s" % head.struct.location basenames = [self.type_name(b) for b in head.struct.bases] --- 289,293 ---- self.generate(struct.get_head()) self.more.add(struct) ! if self.generate_comments and head.struct.location: print >> self.stream, "# %s %s" % head.struct.location basenames = [self.type_name(b) for b in head.struct.bases] *************** *** 463,467 **** print >> self.stream, "%s._fields_ = [" % body.struct.name ! if USE_COMMENTS and body.struct.location: print >> self.stream, " # %s %s" % body.struct.location index = 0 --- 462,466 ---- print >> self.stream, "%s._fields_ = [" % body.struct.name ! if self.generate_comments and body.struct.location: print >> self.stream, " # %s %s" % body.struct.location index = 0 *************** *** 560,568 **** argnames = [a or "p%d" % (i+1) for i, a in enumerate(func.iterArgNames())] ! if USE_COMMENTS and func.location: print >> self.stream, "# %s %s" % func.location print >> self.stream, "%s = %s.%s" % (func.name, libname, func.name) print >> self.stream, "%s.restype = %s" % (func.name, self.type_name(func.returns)) ! print >> self.stream, "# %s(%s)" % (func.name, ", ".join(argnames)) print >> self.stream, "%s.argtypes = [%s]" % (func.name, ", ".join(args)) --- 559,568 ---- argnames = [a or "p%d" % (i+1) for i, a in enumerate(func.iterArgNames())] ! if self.generate_comments and func.location: print >> self.stream, "# %s %s" % func.location print >> self.stream, "%s = %s.%s" % (func.name, libname, func.name) print >> self.stream, "%s.restype = %s" % (func.name, self.type_name(func.returns)) ! if self.generate_comments: ! print >> self.stream, "# %s(%s)" % (func.name, ", ".join(argnames)) print >> self.stream, "%s.argtypes = [%s]" % (func.name, ", ".join(args)) *************** *** 664,668 **** symbols=None, verbose=False, ! use_decorators=False, known_symbols=None, searched_dlls=None, --- 664,668 ---- symbols=None, verbose=False, ! generate_comments=False, known_symbols=None, searched_dlls=None, *************** *** 704,708 **** ################ gen = Generator(outfile, ! use_decorators=use_decorators, known_symbols=known_symbols, searched_dlls=searched_dlls) --- 704,708 ---- ################ gen = Generator(outfile, ! generate_comments=generate_comments, known_symbols=known_symbols, searched_dlls=searched_dlls) Index: dynmod.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/codegen/ctypes_codegen/dynmod.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** dynmod.py 8 Jun 2006 18:46:47 -0000 1.1 --- dynmod.py 23 Jun 2006 19:58:45 -0000 1.2 *************** *** 102,106 **** self.generator = codegenerator.Generator(output=self, ! use_decorators=False, known_symbols=None, searched_dlls=dlls) --- 102,106 ---- self.generator = codegenerator.Generator(output=self, ! generate_comments=False, known_symbols=None, searched_dlls=dlls) |
From: Thomas H. <th...@us...> - 2006-06-22 19:21:33
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv18134 Modified Files: stgdict.c malloc_closure.c ctypes_dlfcn.h ctypes.h cfield.c callproc.c callbacks.c _ctypes_test.c _ctypes.c Log Message: Merge in changes done in Python SVN for 2.5 beta 1: - cleanup whitespace - add Python2.3 compatibility comments - fix the testsuite for openbsd Index: ctypes_dlfcn.h =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/ctypes_dlfcn.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ctypes_dlfcn.h 3 Mar 2006 20:17:15 -0000 1.2 --- ctypes_dlfcn.h 22 Jun 2006 19:21:28 -0000 1.3 *************** *** 1,3 **** ! /******************************************************************/ #ifndef _CTYPES_DLFCN_H_ --- 1,5 ---- ! /***************************************************************** ! This file should be kept compatible with Python 2.3, see PEP 291. ! *****************************************************************/ #ifndef _CTYPES_DLFCN_H_ Index: ctypes.h =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/ctypes.h,v retrieving revision 1.106 retrieving revision 1.107 diff -C2 -d -r1.106 -r1.107 *** ctypes.h 9 Jun 2006 19:20:20 -0000 1.106 --- ctypes.h 22 Jun 2006 19:21:28 -0000 1.107 *************** *** 1,3 **** ! /******************************************************************/ #if (PY_VERSION_HEX < 0x02050000) --- 1,5 ---- ! /***************************************************************** ! This file should be kept compatible with Python 2.3, see PEP 291. ! *****************************************************************/ #if (PY_VERSION_HEX < 0x02050000) Index: callproc.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/callproc.c,v retrieving revision 1.168 retrieving revision 1.169 diff -C2 -d -r1.168 -r1.169 *** callproc.c 12 Jun 2006 20:28:52 -0000 1.168 --- callproc.c 22 Jun 2006 19:21:28 -0000 1.169 *************** *** 1,2 **** --- 1,7 ---- + /***************************************************************** + This file should be kept compatible with Python 2.3, see PEP 291. + *****************************************************************/ + + /* * History: First version dated from 3/97, derived from my SCMLIB version Index: cfield.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/cfield.c,v retrieving revision 1.120 retrieving revision 1.121 diff -C2 -d -r1.120 -r1.121 *** cfield.c 8 Jun 2006 13:23:07 -0000 1.120 --- cfield.c 22 Jun 2006 19:21:28 -0000 1.121 *************** *** 1,2 **** --- 1,6 ---- + /***************************************************************** + This file should be kept compatible with Python 2.3, see PEP 291. + *****************************************************************/ + #include "Python.h" Index: _ctypes_test.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes_test.c,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** _ctypes_test.c 12 May 2006 20:01:48 -0000 1.53 --- _ctypes_test.c 22 Jun 2006 19:21:28 -0000 1.54 *************** *** 1,2 **** --- 1,7 ---- + /***************************************************************** + This file should be kept compatible with Python 2.3, see PEP 291. + *****************************************************************/ + + #include <Python.h> Index: stgdict.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/stgdict.c,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** stgdict.c 12 Jun 2006 20:29:23 -0000 1.41 --- stgdict.c 22 Jun 2006 19:21:28 -0000 1.42 *************** *** 1,2 **** --- 1,6 ---- + /***************************************************************** + This file should be kept compatible with Python 2.3, see PEP 291. + *****************************************************************/ + #include "Python.h" #include <ffi.h> Index: malloc_closure.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/malloc_closure.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** malloc_closure.c 3 Mar 2006 20:17:15 -0000 1.12 --- malloc_closure.c 22 Jun 2006 19:21:28 -0000 1.13 *************** *** 1,2 **** --- 1,6 ---- + /***************************************************************** + This file should be kept compatible with Python 2.3, see PEP 291. + *****************************************************************/ + #include <Python.h> #include <ffi.h> Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.339 retrieving revision 1.340 diff -C2 -d -r1.339 -r1.340 *** _ctypes.c 12 Jun 2006 20:28:16 -0000 1.339 --- _ctypes.c 22 Jun 2006 19:21:28 -0000 1.340 *************** *** 1,2 **** --- 1,7 ---- + /***************************************************************** + This file should be kept compatible with Python 2.3, see PEP 291. + *****************************************************************/ + + /* ToDo: Index: callbacks.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/callbacks.c,v retrieving revision 1.85 retrieving revision 1.86 diff -C2 -d -r1.85 -r1.86 *** callbacks.c 8 Jun 2006 13:24:44 -0000 1.85 --- callbacks.c 22 Jun 2006 19:21:28 -0000 1.86 *************** *** 1,2 **** --- 1,6 ---- + /***************************************************************** + This file should be kept compatible with Python 2.3, see PEP 291. + *****************************************************************/ + #include "Python.h" #include "compile.h" /* required only for 2.3, as it seems */ |
From: Thomas H. <th...@us...> - 2006-06-22 19:21:23
|
Update of /cvsroot/ctypes/ctypes/ctypes/test In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv18106 Modified Files: test_varsize_struct.py test_loading.py test_anon.py Log Message: Merge in changes done in Python SVN for 2.5 beta 1: - cleanup whitespace - add Python2.3 compatibility comments - fix the testsuite for openbsd Index: test_anon.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/test_anon.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_anon.py 9 Jun 2006 19:20:09 -0000 1.2 --- test_anon.py 22 Jun 2006 19:21:20 -0000 1.3 *************** *** 50,54 **** ("y", c_int)] _anonymous_ = ["_"] ! self.failUnlessEqual(Y.x.offset, 0) self.failUnlessEqual(Y.a.offset, sizeof(c_int)) --- 50,54 ---- ("y", c_int)] _anonymous_ = ["_"] ! self.failUnlessEqual(Y.x.offset, 0) self.failUnlessEqual(Y.a.offset, sizeof(c_int)) Index: test_loading.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/test_loading.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** test_loading.py 12 May 2006 20:06:09 -0000 1.19 --- test_loading.py 22 Jun 2006 19:21:20 -0000 1.20 *************** *** 10,25 **** elif os.name == "ce": libc_name = "coredll" - elif sys.platform == "darwin": - libc_name = "libc.dylib" elif sys.platform == "cygwin": libc_name = "cygwin1.dll" else: ! for line in os.popen("ldd %s" % sys.executable): ! if "libc.so" in line: ! if sys.platform == "openbsd3": ! libc_name = line.split()[4] ! else: ! libc_name = line.split()[2] ! break if is_resource_enabled("printing"): --- 10,17 ---- elif os.name == "ce": libc_name = "coredll" elif sys.platform == "cygwin": libc_name = "cygwin1.dll" else: ! libc_name = find_library("c") if is_resource_enabled("printing"): Index: test_varsize_struct.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/test_varsize_struct.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_varsize_struct.py 2 Jun 2006 21:14:29 -0000 1.3 --- test_varsize_struct.py 22 Jun 2006 19:21:20 -0000 1.4 *************** *** 111,115 **** self.failUnlessEqual(array[:], [10, 11, 12, 13, 14, 25, 26, 27, 28, 29, 0, 0, 0, 0, 0]) self.failUnlessEqual(varsize_array[0:10], [10, 11, 12, 13, 14, 25, 26, 27, 28, 29]) ! if __name__ == "__main__": unittest.main() --- 111,115 ---- self.failUnlessEqual(array[:], [10, 11, 12, 13, 14, 25, 26, 27, 28, 29, 0, 0, 0, 0, 0]) self.failUnlessEqual(varsize_array[0:10], [10, 11, 12, 13, 14, 25, 26, 27, 28, 29]) ! if __name__ == "__main__": unittest.main() |
From: Thomas H. <th...@us...> - 2006-06-22 19:21:18
|
Update of /cvsroot/ctypes/ctypes/ctypes/macholib In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv18073 Modified Files: framework.py dylib.py dyld.py __init__.py Log Message: Merge in changes done in Python SVN for 2.5 beta 1: - cleanup whitespace - add Python2.3 compatibility comments - fix the testsuite for openbsd Index: dylib.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/macholib/dylib.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** dylib.py 3 Mar 2006 20:11:15 -0000 1.4 --- dylib.py 22 Jun 2006 19:21:15 -0000 1.5 *************** *** 1,2 **** --- 1,5 ---- + ###################################################################### + # This file should be kept compatible with Python 2.3, see PEP 291. # + ###################################################################### """ Generic dylib path manipulation Index: framework.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/macholib/framework.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** framework.py 3 Mar 2006 20:11:15 -0000 1.4 --- framework.py 22 Jun 2006 19:21:15 -0000 1.5 *************** *** 1,2 **** --- 1,5 ---- + ###################################################################### + # This file should be kept compatible with Python 2.3, see PEP 291. # + ###################################################################### """ Generic framework path manipulation Index: __init__.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/macholib/__init__.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** __init__.py 3 Mar 2006 20:11:15 -0000 1.4 --- __init__.py 22 Jun 2006 19:21:15 -0000 1.5 *************** *** 1,2 **** --- 1,5 ---- + ###################################################################### + # This file should be kept compatible with Python 2.3, see PEP 291. # + ###################################################################### """ Enough Mach-O to make your head spin. Index: dyld.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/macholib/dyld.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** dyld.py 3 Mar 2006 20:11:15 -0000 1.5 --- dyld.py 22 Jun 2006 19:21:15 -0000 1.6 *************** *** 1,2 **** --- 1,5 ---- + ###################################################################### + # This file should be kept compatible with Python 2.3, see PEP 291. # + ###################################################################### """ dyld emulation |
From: Thomas H. <th...@us...> - 2006-06-22 19:21:12
|
Update of /cvsroot/ctypes/ctypes/ctypes In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv18046 Modified Files: wintypes.py util.py _endian.py __init__.py Log Message: Merge in changes done in Python SVN for 2.5 beta 1: - cleanup whitespace - add Python2.3 compatibility comments - fix the testsuite for openbsd Index: wintypes.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/wintypes.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** wintypes.py 14 Jun 2006 09:13:52 -0000 1.4 --- wintypes.py 22 Jun 2006 19:21:10 -0000 1.5 *************** *** 1,3 **** ! # This file contains the most useful windows datatypes. from ctypes import * --- 1,7 ---- ! ###################################################################### ! # This file should be kept compatible with Python 2.3, see PEP 291. # ! ###################################################################### ! ! # The most useful windows datatypes from ctypes import * *************** *** 6,12 **** DWORD = c_ulong BOOLEAN = BYTE BOOL = c_long ! VARIANT_BOOL = c_short ULONG = c_ulong --- 10,26 ---- DWORD = c_ulong + WCHAR = c_wchar + UINT = c_uint + + DOUBLE = c_double + BOOLEAN = BYTE BOOL = c_long ! ! from ctypes import _SimpleCData ! class VARIANT_BOOL(_SimpleCData): ! _type_ = "v" ! def __repr__(self): ! return "%s(%r)" % (self.__class__.__name__, self.value) ULONG = c_ulong *************** *** 14,19 **** # in the windows header files, these are structures. ! LARGE_INTEGER = c_longlong ! ULARGE_INTEGER = c_ulonglong LPCOLESTR = LPOLESTR = OLESTR = c_wchar_p --- 28,33 ---- # in the windows header files, these are structures. ! _LARGE_INTEGER = LARGE_INTEGER = c_longlong ! _ULARGE_INTEGER = ULARGE_INTEGER = c_ulonglong LPCOLESTR = LPOLESTR = OLESTR = c_wchar_p *************** *** 141,142 **** --- 155,172 ---- ("cFileName", c_wchar * MAX_PATH), ("cAlternameFileName", c_wchar * 14)] + + __all__ = ['ATOM', 'BOOL', 'BOOLEAN', 'BYTE', 'COLORREF', 'DOUBLE', + 'DWORD', 'FILETIME', 'HACCEL', 'HANDLE', 'HBITMAP', 'HBRUSH', + 'HCOLORSPACE', 'HDC', 'HDESK', 'HDWP', 'HENHMETAFILE', 'HFONT', + 'HGDIOBJ', 'HGLOBAL', 'HHOOK', 'HICON', 'HINSTANCE', 'HKEY', + 'HKL', 'HLOCAL', 'HMENU', 'HMETAFILE', 'HMODULE', 'HMONITOR', + 'HPALETTE', 'HPEN', 'HRGN', 'HRSRC', 'HSTR', 'HTASK', 'HWINSTA', + 'HWND', 'LANGID', 'LARGE_INTEGER', 'LCID', 'LCTYPE', 'LGRPID', + 'LONG', 'LPARAM', 'LPCOLESTR', 'LPCSTR', 'LPCWSTR', 'LPOLESTR', + 'LPSTR', 'LPWSTR', 'MAX_PATH', 'MSG', 'OLESTR', 'POINT', + 'POINTL', 'RECT', 'RECTL', 'RGB', 'SC_HANDLE', + 'SERVICE_STATUS_HANDLE', 'SIZE', 'SIZEL', 'SMALL_RECT', 'UINT', + 'ULARGE_INTEGER', 'ULONG', 'VARIANT_BOOL', 'WCHAR', + 'WIN32_FIND_DATAA', 'WIN32_FIND_DATAW', 'WORD', 'WPARAM', '_COORD', + '_FILETIME', '_LARGE_INTEGER', '_POINTL', '_RECTL', '_SMALL_RECT', + '_ULARGE_INTEGER', 'tagMSG', 'tagPOINT', 'tagRECT', 'tagSIZE'] Index: util.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/util.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** util.py 20 Apr 2006 18:13:17 -0000 1.7 --- util.py 22 Jun 2006 19:21:10 -0000 1.8 *************** *** 1,4 **** import sys, os - import ctypes # find_library(name) returns the pathname of a library, or None. --- 1,6 ---- + ###################################################################### + # This file should be kept compatible with Python 2.3, see PEP 291. # + ###################################################################### import sys, os # find_library(name) returns the pathname of a library, or None. *************** *** 42,46 **** elif os.name == "posix": # Andreas Degert's find functions, using gcc, /sbin/ldconfig, objdump ! import re, tempfile def _findLib_gcc(name): --- 44,48 ---- elif os.name == "posix": # Andreas Degert's find functions, using gcc, /sbin/ldconfig, objdump ! import re, tempfile, errno def _findLib_gcc(name): Index: __init__.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/__init__.py,v retrieving revision 1.92 retrieving revision 1.93 diff -C2 -d -r1.92 -r1.93 *** __init__.py 23 May 2006 20:27:36 -0000 1.92 --- __init__.py 22 Jun 2006 19:21:10 -0000 1.93 *************** *** 1,2 **** --- 1,5 ---- + ###################################################################### + # This file should be kept compatible with Python 2.3, see PEP 291. # + ###################################################################### """create and manipulate C data types in Python""" *************** *** 75,79 **** argtypes: a sequence specifying the argument types ! The function prototype can be called in three ways to create a callable object: --- 78,82 ---- argtypes: a sequence specifying the argument types ! The function prototype can be called in different ways to create a callable object: Index: _endian.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/_endian.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** _endian.py 14 Mar 2006 19:29:47 -0000 1.3 --- _endian.py 22 Jun 2006 19:21:10 -0000 1.4 *************** *** 1,2 **** --- 1,5 ---- + ###################################################################### + # This file should be kept compatible with Python 2.3, see PEP 291. # + ###################################################################### import sys from ctypes import * |
From: Thomas H. <th...@us...> - 2006-06-22 19:01:34
|
Update of /cvsroot/ctypes/ctypes/docs/manual In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv9170 Modified Files: reference.txt Log Message: Small fixes. Index: reference.txt =================================================================== RCS file: /cvsroot/ctypes/ctypes/docs/manual/reference.txt,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** reference.txt 22 Jun 2006 18:58:38 -0000 1.41 --- reference.txt 22 Jun 2006 19:01:28 -0000 1.42 *************** *** 322,326 **** parameter, it must be a tuple containing 1, 2, or 3 items. ! The first item is an integer containing flags for the parameter. 1 --- 322,326 ---- parameter, it must be a tuple containing 1, 2, or 3 items. ! The first item is an integer containing flags for the parameter: 1 *************** *** 875,879 **** access the members directly off the TYPEDESC instance. ``td.lptdesc`` and ``td.u.lptdesc`` are equivalent, but the former ! is faster since it does not need to create a temporary ``_U`` instance:: --- 875,879 ---- access the members directly off the TYPEDESC instance. ``td.lptdesc`` and ``td.u.lptdesc`` are equivalent, but the former ! is faster since it does not need to create a temporary union instance:: *************** *** 885,889 **** It is possible to defined sub-subclasses of structures, they inherit the fields of the base class. If the subclass definition has a ! separate``_fields_`` variable, the fields specified in this are appended to the fields of the base class. --- 885,889 ---- It is possible to defined sub-subclasses of structures, they inherit the fields of the base class. If the subclass definition has a ! separate ``_fields_`` variable, the fields specified in this are appended to the fields of the base class. |
From: Thomas H. <th...@us...> - 2006-06-22 18:58:46
|
Update of /cvsroot/ctypes/ctypes/docs/manual In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv7854 Modified Files: reference.txt Log Message: Fix markup. Index: reference.txt =================================================================== RCS file: /cvsroot/ctypes/ctypes/docs/manual/reference.txt,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** reference.txt 14 Jun 2006 09:03:08 -0000 1.40 --- reference.txt 22 Jun 2006 18:58:38 -0000 1.41 *************** *** 134,141 **** an underscore to not clash with exported function names: ! ``_handle``: memberdesc The system handle used to access the library. ! ``_name``: memberdesc The name of the library passed in the contructor. --- 134,141 ---- an underscore to not clash with exported function names: ! ``_handle`` : memberdesc The system handle used to access the library. ! ``_name`` : memberdesc The name of the library passed in the contructor. |
From: Thomas H. <th...@us...> - 2006-06-18 21:56:42
|
Update of /cvsroot/ctypes/ctypes/ctypes/test In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv6900 Modified Files: test_objects.py Log Message: *** empty log message *** Index: test_objects.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/test_objects.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_objects.py 18 Jun 2006 21:51:07 -0000 1.3 --- test_objects.py 18 Jun 2006 21:56:37 -0000 1.4 *************** *** 67,69 **** if __name__ == '__main__': ! doctest.testmod(ctypes.test.test_objects) --- 67,70 ---- if __name__ == '__main__': ! if sys.hexversion > 0x02040000: ! doctest.testmod(ctypes.test.test_objects) |
From: Thomas H. <th...@us...> - 2006-06-18 21:51:11
|
Update of /cvsroot/ctypes/ctypes/ctypes/test In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv4256 Modified Files: test_objects.py Log Message: Skip the test with Python 2.3, since doctest doesn't understand the ELLIPSIS flag. Index: test_objects.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/test_objects.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_objects.py 9 Jun 2006 18:45:38 -0000 1.2 --- test_objects.py 18 Jun 2006 21:51:07 -0000 1.3 *************** *** 55,65 **** ''' ! import unittest, doctest import ctypes.test.test_objects class TestCase(unittest.TestCase): ! def test(self): ! doctest.testmod(ctypes.test.test_objects) if __name__ == '__main__': --- 55,68 ---- ''' ! import unittest, doctest, sys import ctypes.test.test_objects class TestCase(unittest.TestCase): ! if sys.hexversion > 0x02040000: ! # Python 2.3 has no ELLIPSIS flag, so we don't test with this ! # version: ! def test(self): ! doctest.testmod(ctypes.test.test_objects) if __name__ == '__main__': |
From: Thomas H. <th...@us...> - 2006-06-18 21:20:03
|
Update of /cvsroot/ctypes/ctypes/docs/manual In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv21679 Modified Files: tutorial.txt Log Message: Some small corrections. Remove code samples that shows '._objects'. Index: tutorial.txt =================================================================== RCS file: /cvsroot/ctypes/ctypes/docs/manual/tutorial.txt,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** tutorial.txt 18 Jun 2006 14:55:04 -0000 1.36 --- tutorial.txt 18 Jun 2006 21:19:54 -0000 1.37 *************** *** 718,727 **** Usually, ctypes does strict type checking. This means, if you have ! ``POINTER(c_int)`` in the ``argtypes`` list of a function or in the ! ``_fields_`` of a structure definition, only instances of exactly the ! same type are accepted. There are some exceptions to this rule, where ! ctypes accepts other objects. For example, you can pass compatible ! array instances instead of pointer types. So, for ``POINTER(c_int)``, ! ctypes accepts an array of c_int values:: >>> class Bar(Structure): --- 718,727 ---- Usually, ctypes does strict type checking. This means, if you have ! ``POINTER(c_int)`` in the ``argtypes`` list of a function or as the ! type of a member field in a structure definition, only instances of ! exactly the same type are accepted. There are some exceptions to this ! rule, where ctypes accepts other objects. For example, you can pass ! compatible array instances instead of pointer types. So, for ! ``POINTER(c_int)``, ctypes accepts an array of c_int:: >>> class Bar(Structure): *************** *** 729,737 **** ... >>> bar = Bar() - >>> print bar._objects - None >>> bar.values = (c_int * 3)(1, 2, 3) - >>> print bar._objects - {'1': ({}, <ctypes._endian.c_long_Array_3 object at ...>)} >>> bar.count = 3 >>> for i in range(bar.count): --- 729,733 ---- *************** *** 752,758 **** Sometimes you have instances of incompatible types. In ``C``, you can cast one type into another type. ``ctypes`` provides a ``cast`` ! function which can be used in the same way. The Bar structure defined ! above accepts ``POINTER(c_int)`` pointers or ``c_int`` arrays for its ! ``values`` field, but not instances of other types:: >>> bar.values = (c_byte * 4)() --- 748,754 ---- Sometimes you have instances of incompatible types. In ``C``, you can cast one type into another type. ``ctypes`` provides a ``cast`` ! function which can be used in the same way. The ``Bar`` structure ! defined above accepts ``POINTER(c_int)`` pointers or ``c_int`` arrays ! for its ``values`` field, but not instances of other types:: >>> bar.values = (c_byte * 4)() *************** *** 985,989 **** >>> ! So, our array sorted now:: >>> for i in ia: print i, --- 981,988 ---- >>> ! It is quite interesting to see that the Windows ``qsort`` function ! needs more comparisons than the linux version! ! ! As we can easily check, our array sorted now:: >>> for i in ia: print i, *************** *** 995,999 **** Make sure you keep references to CFUNCTYPE objects as long as they are ! used from C code. ctypes doesn't, and if you don't, they may be garbage collected, crashing your program when a callback is made. --- 994,998 ---- Make sure you keep references to CFUNCTYPE objects as long as they are ! used from C code. ``ctypes`` doesn't, and if you don't, they may be garbage collected, crashing your program when a callback is made. *************** *** 1002,1006 **** Sometimes, a dll not only exports functions, it also exports ! values. An example in the Python library itself is the ``Py_OptimizeFlag``, an integer set to 0, 1, or 2, depending on the ``-O`` or ``-OO`` flag given on startup. --- 1001,1005 ---- Sometimes, a dll not only exports functions, it also exports ! variables. An example in the Python library itself is the ``Py_OptimizeFlag``, an integer set to 0, 1, or 2, depending on the ``-O`` or ``-OO`` flag given on startup. |
From: Thomas H. <th...@us...> - 2006-06-18 14:55:07
|
Update of /cvsroot/ctypes/ctypes/docs/manual In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv22343 Modified Files: tutorial.txt Log Message: Fix spelling, and better wording. Index: tutorial.txt =================================================================== RCS file: /cvsroot/ctypes/ctypes/docs/manual/tutorial.txt,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** tutorial.txt 18 Jun 2006 14:48:29 -0000 1.35 --- tutorial.txt 18 Jun 2006 14:55:04 -0000 1.36 *************** *** 106,110 **** On Windows, some dlls export functions not by name but by ordinal. These functions can be accessed by indexing the dll object with the ! odinal number:: >>> cdll.kernel32[1] # doctest: +WINDOWS --- 106,110 ---- On Windows, some dlls export functions not by name but by ordinal. These functions can be accessed by indexing the dll object with the ! ordinal number:: >>> cdll.kernel32[1] # doctest: +WINDOWS *************** *** 454,458 **** Please note that a much more powerful error checking mechanism is ! available with the ``errcheck`` attribute; see the reference manual for details. --- 454,458 ---- Please note that a much more powerful error checking mechanism is ! available through the ``errcheck`` attribute; see the reference manual for details. |
From: Thomas H. <th...@us...> - 2006-06-18 14:48:32
|
Update of /cvsroot/ctypes/ctypes/docs/manual In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv19510 Modified Files: tutorial.txt Log Message: Mention the errcheck protocol in the tutorial. Index: tutorial.txt =================================================================== RCS file: /cvsroot/ctypes/ctypes/docs/manual/tutorial.txt,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** tutorial.txt 18 Jun 2006 14:39:31 -0000 1.34 --- tutorial.txt 18 Jun 2006 14:48:29 -0000 1.35 *************** *** 424,435 **** >>> - XXX Mention the ``errcheck`` protocol... - - You can also use a callable Python object (a function or a class for ! example) as the ``restype`` attribute. It will be called with the ! ``integer`` the C function returns, and the result of this call will ! be used as the result of your function call. This is useful to check ! for error return values and automatically raise an exception:: >>> GetModuleHandle = windll.kernel32.GetModuleHandleA # doctest: +WINDOWS --- 424,433 ---- >>> You can also use a callable Python object (a function or a class for ! example) as the ``restype`` attribute, if the foreign function returns ! an integer. The callable will be called with the ``integer`` the C ! function returns, and the result of this call will be used as the ! result of your function call. This is useful to check for error return ! values and automatically raise an exception:: >>> GetModuleHandle = windll.kernel32.GetModuleHandleA # doctest: +WINDOWS *************** *** 455,458 **** --- 453,460 ---- no one is used, it calls ``GetLastError()`` to retrieve it. + Please note that a much more powerful error checking mechanism is + available with the ``errcheck`` attribute; see the reference manual + for details. + Passing pointers (or: passing parameters by reference) ------------------------------------------------------ |
From: Thomas H. <th...@us...> - 2006-06-18 14:39:41
|
Update of /cvsroot/ctypes/ctypes/docs/manual In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv15607 Modified Files: tutorial.txt Log Message: Remove a todo-item. Index: tutorial.txt =================================================================== RCS file: /cvsroot/ctypes/ctypes/docs/manual/tutorial.txt,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** tutorial.txt 18 Jun 2006 14:28:01 -0000 1.33 --- tutorial.txt 18 Jun 2006 14:39:31 -0000 1.34 *************** *** 1067,1073 **** used for testing. Try it out with ``import __hello__`` for example. - XXX Describe how to access the ``code`` member fields, which contain - the byte code for the modules. - Surprises --------- --- 1067,1070 ---- |