ctypes-commit Mailing List for ctypes (Page 15)
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-03-18 17:32:04
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6686 Modified Files: Tag: unaligned_branch cfield.c Log Message: Make d_set work for unaligned accesses. Index: cfield.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/cfield.c,v retrieving revision 1.117.2.1 retrieving revision 1.117.2.2 diff -C2 -d -r1.117.2.1 -r1.117.2.2 *** cfield.c 18 Mar 2006 17:28:24 -0000 1.117.2.1 --- cfield.c 18 Mar 2006 17:31:56 -0000 1.117.2.2 *************** *** 907,911 **** return NULL; } ! *(double *)ptr = x; _RET(value); } --- 907,911 ---- return NULL; } ! memcpy(ptr, &x, sizeof(double)); _RET(value); } |
From: Thomas H. <th...@us...> - 2006-03-18 17:28:26
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5389 Modified Files: Tag: unaligned_branch cfield.c Log Message: Try to make h_set work for unaligned accesses. Index: cfield.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/cfield.c,v retrieving revision 1.117 retrieving revision 1.117.2.1 diff -C2 -d -r1.117 -r1.117.2.1 *** cfield.c 17 Mar 2006 15:11:11 -0000 1.117 --- cfield.c 18 Mar 2006 17:28:24 -0000 1.117.2.1 *************** *** 537,543 **** { long val; if (get_long(value, &val) < 0) return NULL; ! *(short *)ptr = (short)SET(*(short *)ptr, (short)val, size); _RET(value); } --- 537,546 ---- { long val; + short x; if (get_long(value, &val) < 0) return NULL; ! memcpy(&x, ptr, sizeof(short)); ! x = SET(x, (short)val, size); ! memcpy(ptr, &x, sizeof(short)); _RET(value); } |
From: Thomas H. <th...@us...> - 2006-03-18 17:21:37
|
Update of /cvsroot/ctypes/ctypes/ctypes/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2433 Modified Files: Tag: unaligned_branch test_byteswap.py Log Message: Let us see wher it crashes. Index: test_byteswap.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/test_byteswap.py,v retrieving revision 1.7 retrieving revision 1.7.2.1 diff -C2 -d -r1.7 -r1.7.2.1 *** test_byteswap.py 14 Mar 2006 19:09:21 -0000 1.7 --- test_byteswap.py 18 Mar 2006 17:21:34 -0000 1.7.2.1 *************** *** 245,249 **** ("d", c_double)] ! s1 = S(0x12, 0x1234, 0, 0x12345678, 0, 3.14) s2 = struct.pack(fmt, 0x12, 0x1234, 0x12345678, 3.14) self.failUnlessEqual(bin(s1), bin(s2)) --- 245,257 ---- ("d", c_double)] ! s1 = S() ! print "SET b" ! s1.b = 0x12 ! print "SET h" ! s1.h = 0x1234 ! print "SET i" ! s1.i = 0x12345678 ! print "SET d" ! s1.d = 3.14 s2 = struct.pack(fmt, 0x12, 0x1234, 0x12345678, 3.14) self.failUnlessEqual(bin(s1), bin(s2)) *************** *** 268,272 **** ("d", c_double)] ! s1 = S(0x12, 0x1234, 0, 0x12345678, 0, 3.14) s2 = struct.pack(fmt, 0x12, 0x1234, 0x12345678, 3.14) self.failUnlessEqual(bin(s1), bin(s2)) --- 276,288 ---- ("d", c_double)] ! s1 = S() ! print "SET b" ! s1.b = 0x12 ! print "SET h" ! s1.h = 0x1234 ! print "SET i" ! s1.i = 0x12345678 ! print "SET d" ! s1.d = 3.14 s2 = struct.pack(fmt, 0x12, 0x1234, 0x12345678, 3.14) self.failUnlessEqual(bin(s1), bin(s2)) |
From: Thomas H. <th...@us...> - 2006-03-17 21:19:10
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14353 Modified Files: ChangeLog Log Message: Status of MingW port. Index: ChangeLog =================================================================== RCS file: /cvsroot/ctypes/ctypes/ChangeLog,v retrieving revision 1.111 retrieving revision 1.112 diff -C2 -d -r1.111 -r1.112 *** ChangeLog 17 Mar 2006 15:23:22 -0000 1.111 --- ChangeLog 17 Mar 2006 21:19:00 -0000 1.112 *************** *** 1,5 **** 2006-03-17 Thomas Heller <th...@py...> ! * source\libffi_msvc: Remove unneeded #ifdef and #if defined blocks: the code in this directory is for Windows X86 ONLY. --- 1,11 ---- 2006-03-17 Thomas Heller <th...@py...> ! * Several changes that will eventually allow to compile the ! extensions with the MingW32 compiler on Windows (hopefully!). ! Currently, calling foreign functions seems to work with some ! exceptions: functions that return structures raise errors. ! Callback functions crash Python. ! ! * source\libffi_msvc: Remove unneeded #ifdef and #if defined blocks: the code in this directory is for Windows X86 ONLY. |
From: Thomas H. <th...@us...> - 2006-03-17 21:16:16
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13305 Modified Files: setup.py Log Message: Some steps towards compilation with mingw on Windows. Add some magic to select either the 'win32.c' or the 'win32.S' source file depending on the compiler used. The former contains inline MSVC assembler syntax, the latter has ATT syntax or however this is called. Index: setup.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/setup.py,v retrieving revision 1.134 retrieving revision 1.135 diff -C2 -d -r1.134 -r1.135 *** setup.py 14 Mar 2006 19:29:39 -0000 1.134 --- setup.py 17 Mar 2006 21:16:12 -0000 1.135 *************** *** 31,34 **** --- 31,35 ---- from distutils.dir_util import mkpath from distutils.util import get_platform + from distutils.cygwinccompiler import Mingw32CCompiler ################################################################ *************** *** 126,129 **** --- 127,147 ---- # Add .S (preprocessed assembly) to C compiler source extensions. self.compiler.src_extensions.append('.S') + if isinstance(self.compiler, Mingw32CCompiler): + # Windows lowercases the extensions, it seems, before + # determining how to compile a file. So, even if win32.S + # is in sources, we have to add '.s'. + self.compiler.src_extensions.append('.s') + # We should add the '--enable-stdcall-fixup' compiler flag + for ext in self.extensions: + if ext.name == "_ctypes": + ext.sources.remove("source/libffi_msvc/win32.c") + # This doesn't work - the option goes to the end of the command line, + # but it should probably be at the beginning. So, we have to live + # with the warning. + ## ext.extra_compile_args.append("--enable-stdcall-fixup") + else: + for ext in self.extensions: + if ext.name == "_ctypes": + ext.sources.remove("source/libffi_msvc/win32.S") build_ext.build_ext.build_extensions(self) *************** *** 225,229 **** --- 243,250 ---- "source/libffi_msvc/ffi.c", "source/libffi_msvc/prep_cif.c", + # One of these will be removed, in my_build_ext, depending + # on the compiler used: "source/libffi_msvc/win32.c", + "source/libffi_msvc/win32.S", ]) if sys.version_info >= (2, 4): *************** *** 237,241 **** export_symbols=["DllGetClassObject,PRIVATE", "DllCanUnloadNow,PRIVATE"], ! libraries=["ole32", "user32", "oleaut32"], include_dirs=["source/libffi_msvc"], **kw), --- 258,262 ---- export_symbols=["DllGetClassObject,PRIVATE", "DllCanUnloadNow,PRIVATE"], ! libraries=["ole32", "user32", "oleaut32", "uuid"], include_dirs=["source/libffi_msvc"], **kw), |
From: Thomas H. <th...@us...> - 2006-03-17 21:11:23
|
Update of /cvsroot/ctypes/ctypes/source/libffi_msvc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10254 Modified Files: win32.S Log Message: Change ffi_call_SYSV and ffi_call_STDCALL to return the stack delta in bytes, this is what win32.c already does. Index: win32.S =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/libffi_msvc/win32.S,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** win32.S 3 Mar 2006 20:20:11 -0000 1.5 --- win32.S 17 Mar 2006 21:11:17 -0000 1.6 *************** *** 42,46 **** pushl %ebp movl %esp,%ebp ! # Make room for all of the new args. movl 16(%ebp),%ecx --- 42,50 ---- pushl %ebp movl %esp,%ebp ! ! #THe: save previous %esi, and store the current stack pointer in %esi ! pushl %esi ! movl %esp,%esi ! # Make room for all of the new args. movl 16(%ebp),%ecx *************** *** 65,69 **** movl 16(%ebp),%ecx addl %ecx,%esp ! # Load %ecx with the return type code movl 20(%ebp),%ecx --- 69,75 ---- movl 16(%ebp),%ecx addl %ecx,%esp ! ! sub %esp,%esi # calculate stack pointer difference ! # Load %ecx with the return type code movl 20(%ebp),%ecx *************** *** 126,129 **** --- 132,137 ---- noretval: epilogue: + movl %esi,%eax # return the stack pointer detlta in %eax + popl %esi # restore previous %esi movl %ebp,%esp popl %ebp *************** *** 140,143 **** --- 148,155 ---- movl %esp,%ebp + #THe: save previous %esi, and store the current stack pointer in %esi + pushl %esi + movl %esp,%esi + # Make room for all of the new args. movl 16(%ebp),%ecx *************** *** 159,162 **** --- 171,176 ---- call *28(%ebp) + sub %esp,%esi # difference in stack + # stdcall functions pop arguments off the stack themselves *************** *** 221,224 **** --- 235,240 ---- sc_noretval: sc_epilogue: + movl %esi,%eax # return the stack difference + popl %esi # restore previous %esi value movl %ebp,%esp popl %ebp |
From: Thomas H. <th...@us...> - 2006-03-17 21:10:14
|
Update of /cvsroot/ctypes/ctypes/source/libffi_msvc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9322 Modified Files: ffi.c Log Message: Remove most GCC specific stuff - simply assume that the mingw calling conventions are the same as what MSVC uses. Index: ffi.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/libffi_msvc/ffi.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** ffi.c 17 Mar 2006 15:14:44 -0000 1.11 --- ffi.c 17 Mar 2006 21:10:10 -0000 1.12 *************** *** 215,235 **** static void ffi_prep_incoming_args_SYSV (char *stack, void **ret, void** args, ffi_cif* cif); - #ifndef _MSC_VER - static void ffi_closure_SYSV (ffi_closure *) - __attribute__ ((regparm(1))); - static void ffi_closure_raw_SYSV (ffi_raw_closure *) - __attribute__ ((regparm(1))); - #endif - /* This function is jumped to by the trampoline */ - #ifdef _MSC_VER static void __fastcall ffi_closure_SYSV (ffi_closure *closure, int *argp) - #else - static void - ffi_closure_SYSV (closure) - ffi_closure *closure; - #endif { // this is our return value storage --- 215,222 ---- *************** *** 241,249 **** 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,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; *************** *** 369,373 **** /* MOV EDX, ESP is 0x8b 0xd4 */ ! #ifdef _MSC_VER #define FFI_INIT_TRAMPOLINE(TRAMP,FUN,CTX,BYTES) \ --- 356,360 ---- /* MOV EDX, ESP is 0x8b 0xd4 */ ! //#ifdef _MSC_VER #define FFI_INIT_TRAMPOLINE(TRAMP,FUN,CTX,BYTES) \ *************** *** 386,401 **** } ! #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 */ --- 373,388 ---- } ! //#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 */ |
From: Thomas H. <th...@us...> - 2006-03-17 21:08:35
|
Update of /cvsroot/ctypes/ctypes/source/libffi_msvc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8744 Modified Files: ffi_common.h Log Message: Include <malloc.h>, for compatibility with mingw. Index: ffi_common.h =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/libffi_msvc/ffi_common.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ffi_common.h 3 Mar 2006 20:20:11 -0000 1.5 --- ffi_common.h 17 Mar 2006 21:08:32 -0000 1.6 *************** *** 14,35 **** #include <fficonfig.h> ! ! /* Do not move this. Some versions of AIX are very picky about where ! this is positioned. */ ! #ifdef __GNUC__ ! # define alloca __builtin_alloca ! #else ! # if HAVE_ALLOCA_H ! # include <alloca.h> ! # else ! # ifdef _AIX ! #pragma alloca ! # else ! # ifndef alloca /* predefined by HP cc +Olibcalls */ ! char *alloca (); ! # endif ! # endif ! # endif ! #endif /* Check for the existence of memcpy. */ --- 14,18 ---- #include <fficonfig.h> ! #include <malloc.h> /* Check for the existence of memcpy. */ |
From: Thomas H. <th...@us...> - 2006-03-17 21:07:32
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8240 Modified Files: callproc.c Log Message: Include <malloc.h>, for compatibility with mingw. Don't use SEH on Windows, when compiling with MingW, or in debug mode. Rename the CPP definition. Index: callproc.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/callproc.c,v retrieving revision 1.160 retrieving revision 1.161 diff -C2 -d -r1.160 -r1.161 *** callproc.c 17 Mar 2006 15:12:22 -0000 1.160 --- callproc.c 17 Mar 2006 21:07:27 -0000 1.161 *************** *** 65,69 **** #ifdef MS_WIN32 ! #define alloca _alloca #endif --- 65,69 ---- #ifdef MS_WIN32 ! #include <malloc.h> #endif *************** *** 71,76 **** #include "ctypes.h" ! #ifdef _DEBUG ! #define DEBUG_EXCEPTIONS /* */ #endif --- 71,79 ---- #include "ctypes.h" ! #if defined(_DEBUG) || defined(__MINGW32__) ! /* Don't use structured exception handling on Windows if this is defined. ! MingW, AFAIK, doesn't support it. ! */ ! #define DONT_USE_SEH #endif *************** *** 97,100 **** --- 100,104 ---- } + #ifndef DONT_USE_SEH void SetException(DWORD code, EXCEPTION_RECORD *pr) { *************** *** 255,258 **** --- 259,263 ---- return EXCEPTION_EXECUTE_HANDLER; } + #endif static PyObject * *************** *** 613,619 **** --- 618,626 ---- #ifdef MS_WIN32 int delta; + #ifndef DONT_USE_SEH DWORD dwExceptionCode = 0; EXCEPTION_RECORD record; #endif + #endif /* XXX check before here */ if (restype == NULL) { *************** *** 641,645 **** Py_UNBLOCK_THREADS #ifdef MS_WIN32 ! #ifndef DEBUG_EXCEPTIONS __try { #endif --- 648,652 ---- Py_UNBLOCK_THREADS #ifdef MS_WIN32 ! #ifndef DONT_USE_SEH __try { #endif *************** *** 648,652 **** ffi_call(&cif, (void *)pProc, resmem, avalues); #ifdef MS_WIN32 ! #ifndef DEBUG_EXCEPTIONS } __except (HandleException(GetExceptionInformation(), --- 655,659 ---- ffi_call(&cif, (void *)pProc, resmem, avalues); #ifdef MS_WIN32 ! #ifndef DONT_USE_SEH } __except (HandleException(GetExceptionInformation(), *************** *** 659,666 **** --- 666,675 ---- Py_BLOCK_THREADS #ifdef MS_WIN32 + #ifndef DONT_USE_SEH if (dwExceptionCode) { SetException(dwExceptionCode, &record); return -1; } + #endif if (delta < 0) { if (flags & FUNCFLAG_CDECL) |
From: Thomas H. <th...@us...> - 2006-03-17 21:02:07
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5708 Modified Files: _ctypes.c Log Message: Include <malloc.h>, for compatibility with mingw. Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.313 retrieving revision 1.314 diff -C2 -d -r1.313 -r1.314 *** _ctypes.c 17 Mar 2006 15:13:18 -0000 1.313 --- _ctypes.c 17 Mar 2006 21:02:01 -0000 1.314 *************** *** 106,109 **** --- 106,110 ---- #ifdef MS_WIN32 #include <windows.h> + #include <malloc.h> # ifdef _WIN32_WCE /* Unlike desktop Windows, WinCE has both W and A variants of *************** *** 2402,2406 **** where n is 0, 4, 8, 12, ..., 128 */ ! mangled_name = _alloca(strlen(name) + 1 + 1 + 1 + 3); /* \0 _ @ %d */ for (i = 0; i < 32; ++i) { sprintf(mangled_name, "_%s@%d", name, i*4); --- 2403,2407 ---- where n is 0, 4, 8, 12, ..., 128 */ ! mangled_name = alloca(strlen(name) + 1 + 1 + 1 + 3); /* \0 _ @ %d */ for (i = 0; i < 32; ++i) { sprintf(mangled_name, "_%s@%d", name, i*4); |
From: Thomas H. <th...@us...> - 2006-03-17 17:23:48
|
Update of /cvsroot/ctypes/ctypes/docs/manual In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16927 Added Files: mkpydoc.py Log Message: Script to convert REST into LATEX. Shamelessly stolen from the optik repository, and hacked upon. --- NEW FILE: mkpydoc.py --- #!/usr/bin/python # Convert the Optik docs to LaTeX for use in Python docs import sys, os import re from popen2 import popen2 from glob import glob import rfc822 from distutils.dep_util import newer_group, newer from docutils.core import Publisher from docutils.readers.standalone import Reader as StandaloneReader from docutils.transforms import Transform from docutils.writers.latex2e import Writer as LaTeXWriter, LaTeXTranslator from docutils import nodes class OptikReader(StandaloneReader): #default_transforms = (StandaloneReader.default_transforms + # (ReplacementTransform,)) pass class PyLaTeXWriter(LaTeXWriter): def __init__(self): LaTeXWriter.__init__(self) self.translator_class = PyLaTeXTranslator class PyLaTeXTranslator(LaTeXTranslator): codemarkup = { 'optik' : 'module', # Methods of OptionParser, Option, Values, ... 'add_option()' : 'method', 'set_defaults()' : 'method', 'parse_args()' : 'method', 'OptionParser.parse_args()' : 'method', 'parser.print_help()' : 'method', 'error()' : 'method', 'take_action()' : 'method', 'Option.take_action()' : 'method', 'MyOption.take_action()': 'method', 'ensure_value()' : 'method', '_process_long_opt()' : 'method', '_process_short_opts()' : 'method', # Optik/optparse classes 'OptionParser' : 'class', 'Option' : 'class', 'make_option()' : 'function', # Class attributes of Option 'ACTIONS' : 'member', 'STORE_ACTIONS' : 'member', 'TYPED_ACTIONS' : 'member', 'TYPES' : 'member', 'TYPE_CHECKER' : 'member', 'Option.TYPE_CHECKER' : 'member', # Miscellaneous builtins / other standard stuff 'sys.exit()' : 'function', 'sys.argv' : 'var', 'str()' : 'function', 'getattr()' : 'function', 'copy()' : 'function', 'None' : 'code', 'True' : 'code', 'False' : 'code', # Hmmm, these sorta depend on context (but they're pretty # consistently the main Option attributes). 'action' : 'member', 'type' : 'member', 'dest' : 'member', 'help' : 'member', # Various values for Option.action: what is the right markup? 'store' : 'code', 'store_true' : 'code', 'store_false' : 'code', 'store_const' : 'code', 'append' : 'code', 'extend' : 'code', 'count' : 'code', 'callback' : 'code', 'version' : 'code', } remap_title = { "The Tao of Option Parsing" : "Background", "Optik Tutorial": "Tutorial", "Optik Reference Guide": "Reference Guide", } # XXX need to factor this out module_name = "ctypes" module_summary = "A foreign function library for Python." module_type = "standard" module_author = "Thomas Heller" module_author_email = "th...@py..." module_synopsis = ("A foreign function library for Python.") version_added = "2.5" refuri_override = { "reference" : "reference-guide", "callbacks" : "option-callbacks", } def __init__(self, document): LaTeXTranslator.__init__(self, document) self.head_prefix = [] self.head = [] self.body_prefix = [] self.in_title = False # Disable a bunch of methods from the base class. empty_method = lambda self: None for nodetype in ('field_argument', 'field_body', 'field_list', 'field_name'): setattr(self, 'visit_' + nodetype, empty_method) setattr(self, 'depart_' + nodetype, empty_method) self.head_prefix = [ "\\section{\\module{%(module_name)s} --- %(module_summary)s}\n" "\\declaremodule{%(module_type)s}{%(module_name)s}\n" "\\moduleauthor{%(module_author)s}{%(module_author_email)s}\n" "\\modulesynopsis{%(module_synopsis)s}\n" "\\versionadded{%(version_added)s}\n" % vars(self.__class__) ] def astext(self): return ''.join(self.head_prefix + self.head + self.body_prefix + self.body + self.body_suffix) def generate_section_label(self, title): title = title.lower() title = re.sub(r'\([^\)]*\)', '', title) title = re.sub(r'[^\w\s\-]', '', title) title = re.sub(r'\b(the|an?|and|your|are)\b', '', title) title = re.sub(r'(example \d+).*', r'\1', title) title = title.replace("optik", "optparse") return "ctypes-" + "-".join(title.split()) def visit_document(self, node): pass def depart_document(self, node): pass def visit_docinfo(self, node): #print "visit_docinfo: %r" % node self.docinfo = [] def depart_docinfo(self, node): #print "depart_docinfo: %r" % node self.body = self.docinfo + self.body self.docinfo = None def visit_docinfo_item(self, node, name): #print "visit_docinfo_item: node=%r, name=%r" % (node, name) if name == "author": (name, email) = rfc822.parseaddr(node.astext()) self.docinfo.append("\\sectionauthor{%s}{%s}\n" % (name, email)) raise nodes.SkipNode def depart_docinfo_item(self, node): pass #def visit_field(self, node): # (name, value) = (node[0].astext(), node[1].astext()) # print "visit_field: node=%r (name=%r, value=%r)" % (node, name, value) # if self.docinfo is not None: # if name == "VersionAdded": # self.docinfo.append("\\versionadded{%s}\n" % value) # raise nodes.SkipNode _quoted_string_re = re.compile(r'\"[^\"]*\"') _short_opt_string_re = re.compile(r'-[a-zA-Z]') _long_opt_string_re = re.compile(r'--[a-zA-Z-]+') _identifier_re = re.compile(r'[a-zA-Z_][a-zA-Z_0-9]*' r'(\.[a-zA-Z_][a-zA-Z_0-9]*)*' r'(\(\))?$') def visit_literal(self, node): assert isinstance(node[0], nodes.Text) text = node[0].data #### text = re.sub(r'optik(\.[a-z]+)?\.', 'optparse.', text) if self.in_title: cmd = None elif self._quoted_string_re.match(text): cmd = 'code' elif self._short_opt_string_re.match(text): cmd = 'programopt' elif self._long_opt_string_re.match(text): cmd = 'longprogramopt' text = text[2:] elif self._identifier_re.match(text): cmd = self.codemarkup.get(text) if cmd is None: #print "warning: unrecognized code word %r" % text cmd = 'code' else: cmd = 'code' self.literal = 1 node[0].data = text if cmd is not None: self.body.append('\\%s{' % cmd) def depart_literal(self, node): if not self.in_title: self.body.append('}') self.literal = 0 def visit_literal_block(self, node): self.body.append("\\begin{verbatim}\n") self.verbatim = 1 def depart_literal_block(self, node): self.verbatim = 0 self.body.append("\n\\end{verbatim}\n") def visit_title(self, node): title = node.astext() title = self.remap_title.get(title, title) label = self.generate_section_label(title) #print "%s -> %s" % (title, label) section_name = self.d_class.section(self.section_level + 1) self.body.append("\n\n\\%s{" % section_name) self.context.append("\\label{%s}}\n" % label) self.in_title = True def depart_title(self, node): self.in_title = False self.body.append(self.context.pop()) def visit_target(self, node): pass def depart_target(self, node): pass def bookmark(self, node): pass def visit_definition(self, node): pass def depart_definition(self, node): pass def visit_definition_list_item(self, node): pass def depart_definition_list_item(self, node): pass # override merely to lose the newline, which causes problems # in one obscure case -- can go away if the docutils developers # accept my second patch to latex2e.py def depart_term(self, node): self.body.append(']') def visit_reference(self, node): if node.has_key('refuri'): refuri = node['refuri'] basename = os.path.splitext(refuri)[0] label = "optparse-" + self.refuri_override.get(basename, basename) print "got refuri=%r, label=%r" % (refuri, label) elif node.has_key('refid'): label = self.generate_section_label(node['refid']) print "got refid=%r, label=%r" % (node['refid'], label) else: print "warning: unhandled reference: node=%r" % node LaTeXTranslator.visit_reference(self, node) self.body.append("section~\\ref{%s}, " % label) raise nodes.SkipDeparture _quoted_phrase_re = re.compile(r'"([^"]+)"') _em_dash_re = re.compile(r'\s+\-\-\s+') def visit_Text(self, node): text = node.astext() if self.in_title: text = self.remap_title.get(text, text) if not (self.literal or self.verbatim): text = self._em_dash_re.sub(u"\u2014", text) text = self._quoted_phrase_re.sub(u"\u201C\\1\u201D", text) text = re.sub(r'\bdocument\b', "section", text) #### text = re.sub(r'optik(\.[a-z]+)?', 'optparse', text) text = self.encode(text) # A couple of transformations are easiest if they go direct # to LaTeX, so do them *after* encode(). text = text.replace("Optik", "\\module{optparse}") text = text.replace("UNIX", "\\UNIX{}") self.body.append(text) def depart_Text(self, node): pass def concatenate_sources(sources, target): print "concatenating source files to %s" % target outdir = os.path.dirname(target) if not os.path.isdir(outdir): os.makedirs(outdir) outfile = open(target, "wt") for filename in sources: file = open(filename, "rt") for line in file: outfile.write(line) outfile.write("\n\n") file.close() outfile.close() def convert(infilename, outfilename): print "converting %s to %s" % (infilename, outfilename) pub = Publisher() pub.set_components('standalone', # reader 'restructuredtext', # parser 'latex') # writer (arg, will be discarded) pub.reader = OptikReader() pub.writer = PyLaTeXWriter() pub.process_programmatic_settings(None, None, None) pub.set_source(source_path=infilename) pub.set_destination(destination_path=outfilename) pub.publish() def main(): convert("manual.txt", "manual.tex") main() |
From: Thomas H. <th...@us...> - 2006-03-17 15:34:49
|
Update of /cvsroot/ctypes/ctypes/ctypes/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26930 Modified Files: test_posix.py Log Message: Test failed when libGL.so or libGLU.ps were not installed. Index: test_posix.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/test_posix.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_posix.py 14 Mar 2006 19:09:21 -0000 1.3 --- test_posix.py 17 Mar 2006 15:34:44 -0000 1.4 *************** *** 9,14 **** class TestRTLD_GLOBAL(unittest.TestCase): def test_GL(self): ! cdll.load('libGL.so', mode=RTLD_GLOBAL) ! cdll.load('libGLU.so') ##if os.name == "posix" and sys.platform != "darwin": --- 9,16 ---- class TestRTLD_GLOBAL(unittest.TestCase): def test_GL(self): ! if os.path.exists('/usr/lib/libGL.so'): ! cdll.load('libGL.so', mode=RTLD_GLOBAL) ! if os.path.exists('/usr/lib/libGLU.so'): ! cdll.load('libGLU.so') ##if os.name == "posix" and sys.platform != "darwin": |
From: Thomas H. <th...@us...> - 2006-03-17 15:23:26
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21590 Modified Files: ChangeLog Log Message: Index: ChangeLog =================================================================== RCS file: /cvsroot/ctypes/ctypes/ChangeLog,v retrieving revision 1.110 retrieving revision 1.111 diff -C2 -d -r1.110 -r1.111 *** ChangeLog 10 Mar 2006 17:42:21 -0000 1.110 --- ChangeLog 17 Mar 2006 15:23:22 -0000 1.111 *************** *** 1,2 **** --- 1,49 ---- + 2006-03-17 Thomas Heller <th...@py...> + + * source\libffi_msvc: Remove unneeded #ifdef and #if defined + blocks: the code in this directory is for Windows X86 ONLY. + + * source: Backport some changes made in the Python SVN repository + that made the code more robust and did better handling of errors. + The only visible change should be that for [in, lcid] parameter + types a default value of int(0) is used if not default has been + supplied in paramflags. + + + 2006-03-15 Thomas Heller <th...@py...> + + * source/libffi/include/ffi.h.in: Suppress most warnings when + files that include ffi.h are compiled by using proper function + prototypes. + + 2006-03-15 Thomas Heller <th...@py...> + + * source/cfield.c: PyString_FromFormat()b understands the C99 "z" + qualifier on all platforms, in Python 2.5. Patch from Tim Peters, + adapted to work with older Python versions. + + 2006-03-14 Thomas Heller <th...@py...> + + * source\ctypes.h, source\_ctypes.c: Apply a patch (after adding + support for older versions of Python) supplied by Neal Norwitz. + This patch implements the changes needed for PEP353 (Py_ssize_t). + He writes: + + The attached patch fixes all the ctypes tests so they pass on + amd64. It also fixes several warnings. I'm not sure what else to + do with the patch. Let me know how you want to handle these in + the future. + + I'm not sure the patch is 100% correct. You will need to decide + what can be 64 bits and what can't. I believe + sq_{item,slice,ass_item,ass_slice} all need to use Py_ssize_t. + The types in ctypes.h may not require all the changes I made. I + don't know how you want to support older version, so I + unconditionally changed the types to Py_ssize_t. + + 2006-03-10 Thomas Heller <th...@py...> + + * source/_ctypes.c: Fix foreign functions loaded via ordinal on Windows CE. + 2006-03-10 Thomas Heller <th...@py...> |
From: Thomas H. <th...@us...> - 2006-03-14 20:04:13
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18992 Modified Files: ctypes.h _ctypes.c Log Message: Apply a patch (after adding support for older versions of Python) supplied by Neal Norwitz. He writes: """ The attached patch fixes all the ctypes tests so they pass on amd64. It also fixes several warnings. I'm not sure what else to do with the patch. Let me know how you want to handle these in the future. I'm not sure the patch is 100% correct. You will need to decide what can be 64 bits and what can't. I believe sq_{item,slice,ass_item,ass_slice} all need to use Py_ssize_t. The types in ctypes.h may not require all the changes I made. I don't know how you want to support older version, so I unconditionally changed the types to Py_ssize_t. """ Index: ctypes.h =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/ctypes.h,v retrieving revision 1.100 retrieving revision 1.101 diff -C2 -d -r1.100 -r1.101 *** ctypes.h 3 Mar 2006 20:17:15 -0000 1.100 --- ctypes.h 14 Mar 2006 20:04:07 -0000 1.101 *************** *** 1,4 **** --- 1,17 ---- /******************************************************************/ + #if (PY_VERSION_HEX < 0x02050000) + typedef int Py_ssize_t; + #define lenfunc inquiry + #define readbufferproc getreadbufferproc + #define writebufferproc getwritebufferproc + #define segcountproc getsegcountproc + #define charbufferproc getcharbufferproc + #define ssizeargfunc intargfunc + #define ssizessizeargfunc intintargfunc + #define ssizeobjargproc intobjargproc + #define ssizessizeobjargproc intintobjargproc + #endif + #ifndef MS_WIN32 #define max(a, b) ((a) > (b) ? (a) : (b)) *************** *** 51,57 **** int b_needsfree; /* need _we_ free the memory? */ CDataObject *b_base; /* pointer to base object or NULL */ ! int b_size; /* size of memory block in bytes */ ! int b_length; /* number of references we need */ ! int b_index; /* index of this object into base's b_object list */ PyObject *b_objects; /* list of references we need to keep */ --- 64,70 ---- int b_needsfree; /* need _we_ free the memory? */ CDataObject *b_base; /* pointer to base object or NULL */ ! Py_ssize_t b_size; /* size of memory block in bytes */ ! Py_ssize_t b_length; /* number of references we need */ ! Py_ssize_t b_index; /* index of this object into base's b_object list */ PyObject *b_objects; /* list of references we need to keep */ *************** *** 65,71 **** int b_needsfree; /* need _we_ free the memory? */ CDataObject *b_base; /* pointer to base object or NULL */ ! int b_size; /* size of memory block in bytes */ ! int b_length; /* number of references we need */ ! int b_index; /* index of this object into base's b_object list */ PyObject *b_objects; /* list of references we need to keep */ --- 78,84 ---- int b_needsfree; /* need _we_ free the memory? */ CDataObject *b_base; /* pointer to base object or NULL */ ! Py_ssize_t b_size; /* size of memory block in bytes */ ! Py_ssize_t b_length; /* number of references we need */ ! Py_ssize_t b_index; /* index of this object into base's b_object list */ PyObject *b_objects; /* list of references we need to keep */ *************** *** 95,100 **** extern int StructUnionType_update_stgdict(PyObject *fields, PyObject *type, int isStruct); ! extern int PyType_stginfo(PyTypeObject *self, int *psize, int *palign, int *plength); ! extern int PyObject_stginfo(PyObject *self, int *psize, int *palign, int *plength); --- 108,113 ---- extern int StructUnionType_update_stgdict(PyObject *fields, PyObject *type, int isStruct); ! extern int PyType_stginfo(PyTypeObject *self, Py_ssize_t *psize, Py_ssize_t *palign, Py_ssize_t *plength); ! extern int PyObject_stginfo(PyObject *self, Py_ssize_t *psize, Py_ssize_t *palign, Py_ssize_t *plength); *************** *** 119,123 **** extern PyObject *CData_AtAddress(PyObject *type, void *buf); ! extern PyObject *CData_FromBytes(PyObject *type, char *data, int length); extern PyTypeObject ArrayType_Type; --- 132,136 ---- extern PyObject *CData_AtAddress(PyObject *type, void *buf); ! extern PyObject *CData_FromBytes(PyObject *type, char *data, Py_ssize_t length); extern PyTypeObject ArrayType_Type; *************** *** 138,142 **** extern PyObject * ! CreateArrayType(PyObject *itemtype, int length); extern void init_callbacks_in_module(PyObject *m); --- 151,155 ---- extern PyObject * ! CreateArrayType(PyObject *itemtype, Py_ssize_t length); extern void init_callbacks_in_module(PyObject *m); *************** *** 165,171 **** typedef struct { PyObject_HEAD ! int offset; ! int size; ! int index; /* Index into CDataObject's object array */ PyObject *proto; /* a type or NULL */ --- 178,184 ---- typedef struct { PyObject_HEAD ! Py_ssize_t offset; ! Py_ssize_t size; ! Py_ssize_t index; /* Index into CDataObject's object array */ PyObject *proto; /* a type or NULL */ *************** *** 186,192 **** belong into this structure anyway. Maybe in ctypes 2.0... (ctypes 2000?) */ ! int size; /* number of bytes */ ! int align; /* alignment requirements */ ! int length; /* number of fields */ ffi_type ffi_type; PyObject *proto; /* Only for Pointer/ArrayObject */ --- 199,205 ---- belong into this structure anyway. Maybe in ctypes 2.0... (ctypes 2000?) */ ! Py_ssize_t size; /* number of bytes */ ! Py_ssize_t align; /* alignment requirements */ ! Py_ssize_t length; /* number of fields */ ffi_type ffi_type; PyObject *proto; /* Only for Pointer/ArrayObject */ *************** *** 299,307 **** extern PyObject * CData_get(PyObject *type, GETFUNC getfunc, PyObject *src, ! int index, int size, char *ptr); extern int CData_set(PyObject *dst, PyObject *type, SETFUNC setfunc, PyObject *value, ! int index, int size, char *ptr); extern void Extend_Error_Info(PyObject *exc_class, char *fmt, ...); --- 312,320 ---- extern PyObject * CData_get(PyObject *type, GETFUNC getfunc, PyObject *src, ! Py_ssize_t index, Py_ssize_t size, char *ptr); extern int CData_set(PyObject *dst, PyObject *type, SETFUNC setfunc, PyObject *value, ! Py_ssize_t index, Py_ssize_t size, char *ptr); extern void Extend_Error_Info(PyObject *exc_class, char *fmt, ...); *************** *** 309,313 **** struct basespec { CDataObject *base; ! int index; char *adr; }; --- 322,326 ---- struct basespec { CDataObject *base; ! Py_ssize_t index; char *adr; }; *************** *** 375,379 **** extern void _AddTraceback(char *, char *, int); ! extern PyObject *CData_FromBaseObj(PyObject *type, PyObject *base, int index, char *adr); /* XXX better name needed! */ --- 388,392 ---- extern void _AddTraceback(char *, char *, int); ! extern PyObject *CData_FromBaseObj(PyObject *type, PyObject *base, Py_ssize_t index, char *adr); /* XXX better name needed! */ Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.311 retrieving revision 1.312 diff -C2 -d -r1.311 -r1.312 *** _ctypes.c 10 Mar 2006 20:08:27 -0000 1.311 --- _ctypes.c 14 Mar 2006 20:04:07 -0000 1.312 *************** *** 336,340 **** static PyObject * ! CDataType_repeat(PyObject *self, int length) { return CreateArrayType(self, length); --- 336,340 ---- static PyObject * ! CDataType_repeat(PyObject *self, Py_ssize_t length) { return CreateArrayType(self, length); *************** *** 696,700 **** { char *ptr; ! int size; if (PyBuffer_Check(value)) { size = value->ob_type->tp_as_buffer->bf_getreadbuffer(value, 0, (void *)&ptr); --- 696,700 ---- { char *ptr; ! Py_ssize_t size; if (PyBuffer_Check(value)) { size = value->ob_type->tp_as_buffer->bf_getreadbuffer(value, 0, (void *)&ptr); *************** *** 1790,1794 **** char string[256]; /* XXX is that enough? */ char *cp = string; - int len; *cp++ = index + '0'; while (target->b_base) { --- 1790,1793 ---- *************** *** 1796,1800 **** target = target->b_base; } - len = cp - string; return PyString_FromStringAndSize(string, cp-string); } --- 1795,1798 ---- *************** *** 1876,1880 **** }; ! static int CData_GetBuffer(CDataObject *self, int seg, void **pptr) { if (seg != 0) { --- 1874,1878 ---- }; ! static Py_ssize_t CData_GetBuffer(CDataObject *self, Py_ssize_t seg, void **pptr) { if (seg != 0) { *************** *** 1886,1890 **** } ! static int CData_GetSegcount(CDataObject *self, int *lenp) { if (lenp) --- 1884,1888 ---- } ! static Py_ssize_t CData_GetSegcount(CDataObject *self, Py_ssize_t *lenp) { if (lenp) *************** *** 1894,1901 **** static PyBufferProcs CData_as_buffer = { ! (getreadbufferproc)CData_GetBuffer, ! (getwritebufferproc)CData_GetBuffer, ! (getsegcountproc)CData_GetSegcount, ! (getcharbufferproc)NULL, }; --- 1892,1899 ---- static PyBufferProcs CData_as_buffer = { ! (readbufferproc)CData_GetBuffer, ! (writebufferproc)CData_GetBuffer, ! (segcountproc)CData_GetSegcount, ! (charbufferproc)NULL, }; *************** *** 1986,1990 **** PyObject * ! CData_FromBaseObj(PyObject *type, PyObject *base, int index, char *adr) { CDataObject *cmem; --- 1984,1988 ---- PyObject * ! CData_FromBaseObj(PyObject *type, PyObject *base, Py_ssize_t index, char *adr) { CDataObject *cmem; *************** *** 2065,2069 **** PyObject * CData_get(PyObject *type, GETFUNC getfunc, PyObject *src, ! int index, int size, char *adr) { StgDictObject *dict; --- 2063,2067 ---- PyObject * CData_get(PyObject *type, GETFUNC getfunc, PyObject *src, ! Py_ssize_t index, Py_ssize_t size, char *adr) { StgDictObject *dict; *************** *** 2082,2086 **** static PyObject * _CData_set(CDataObject *dst, PyObject *type, SETFUNC setfunc, PyObject *value, ! int size, char *ptr) { CDataObject *src; --- 2080,2084 ---- static PyObject * _CData_set(CDataObject *dst, PyObject *type, SETFUNC setfunc, PyObject *value, ! Py_ssize_t size, char *ptr) { CDataObject *src; *************** *** 2178,2182 **** int CData_set(PyObject *dst, PyObject *type, SETFUNC setfunc, PyObject *value, ! int index, int size, char *ptr) { CDataObject *mem = (CDataObject *)dst; --- 2176,2180 ---- int CData_set(PyObject *dst, PyObject *type, SETFUNC setfunc, PyObject *value, ! Py_ssize_t index, Py_ssize_t size, char *ptr) { CDataObject *mem = (CDataObject *)dst; *************** *** 3351,3355 **** if (kwds) { PyObject *key, *value; ! int pos = 0; while(PyDict_Next(kwds, &pos, &key, &value)) { if (-1 == PyObject_SetAttr(self, key, value)) --- 3349,3353 ---- if (kwds) { PyObject *key, *value; ! Py_ssize_t pos = 0; while(PyDict_Next(kwds, &pos, &key, &value)) { if (-1 == PyObject_SetAttr(self, key, value)) *************** *** 3504,3513 **** static PyObject * ! Array_slice(CDataObject *self, int ilow, int ihigh) { StgDictObject *stgdict, *itemdict; PyObject *proto; PyListObject *np; ! int i, len; if (ilow < 0) --- 3502,3511 ---- static PyObject * ! Array_slice(CDataObject *self, Py_ssize_t ilow, Py_ssize_t ihigh) { StgDictObject *stgdict, *itemdict; PyObject *proto; PyListObject *np; ! Py_ssize_t i, len; if (ilow < 0) *************** *** 3620,3630 **** static PySequenceMethods Array_as_sequence = { ! (inquiry)Array_length, /* sq_length; */ 0, /* sq_concat; */ 0, /* sq_repeat; */ ! (intargfunc)Array_item, /* sq_item; */ ! (intintargfunc)Array_slice, /* sq_slice; */ ! (intobjargproc)Array_ass_item, /* sq_ass_item; */ ! (intintobjargproc)Array_ass_slice, /* sq_ass_slice; */ 0, /* sq_contains; */ --- 3618,3628 ---- static PySequenceMethods Array_as_sequence = { ! (lenfunc)Array_length, /* sq_length; */ 0, /* sq_concat; */ 0, /* sq_repeat; */ ! (ssizeargfunc)Array_item, /* sq_item; */ ! (ssizessizeargfunc)Array_slice, /* sq_slice; */ ! (ssizeobjargproc)Array_ass_item, /* sq_ass_item; */ ! (ssizessizeobjargproc)Array_ass_slice, /* sq_ass_slice; */ 0, /* sq_contains; */ *************** *** 3697,3701 **** PyObject * ! CreateArrayType(PyObject *itemtype, int length) { static PyObject *cache; --- 3695,3699 ---- PyObject * ! CreateArrayType(PyObject *itemtype, Py_ssize_t length) { static PyObject *cache; *************** *** 3709,3713 **** --- 3707,3715 ---- return NULL; } + #if (PY_VERSION_HEX < 0x02050000) key = Py_BuildValue("(Oi)", itemtype, length); + #else + key = Py_BuildValue("(On)", itemtype, length); + #endif if (!key) return NULL; *************** *** 3724,3732 **** return NULL; } ! sprintf(name, "%.200s_Array_%d", ((PyTypeObject *)itemtype)->tp_name, length); result = PyObject_CallFunction((PyObject *)&ArrayType_Type, "s(O){s:i,s:O}", name, &Array_Type, --- 3726,3743 ---- return NULL; } ! #ifdef MS_WIN64 ! sprintf(name, "%.200s_Array_%Id", ((PyTypeObject *)itemtype)->tp_name, length); + #else + sprintf(name, "%.200s_Array_%ld", + ((PyTypeObject *)itemtype)->tp_name, (long)length); + #endif result = PyObject_CallFunction((PyObject *)&ArrayType_Type, + #if (PY_VERSION_HEX < 0x02050000) "s(O){s:i,s:O}", + #else + "s(O){s:n,s:O}", + #endif name, &Array_Type, *************** *** 4134,4143 **** static PyObject * ! Pointer_slice(CDataObject *self, int ilow, int ihigh) { PyListObject *np; StgDictObject *stgdict, *itemdict; PyObject *proto; ! int i, len; if (ilow < 0) --- 4145,4154 ---- static PyObject * ! Pointer_slice(CDataObject *self, Py_ssize_t ilow, Py_ssize_t ihigh) { PyListObject *np; StgDictObject *stgdict, *itemdict; PyObject *proto; ! Py_ssize_t i, len; if (ilow < 0) *************** *** 4175,4181 **** 0, /* binaryfunc sq_concat; */ 0, /* intargfunc sq_repeat; */ ! (intargfunc)Pointer_item, /* intargfunc sq_item; */ ! (intintargfunc)Pointer_slice, /* intintargfunc sq_slice; */ ! (intobjargproc)Pointer_ass_item, /* intobjargproc sq_ass_item; */ 0, /* intintobjargproc sq_ass_slice; */ 0, /* objobjproc sq_contains; */ --- 4186,4192 ---- 0, /* binaryfunc sq_concat; */ 0, /* intargfunc sq_repeat; */ ! (ssizeargfunc)Pointer_item, /* intargfunc sq_item; */ ! (ssizessizeargfunc)Pointer_slice, /* intintargfunc sq_slice; */ ! (ssizeobjargproc)Pointer_ass_item, /* intobjargproc sq_ass_item; */ 0, /* intintobjargproc sq_ass_slice; */ 0, /* objobjproc sq_contains; */ *************** *** 4351,4355 **** static PyObject * ! string_at(const char *ptr, int size) { if (size == 0) --- 4362,4366 ---- static PyObject * ! string_at(const char *ptr, Py_ssize_t size) { if (size == 0) *************** *** 4405,4409 **** #endif ! DL_EXPORT(void) init_ctypes(void) { --- 4416,4420 ---- #endif ! PyMODINIT_FUNC init_ctypes(void) { |
From: Thomas H. <th...@us...> - 2006-03-10 20:08:30
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3892 Modified Files: _ctypes.c Log Message: Fix foreign functions loaded via ordinal on Windows CE. Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.310 retrieving revision 1.311 diff -C2 -d -r1.310 -r1.311 *** _ctypes.c 10 Mar 2006 17:35:37 -0000 1.310 --- _ctypes.c 10 Mar 2006 20:08:27 -0000 1.311 *************** *** 2501,2505 **** #ifdef MS_WIN32 if (PyInt_Check(obj) || PyLong_Check(obj)) { ! *pname = MAKEINTRESOURCE(PyInt_AsUnsignedLongMask(obj) & 0xFFFF); return 1; } --- 2501,2508 ---- #ifdef MS_WIN32 if (PyInt_Check(obj) || PyLong_Check(obj)) { ! /* We have to use MAKEINTRESOURCEA for Windows CE. ! Works on Windows as well, of course. ! */ ! *pname = MAKEINTRESOURCEA(PyInt_AsUnsignedLongMask(obj) & 0xFFFF); return 1; } |
From: Thomas H. <th...@us...> - 2006-03-10 19:05:05
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10650 Modified Files: test-cf.py Log Message: Try all machines on the SF compile farm (they are down too often). Index: test-cf.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/test-cf.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test-cf.py 9 Mar 2006 12:57:31 -0000 1.4 --- test-cf.py 10 Mar 2006 19:04:57 -0000 1.5 *************** *** 23,29 **** ("amd64-linux1", "/usr/bin/python -u"), ! ! # Same platform as the previous one: ! ## ("amd64-linux2", "/usr/bin/python -u"), # Host key verification failed --- 23,27 ---- ("amd64-linux1", "/usr/bin/python -u"), ! ("amd64-linux2", "/usr/bin/python -u"), # Host key verification failed *************** *** 37,44 **** # Not python 2.3 or newer, so use my own build of Python 2.4.2: ! ("sparc-solaris1", ! # "/usr/local/bin/python -u" "env PATH=/usr/bin:/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin ~/sparc/bin/python2.4 -u"), - ## ("sparc-solaris2", "/usr/local/bin/python -u"), ("openpower-linux1", "python -u")] --- 35,42 ---- # Not python 2.3 or newer, so use my own build of Python 2.4.2: ! ("sparc-solaris1", # "/usr/local/bin/python -u" ! "env PATH=/usr/bin:/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin ~/sparc/bin/python2.4 -u"), ! ("sparc-solaris2", # "/usr/local/bin/python -u" "env PATH=/usr/bin:/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin ~/sparc/bin/python2.4 -u"), ("openpower-linux1", "python -u")] |
From: Thomas H. <th...@us...> - 2006-03-10 17:58:13
|
Update of /cvsroot/ctypes/ctypes/ctypes/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9727 Modified Files: test_loading.py Log Message: (Try to) fix the test for netbsd. Index: test_loading.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/test_loading.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** test_loading.py 10 Mar 2006 17:56:16 -0000 1.7 --- test_loading.py 10 Mar 2006 17:58:10 -0000 1.8 *************** *** 18,24 **** elif sys.platform == "sunos5": name = "libc.so" else: name = "libc.so.6" ! print (sys.platform, os.name) cdll.load(name) self.assertRaises(OSError, cdll.load, self.unknowndll) --- 18,26 ---- elif sys.platform == "sunos5": name = "libc.so" + elif sys.platform.startswith("netbsd"): + name = "libc.so" else: name = "libc.so.6" ! ## print (sys.platform, os.name) cdll.load(name) self.assertRaises(OSError, cdll.load, self.unknowndll) |
From: Thomas H. <th...@us...> - 2006-03-10 17:56:19
|
Update of /cvsroot/ctypes/ctypes/ctypes/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8108 Modified Files: test_loading.py Log Message: *** empty log message *** Index: test_loading.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/test_loading.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** test_loading.py 10 Mar 2006 17:54:04 -0000 1.6 --- test_loading.py 10 Mar 2006 17:56:16 -0000 1.7 *************** *** 20,24 **** else: name = "libc.so.6" - import sys print (sys.platform, os.name) cdll.load(name) --- 20,23 ---- |
From: Thomas H. <th...@us...> - 2006-03-10 17:42:25
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28366 Modified Files: ChangeLog Log Message: *** empty log message *** Index: ChangeLog =================================================================== RCS file: /cvsroot/ctypes/ctypes/ChangeLog,v retrieving revision 1.109 retrieving revision 1.110 diff -C2 -d -r1.109 -r1.110 *** ChangeLog 10 Mar 2006 07:58:47 -0000 1.109 --- ChangeLog 10 Mar 2006 17:42:21 -0000 1.110 *************** *** 4,10 **** This should fix potential issues on 64-bit platforms. ! Bumped version number to 0.9.9.5. ! Use /Wp64 compiler flag on Windows. 2006-03-08 Thomas Heller <th...@py...> --- 4,32 ---- This should fix potential issues on 64-bit platforms. ! * On Windows, it is now possible to access functions ! exported by ordinal by indexing the loaded dll with the ordinal ! number: ! my_function = somedll[42] ! ! To implement this, the signature of the _CFuncPtr class has changed. ! The _CFuncPtr constructor now be accepts these arguments: ! ! _CFuncPtr(integer address) -> foreign function ! _CFuncPtr(callable) -> create a C callable function from callable ! _CFuncPtr(integer index, method name) -> foreign function ! calling a COM method ! _CFuncPtr((ordinal number, dll object), ...) -> foreign ! function exported by ordinal ! _CFuncPtr((function name, dll object), ...) -> foreign ! function exported by name ! ! WINFUNCTYPE and CFUNCTYPE are factory functions for _CFuncPtr ! subclasses, so the above applies to the types returned from those ! as well. ! ! * Changed version number to 0.9.9.5. ! ! * Use /Wp64 compiler flag on Windows. 2006-03-08 Thomas Heller <th...@py...> |
From: Thomas H. <th...@us...> - 2006-03-10 17:35:37
|
Update of /cvsroot/ctypes/ctypes/ctypes/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22822 Modified Files: test_loading.py test_cfuncs.py Log Message: On Windows, it is now possible to access functions exported by ordinal by indexing the loaded dll with the ordinal number: my_function = somedll[42] To implement this, the signature of the _CFuncPtr class has changed. _CFuncPtr can now be called with these arguments: _CFuncPtr(integer address) -> foreign function _CFuncPtr(callable) -> create a C callable function from callable _CFuncPtr(integer index, method name) -> foreign function calling a COM method _CFuncPtr((ordinal number, dll object), ...) -> foreign function exported by ordinal _CFuncPtr((function name, dll object), ...) -> foreign function exported by name WINFUNCTYPE and CFUNCTYPE are factory functions for _CFuncPtr subclasses, so the above applies to the types returned from those as well. Index: test_cfuncs.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/test_cfuncs.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_cfuncs.py 3 Mar 2006 20:11:23 -0000 1.2 --- test_cfuncs.py 10 Mar 2006 17:35:30 -0000 1.3 *************** *** 180,184 **** if name[:2] == '__' and name[-2:] == '__': raise AttributeError, name ! func = self._FuncPtr("s_" + name, self) setattr(self, name, func) return func --- 180,184 ---- if name[:2] == '__' and name[-2:] == '__': raise AttributeError, name ! func = self._FuncPtr(("s_" + name, self)) setattr(self, name, func) return func Index: test_loading.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/test_loading.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test_loading.py 10 Mar 2006 15:40:47 -0000 1.4 --- test_loading.py 10 Mar 2006 17:35:30 -0000 1.5 *************** *** 47,51 **** if os.name in ("nt", "ce"): import _ctypes_test ! dll = CDLL(_ctypes_test.__file__) # We load the same function both via ordinal and name func_ord = dll[42] --- 47,51 ---- if os.name in ("nt", "ce"): import _ctypes_test ! dll = WinDLL(_ctypes_test.__file__) # We load the same function both via ordinal and name func_ord = dll[42] *************** *** 58,61 **** --- 58,62 ---- self.failUnlessEqual(hex(f_ord_addr), hex(f_name_addr)) + dll[1234] if __name__ == "__main__": |
From: Thomas H. <th...@us...> - 2006-03-10 17:35:26
|
Update of /cvsroot/ctypes/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22728 Modified Files: __init__.py Log Message: On Windows, it is now possible to access functions exported by ordinal by indexing the loaded dll with the ordinal number: my_function = somedll[42] To implement this, the signature of the _CFuncPtr class has changed. _CFuncPtr can now be called with these arguments: _CFuncPtr(integer address) -> foreign function _CFuncPtr(callable) -> create a C callable function from callable _CFuncPtr(integer index, method name) -> foreign function calling a COM method _CFuncPtr((ordinal number, dll object), ...) -> foreign function exported by ordinal _CFuncPtr((function name, dll object), ...) -> foreign function exported by name WINFUNCTYPE and CFUNCTYPE are factory functions for _CFuncPtr subclasses, so the above applies to the types returned from those as well. Index: __init__.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/__init__.py,v retrieving revision 1.81 retrieving revision 1.82 diff -C2 -d -r1.81 -r1.82 *** __init__.py 10 Mar 2006 07:51:55 -0000 1.81 --- __init__.py 10 Mar 2006 17:35:23 -0000 1.82 *************** *** 313,320 **** return self.__getitem__(name) ! def __getitem__(self, name): ! func = self._FuncPtr(name, self) ! func.__name__ = name ! setattr(self, name, func) return func --- 313,321 ---- return self.__getitem__(name) ! def __getitem__(self, name_or_ordinal): ! func = self._FuncPtr((name_or_ordinal, self)) ! if not isinstance(name_or_ordinal, (int, long)): ! func.__name__ = name_or_ordinal ! setattr(self, name_or_ordinal, func) return func |
From: Thomas H. <th...@us...> - 2006-03-10 15:40:50
|
Update of /cvsroot/ctypes/ctypes/ctypes/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21071 Modified Files: test_loading.py Log Message: Add test for loading a function by ordinal. Index: test_loading.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/test_loading.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_loading.py 10 Mar 2006 06:58:12 -0000 1.3 --- test_loading.py 10 Mar 2006 15:40:47 -0000 1.4 *************** *** 44,50 **** WinDLL("kernel32").GetModuleHandleW ! def XXX_test_load_ordinal_functions(self): ! # Not yet ! pass if __name__ == "__main__": --- 44,61 ---- WinDLL("kernel32").GetModuleHandleW ! def test_load_ordinal_functions(self): ! if os.name in ("nt", "ce"): ! import _ctypes_test ! dll = CDLL(_ctypes_test.__file__) ! # We load the same function both via ordinal and name ! func_ord = dll[42] ! func_name = dll.GetString ! # addressof gets the address where the function pointer is stored ! a_ord = addressof(func_ord) ! a_name = addressof(func_name) ! f_ord_addr = c_void_p.from_address(a_ord).value ! f_name_addr = c_void_p.from_address(a_name).value ! self.failUnlessEqual(hex(f_ord_addr), hex(f_name_addr)) ! if __name__ == "__main__": |
From: Thomas H. <th...@us...> - 2006-03-10 15:39:24
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19851 Modified Files: setup.py Log Message: Export one function in _ctypes_test by a known ordinal, for testing. Index: setup.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/setup.py,v retrieving revision 1.131 retrieving revision 1.132 diff -C2 -d -r1.131 -r1.132 *** setup.py 10 Mar 2006 07:51:49 -0000 1.131 --- setup.py 10 Mar 2006 15:39:21 -0000 1.132 *************** *** 240,243 **** --- 240,244 ---- **kw), Extension("_ctypes_test", + export_symbols=["GetString,@42"], libraries=["oleaut32", "user32"], sources=["source/_ctypes_test.c"], |
From: Thomas H. <th...@us...> - 2006-03-10 07:58:53
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19914 Modified Files: ChangeLog Log Message: Index: ChangeLog =================================================================== RCS file: /cvsroot/ctypes/ctypes/ChangeLog,v retrieving revision 1.108 retrieving revision 1.109 diff -C2 -d -r1.108 -r1.109 *** ChangeLog 10 Mar 2006 07:00:34 -0000 1.108 --- ChangeLog 10 Mar 2006 07:58:47 -0000 1.109 *************** *** 1,7 **** 2006-03-10 Thomas Heller <th...@py...> ! * (Repository): cast is now implemented as foreign function. This should fix potential issues on 64-bit platforms. 2006-03-08 Thomas Heller <th...@py...> --- 1,11 ---- 2006-03-10 Thomas Heller <th...@py...> ! * (Repository): cast is now implemented as foreign function. This should fix potential issues on 64-bit platforms. + Bumped version number to 0.9.9.5. + + Use /Wp64 compiler flag on Windows. + 2006-03-08 Thomas Heller <th...@py...> |
From: Thomas H. <th...@us...> - 2006-03-10 07:52:05
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16147 Modified Files: _ctypes.c Log Message: Bump version number to 0.9.9.5. Check for 64-bit portability issues on Windows, by using the /Wp64 compiler switch. Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.308 retrieving revision 1.309 diff -C2 -d -r1.308 -r1.309 *** _ctypes.c 10 Mar 2006 06:59:45 -0000 1.308 --- _ctypes.c 10 Mar 2006 07:52:02 -0000 1.309 *************** *** 4492,4496 **** PyModule_AddObject(m, "FUNCFLAG_CDECL", PyInt_FromLong(FUNCFLAG_CDECL)); PyModule_AddObject(m, "FUNCFLAG_PYTHONAPI", PyInt_FromLong(FUNCFLAG_PYTHONAPI)); ! PyModule_AddStringConstant(m, "__version__", "0.9.9.4"); PyModule_AddObject(m, "_memmove_addr", PyLong_FromVoidPtr(memmove)); --- 4492,4496 ---- PyModule_AddObject(m, "FUNCFLAG_CDECL", PyInt_FromLong(FUNCFLAG_CDECL)); PyModule_AddObject(m, "FUNCFLAG_PYTHONAPI", PyInt_FromLong(FUNCFLAG_PYTHONAPI)); ! PyModule_AddStringConstant(m, "__version__", "0.9.9.5"); PyModule_AddObject(m, "_memmove_addr", PyLong_FromVoidPtr(memmove)); |