[Python-modules-commits] r940 - in
/packages/ctypes/branches/upstream/current: ./ ctypes/
ctypes/test/ ctypes/wrap/ docs/ docs/manual/ samples/ source/
source/darwin/ source/libffi/ source/libffi/include/
source/libffi/src/alpha/ source/libffi/src/frv/ source/libffi/src/powerpc/
source/libffi/src/x86/ source/libffi_arm_wince/ source/libffi_msvc/ wince/
rganesan at users.alioth.debian.org
rganesan at users.alioth.debian.org
Mon Jun 19 12:32:01 UTC 2006
Author: rganesan
Date: Mon Jun 19 12:31:53 2006
New Revision: 940
URL: http://svn.debian.org/wsvn/python-modules/?sc=1&rev=940
Log:
Load /tmp/tmp.zxrSw15776/ctypes-0.9.9.6 into
packages/ctypes/branches/upstream/current.
Added:
packages/ctypes/branches/upstream/current/ACKS
packages/ctypes/branches/upstream/current/ANNOUNCE
packages/ctypes/branches/upstream/current/MANIFEST
packages/ctypes/branches/upstream/current/MANIFEST.in
packages/ctypes/branches/upstream/current/ctypes-dev.el
packages/ctypes/branches/upstream/current/ctypes/test/test_array_in_pointer.py
packages/ctypes/branches/upstream/current/ctypes/test/test_find.py
packages/ctypes/branches/upstream/current/ctypes/test/test_sizes.py
packages/ctypes/branches/upstream/current/ctypes/test/test_unaligned_structures.py
packages/ctypes/branches/upstream/current/ctypes/wintypes.py
packages/ctypes/branches/upstream/current/docs/manual/markup.py
packages/ctypes/branches/upstream/current/docs/manual/mkpydoc.py
packages/ctypes/branches/upstream/current/docs/manual/tutorial.html
packages/ctypes/branches/upstream/current/source/ctypes_dlfcn.h
packages/ctypes/branches/upstream/current/source/libffi_arm_wince/
packages/ctypes/branches/upstream/current/source/libffi_arm_wince/debug.c
packages/ctypes/branches/upstream/current/source/libffi_arm_wince/ffi.c
packages/ctypes/branches/upstream/current/source/libffi_arm_wince/ffi.h
packages/ctypes/branches/upstream/current/source/libffi_arm_wince/ffi_common.h
packages/ctypes/branches/upstream/current/source/libffi_arm_wince/fficonfig.h
packages/ctypes/branches/upstream/current/source/libffi_arm_wince/ffitarget.h
packages/ctypes/branches/upstream/current/source/libffi_arm_wince/prep_cif.c
packages/ctypes/branches/upstream/current/source/libffi_arm_wince/sysv.asm
packages/ctypes/branches/upstream/current/source/libffi_msvc/
packages/ctypes/branches/upstream/current/source/libffi_msvc/ffi.c
packages/ctypes/branches/upstream/current/source/libffi_msvc/ffi.h
packages/ctypes/branches/upstream/current/source/libffi_msvc/ffi_common.h
packages/ctypes/branches/upstream/current/source/libffi_msvc/fficonfig.h
packages/ctypes/branches/upstream/current/source/libffi_msvc/ffitarget.h
packages/ctypes/branches/upstream/current/source/libffi_msvc/prep_cif.c
packages/ctypes/branches/upstream/current/source/libffi_msvc/types.c
packages/ctypes/branches/upstream/current/source/libffi_msvc/win32.S
packages/ctypes/branches/upstream/current/source/libffi_msvc/win32.c
packages/ctypes/branches/upstream/current/wince/
packages/ctypes/branches/upstream/current/wince/_ctypes.vcp
packages/ctypes/branches/upstream/current/wince/_ctypes.vcw
Removed:
packages/ctypes/branches/upstream/current/MANIFEST.other.in
packages/ctypes/branches/upstream/current/NEWS.txt
packages/ctypes/branches/upstream/current/ctypes/_loader.py
packages/ctypes/branches/upstream/current/ctypes/decorators.py
packages/ctypes/branches/upstream/current/ctypes/test/test_codegen.py
packages/ctypes/branches/upstream/current/ctypes/test/test_leaks.py
packages/ctypes/branches/upstream/current/ctypes/test/test_posix.py
packages/ctypes/branches/upstream/current/ctypes/wrap/
packages/ctypes/branches/upstream/current/docs/default.css
packages/ctypes/branches/upstream/current/docs/faq.stx
packages/ctypes/branches/upstream/current/docs/index.stx
packages/ctypes/branches/upstream/current/docs/internals.stx
packages/ctypes/branches/upstream/current/docs/reference.stx
packages/ctypes/branches/upstream/current/run_remote_test.py
packages/ctypes/branches/upstream/current/samples/
Modified:
packages/ctypes/branches/upstream/current/ChangeLog
packages/ctypes/branches/upstream/current/LICENSE.txt
packages/ctypes/branches/upstream/current/PKG-INFO
packages/ctypes/branches/upstream/current/ctypes/.CTYPES_DEVEL
packages/ctypes/branches/upstream/current/ctypes/__init__.py
packages/ctypes/branches/upstream/current/ctypes/_endian.py
packages/ctypes/branches/upstream/current/ctypes/test/__init__.py
packages/ctypes/branches/upstream/current/ctypes/test/test_bitfields.py
packages/ctypes/branches/upstream/current/ctypes/test/test_buffers.py
packages/ctypes/branches/upstream/current/ctypes/test/test_byteswap.py
packages/ctypes/branches/upstream/current/ctypes/test/test_callbacks.py
packages/ctypes/branches/upstream/current/ctypes/test/test_cast.py
packages/ctypes/branches/upstream/current/ctypes/test/test_cfuncs.py
packages/ctypes/branches/upstream/current/ctypes/test/test_checkretval.py
packages/ctypes/branches/upstream/current/ctypes/test/test_funcptr.py
packages/ctypes/branches/upstream/current/ctypes/test/test_functions.py
packages/ctypes/branches/upstream/current/ctypes/test/test_keeprefs.py
packages/ctypes/branches/upstream/current/ctypes/test/test_libc.py
packages/ctypes/branches/upstream/current/ctypes/test/test_loading.py
packages/ctypes/branches/upstream/current/ctypes/test/test_macholib.py
packages/ctypes/branches/upstream/current/ctypes/test/test_numbers.py
packages/ctypes/branches/upstream/current/ctypes/test/test_parameters.py
packages/ctypes/branches/upstream/current/ctypes/test/test_pointers.py
packages/ctypes/branches/upstream/current/ctypes/test/test_prototypes.py
packages/ctypes/branches/upstream/current/ctypes/test/test_random_things.py
packages/ctypes/branches/upstream/current/ctypes/test/test_refcounts.py
packages/ctypes/branches/upstream/current/ctypes/test/test_repr.py
packages/ctypes/branches/upstream/current/ctypes/test/test_returnfuncptrs.py
packages/ctypes/branches/upstream/current/ctypes/test/test_slicing.py
packages/ctypes/branches/upstream/current/ctypes/test/test_stringptr.py
packages/ctypes/branches/upstream/current/ctypes/test/test_strings.py
packages/ctypes/branches/upstream/current/ctypes/test/test_structures.py
packages/ctypes/branches/upstream/current/ctypes/test/test_unicode.py
packages/ctypes/branches/upstream/current/ctypes/test/test_values.py
packages/ctypes/branches/upstream/current/ctypes/test/test_win32.py
packages/ctypes/branches/upstream/current/ctypes/util.py
packages/ctypes/branches/upstream/current/docs/manual/tutorial.txt
packages/ctypes/branches/upstream/current/setup.py
packages/ctypes/branches/upstream/current/source/_ctypes.c
packages/ctypes/branches/upstream/current/source/_ctypes_test.c
packages/ctypes/branches/upstream/current/source/callbacks.c
packages/ctypes/branches/upstream/current/source/callproc.c
packages/ctypes/branches/upstream/current/source/cfield.c
packages/ctypes/branches/upstream/current/source/ctypes.h
packages/ctypes/branches/upstream/current/source/darwin/dlfcn.h
packages/ctypes/branches/upstream/current/source/darwin/dlfcn_simple.c
packages/ctypes/branches/upstream/current/source/libffi/config.guess (props changed)
packages/ctypes/branches/upstream/current/source/libffi/config.sub (props changed)
packages/ctypes/branches/upstream/current/source/libffi/configure (contents, props changed)
packages/ctypes/branches/upstream/current/source/libffi/configure.ac
packages/ctypes/branches/upstream/current/source/libffi/fficonfig.py.in
packages/ctypes/branches/upstream/current/source/libffi/include/ffi.h.in
packages/ctypes/branches/upstream/current/source/libffi/install-sh (props changed)
packages/ctypes/branches/upstream/current/source/libffi/src/alpha/osf.S
packages/ctypes/branches/upstream/current/source/libffi/src/frv/eabi.S
packages/ctypes/branches/upstream/current/source/libffi/src/powerpc/darwin_closure.S
packages/ctypes/branches/upstream/current/source/libffi/src/x86/ffi.c
packages/ctypes/branches/upstream/current/source/stgdict.c
Added: packages/ctypes/branches/upstream/current/ACKS
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/ACKS?rev=940&op=file
==============================================================================
--- packages/ctypes/branches/upstream/current/ACKS (added)
+++ packages/ctypes/branches/upstream/current/ACKS Mon Jun 19 12:31:53 2006
@@ -1,0 +1,37 @@
+Acknowledgements
+----------------
+
+This list is probably incomplete, but I would like to thank everybody
+who contributed code, patches, bug reports, encouragement, ...
+
+Apologies if I have forgotten anyone.
+
+-- Thomas Heller
+
+----------------
+
+Nick Adams
+Robin Becker
+Dave Brueck
+Hye-Shik Chang
+Greg Chapman
+David Creemer
+Andreas Daegert
+Bruce Dodson
+Luke Dunstan
+Chuck Esterbrook
+Mike Fletcher
+David Foster
+Richie Hindle
+Shane Holloway
+Andrew MacIntyre
+Paul Moore
+Neal Norwitz
+Ronald Oussoren
+Henk Punt
+Jimmy Retzlaff
+Armin Rigo
+Just van Rossum
+Alexander Semenov
+Wolfgang Strobl
+Niki Spahiev
Added: packages/ctypes/branches/upstream/current/ANNOUNCE
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/ANNOUNCE?rev=940&op=file
==============================================================================
--- packages/ctypes/branches/upstream/current/ANNOUNCE (added)
+++ packages/ctypes/branches/upstream/current/ANNOUNCE Mon Jun 19 12:31:53 2006
@@ -1,0 +1,118 @@
+ctypes 0.9.9.6 released - Apr 20, 2006
+=====================================
+
+Overview
+
+ ctypes is an advanced ffi (Foreign Function Interface) package for
+ Python 2.3 and higher.
+
+ ctypes allows to call functions exposed from dlls/shared libraries
+ and has extensive facilities to create, access and manipulate
+ simple and complicated C data types in Python - in other words:
+ wrap libraries in pure Python. It is even possible to implement C
+ callback functions in pure Python.
+
+ ctypes runs on Windows, Windows CE, MacOS X, Linux, Solaris,
+ FreeBSD, OpenBSD. It may also run on other systems, provided that
+ libffi supports this platform.
+
+
+Changes in 0.9.9.6
+
+ The most important change is that the old way to load libraries
+ has been restored: cdll.LoadLibrary(path), and CDLL(path) work
+ again. For details see the changelog in CVS and in the source
+ distribution.
+
+ It was a mistake to change that in the 0.9.9.3 release - I
+ apologize for any confusion and additional work this has caused or
+ will cause.
+
+ New module ctypes.util which contains a cross-platform
+ find_library function.
+
+ Sized integer types (c_int8, c_int16, and so on) have been added
+ by integrating a patch from Joe Wreschnig. Also c_size_t, which
+ corresonds to the 'size_t' C type has been added.
+
+ Two long standing bugs with pointers have been fixed. Thanks to
+ Axel Seibert for pushing me to the first, and thanks to Armin Rigo
+ for finding the second one.
+
+ The ctypes.decorator module has been removed completely, so the
+ 'cdecl' and 'stdcall' symbols are no longer available.
+ The code generator has been removed completely. It will probably
+ be made available as a separate project later.
+
+ The samples directory has been removed because it was completely
+ out-of-date.
+
+ The .zip and .tar.gz source distributions no longer contain
+ different file sets.
+
+ The development in CVS now takes place in the HEAD again, the
+ 'branch_1_0' branch is no longer used.
+
+
+Changes in 0.9.9.3
+
+ Windows
+
+ The ctypes.com package is no longer included and supported.
+ It is replaced by the comtypes package which will be released
+ separately.
+
+ ctypes has been ported to Windows CE by Luke Dunstan.
+
+ Other platforms
+
+ Hye-Shik Chang has written a new build system for libffi
+ which should remove possible licensing issues.
+
+ All platforms
+
+ The library loading code has been rewritten by Andreas Degert,
+ there are now sophisticated methods to find shared libraries.
+ On OS X, this uses files from Bob Ippolito's macholib.
+ See the manual for details.
+
+ Finally I started to write the manual, it is available online:
+
+ http://tinyurl.com/7bpg4
+
+ New 'errcheck' protocol to check the return values of foreign
+ functions, suggested by Mike Fletcher.
+
+ Lots of bug fixes, especially for 64-bit platforms. Improved
+ performance when creating ctypes instances.
+
+ Subclasses of simple types (c_int, c_void_p, and so on) now
+ behave as expected - they are not automatically converted into
+ native Python types any longer.
+
+ Support for explicit byte ordering in structures has been
+ added (BigEndianStructure, LittleEndianStructure base
+ classes).
+
+ call byref() automatically, if needed, for POINTER types in
+ argtypes.
+
+ Lots of improvements to the code generator.
+
+Download
+
+ Downloads are available in the sourceforge files section
+ <http://sourceforge.net/project/showfiles.php?group_id=71702>
+
+ Binary windows installers, which contain compiled extension
+ modules, are also available, be sure to download the correct one
+ for the Python version you are using.
+
+
+Homepage
+
+ <http://starship.python.net/crew/theller/ctypes/>
+
+Enjoy,
+
+Thomas
Modified: packages/ctypes/branches/upstream/current/ChangeLog
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/ChangeLog?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/ChangeLog (original)
+++ packages/ctypes/branches/upstream/current/ChangeLog Mon Jun 19 12:31:53 2006
@@ -1,136 +1,1352 @@
-Changes in ctypes 0.6
-
- Version 0.6.3
-
- A critical bug with pointer instances was fixed, this makes the
- 'incomplete types' sample code in the tutorial actually work.
-
- All ctypes objects are now correctly garbarge collected. This
- *may* lead to crashes in your program (especially with callback
- functions, or pointers handed out to longer running C code). You
- must keep a reference in Python to any object as long as it is
- used in foreign C code.
-
- All known bugs have been fixed.
-
- Again, a lot of changes to the COM package, but all this is still work in
- progress and unstable, and it has to be properly documented.
-
- Version 0.6.2
-
- Fixed a bug which prevented callback functions to return data
- types other than integers. They can now also return pointers,
- floats, and doubles.
-
- It is now possible to pass structures and unions to function calls
- *by value*. Currently this works only on Windows.
-
- A lot of changes to the COM package, but all this is still work in
- progress and unstable, and it has to be properly documented.
-
- Version 0.6.1
-
- 'ctypes' types now have a 'in_dll(dll, symbolname)' class method.
- It allows to access and/or change values exported by dlls.
-
- Several bugs have been fixed.
-
- Installation
-
- 'ctypes' has been converted into a package, it is no longer a
- couple of modules.
-
- **This requires that you remove any previous version** of
- ctypes you may have installed, either (on Windows, if you have
- installed from the exe-file) by running the uninstaller from
- *Control Panel->Add/Remove Programs*, or by deleting the files
- 'Lib/site-packages/ctypes.py' and 'Lib/site-packages/_ctypes.pyd'.
-
- Package contents
-
- All platforms:
-
- 'ctypes' - the basic stuff mentioned in the tutorial
-
- On Windows:
-
- 'ctypes.wintypes' - defines several common windows datatypes
-
- 'ctypes.com' - the beginning of a com framework, client code
- as well as localserver code. This is only proof-of-concept
- code, the interface is *not* stable at all.
-
- 'ctypes.com.tools' - an utility 'readtlb.py' which generates
- Python wrapper code from type libraries.
-
- 'ctypes.com.samples' - this is not really a package, currently
- it contains a sample which controls Internet Explorer, and
- receives events.
-
- The com framework is currently undocumented, but I believe it
- contains quite some code which should be quite easy to read,
- at least for experienced com/C programmers. The basic goal of
- this framework is to allow easy collaboration with ATL servers
- and clients, it is centered around typelibraries.
-
- The source distribution contains additional code in a samples
- directory tree and full documentation.
-
- General
-
- It is now safe to do 'from ctypes import *', only symbols actually
- needed are exposed.
-
- Format characters
-
- Format characters like '"i"' or '"H"' are no longer supported
- anywhere. They must be replaced by the corresponding type like
- 'c_int' or 'c_ushort'. String formats in Structures or Unions
- like '"6c"' which describe an array of 6 characters must be
- replaced by 'c_char * 6'.
-
- Functions
-
- Again, format characters are no longer allowed as function's
- restype attribute. Replace them by the appropriate ctypes' type
- like c_char_p instead of '"s"' or '"z"' if the function returns a
- string pointer, for example.
-
- Callback functions
-
- The type for callback functions can no longer be defined by
- subclassing 'CFunction', actually this type no longer exists. The
- recommended way to define the type of a callback function is to
- call 'WINFUNCTYPE()' if you need a C-callable function pointer using
- the __stdcall calling convention, or 'CFUNCTYPE()' if you need a
- function pointer using the standard cdecl calling convention.
-
- You have to supply the result type and the expected argument
- types.
-
- Instances of these types are callable from C, but they are now
- also callable from Python directly.
-
- These types can also be used in the 'argtypes' sequence, or as the
- 'restype' attribute if you have a dll function expecting or returning
- a function pointer.
-
- Pointers
-
- Pointer *types* are created by calling 'POINTER(c_int)' for
- example. The 'POINTER' function maintains a cache of created
- types, so calling it with the same argument always returns the
- *same* identical type.
-
- pointer instances are usually created by 'pointer(c_int(42))' for
- example. 'pointer()' internally calls 'POINTER()' to get the type.
-
- c_string and c_wstring have been removed
-
- In previous versions the 'c_string' and 'c_wstring' types could be
- used to allocate mutable buffers and fill them from or convert
- them to Python strings or unicode objects. These do no longer exist.
-
- ctypes now exports a 'c_buffer()' function as a replacement.
- Actually 'c_buffer' returns a character array (an instance of
- 'c_char * size').
+2006-04-19 Thomas Heller <theller at python.net>
+
+ * docs\manual\tutorial.txt: Updates to the tutorial.
+
+ * When a 'source' object is casted to another object, the other
+ object keeps a reference to the source object to keep it alive.
+
+2006-04-18 Thomas Heller <theller at python.net>
+
+ * Patch from Skip Montanaro, in Python SVN: C++ compiler cleanup:
+ the typical few casts, and ... C++ didn't like that the
+ StgDictObject's ffi_type member had the same name as its type. I
+ changed that to ffi_type_pointer.
+
+ Fix refcount issues in CreateSwappedType - this removes the
+ refleak when reloading ctypes.
+
+2006-04-15 Thomas Heller <theller at python.net>
+
+ * source\libffi\src\x86\ffi.c (ffi_prep_cif_machdep): Add a fix
+ for FreeBSD. See also http://python.org/sf/1470353.
+
+2006-04-13 Thomas Heller <theller at python.net>
+
+ * Changed version number to 0.9.9.6.
+
+ * Merged in changes made in the 'LoadLibrary_branch' branch:
+
+ Restore the old way to load libraries again:
+
+ cdll/windll have a LoadLibrary method, and no other public
+ attributes. CDLL/WinDLL accept library pathname in the
+ constructor, that's the only public attribute: all the find(),
+ load(), and load_library() methods are gone. In other words,
+ use these ways to load shared libraries:
+
+ CDLL("path_to_lib")
+ CDLL("path_to_lib", mode=RTLD_GLOBAL)
+ cdll.path_to_lib
+ cdll.LoadLibrary("path_to_lib")
+ cdll.LoadLibrary("path_to_lib", mode=RTLD_GLOBAL)
+
+ The CDLL/WinDLL base class has been renamed to LibraryLoader,
+ in case anyone wants to subclass it.
+
+ The ctypes._loader module has been removed completely.
+
+ ctypes.util has been revived, it implements a find_library()
+ function which should be useful to find libraries from the linker
+ name (on platforms where this makes sense):
+
+ find_library("c") -> "/usr/lib/libc.so.6" (Linux)
+ find_library("c") -> "/usr/lib/libc.dylib" (OS X)
+ find_library("msvcr71") -> "c:\windows\system32\msvcr71.dll" (Windows)
+
+ If the library is not found, None is returned.
+
+2006-04-13 Thomas Heller <theller at python.net>
+
+ * Merged in several changes made in Python SVN: RTLD_LOCAL and
+ RTLD_GLOBAL are defined for each platform.
+
+2006-04-06 Thomas Heller <theller at python.net>
+
+ * Simplify code, improve error handling, and a Py_ssize_t fix by
+ Neal Norwitz.
+
+ * Spelled 'signed char' instead of 'char', to avoid test failures
+ on platforms where the C 'char' type is unsigned.
+
+2006-04-05 Thomas Heller <theller at python.net>
+
+ * ctypes/_loader.py: Extend the posix findLib_ld function to try
+ output from 'ldd'. This makes findLib work on OSF1 (True
+ 64). Patch from Neal Norwitz.
+
+ * source/libffi/src/powerpc/darwin_closure.S: Remove the
+ live_support segment attribute so that this file compiles on OSX 10.3.
+
+ * source/libffi: Add support for OpenBSD. The ctypes test-suite
+ works.
+
+2006-03-29 Thomas Heller <theller at python.net>
+
+ * source\_ctypes.c: Accept function pointers as first argument,
+ and a function pointer types as second argument in the cast
+ function.
+
+ Fix a potential segfault.
+
+2006-03-27 Thomas Heller <theller at python.net>
+
+ * source/libffi_msvc/prep_cif.c: Fix calling of stdcall functions
+ on Windows, when compiled with MingW32.
+
+ * setup.py: Fixes from Khalid A. Bakr.
+
+ He writes: """I have made some changes (see attached diff) to the
+ setup.py to have MinGW pass the "--enable-stdcall-fixup" to the
+ linker to suppress some warnings. And I have added another linker
+ option, namely "--kill-at" to remove the @XY decoration that MinGW
+ normally attaches to stdcall functions.
+
+ With the latter change, test_cfuncs (which had previously reported
+ 26 failures out of 52 tests) now only reports 3. It seems that the
+ stdcall part now passes as it does when compiled with a MSVC type
+ compiler."""
+
+ Still, all ctypes callback tests crash Python, and there are other
+ failures as well - when compiled with mingw.
+
+2006-03-20 Thomas Heller <theller at python.net>
+
+ * source\cfield.c: Accessing unaligned structure fields
+ is now supported on all machines.
+
+2006-03-17 Thomas Heller <theller at python.net>
+
+ * 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.
+
+ * 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 <theller at python.net>
+
+ * 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 <theller at python.net>
+
+ * 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 <theller at python.net>
+
+ * 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 <theller at python.net>
+
+ * source/_ctypes.c: Fix foreign functions loaded via ordinal on Windows CE.
+
+2006-03-10 Thomas Heller <theller at python.net>
+
+ * (Repository): cast is now implemented as foreign function.
+ 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 <theller at python.net>
+
+ * (Repository): Tagged as release_0_9_9_4.
+
+2006-03-07 Thomas Heller <theller at python.net>
+
+ * (Repository): Removed the ctypes.decorators module completely,
+ so the cdecl and stdcall symbols are no longer available.
+
+2006-03-03 Thomas Heller <theller at python.net>
+
+ * (Repository): Moved all files from the CVS branch 'branch_1_0'
+ to CVS head. The branch is dead, long live the HEAD!
+
+ * ctypes/__init__.py, ctypes/test/test_sizes.py: Added c_int8,
+ c_int16, c_int32, c_int64, c_uint8, c_uint16, c_uint32, c_uint64
+ types. Patch and unittest provided by Joe Wreschnig.
+ Also added c_size_t which represents the C type size_t.
+
+ * ctypes/_loader.py: Added a load_library() method to library
+ loader classes. Plus an alias LoadLibrary() for backwards
+ compatibility.
+
+ * (Repository): Removed the codegenerator in ctypes/wrap
+ completely. The last state has been tagged in CVS as
+ 'BEFORE_REMOVAL'. It will be revived later - not yet sure where.
+
+ * Changed the version number to 0.9.9.4.
+
+2006-03-01 Thomas Heller <theller at python.net>
+
+ * (Repository): Removed the samples subdirectory completely,
+ because it has become out of sync.
+
+ * (Repository): Moved the ctypes.wintypes module into the ctypes/
+ directory, got rid of the platform specific modules magic in setup.py
+ and the .CTYPES_DEVEL file.
+
+ * source\callbacks.c: Checked the return value of PyErr_Warn().
+
+2006-02-28 Thomas Heller <theller at python.net>
+
+ * ctypes\__init__.py (OleDLL._FuncPtr._restype_): oledll now uses
+ the HRESULT restype, no longer the ctypes builtin FUNCFLAG_HRESULT
+ magic flag. This allows easier overriding.
+
+
+2006-02-22 Thomas Heller <theller at python.net>
+
+ * source/callbacks.c: Discovered and hacked around a problem with
+ callback functions.
+
+ If the callback function has a return type other than void,
+ py_object, or an integral C type, it is impossible to either avoid
+ a memory leak or return a possibly invalid result. Previously,
+ the possibly invalid result has been returned, now the memory leak
+ will appear but a "RuntimeWarning: memory leak in callback
+ function" will be emitted.
+
+
+2006-02-21 Thomas Heller <theller at python.net>
+
+ * source/_ctypes.c: The _b_needsfree_ member is now always 1 if
+ the object 'owns' it's memory buffer (even if it uses it's small
+ builtin buffer, instead of mallocing a new one). This is useful
+ to determine whether resources in the buffer need to be freed when
+ the object is destroyed.
+
+ * source/_ctypes.c: Finally fix this nasty 'set array through
+ pointer' bug. See ctypes.test.test_array_in_pointer
+
+ * source/malloc_closure.c: Fix compilation on Windows.
+
+2006-02-15 Bob Ippolito <bob at redivi.com>
+
+ * New ctypes_dlfcn.h created to allow for potential indirection
+ of dl functions. Changed code to use "ctypes_" prefix on all
+ dl functions.
+
+ * Darwin's dlfcn compatibility wrapper no longer used for 10.3
+ and later, as it has a native implementation in libSystem.
+ Compiler macros and weak linking are used to make sure
+ the right thing happens even if compiled on OS X 10.3+ with a
+ deployment target of 10.2. Tested with gcc-3.3 and gcc-4.0.
+
+2006-02-15 Thomas Heller <theller at python.net>
+
+ * ctypes 0.9.9.3 released.
+
+2006-02-10 Thomas Heller <theller at python.net>
+
+ * string_at and wstring_at are now implemented in the same way as
+ memmove and memset.
+
+ * Fixed the wrong return type of memmove.
+
+2006-02-09 Thomas Heller <theller at python.net>
+
+ * memmove and memset are now implemented as foreign functions,
+ using the standard ctypes mechanism. The addresses are exported
+ by the _ctypes extension, restype and argtypes are set in
+ ctypes/__init__.py.
+
+ This Required to extend c_void_p.from_param to accept int/long
+ arguments as well.
+
+ memmove and memset now work on 64-bit platforms.
+
+2006-02-02 Hye-Shik Chang <perky at FreeBSD.org>
+
+ * source/callproc.c: ConvParam() is fixed to convert Python
+ int and long types via libffi signed long. This fixes a
+ compatibility problem on alpha and ia64.
+
+2006-02-01 Thomas Heller <theller at python.net>
+
+ * Hye-Shik Chang <perky at users.sourceforge.net> made these changes:
+ Update libffi to gcc head as of 2006/02/01. This fixes several
+ unittest failures on 64bit platforms.
+
+2006-02-01 Thomas Heller <theller at python.net>
+
+ * Committed a patch from Hye-Shik Chang (perky).
+
+ See http://mail.python.org/pipermail/python-dev/2006-January/060199.html,
+ where he wrote:
+
+ I did some work to make ctypes+libffi compacter and liberal. I
+ removed sources/gcc and put sources/libffi copied from gcc 4.0.2.
+ And removed all automake-related build processes and integrated
+ them info setup.py. There's still aclocal.m4 in
+ sources/libffi. But it is just identical to libffi's acinclude.m4
+ which looks liberal.
+
+
+2006-01-26 Thomas Heller <theller at python.net>
+
+ * ctypes._loader implements the new LibraryLoader class. The
+ class itself is exposed from the ctypes module itself.
+
+ LibraryLoader objects expose load(), find(), and load_version()
+ methods - see the docstrings.
+
+ The register_library_alias() function is gone, it does belong
+ somewhere else (if at all).
+
+2006-01-02 Thomas Heller <theller at python.net>
+
+ * Subtypes of simple types (the c_int and c_char variations,
+ c_void_p, c_char_p and c_wchar_p) behave different now. XXX More
+ explanations needed.
+
+ * Removed the complete ctypes.com package, which lived
+ (in CVS) in the ctypes\win32\com directory.
+
+2005-12-30 Thomas Heller <theller at python.net>
+
+ * Changes for Windows CE, contributed by Luke Dunstan.
+
+2005-12-14 Thomas Heller <theller at python.net>
+
+ * Implemented different endians for c_float and c_double.
+ Added testcases for them.
+
+2005-11-30 Thomas Heller <theller at python.net>
+
+ * Implemented BigEndianStructure and LittleEndianStructure base
+ classes which support different endians. The fields of structures
+ with non-native byte ordering are limited to c_char and all the
+ integer variantions of different sizes, plus arrays of these.
+ Integer bit fields do work. c_double, c_float, and structures are
+ not yet supported as field types.
+
+ * Changed version number to 0.9.9.1.
+
+2005-11-04 Thomas Heller <theller at python.net>
+
+ * Moved tests from the 'unittests' directories to packages
+ 'ctypes.test' and 'ctypes.com.test'. The ctypes.test package's
+ __init__.py file contains test support functions, and a test
+ runner. The test runner is also called by starting the script
+ ctypes/test/runtests.py.
+
+ The test runner can search for refcount leaks by running the tests
+ in a loop, this requires a debug build of Python and takes quite
+ some time. Start runtests.py with a '-r' command line option.
+
+ Tests can now 'require' additional resources (which are strings),
+ by default these tests are disabled. To provide resources, these
+ can be specified by the '-u' command line flag.
+
+ The 'out-of-process' test command has been removed.
+ Tests can also be run by setup in this way:
+
+ python setup.py test [-u<resources>] [-r]
+
+2005-11-03 Thomas Heller <theller at python.net>
+
+ * source\callbacks.c: For callback functions with result type None
+ ('void'), actually ignore the return value. Add some assert
+ statements for easier debugging.
+
+ * source\_ctypes.c: Enable cycle GC on CFuncPtrType objects (does
+ not seem to have a visible effect). Fix quite some refcount leaks,
+ and a crash when outargs is NULL. Add some asserts for easier
+ debugging.
+
+ * source\stgdict.c: Fixed a very nasty bug: The dict portion of
+ StgDict objects were never freed. Assigning a non-sequence to a
+ Structure _fields_ raises TypeError, not AttributeError. Fix
+ another refcount leak.
+
+2005-10-28 Thomas Heller <theller at python.net>
+
+ * setup.py: ctypes.macholib was missing in the packages list.
+ Remove the comtypes package from the tests.
+
+ * source\cfield.c: Fix a refcount leak when unicode is converted
+ to ascii.
+
+ * source\_ctypes.c: Fix a refcount leak. And finally correct the
+ wrong static declaration of Pointer_Type, preventing compilation
+ with gcc4 (which I don't have).
+
+ * source\callproc.c: Fix a refcount leak when COMError is raised.
+
+2005-10-21 Thomas Heller <theller at python.net>
+
+ * ctypes\wrap\codegenerator.py: The codegenerator now by default
+ assumes 'char *' and 'wchar_t *' types are pointers to
+ zero-terminated strings. It generates
+
+ STRING = c_char_p
+ WSTRING = c_wchar_p
+
+ and STRING / WSTRING is used instead of POINTER(c_char) and
+ POINTER(c_wchar). This behaviour can be changed by setting the
+ global variable ASSUME_STRINGS to False.
+
+2005-10-18 Thomas Heller <theller at python.net>
+
+ * source\callproc.c: Remove all the too fancy traceback printing
+ stuff.
+
+ The DllGetClassObject() and DllCanUnloadNow() functions are now
+ exposed by the ctypes module itself, which forwards their requests
+ to ctypes.com.server. Later, there should also be a way to
+ forward to comtypes.server (when that exists).
+
+ * source\_ctypes.c: Implemented __nonzero__ for simple types.
+
+2005-10-14 Thomas Heller <theller at python.net>
+
+ * source\callbacks.c: Fixed a refcount leak in callbacks.
+
+2005-09-06 Thomas Heller <theller at python.net>
+
+ * source\_ctypes.c (CData_FromBaseObj): The b_size member is now
+ set. Before, the effect was that sizeof(obj) would return always
+ zero for objects retrieved from structure fields, for example.
+
+2005-09-02 Thomas Heller <theller at python.net>
+
+ * source: Implemented Mike Fletcher's errcheck protocol. A new
+ 'errcheck' field has been added to CFuncPtrObject. If the
+ function has an 'errcheck' attribute, this is called with
+ (function_return_value, function, arguments, ...) and the result
+ of this call is returned. The 'errcheck' function must accept
+ more than three parameters for future compatibility.
+
+ * source/callproc.c: Call checker (which is the _check_retval_
+ attribute of the restype) also when restype is *not* a simple
+ ctypes type.
+
+2005-08-30 Thomas Heller <theller at python.net>
+
+ * source/callproc.c: Don't call __new__ and __init__ when a ctypes
+ instance is created from a function return value.
+
+ * ctypes/wrap/cparser.py: Added a function to find gccxml on
+ $PATH.
+
+2005-08-24 Thomas Heller <theller at python.net>
+
+ * ctypes/wrap: Merged some of Andreas Degert's changes from CVS
+ HEAD:
+
+ The code generator now sorts the generated definitions according
+ to the location in the source code.
+
+ If function argument names are found in the xml-file (newer gccxml
+ create these), the code generator uses them in the generated
+ wrappers.
+
+2005-08-22 Thomas Heller <theller at python.net>
+
+ * source\_ctypes.c (CDataType_from_address): Fixed another
+ potential problem for systems where sizeof(int) != sizeof(void *).
+
+ * Fix a problem which showed up as array.value != array[:].
+
+2005-08-19 Thomas Heller <theller at python.net>
+
+ * source\_ctypes.c: Add a CFuncPtr_repr which gives more useful
+ output when the instance is a COM method.
+
+ Fix two problems that will show up on platforms where sizeof(int)
+ != sizeof(void *). Get pointer values by PyLong_AsVoidPtr.
+
+ Fix a bug when paramflags are specified as [], and so the
+ numerical flag value is 0.
+
+ Per suggestion from Mike Fletcher: call byref() automatically, if
+ needed, for POINTER types in argtypes. Fix crash with ARRAY types
+ in argtypes. Fix a small refcount leak. Cleanup and clarify some
+ code.
+
+2005-08-18 Thomas Heller <theller at python.net>
+
+ * Finally committed a patch from Mike Fletcher which allows to use
+ the RTLD_GLOBAL flag to load libraries.
+
+2005-08-17 Thomas Heller <theller at python.net>
+
+ * source\*.[ch]: Implement rich error reporting for COM method
+ calls (on Windows).
+
+ CFuncPtrObject gets a new 'iid' slot which stores a pointer to the
+ guid of the interface this method belongs to. When iid is !=
+ NULL, use IErrorInfo to get rich error information from the com
+ object.
+
+ Add a COMError class, and implement custom __init__ and __str__
+ methods.
+
+2005-08-12 Thomas Heller <theller at python.net>
+
+ * source\callbacks.c: A buffer allocated for callbacks was too
+ small. This could lead to crashed when callbacks were garbage
+ collected. Problem reported by Mike Fletcher.
+
+2005-05-20 Thomas Heller <theller at python.net>
+
+ * source\_ctypes.c: Also don't call __new__ when a ctypes instance
+ is created from a base object.
+
+2005-05-17 Andreas Degert <ad at papyrus-gmbh.de>
+
+ * source/gcc, README.txt: merged with HEAD
+
+2005-05-11 Thomas Heller <theller at python.net>
+
+ * source\_ctypes.c (CData_FromBaseObj): Don't call __init__, only
+ __new__, when a ctypes instance is retrieved from a base object.
+ This avoids confusion when structure fields containing structures
+ (for example) are accessed.
+
+2005-05-06 Thomas Heller <theller at python.net>
+
+ * source/_ctypes.c: Clearer code, less code, and greater
+ performance by reworking CData_FromBaseObj.
+
+ * source/_ctypes.c, source/ctypes.h: CDataObject and
+ CFuncPtrObject now have a small buffer. If the C type fits into
+ that it is used, otherwise PyMem_Malloc() is called to create a
+ bigger one. This speeds up instance creation a lot.
+
+2005-04-22 Thomas Heller <theller at python.net>
+
+ * Committed a patch from Andreas Degert which allows to call
+ vararg functions on x86_64b platforms (although not officially
+ supported by libffi).
+
+2005-04-19 Thomas Heller <theller at python.net>
+
+ * Fixed quite a few problems on 64-bit platforms. Reported and
+ partly patched by Mike Flechter.
+
+2005-04-15 Thomas Heller <theller at python.net>
+
+ * Added some files from Bob Ippolito's macholib, to help finding
+ shared libraries on OS X.
+
+2005-04-14 Thomas Heller <theller at python.net>
+
+ * source/_ctypes.c: Fix a crash when a POINTER type has no _type_.
+ Reported by Georg Thalhammer, patch provided by Andreas Degert,
+ somewhat modified.
+
+2005-04-07 Thomas Heller <theller at python.net>
+
+ * Changed version number to 0.9.8.
+
+2005-04-04 Thomas Heller <theller at python.net>
+
+ * Fix a refcount leak.
+
+ * Fix a possible segfault in the 'cast' function (the code
+ possibly tried to Py_DECREF an uninitialized pointer).
+
+2005-04-04 Thomas Heller <theller at python.net>
+
+ * CVS: Created a branch_1_0 branch.
+
+2005-03-18 Thomas Heller <theller at python.net>
+
+ * ctypes-0.9.6 released.
+
+ * Back out the '.so' magic again.
+
+2005-03-17 Thomas Heller <theller at python.net>
+
+ * ctypes\__init__.py: On platforms where dlopen is used, and '.so'
+ is the default shared library extension, if dlopen fails and the
+ filename doesn't end with '.so', try again with '.so' appended to
+ the filename. This allows to use the attribute access syntax to
+ cdll to load libraries in some cases: 'cdll.libm'.
+
+ * ctypes\__init__.py: Removed the __del__ method in _CDLL. This
+ caused garbage in Python's gc. Reported by Erik Andersen.
+
+ * ctypes.com.register: Enclose the Python script to run as com
+ server in double quotes in case the path contains spaces. Fix by
+ Juan Carlos Coruna.
+
+ * ctypes.wrap.h2xml script: Added command line options to include
+ preprocessor symbols into the xml file (that was the default
+ before), and to not delete temporary files which may help locating
+ problems in the compilation. The latter was suggested by 'Bryan'
+ on the ctypes-users list.
+
+ Expanded the default excluded symbols list on Windows, so that
+ 'limits.h' can be processed.
+
+ 'h2xml.py' can now read preprocessor symbol names to exclude from
+ a local configuration file 'h2xml.cfg' inb the current directory.
+
+2005-03-16 Thomas Heller <theller at python.net>
+
+ * ctypes\source\_ctypes.c: Subclasses of c_char_p, c_wchar_p, and
+ c_void_p were not able to override the from_param class method in
+ their class definitions because SimpleType_new overwrote them.
+ Reported by Andreas Degert.
+
+ * ctypes\source: Removed the unneeded nArgBytes member from
+ StgDictObject, and changed the code accordingly. Thanks to
+ Andreas Degert for spotting this.
+
+ * ctypes\wrap\cparser_config.py: Added some symbols from windows
+ limits.h header file to the excluded list - h2xml.py choked on
+ them.
+
+2005-03-14 Thomas Heller <theller at python.net>
+
+ * _ctypes.c: Fixed refcount leak in functions with 'out'
+ parameters. This has only relevance for the unreleased comtypes
+ package.
+
+ * _ctypes.c: Keyword arguments to Structures/Unions were ignored.
+ Thanks to Jimmy Retzlaff for finding this.
+
+2005-03-11 Thomas Heller <theller at python.net>
+
+ * ctypes-0.9.5 released.
+
+ * The prototypes that WINFUNCTYPE or CFUNCTYPE return can now be
+ called with an optional third parameter: paramflags. This must be
+ a tuple specifying the parameter direction (in, out), the
+ parameter name (optional), and the default parameter value (also
+ optional). This creates a somewhat higher level function, and
+ also allows to call functions with named parameters.
+
+ The change made on 2005-01-15 has been reverted again - it is
+ better to create instancemethods, if needed, in the calling code.
+
+2005-02-10 Thomas Heller <theller at python.net>
+
+ * Clean up the_ semantics on Structure/Union types. The _fields_
+ attribute can no longer be set after one of the following happens:
+
+ - The _fields_ attribute is set.
+ - An instance of the type is created.
+ - The type is used as field in another Structure/Union.
+ - The type is subclassed.
+
+2005-01-26 Thomas Heller <theller at python.net>
+
+ * source\_ctypes.c: Prevent a crash when .restype or .argtypes
+ attribute of a function is deleted.
+
+2005-01-20 Thomas Heller <theller at python.net>
+
+ * source\callproc.c: Print a real traceback when an exception is
+ raised in a callback function.
+
+2005-01-15 Thomas Heller <theller at python.net>
+
+ * source\_ctypes.c: WINFUNCTYPE (and CFUNCTYPE) can now be called
+ with three parameters: integer, string, class. It returns an
+ unbound method fpr class, calling into a COM vtable at the integer
+ index. The string is the method name.
+
+ Better error chcking, and fix a compiler warning in CFuncPtr_new.
+
+2004-12-30 Thomas Heller <theller at python.net>
+
+ * _ctypes.c (_CData_set): Assinging None to a POINTER structure
+ field makes a NULL pointer.
+
+ * source\_ctypes.c (Pointer_ass_item): Prevent NULL pointer access
+ when assigning to pointer instances.
+
+2004-12-17 Thomas Heller <theller at python.net>
+
+ * source/callbacks.c: Corrected the exception handling in callback
+ functions. SystemExit in a callback now actually exits Python.
+
+2004-12-02 Thomas Heller <theller at python.net>
+
+ * Structure types as restype and in argtypes of functions do work
+ now. Not sure about callback functions.
+
+ The _fields_ attribute is now handled correctly in Structure
+ sub-subclasses. It is extended instead of replaced.
+
+ if 'sizeof(int) == sizeof(long)', c_int/c_uint are now aliases for
+ c_long/c_ulong, and if 'sizeof(long) == sizeof(long long)',
+ c_longlong/c_ulonglong are now aliases now for c_long/c_ulong.
+
+
+2004-12-01 Thomas Heller <theller at python.net>
+
+ * The annoying pointer bug has been fixed.
+
+2004-11-19 Thomas Heller <theller at python.net>
+
+ * (Message): The _fields_ attribute can now be set *after* a
+ Structure or Union type has been created.
+ XXX Describe the exact semantics.
+
+2004-10-29 Thomas Heller <theller at python.net>
+
+ * (Message): Define a new protocol for function's restype. If it
+ is a ctypes' type, it is handled in the usual way. But if it
+ additionally has an _check_retval_ attribute, this is called with
+ the result, and the return value of this call is the functions
+ return value.
+
+ This allows to define HRESULT as a ctypes' type, because it can
+ check for failure in it's _check_retval_ static method, and raise
+ a WindowsError.
+
+ The big advantage is that now HRESULT is also usable in the
+ argtypes list.
+
+ Although HRESULT is defined in python code (since it is derived
+ from c_long), the _check_retval_ method is implemented in C - in
+ this way the traceback won't include the _check_retval_ method
+ definition itself.
+
+ * (Message): Increased version number to 0.9.3.
+
+2004-10-28 Thomas Heller <theller at python.net>
+
+ * (Message): ctypes 0.9.2 released.
+
+ * Renamed the functions: get_string -> string_at,
+ get_wstring -> wstring_at
+
+2004-10-20 Thomas Heller <theller at python.net>
+
+ * Cycle GC support added for the PointerType_Type metaclass.
+ This makes the test_leaks unittests work.
+ Reverted the changes for lazy structures again.
+
+ * Remove CFuncPtrType_from_param again. Later.
+
+2004-10-19 Thomas Heller <theller at python.net>
+
+ * unittests\test_cfuncs.py: Fixed the test to work on OS X. The
+ problem probably was that OS X loads several different instances
+ of the _ctypes_test shared library.
+
+2004-10-15 Thomas Heller <theller at python.net>
+
+ * Implemented memmove, memset and get_string functions. They will operate
+ on any type of argument, so they should be used carefully.
+
+ * Reinstalled the magic _abstract_ attribute for Structure and
+ Union types. If this attribute is defined, the _fields_ attribute
+ looses it's special meaning. Kept for backwards compatibility.
+
+ * Work around a bug in Python's PyUnicode_FromWideChar and
+ PyUnicode_AsWideChar api functions.
+
+2004-10-14 Thomas Heller <theller at python.net>
+
+ * Implemented cycle GC for several internal types fixed some
+ leaks. Fixed another memory leak and a refcount leak.
+ Added a unittest to check for leaks.
+
+2004-10-13 Thomas Heller <theller at python.net>
+
+ * Bit fields in structures and unions are now implemented. They
+ are defined using a third item in the _fields_ list, which
+ specifies the number of bits in this field. Bit fields are only
+ allowed for numeric types, not for character types like c_char.
+ Tested on several x86, windows and linux.
+
+2004-10-12 Thomas Heller <theller at python.net>
+
+ * Implemented a cast(obj, ctype) function. This should be used to
+ convert one type of pointer to abother type of pointer. For
+ example, a POINTER(c_byte) instance could be converted to a
+ c_char_p instance pointing to the same memory location, allowing
+ to access the zero-terminated string pointed to.
+
+ * Unicode should now work on non-windows systems. Tested on Suse
+ Linux x86 and x86-64, Redhat linux x86 (wide unicode build).
+
+2004-10-08 Thomas Heller <theller at python.net>
+
+ * source\callbacks.c: Added a cast function, which creates a new
+ ctypes type instance from an existing instance. Does not yet work
+ correctly for integers of different sizes, but should work for
+ pointers - and that's where it is needed.
+
+ * ctypes\__init__.py: POINTER(None) will now return c_void_p.
+ This change was made to ease automatic code generation (and makes
+ sense, since None is used in other places for 'void' as well.
+
+ * source\_ctypes.c: ctypes _pointer_type_cache now lives in the
+ _ctypes module, to make it available to C code.
+
+ Setting the _fields_ attribute on a Structure or Union type after
+ creation automatically update the POINTER instance to it when it
+ already exists, this allows to use POINTER(<type>) in the _fields_
+ list without need to update the POINTER type later.
+
+ Implemented a customg from_param class method for CFuncPtrType:
+ Python callables can now be passed directly as arguments to
+ functions requiring callbacks: WINFUNCTYPE() or CFUNCTYPE() in the
+ argtypes list.
+
+ To avoid having to keep a reference to the created callback
+ function explicitely (which will always be forgotten), started
+ code to keep a reference automatically - currently this only works
+ for functions, *not* for methods!!!
+
+2004-09-28 Thomas Heller <theller at python.net>
+
+ * (Message): Support for 'lazy' Structure and Union definitions.
+ The _fields_ attribute can now be set after the class has been
+ defined.
+
+2004-09-21 Thomas Heller <theller at python.net>
+
+ * (Message): Increased version number to 0.9.2.
+
+2004-09-16 Thomas Heller <theller at python.net>
+
+ * (Message): ctypes 0.9.1 released.
+
+ * (Message): The internal conversions that ctypes does between
+ unicode and strings can now use a specified encoding and error
+ handling. A set_conversion_mode() function allows to set them, it
+ returns the previous values. The inital values are ('mbcs',
+ 'ignore') on Windows, and ('ascii', 'strist') on other systems.
+
+ (source\callproc.c): The Extend_Error_Info() function has been
+ fixed - sometimes is displayed weird error messages like
+ 'TypeError: function takes 5 arguments (1 given)' when an
+ UnicodeEncodingError was raised.
+
+ When internal processing of an argument for a function call fails,
+ the new ctypes.ArgumentError exception is raised.
+
+
+2004-09-15 Thomas Heller <theller at python.net>
+
+ * ctypes\__init__.py: CDLL and subclasses now accept an optional
+ second handle parameter. If this is supplied, it is used instead
+ of calling LoadLibrary() or dlopen() to get one.
+
+ * source\callproc.c: Important fix - sometimes pointers to
+ arguments in function call have been free'd too early, especially
+ when argtypes have been specified for functions.
+
+2004-09-07 Thomas Heller <theller at python.net>
+
+ * (Message): Fix the create_unicode_buffer function - it was
+ returning c_char arrays instead of c_wchar arrays.
+
+ Both create_string_buffer and create_unicode_buffer can now be
+ called with string and unicode instances, they will do the needed
+ conversions themselves.
+
+2004-09-01 Thomas Heller <theller at python.net>
+
+ * (Message): A pythonapi object has been added to the ctypes
+ package. On windows, it is bound to the python dll, on other
+ systems it is bound to the current process.
+
+ It allows to access C Python api functions.
+
+ py_object is the ctypes type corresponding to the C 'PyObject *'
+ type.
+
+ * ctypes: It is now possible to call cdecl functions with more
+ arguments than the length of the argtypes attribute, even if this
+ is set. This allows specify argtypes for functions like sprintf().
+
+2004-08-27 Thomas Heller <theller at python.net>
+
+ * ctypes: Accept integer addresses, uncode strings, and strings in
+ the c_char_p and c_wchar_p constructor and as c_char_p and
+ c_wchar_p fields in Structures. strings are automatically decoded
+ to unicode, and unicode is automatically encoded in strings if
+ needed.
+
+ Integer addresses are *not* accepted in function parameter lists,
+ they must before be converted to c_char_p or c_wchar_p.
+
+
+2004-08-26 Thomas Heller <theller at python.net>
+
+ * source\callproc.c: Implemented Py_INCREF and Py_DECREF as
+ functions.
+
+ * ctypes\__init__.py: Cache the types that WINFUNCTYPE and
+ CFUNCTYPE creates, to avoid creation of a lot of similar classes.
+ Rearrange the code to use try:except: instead of dict.get(xxx,
+ None), the former is faster if lookup mostly succeeds - as is the
+ case for POINTER imo.
+
+ This makes importing large COM files created by readtlb a lot
+ faster, since WINFUNCTYPE is called for every COM method. The
+ python wrapper for mshtml.tlb, which contains nearly 600
+ interfaces, now imports in 3 seconds instead of 40!
+
+
+2004-08-20 Thomas Heller <theller at python.net>
+
+ * (Message): Add the PyDLL class and pydll object to ctypes, they
+ will expose functions using FUNCFLAG_PYTHONAPI allowing to call
+ Python api functions.
+
+ * source/cfield.c: Add accessors for 'O' typecode (which converts
+ to/from python objects).
+
+ * (Message): Implement the FUNCFLAG_PYTHONAPI flag which allows to
+ call Python API functions with ctypes. Somewhat tricky - we have
+ to keep the thread state during the call, and we have to make sure
+ to return failure if the Python error flag has been set.
+
+2004-08-19 Thomas Heller <theller at python.net>
+
+ * (Message): the alignment function was not exported by the ctypes
+ module. It returns the alignment requirements in bytes of a type
+ or instance.
+
+ * source/callproc.c: The _ctypes.call_function function, although
+ private and deprecated, has been put back in - it is used by Gary
+ Bishop's readline module.
+
+2004-08-18 Thomas Heller <theller at python.net>
+
+ * (Message): Array and POINTER instance now support slicing, for
+ POINTER only getslice is implemented (setslice is too dangerous,
+ probably). Slices are accepted or returned as lists of the
+ elements, except for character and unicode character pointer and
+ arrays, where strings resp. unicode strings are used - much more
+ convenient.
+
+ * MANIFEST.windows.in: Added the include files which were missing
+ from the source distribution.
+
+2004-07-28 Thomas Heller <theller at python.net>
+
+ * (Message): CopyComPointer is no longer a function exported from
+ the _ctypes dll/shared lib, instead it is a normal Python function
+ implemented in the _ctypes extension. This allows to build
+ _ctypes as a builtin module.
+
+2004-07-23 Thomas Heller <theller at python.net>
+
+ (Message): ctypes 0.9.0 released.
+
+
+ * (Message): c_int, c_uint and other integer variants now use the
+ masked functions when converting Python integers/longs to C
+ integers. This has the effect that the value of the integer is
+ never checked, it is silently truncated.
+
+ * (Message): ctypes now requires Python 2.3 or better.
+
+ * (Message): Add some 'hacks' which make ctypes work on big-endian
+ platforms. On platforms with strict alignment rules, there are
+ still some crashes (solaris sparc).
+
+2004-xx-xx Thomas Heller <theller at python.net>
+
+ * (Message): Conversion to libffi is now complete. libffi is now
+ used on all platforms. unittests pass, at least on x86
+ architectures. Tested on Linux, FreeBSD.
+
+2004-05-07 Thomas Heller <theller at python.net>
+
+ * (Message): Tag the HEAD with before_libffi_2004_05_07
+
+ * ctypes\source\callbacks.c: Callback functions can now return
+ c_char and c_char_p data types.
+
+2004-05-06 Thomas Heller <theller at python.net>
+
+ * Finally fixed the sometimes shortened traceback prints when an
+ exception occurrs in a callback function - only the exception
+ class was printed, not the value.
+
+2004-05-03 Thomas Heller <theller at python.net>
+
+ * win32\com\client.py: Add a COMError class, compatible to that
+ used in pywin32. If _DispMethod.__call__ fails, a COMError is now
+ raised, with more detailed information.
+
+ * ctypes\__init__.py: The WinError function does now accept an
+ optional second parameter, this is the textual error description.
+
+2004-04-20 Thomas Heller <theller at python.net>
+
+ * ctypes\__init__.py: c_buffer is silently deprecated, and
+ replaced by create_string_buffer. A similar function
+ create_unicode_buffer has been added.
+
+ * source\callproc.c: Improve the error reporting for access
+ violations - the message now reports the faulting address in
+ charge, and whether reading or writing failed.
+
+2004-02-05 Thomas Heller <theller at python.net>
+
+ * source\_ctypes.c: Added c_char_p_from_param and
+ c_void_p_from_param class methods to the _SimpleCData type. These
+ are later used as from_param class methods for the c_void_p,
+ c_char_p, and POINTER(c_char) types. Added unittests for them.
+
+ * (CFuncPtr_set_argtypes): It is now possible to assign None to a
+ functions argtypes attribute. This clear the argtypes sequence,
+ after that the function can be called with any number and types of
+ arguments.
+
+2004-01-20 Thomas Heller <theller at python.net>
+
+ * source\_ctypes.c: Moved the test functions into a seaparate
+ Python extension module _ctypes_test.c. Setup-script and
+ unittests updated.
+
+2003-10-30 Thomas Heller <theller at python.net>
+
+ * source\_ctypes.c: Finally added cycle GC support for all the
+ base-types implemented in this module, without breaking the
+ test-suite.
+
+2003-10-24 Thomas Heller <theller at python.net>
+
+ * win32\com\__init__.py: Changes to prevent crashes when the
+ interpreter exits, and COM pointers are to be cleaned up. The
+ problem was that CoUninitialize was registered by the atexit
+ module, and this runs *before* all the modules are cleared out and
+ the final Release() call on the COM pointers is done. The
+ solution is to create an object in the com\__init__.py module
+ which will call CoUninitialize when it's refcount reaches zero.
+ Even better would probably be to make this an attribute of the sys
+ module, because sys is cleaned last, only __builtins__ is cleaned
+ later.
+
+2003-07-18 Thomas Heller <theller at python.net>
+
+ * ctypes\__init__.py (c_buffer): Accept int as well as long
+ integers as the size argment for c_buffer.
+
+2003-07-09 Thomas Heller <theller at python.net>
+
+ * source\_ctypes.c: Prevent crashes on pointer(IUnknown()) call.
+
+2003-07-08 Thomas Heller <theller at python.net>
+
+ * source\_ctypes.c: Finally fixed this nasty pointer bug. The
+ incomplete pointer sample from the tutorial now works.
+
+2003-07-03 Thomas Heller <theller at python.net>
+
+ * ctypes\__init__.py: Use __getitem__ to load libaries or get functions.
+ gpib = cdll["gpib-32.dll"], and gpib["Function-With-A-Strange_Name@@@"].
+ Suggested by Chuck Esterbrook.
+
+2003-06-24 Thomas Heller <theller at python.net>
+
+ * source\_callbacks.c: Callback functions can now return simple
+ data types like floats, doubles, long long and so on. Before,
+ only integers were returned.
+
+2003-06-12 Thomas Heller <theller at python.net>
+
+ * source\*.c: On Windows, structures and unions can now be passed
+ *by value* to function calls.
+
+2003-06-03 Thomas Heller <theller at python.net>
+
+ * source\_ctypes.c: Raise AttributeError instead of ValueError
+ when a function is not found in a dll. Suggested by Chuck Esterbrook.
+
+2003-05-16 Thomas Heller <theller at python.net>
+
+ * source\_ctypes.c: Fix some (but not all) problems with pointer
+ instance and types.
+
+ * source\_ctypes.c: Make the restype atribute of functions readable.
+ VisualPython's debugger had problems if it was not.
+ Contributed by Nick Adams.
+
+ * ctypes\__init__.py: Fix the name of the void pointer type, it's
+ c_void_p not c_voidp (but leave the old name intact)
+
+ * source\cfield.c: The c_wchar_p.from_param method did not accept
+ None (NULL pointer as parameter). Unittests updated.
+
+ * source\_ctypes.c: ctypes' types now have a in_dll() class method.
+ It allows to access values exported from dlls. Also added a unittest.
+ Often requested feature.
+
+2003-05-14 Thomas Heller <theller at python.net>
+
+ * win32\com\register.py: Register the script with the absolute
+ pathname.
+
+2003-03-11 Thomas Heller <theller at python.net>
+
+ * ctypes/source: CFuncPtr changes: The _argtypes_ attribute is now
+ optional (but required if you want to construct callbacks).
+ CFuncPtr now has two contructors: CFuncPtr(callable), and
+ CFuncPtr(funcname, dll). So CFuncPtr can now completely replace
+ both CFunction (for callbacks) and DynFunction (for dll
+ functions).
+
+2003-03-07 Thomas Heller <theller at python.net>
+
+ * ctypes: The CFuncPtr type now supports cyclic garbage
+ collection, it is especially useful here, but GC support for other
+ types is not far away.
+
+ * ctypes: The CFunction subclass _types_ attribute does not accept
+ format characters any more, types like c_int, c_char_p and so on
+ must now be used. The same change has been made for the argtypes
+ and restype attribute of dll functions.
+
+ A new base type CFuncPtr was added. This will soon make CFunction
+ and DynFunction obsolete. Subclass creation requires an _argtype_
+ attribute mush must be a sequence of types like c_int or c_charp,
+ a _flags_attribute which must be a bitwise or of FUNCFLAG_CDECL,
+ FUNCFLAG_STDCALL and FUNCFLAG_HRESULT (the latter two only on
+ Windows) to specify the calling convention, and an optional
+ _restype_ attribute which defaults to c_int.
+
+ The plan is to create some factory functions like STDCALL() and
+ CDECL() which return CFuncPtr subclasses, this is useful to define
+ these subclasses in an expression instead of a class statement, also
+ it probably makes it easier to use.
+
+ Obscure change: If the CFunction instance uses c_int in the
+ _types_ sequence, it will now receive a standard Python integer
+ and no longer a c_int instance if it is called. (CFuncPtr
+ instances behave in the same way).
+
+2003-03-04 Thomas Heller <theller at python.net>
+
+ * ctypes.py (cdll): Changed the __getattr__ implementations for
+ all *DLL classes to raise an attribute error if the requested name
+ both starts and ends with a double underscore. Thanks to Wolfgang
+ Strobl for pointing at this.
+
+2003-02-26 Thomas Heller <theller at python.net>
+
+ * source\_ctypes.c: Removed the unused from_bytes stuff.
+
+ * source\_ctypes.c (CString_new): The buffer is only initialized
+ to the bytes from the string is passed in, if any. The
+ terminating NUL byte is always set. This allows large c_string
+ instances to be created with minimum overhead.
+
+ * source: Moved code from _ctypes.c into the new files cfield.c
+ (field accessors) and stgdict.c (storage info dict).
+
+2003-02-25 Thomas Heller <theller at python.net>
+
+ * source\callproc.c: Added call_cdeclfunction.
+
+ * source\_ctypes.c: addressof() now accepts CFunction instances.
+
+2003-02-24 Thomas Heller <theller at python.net>
+
+ * source\_ctypes.c: c_string() and c_wstring() signatures
+ changed. If the first parameter is a string, an optional positive
+ integer can be used as second parameter to specify the size of the
+ internal buffer. This size does NOT include the terminating NUL
+ byte. Since sizeof() does now support c_string and c_wstring,
+ len() is no longer supported (c_string and c_wstring have never
+ really been sequences).
+
+ * source\_ctypes.c: Made sizeof() and addressof() work with
+ c_string and c_wstring objects.
+
+ * source\callproc.c: PyCArgObjects now have a readonly _obj
+ attribute, this is the object passed to the byref() call. Useful
+ for implmenting custom argument type checking in Python.
+
+2003-02-20 Thomas Heller <theller at python.net>
+
+ * unittests\test_strings.py (StringTestCase.test_sized_strings):
+ Added tests for the new c_string constructor.
+
+ * source\_ctypes.c (CString_new): The c_string constructor can now
+ be called with a positive integer, this will create an empty
+ string buffer of the specified length (+ 1 for a terminating NUL
+ character).
+
+ * source\_ctypes.c (CString_new): It's no longer possible to call
+ c_string with None as argument. It created a string of zero size,
+ but this doesn't seem to make sense.
+
+2003-02-19 Thomas Heller <theller at python.net>
+
+ * source/_ctypes.c, ctypes.py: Add a c_voidp data type, which
+ represents (void) pointers to memory locations. The value
+ attribute is a Python integer (or a long).
+
+2003-02-18 Thomas Heller <theller at python.net>
+
+ * (Repository): Added a packages directory, and created a ctcom
+ package. See separate changelog.
+
+2003-02-11 Thomas Heller <theller at python.net>
+
+ * source/_ctypes.c: The .from_parameter method of POINTER classes now
+ accept Array instances containing elements of exactly the same
+ type.
+
+ * source/callproc.c: Make sure call_comproc checks for valid
+ number of arguments before calling _CallProc.
+
+2003-02-07 Thomas Heller <theller at python.net>
+
+ * Version 0.4.0 released and uploaded.
+
+ * source/_ctypes.c: PointerType_new, ArrayType_new,
+ SimpleType_new, and CFunctionType_new did not check for NULL
+ result from PyType_Type.tp_new() call. This call will fail in
+ Python 2.3 when 'object' is listed as the first base class with a
+ TypeError: MRO conflict among bases. Spotted by Greg Chapman.
+
+2003-02-05 Thomas Heller <theller at python.net>
+
+ * The 'raw' and 'value' properties of c_wstring are back, also
+ fixed some severe bugs (it seems c_wstring never worked
+ correctly).
+
+ Added unittests.
+
+ * Fixed a problem in c_string: The NUL byte at the buffer end
+ could be overwritten. Added unittests for c_strings.
+
+ Per suggestion from Niki Spahiev, CFieldObjects now have a
+ readonly size and offset property. Added short docs for them.
+
+
+2003-01-31 Thomas Heller <theller at python.net>
+
+ * Item deletion on Array or Pointer instances did crash with a
+ NULL pointer access. Added unittest for this, and also for
+ Arrays.
+
+2003-01-28 Thomas Heller <theller at python.net>
+
+ * source\_ctypes.c: Dangerous code checked in. Pointer instances
+ can point to a single data item, or they can point to an array of
+ values. Back in the distant past ;-), I had a SetSize() method,
+ which would enable indexes != 0. Don't know when and why I
+ removed it, but I need it again. Should it have to be enabled
+ explicitely? Would be better, it seems.
+
+ Note that there's no corresponding ass_item implementation with
+ indexes != 0. This means, we can get and change the items the
+ pointer points to, if they are mutable, but not replace the items
+ by different ones.
+
+
+2003-01-24 Thomas Heller <theller at python.net>
+
+ * (several): Fixed the alignment and size of the compound
+ datatypes Structure, Union, and hopefully also Array.
+
+2003-01-23 Thomas Heller <theller at python.net>
+
+ * source/_ctypes.c: Raise a TypeError if a SimpleCData type or a
+ CDataType is specified as a CFunction's restype.
+
+ * source/_ctypes.c: CFunction now has a from_param class method.
+ This means that CFunction subclasses can now be used in the
+ argtypes attribute, and so typechecking is done.
+
+ * unittests: Rewrote the tests from doctest to pyunit.
+
+2003-01-21 Thomas Heller <theller at python.net>
+
+ * source/: Merged in these changes from the C_FAST_CARGS branch:
+
+ ConvParam returns PyCArgObject instances now. Fixed the
+ _as_parameter_ properties of Array, CString, and CFunction so that
+ they 'return' PyCArgObject instances instead of magic tuples.
+
+ Added a public 'P' fielddescriptor, which is mostly for internal
+ use.
+
+ The 's' rettype value for functions is probably useless, because
+ functions return *pointers* to strings (char *), not strings.
+
+ Adapted all the unittests to work, and also changed the samples.
+
+2003-01-20 Thomas Heller <theller at python.net>
+
+ * source/*.[ch]: Introduced PyCArgObject objects, which contain a
+ Python object itself and also the data converted to C. This
+ replaces the magic 3-tuples, and should be somewhat faster because
+ no two conversions take place.
+
+ This is now used by SimpleType_from_param(), byref(), and
+ Pointer_as_parameter(), and is understood by ConvParam().
+
+ In the long run this should be the only thing (besides primitive
+ Python data types with trivial conversions) used by ConvParam().
+
+ Also ConvParam should probably *return* these things.
+
+
+2003-01-17 Thomas Heller <theller at python.net>
+
+ * source/_ctypes.c: Rewrite of SimpleType_from_param complete.
+ unittests/test_parameters.py shows that it does the right things
+ in most cases.
+
+ * (Repository): Moved everything from local CVS to the SF
+ repository, and restructured the directories.
+
Modified: packages/ctypes/branches/upstream/current/LICENSE.txt
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/LICENSE.txt?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/LICENSE.txt (original)
+++ packages/ctypes/branches/upstream/current/LICENSE.txt Mon Jun 19 12:31:53 2006
@@ -1,4 +1,4 @@
- Copyright (c) 2000, 2001, 2002, 2003, 2004 Thomas Heller
+ Copyright (c) 2000 - 2006 Thomas Heller
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Added: packages/ctypes/branches/upstream/current/MANIFEST
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/MANIFEST?rev=940&op=file
==============================================================================
--- packages/ctypes/branches/upstream/current/MANIFEST (added)
+++ packages/ctypes/branches/upstream/current/MANIFEST Mon Jun 19 12:31:53 2006
@@ -1,0 +1,171 @@
+ACKS
+ANNOUNCE
+ChangeLog
+LICENSE.txt
+MANIFEST
+MANIFEST.in
+README.CVS
+README.txt
+ctypes-dev.el
+setup.py
+ctypes/.CTYPES_DEVEL
+ctypes/__init__.py
+ctypes/_endian.py
+ctypes/util.py
+ctypes/wintypes.py
+ctypes/macholib/__init__.py
+ctypes/macholib/dyld.py
+ctypes/macholib/dylib.py
+ctypes/macholib/framework.py
+ctypes/test/__init__.py
+ctypes/test/runtests.py
+ctypes/test/test_array_in_pointer.py
+ctypes/test/test_arrays.py
+ctypes/test/test_bitfields.py
+ctypes/test/test_buffers.py
+ctypes/test/test_byteswap.py
+ctypes/test/test_callbacks.py
+ctypes/test/test_cast.py
+ctypes/test/test_cfuncs.py
+ctypes/test/test_checkretval.py
+ctypes/test/test_errcheck.py
+ctypes/test/test_find.py
+ctypes/test/test_funcptr.py
+ctypes/test/test_functions.py
+ctypes/test/test_incomplete.py
+ctypes/test/test_init.py
+ctypes/test/test_integers.py
+ctypes/test/test_internals.py
+ctypes/test/test_keeprefs.py
+ctypes/test/test_libc.py
+ctypes/test/test_loading.py
+ctypes/test/test_macholib.py
+ctypes/test/test_memfunctions.py
+ctypes/test/test_numbers.py
+ctypes/test/test_parameters.py
+ctypes/test/test_pointers.py
+ctypes/test/test_prototypes.py
+ctypes/test/test_python_api.py
+ctypes/test/test_random_things.py
+ctypes/test/test_refcounts.py
+ctypes/test/test_repr.py
+ctypes/test/test_returnfuncptrs.py
+ctypes/test/test_simplesubclasses.py
+ctypes/test/test_sizes.py
+ctypes/test/test_slicing.py
+ctypes/test/test_stringptr.py
+ctypes/test/test_strings.py
+ctypes/test/test_struct_fields.py
+ctypes/test/test_structures.py
+ctypes/test/test_unaligned_structures.py
+ctypes/test/test_unicode.py
+ctypes/test/test_values.py
+ctypes/test/test_win32.py
+docs/manual/markup.py
+docs/manual/mkpydoc.py
+docs/manual/tutorial.html
+docs/manual/tutorial.txt
+source/_ctypes.c
+source/_ctypes_test.c
+source/_ctypes_test.h
+source/callbacks.c
+source/callproc.c
+source/cfield.c
+source/ctypes.h
+source/ctypes_dlfcn.h
+source/malloc_closure.c
+source/stgdict.c
+source/darwin/dlfcn.h
+source/darwin/dlfcn_simple.c
+source/libffi/LICENSE
+source/libffi/README
+source/libffi/aclocal.m4
+source/libffi/config.guess
+source/libffi/config.sub
+source/libffi/configure
+source/libffi/configure.ac
+source/libffi/fficonfig.h.in
+source/libffi/fficonfig.py.in
+source/libffi/install-sh
+source/libffi/include/ffi.h.in
+source/libffi/include/ffi_common.h
+source/libffi/src/prep_cif.c
+source/libffi/src/alpha/ffi.c
+source/libffi/src/alpha/ffitarget.h
+source/libffi/src/alpha/osf.S
+source/libffi/src/arm/ffi.c
+source/libffi/src/arm/ffitarget.h
+source/libffi/src/arm/sysv.S
+source/libffi/src/cris/ffi.c
+source/libffi/src/cris/ffitarget.h
+source/libffi/src/cris/sysv.S
+source/libffi/src/frv/eabi.S
+source/libffi/src/frv/ffi.c
+source/libffi/src/frv/ffitarget.h
+source/libffi/src/ia64/ffi.c
+source/libffi/src/ia64/ffitarget.h
+source/libffi/src/ia64/ia64_flags.h
+source/libffi/src/ia64/unix.S
+source/libffi/src/m32r/ffi.c
+source/libffi/src/m32r/ffitarget.h
+source/libffi/src/m32r/sysv.S
+source/libffi/src/m68k/ffi.c
+source/libffi/src/m68k/ffitarget.h
+source/libffi/src/m68k/sysv.S
+source/libffi/src/mips/ffi.c
+source/libffi/src/mips/ffitarget.h
+source/libffi/src/mips/n32.S
+source/libffi/src/mips/o32.S
+source/libffi/src/pa/ffi.c
+source/libffi/src/pa/ffitarget.h
+source/libffi/src/pa/linux.S
+source/libffi/src/powerpc/aix.S
+source/libffi/src/powerpc/aix_closure.S
+source/libffi/src/powerpc/asm.h
+source/libffi/src/powerpc/darwin.S
+source/libffi/src/powerpc/darwin_closure.S
+source/libffi/src/powerpc/ffi.c
+source/libffi/src/powerpc/ffi_darwin.c
+source/libffi/src/powerpc/ffitarget.h
+source/libffi/src/powerpc/linux64.S
+source/libffi/src/powerpc/linux64_closure.S
+source/libffi/src/powerpc/ppc_closure.S
+source/libffi/src/powerpc/sysv.S
+source/libffi/src/s390/ffi.c
+source/libffi/src/s390/ffitarget.h
+source/libffi/src/s390/sysv.S
+source/libffi/src/sh/ffi.c
+source/libffi/src/sh/ffitarget.h
+source/libffi/src/sh/sysv.S
+source/libffi/src/sh64/ffi.c
+source/libffi/src/sh64/ffitarget.h
+source/libffi/src/sh64/sysv.S
+source/libffi/src/sparc/ffi.c
+source/libffi/src/sparc/ffitarget.h
+source/libffi/src/sparc/v8.S
+source/libffi/src/sparc/v9.S
+source/libffi/src/x86/ffi.c
+source/libffi/src/x86/ffi64.c
+source/libffi/src/x86/ffitarget.h
+source/libffi/src/x86/sysv.S
+source/libffi/src/x86/unix64.S
+source/libffi/src/x86/win32.S
+source/libffi_arm_wince/debug.c
+source/libffi_arm_wince/ffi.c
+source/libffi_arm_wince/ffi.h
+source/libffi_arm_wince/ffi_common.h
+source/libffi_arm_wince/fficonfig.h
+source/libffi_arm_wince/ffitarget.h
+source/libffi_arm_wince/prep_cif.c
+source/libffi_arm_wince/sysv.asm
+source/libffi_msvc/ffi.c
+source/libffi_msvc/ffi.h
+source/libffi_msvc/ffi_common.h
+source/libffi_msvc/fficonfig.h
+source/libffi_msvc/ffitarget.h
+source/libffi_msvc/prep_cif.c
+source/libffi_msvc/types.c
+source/libffi_msvc/win32.S
+source/libffi_msvc/win32.c
+wince/_ctypes.vcp
+wince/_ctypes.vcw
Added: packages/ctypes/branches/upstream/current/MANIFEST.in
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/MANIFEST.in?rev=940&op=file
==============================================================================
--- packages/ctypes/branches/upstream/current/MANIFEST.in (added)
+++ packages/ctypes/branches/upstream/current/MANIFEST.in Mon Jun 19 12:31:53 2006
@@ -1,0 +1,31 @@
+# standard files
+include ACKS ANNOUNCE ChangeLog MANIFEST MANIFEST.in LICENSE.txt NEWS.txt README*
+
+# support files for development
+include ctypes-dev.el
+include ctypes/.CTYPES_DEVEL
+include setup.py
+
+# libffi build files
+include source/libffi/aclocal.m4
+include source/libffi/config.guess
+include source/libffi/config.sub
+include source/libffi/configure
+include source/libffi/configure.ac
+include source/libffi/fficonfig.h.in
+include source/libffi/fficonfig.py.in
+include source/libffi/install-sh
+include source/libffi/LICENSE
+include source/libffi/README
+
+# all source files
+recursive-include source *.c *.h *.S *.asm *.in
+
+# windows CE project files
+include wince/_ctypes.vcw wince/_ctypes.vcp wince/_ctypes_test.vcp
+
+# docs/manual
+include docs/manual/tutorial.txt
+include docs/manual/tutorial.html
+include docs/manual/mkpydoc.py
+include docs/manual/markup.py
Modified: packages/ctypes/branches/upstream/current/PKG-INFO
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/PKG-INFO?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/PKG-INFO (original)
+++ packages/ctypes/branches/upstream/current/PKG-INFO Mon Jun 19 12:31:53 2006
@@ -1,6 +1,6 @@
Metadata-Version: 1.0
Name: ctypes
-Version: 0.9.9.3
+Version: 0.9.9.6
Summary: create and manipulate C data types in Python, call functions in shared libraries
Home-page: http://starship.python.net/crew/theller/ctypes.html
Author: Thomas Heller
Added: packages/ctypes/branches/upstream/current/ctypes-dev.el
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/ctypes-dev.el?rev=940&op=file
==============================================================================
--- packages/ctypes/branches/upstream/current/ctypes-dev.el (added)
+++ packages/ctypes/branches/upstream/current/ctypes-dev.el Mon Jun 19 12:31:53 2006
@@ -1,0 +1,106 @@
+;; In the ~/init.el file, write:
+;; (setq load-path (cons "c:\\sf\\ctypes" load-path)
+;; (require 'ctypes-dev)
+;;
+;; Try M-x customize-group ctypes-dev
+;;
+;; Based on twisted-dev.el
+
+(provide 'ctypes-dev)
+
+(defgroup ctypes-dev nil
+ "Various ctypes development utilities"
+ :group 'development)
+
+(defcustom ctypes-dev-directory "c:\\sf\\ctypes_dist"
+ "ctypes root directory"
+ :group 'ctypes-dev
+ :type 'string)
+
+(setenv "PYTHONPATH" ctypes-dev-directory)
+
+(defmacro with-cd (dirname &rest code)
+ `(let ((old-dirname default-directory)
+ (start-buffer (current-buffer)))
+ (cd ,dirname)
+ (unwind-protect (progn , at code)
+ (let ((end-buffer (current-buffer)))
+ ;; (cd ,dirname)
+ (set-buffer start-buffer)
+ (cd old-dirname)
+ (set-buffer end-buffer)))))
+
+(defun ctypes-dev-build ()
+ (interactive)
+ (with-cd ctypes-dev-directory
+ (compile "python setup.py build")))
+
+(defun ctypes-dev-build-debug ()
+ (interactive)
+ (with-cd ctypes-dev-directory
+ (compile "py_d setup.py build -g")))
+
+(defun ctypes-dev-rebuild ()
+ (interactive)
+ (with-cd ctypes-dev-directory
+ (compile "python setup.py build -f")))
+
+(defun ctypes-dev-test ()
+ (interactive)
+ (with-cd (concat ctypes-dev-directory "\\unittests")
+ (compile "python runtests.py")))
+
+(defun ctypes-dev-test-debug ()
+ (interactive)
+ (with-cd (concat ctypes-dev-directory "\\unittests")
+ (compile "py_d runtests.py")))
+
+(defun comtypes-test ()
+ (interactive)
+ (with-cd (concat ctypes-dev-directory "\\comtypes\\unittests")
+ (compile "python runtests.py")))
+
+(defun comtypes-test-debug ()
+ (interactive)
+ (with-cd (concat ctypes-dev-directory "\\comtypes\\unittests")
+ (compile "py_d runtests.py")))
+
+(define-minor-mode ctypes-dev-mode
+ "Toggle ctypes-dev mode.
+With no argument, this command toggles the mode.
+Non-null prefix argument turns on the mode.
+Null prefix argument turns off the mode."
+ ;; The initial value.
+ nil
+ ;; The indicator for the mode line.
+ " ctypes"
+ ;; The minor mode bindings.
+ '(
+;; ([f6] . ctypes-dev-genapidoc)
+;; ([f7] . ctypes-dev-gendoc)
+ ('(shift f8) . ctypes-dev-build-debug)
+ ([f8] . ctypes-dev-build)
+ ('(shift f9) . ctypes-dev-test-debug)
+ ([f9] . ctypes-dev-test)
+ ([f10] . comtypes-test)
+ ('(shift f10) . comtypes-test-debug)
+;; ([f11] . ctypes-dev-grep)
+;; ([f12] . ctypes-dev-gendocs)
+))
+
+
+(add-hook
+ 'find-file-hooks
+ (lambda ()
+ (let ((full-ctypes-path (expand-file-name ctypes-dev-directory)))
+ (if (> (length (buffer-file-name)) (length full-ctypes-path))
+ (if (string=
+ (substring (buffer-file-name) 0 (length full-ctypes-path))
+ full-ctypes-path)
+ (ctypes-dev-mode)
+ )))))
+
+;(add-hook
+; 'python-mode-hook
+; (lambda ()
+; (ctypes-dev-mode t)))
Modified: packages/ctypes/branches/upstream/current/ctypes/.CTYPES_DEVEL
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/ctypes/.CTYPES_DEVEL?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/ctypes/.CTYPES_DEVEL (original)
+++ packages/ctypes/branches/upstream/current/ctypes/.CTYPES_DEVEL Mon Jun 19 12:31:53 2006
@@ -1,13 +1,6 @@
# -*- python -*-
def install():
import sys, os
-
- p = os.path.abspath(
- os.path.join(os.path.dirname(__file__), "..", sys.platform))
- try:
- __path__.insert(0, p)
- except NameError:
- pass # when ctypes/__init__.py is imported *not* as package
from distutils.util import get_platform
plat_specifier = ".%s-%s" % (get_platform(), sys.version[0:3])
Modified: packages/ctypes/branches/upstream/current/ctypes/__init__.py
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/ctypes/__init__.py?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/ctypes/__init__.py (original)
+++ packages/ctypes/branches/upstream/current/ctypes/__init__.py Mon Jun 19 12:31:53 2006
@@ -1,26 +1,23 @@
"""create and manipulate C data types in Python"""
+
+import os as _os, sys as _sys
+from itertools import chain as _chain
# special developer support to use ctypes from the CVS sandbox,
# without installing it
-import os as _os, sys as _sys
-from itertools import chain as _chain
-
+# XXX Remove this for the python core version
_magicfile = _os.path.join(_os.path.dirname(__file__), ".CTYPES_DEVEL")
if _os.path.isfile(_magicfile):
execfile(_magicfile)
del _magicfile
-__version__ = "0.9.9.3"
+__version__ = "0.9.9.6"
from _ctypes import Union, Structure, Array
from _ctypes import _Pointer
from _ctypes import CFuncPtr as _CFuncPtr
from _ctypes import __version__ as _ctypes_version
-try:
- from _ctypes import RTLD_LOCAL, RTLD_GLOBAL
-except (ImportError, AttributeError):
- RTLD_GLOBAL = RTLD_LOCAL = None
-
+from _ctypes import RTLD_LOCAL, RTLD_GLOBAL
from _ctypes import ArgumentError
from struct import calcsize as _calcsize
@@ -33,8 +30,6 @@
from _ctypes import FUNCFLAG_CDECL as _FUNCFLAG_CDECL, \
FUNCFLAG_PYTHONAPI as _FUNCFLAG_PYTHONAPI
-
-from ctypes._loader import LibraryLoader
"""
WINOLEAPI -> HRESULT
@@ -76,16 +71,18 @@
_c_functype_cache = {}
def CFUNCTYPE(restype, *argtypes):
"""CFUNCTYPE(restype, *argtypes) -> function prototype.
-
+
restype: the result type
argtypes: a sequence specifying the argument types
-
+
The function prototype can be called in three ways to create a
callable object:
-
- prototype(funct) - returns a C callable function calling funct
- prototype(vtbl_index, method_name[, paramflags]) - a Python callable that calls a COM method
- prototype(funct_name, dll[, paramflags]) - a Python callable that calls an exported function in a dll
+
+ prototype(integer address) -> foreign function
+ prototype(callable) -> create and return a C callable function from callable
+ prototype(integer index, method name[, paramflags]) -> foreign function calling a COM method
+ prototype((ordinal number, dll object)[, paramflags]) -> foreign function exported by ordinal
+ prototype((function name, dll object)[, paramflags]) -> foreign function exported by name
"""
try:
return _c_functype_cache[(restype, argtypes)]
@@ -99,8 +96,7 @@
if _os.name in ("nt", "ce"):
from _ctypes import LoadLibrary as _dlopen
- from _ctypes import FUNCFLAG_HRESULT as _FUNCFLAG_HRESULT, \
- FUNCFLAG_STDCALL as _FUNCFLAG_STDCALL
+ from _ctypes import FUNCFLAG_STDCALL as _FUNCFLAG_STDCALL
if _os.name == "ce":
# 'ce' doesn't have the stdcall calling convention
_FUNCFLAG_STDCALL = _FUNCFLAG_CDECL
@@ -140,7 +136,7 @@
class c_ulong(_SimpleCData):
_type_ = "L"
-
+
if _calcsize("i") == _calcsize("l"):
# if int and long have the same size, make c_int an alias for c_long
c_int = c_long
@@ -154,7 +150,7 @@
class c_float(_SimpleCData):
_type_ = "f"
-
+
class c_double(_SimpleCData):
_type_ = "d"
@@ -312,10 +308,11 @@
raise AttributeError, name
return self.__getitem__(name)
- def __getitem__(self, name):
- func = self._FuncPtr(name, self)
- func.__name__ = name
- setattr(self, name, func)
+ 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
class PyDLL(CDLL):
@@ -328,7 +325,7 @@
_restype_ = c_int # default, can be overridden in instances
if _os.name in ("nt", "ce"):
-
+
class WinDLL(CDLL):
"""This class represents a dll exporting functions using the
Windows stdcall calling convention.
@@ -352,7 +349,7 @@
# doesn't have a way to raise an exception in the caller's
# frame).
_check_retval_ = _check_HRESULT
-
+
class OleDLL(CDLL):
"""This class represents a dll exporting functions using the
Windows stdcall calling convention, and returning HRESULT.
@@ -360,12 +357,25 @@
exceptions.
"""
class _FuncPtr(_CFuncPtr):
- # It would be possible to remove the _FUNCFLAG_HRESULT
- # code, and use HRESULT as _restype_. But
- # _FUNCFLAG_HRESULT is used in other places in the C code
- # as well, so we leave it as it is.
- _flags_ = _FUNCFLAG_STDCALL | _FUNCFLAG_HRESULT
- _restype_ = c_int # needed, but unused (see _FUNCFLAG_HRESULT flag)
+ _flags_ = _FUNCFLAG_STDCALL
+ _restype_ = HRESULT
+
+class LibraryLoader(object):
+ def __init__(self, dlltype):
+ self._dlltype = dlltype
+
+ def __getattr__(self, name):
+ if name[0] == '_':
+ raise AttributeError(name)
+ dll = self._dlltype(name)
+ setattr(self, name, dll)
+ return dll
+
+ def __getitem__(self, name):
+ return getattr(self, name)
+
+ def LoadLibrary(self, name):
+ return self._dlltype(name)
cdll = LibraryLoader(CDLL)
pydll = LibraryLoader(PyDLL)
@@ -396,20 +406,33 @@
_pointer_type_cache[None] = c_void_p
-# functions
-
-from _ctypes import _memmove_addr, _memset_addr, _string_at_addr, cast
-
if sizeof(c_uint) == sizeof(c_void_p):
c_size_t = c_uint
elif sizeof(c_ulong) == sizeof(c_void_p):
c_size_t = c_ulong
+# functions
+
+from _ctypes import _memmove_addr, _memset_addr, _string_at_addr, _cast_addr
+
## void *memmove(void *, const void *, size_t);
memmove = CFUNCTYPE(c_void_p, c_void_p, c_void_p, c_size_t)(_memmove_addr)
## void *memset(void *, int, size_t)
memset = CFUNCTYPE(c_void_p, c_void_p, c_int, c_size_t)(_memset_addr)
+
+def PYFUNCTYPE(restype, *argtypes):
+ class CFunctionType(_CFuncPtr):
+ _argtypes_ = argtypes
+ _restype_ = restype
+ _flags_ = _FUNCFLAG_CDECL | _FUNCFLAG_PYTHONAPI
+ return CFunctionType
+_cast = PYFUNCTYPE(py_object, c_void_p, py_object)(_cast_addr)
+
+def cast(obj, typ):
+ result = _cast(obj, typ)
+ result.__keepref = obj
+ return result
_string_at = CFUNCTYPE(py_object, c_void_p, c_int)(_string_at_addr)
def string_at(ptr, size=0):
@@ -429,11 +452,7 @@
Return the string at addr."""
return _wstring_at(ptr, size)
-
-
-from decorators import cdecl
-if _os.name == "nt":
- from decorators import stdcall
+
if _os.name == "nt": # COM stuff
def DllGetClassObject(rclsid, riid, ppv):
@@ -483,3 +502,16 @@
return result
from ctypes._endian import BigEndianStructure, LittleEndianStructure
+
+# Fill in specifically-sized types
+c_int8 = c_byte
+c_uint8 = c_ubyte
+for kind in [c_short, c_int, c_long, c_longlong]:
+ if sizeof(kind) == 2: c_int16 = kind
+ elif sizeof(kind) == 4: c_int32 = kind
+ elif sizeof(kind) == 8: c_int64 = kind
+for kind in [c_ushort, c_uint, c_ulong, c_ulonglong]:
+ if sizeof(kind) == 2: c_uint16 = kind
+ elif sizeof(kind) == 4: c_uint32 = kind
+ elif sizeof(kind) == 8: c_uint64 = kind
+del(kind)
Modified: packages/ctypes/branches/upstream/current/ctypes/_endian.py
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/ctypes/_endian.py?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/ctypes/_endian.py (original)
+++ packages/ctypes/branches/upstream/current/ctypes/_endian.py Mon Jun 19 12:31:53 2006
@@ -55,4 +55,3 @@
else:
raise RuntimeError("Invalid byteorder")
-
Modified: packages/ctypes/branches/upstream/current/ctypes/test/__init__.py
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/ctypes/test/__init__.py?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/ctypes/test/__init__.py (original)
+++ packages/ctypes/branches/upstream/current/ctypes/test/__init__.py Mon Jun 19 12:31:53 2006
@@ -83,7 +83,7 @@
ptc = ctypes._pointer_type_cache.copy()
cfc = ctypes._c_functype_cache.copy()
wfc = ctypes._win_functype_cache.copy()
-
+
# when searching for refcount leaks, we have to manually reset any
# caches that ctypes has.
def cleanup():
Added: packages/ctypes/branches/upstream/current/ctypes/test/test_array_in_pointer.py
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/ctypes/test/test_array_in_pointer.py?rev=940&op=file
==============================================================================
--- packages/ctypes/branches/upstream/current/ctypes/test/test_array_in_pointer.py (added)
+++ packages/ctypes/branches/upstream/current/ctypes/test/test_array_in_pointer.py Mon Jun 19 12:31:53 2006
@@ -1,0 +1,64 @@
+import unittest
+from ctypes import *
+from binascii import hexlify
+import re
+
+def dump(obj):
+ # helper function to dump memory contents in hex, with a hyphen
+ # between the bytes.
+ h = hexlify(buffer(obj))
+ return re.sub(r"(..)", r"\1-", h)[:-1]
+
+
+class Value(Structure):
+ _fields_ = [("val", c_byte)]
+
+class Container(Structure):
+ _fields_ = [("pvalues", POINTER(Value))]
+
+class Test(unittest.TestCase):
+ def test(self):
+ # create an array of 4 values
+ val_array = (Value * 4)()
+
+ # create a container, which holds a pointer to the pvalues array.
+ c = Container()
+ c.pvalues = val_array
+
+ # memory contains 4 NUL bytes now, that's correct
+ self.failUnlessEqual("00-00-00-00", dump(val_array))
+
+ # set the values of the array through the pointer:
+ for i in range(4):
+ c.pvalues[i].val = i + 1
+
+ values = [c.pvalues[i].val for i in range(4)]
+
+ # These are the expected results: here s the bug!
+ self.failUnlessEqual(
+ (values, dump(val_array)),
+ ([1, 2, 3, 4], "01-02-03-04")
+ )
+
+ def test_2(self):
+
+ val_array = (Value * 4)()
+
+ # memory contains 4 NUL bytes now, that's correct
+ self.failUnlessEqual("00-00-00-00", dump(val_array))
+
+ ptr = cast(val_array, POINTER(Value))
+ # set the values of the array through the pointer:
+ for i in range(4):
+ ptr[i].val = i + 1
+
+ values = [ptr[i].val for i in range(4)]
+
+ # These are the expected results: here s the bug!
+ self.failUnlessEqual(
+ (values, dump(val_array)),
+ ([1, 2, 3, 4], "01-02-03-04")
+ )
+
+if __name__ == "__main__":
+ unittest.main()
Modified: packages/ctypes/branches/upstream/current/ctypes/test/test_bitfields.py
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/ctypes/test/test_bitfields.py?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/ctypes/test/test_bitfields.py (original)
+++ packages/ctypes/branches/upstream/current/ctypes/test/test_bitfields.py Mon Jun 19 12:31:53 2006
@@ -15,7 +15,7 @@
("G", c_int, 7),
("H", c_int, 8),
("I", c_int, 9),
-
+
("M", c_short, 1),
("N", c_short, 2),
("O", c_short, 3),
@@ -24,7 +24,7 @@
("R", c_short, 6),
("S", c_short, 7)]
-func = cdll.load(_ctypes_test.__file__).unpack_bitfields
+func = CDLL(_ctypes_test.__file__).unpack_bitfields
func.argtypes = POINTER(BITS), c_char
##for n in "ABCDEFGHIMNOPQRS":
@@ -62,7 +62,7 @@
x = X()
x.a, x.b, x.c = -1, 7, -1
self.failUnlessEqual((x.a, x.b, x.c), (-1, 7, -1))
-
+
def test_ulonglong(self):
class X(Structure):
_fields_ = [("a", c_ulonglong, 1),
@@ -79,7 +79,7 @@
for c_typ in signed_int_types:
class X(Structure):
_fields_ = [("dummy", c_typ),
- ("a", c_typ, 3),
+ ("a", c_typ, 3),
("b", c_typ, 3),
("c", c_typ, 1)]
self.failUnlessEqual(sizeof(X), sizeof(c_typ)*2)
Modified: packages/ctypes/branches/upstream/current/ctypes/test/test_buffers.py
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/ctypes/test/test_buffers.py?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/ctypes/test/test_buffers.py (original)
+++ packages/ctypes/branches/upstream/current/ctypes/test/test_buffers.py Mon Jun 19 12:31:53 2006
@@ -8,14 +8,14 @@
self.failUnlessEqual(len(b), 32)
self.failUnlessEqual(sizeof(b), 32 * sizeof(c_char))
self.failUnless(type(b[0]) is str)
-
+
b = create_string_buffer("abc")
self.failUnlessEqual(len(b), 4) # trailing nul char
self.failUnlessEqual(sizeof(b), 4 * sizeof(c_char))
self.failUnless(type(b[0]) is str)
self.failUnlessEqual(b[0], "a")
self.failUnlessEqual(b[:], "abc\0")
-
+
def test_string_conversion(self):
b = create_string_buffer(u"abc")
self.failUnlessEqual(len(b), 4) # trailing nul char
Modified: packages/ctypes/branches/upstream/current/ctypes/test/test_byteswap.py
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/ctypes/test/test_byteswap.py?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/ctypes/test/test_byteswap.py (original)
+++ packages/ctypes/branches/upstream/current/ctypes/test/test_byteswap.py Mon Jun 19 12:31:53 2006
@@ -11,11 +11,11 @@
# byte order, and a __ctype_le__ attribute that is the same type in
# LITTLE ENDIAN byte order.
#
-# For Structures and Unions, these types are created on demand.
+# For Structures and Unions, these types are created on demand.
class Test(unittest.TestCase):
def X_test(self):
- print sys.byteorder
+ print >> sys.stderr, sys.byteorder
for i in range(32):
bits = BITS()
setattr(bits, "i%s" % i, 1)
@@ -149,7 +149,7 @@
self.failUnless(c_char.__ctype_le__ is c_char)
self.failUnless(c_char.__ctype_be__ is c_char)
- def test_struct_fields(self):
+ def test_struct_fields_1(self):
if sys.byteorder == "little":
base = BigEndianStructure
else:
@@ -198,16 +198,20 @@
pass
self.assertRaises(TypeError, setattr, S, "_fields_", [("s", T)])
- def test_struct_fields(self):
- if sys.byteorder == "little":
- base = BigEndianStructure
- fmt = ">bhid"
- else:
- base = LittleEndianStructure
- fmt = "<bhid"
+ def test_struct_fields_2(self):
+ # standard packing in struct uses no alignment.
+ # So, we have to align using pad bytes.
+ #
+ # Unaligned accesses will crash Python (on those platforms that
+ # don't allow it, like sparc solaris).
+ if sys.byteorder == "little":
+ base = BigEndianStructure
+ fmt = ">bxhid"
+ else:
+ base = LittleEndianStructure
+ fmt = "<bxhid"
class S(base):
- _pack_ = 1 # struct with '<' or '>' uses standard alignment.
_fields_ = [("b", c_byte),
("h", c_short),
("i", c_int),
@@ -217,5 +221,60 @@
s2 = struct.pack(fmt, 0x12, 0x1234, 0x12345678, 3.14)
self.failUnlessEqual(bin(s1), bin(s2))
+ def test_unaligned_nonnative_struct_fields(self):
+ if sys.byteorder == "little":
+ base = BigEndianStructure
+ fmt = ">b h xi xd"
+ else:
+ base = LittleEndianStructure
+ fmt = "<b h xi xd"
+
+ class S(base):
+ _pack_ = 1
+ _fields_ = [("b", c_byte),
+
+ ("h", c_short),
+
+ ("_1", c_byte),
+ ("i", c_int),
+
+ ("_2", c_byte),
+ ("d", c_double)]
+
+ s1 = S()
+ s1.b = 0x12
+ s1.h = 0x1234
+ s1.i = 0x12345678
+ s1.d = 3.14
+ s2 = struct.pack(fmt, 0x12, 0x1234, 0x12345678, 3.14)
+ self.failUnlessEqual(bin(s1), bin(s2))
+
+ def test_unaligned_native_struct_fields(self):
+ if sys.byteorder == "little":
+ fmt = "<b h xi xd"
+ else:
+ base = LittleEndianStructure
+ fmt = ">b h xi xd"
+
+ class S(Structure):
+ _pack_ = 1
+ _fields_ = [("b", c_byte),
+
+ ("h", c_short),
+
+ ("_1", c_byte),
+ ("i", c_int),
+
+ ("_2", c_byte),
+ ("d", c_double)]
+
+ s1 = S()
+ s1.b = 0x12
+ s1.h = 0x1234
+ s1.i = 0x12345678
+ s1.d = 3.14
+ s2 = struct.pack(fmt, 0x12, 0x1234, 0x12345678, 3.14)
+ self.failUnlessEqual(bin(s1), bin(s2))
+
if __name__ == "__main__":
unittest.main()
Modified: packages/ctypes/branches/upstream/current/ctypes/test/test_callbacks.py
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/ctypes/test/test_callbacks.py?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/ctypes/test/test_callbacks.py (original)
+++ packages/ctypes/branches/upstream/current/ctypes/test/test_callbacks.py Mon Jun 19 12:31:53 2006
@@ -3,7 +3,7 @@
import _ctypes_test
class Callbacks(unittest.TestCase):
- functype = CFUNCTYPE
+ functype = CFUNCTYPE
## def tearDown(self):
## import gc
@@ -29,21 +29,6 @@
else:
self.failUnlessEqual(self.got_args, (-3, arg))
self.failUnlessEqual(result, arg)
-
- if not hasattr(unittest.TestCase, "failUnlessAlmostEqual"):
- # This method is not present in Python 2.2
- # Copied from Python 2.3
- def failUnlessAlmostEqual(self, first, second, places=7, msg=None):
- """Fail if the two objects are unequal as determined by their
- difference rounded to the given number of decimal places
- (default 7) and comparing to zero.
-
- Note that decimal places (from zero) is usually not the same
- as significant digits (measured from the most signficant digit).
- """
- if round(second-first, places) != 0:
- raise self.failureException, \
- (msg or '%s != %s within %s places' % (`first`, `second`, `places` ))
################
@@ -96,9 +81,25 @@
self.check_type(c_char, "x")
self.check_type(c_char, "a")
- def test_char_p(self):
- self.check_type(c_char_p, "abc")
- self.check_type(c_char_p, "def")
+ # disabled: would now (correctly) raise a RuntimeWarning about
+ # a memory leak. A callback function cannot return a non-integral
+ # C type without causing a memory leak.
+## def test_char_p(self):
+## self.check_type(c_char_p, "abc")
+## self.check_type(c_char_p, "def")
+
+ def test_pyobject(self):
+ o = ()
+ from sys import getrefcount as grc
+ for o in (), [], object():
+ initial = grc(o)
+ # This call leaks a reference to 'o'...
+ self.check_type(py_object, o)
+ before = grc(o)
+ # ...but this call doesn't leak any more. Where is the refcount?
+ self.check_type(py_object, o)
+ after = grc(o)
+ self.failUnlessEqual((after, o), (before, o))
try:
WINFUNCTYPE
@@ -114,7 +115,7 @@
def test_integrate(self):
# Derived from some then non-working code, posted by David Foster
- dll = cdll.load(_ctypes_test.__file__)
+ dll = CDLL(_ctypes_test.__file__)
# The function prototype called by 'integrate': double func(double);
CALLBACK = CFUNCTYPE(c_double, c_double)
@@ -129,7 +130,7 @@
result = integrate(0.0, 1.0, CALLBACK(func), 10)
diff = abs(result - 1./3.)
-
+
self.failUnless(diff < 0.01, "%s not less than 0.01" % diff)
################################################################
Modified: packages/ctypes/branches/upstream/current/ctypes/test/test_cast.py
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/ctypes/test/test_cast.py?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/ctypes/test/test_cast.py (original)
+++ packages/ctypes/branches/upstream/current/ctypes/test/test_cast.py Mon Jun 19 12:31:53 2006
@@ -23,33 +23,24 @@
def test_address2pointer(self):
array = (c_int * 3)(42, 17, 2)
- # on AMD64, sizeof(int) == 4 and sizeof(void *) == 8.
- # By default, cast would convert a Python int (or long) into
- # a C int, which would be too short to represent a pointer
- # on this platform.
-
- # So we have to wrap the address into a c_void_p for this to work.
- #
- # XXX Better would be to hide the differences in the cast function.
address = addressof(array)
ptr = cast(c_void_p(address), POINTER(c_int))
+ self.failUnlessEqual([ptr[i] for i in range(3)], [42, 17, 2])
+
+ ptr = cast(address, POINTER(c_int))
self.failUnlessEqual([ptr[i] for i in range(3)], [42, 17, 2])
def test_ptr2array(self):
array = (c_int * 3)(42, 17, 2)
-## # Hm, already tested above.
-## ptr = cast(array, POINTER(c_int))
-## self.failUnlessEqual([ptr[i] for i in range(3)], [42, 17, 2])
+ from sys import getrefcount
-# print cast(addressof(array), c_int * 3)[:]
-## ptr = cast(addressof(ptr)
-
-## print ptr[0], ptr[1], ptr[2]
-## ptr = POINTER(c_int).from_address(addressof(array))
-## # XXX this crashes:
-## print ptr[0], ptr[1], ptr[2]
+ before = getrefcount(array)
+ ptr = cast(array, POINTER(c_int))
+ self.failUnlessEqual(getrefcount(array), before + 1)
+ del ptr
+ self.failUnlessEqual(getrefcount(array), before)
if __name__ == "__main__":
unittest.main()
Modified: packages/ctypes/branches/upstream/current/ctypes/test/test_cfuncs.py
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/ctypes/test/test_cfuncs.py?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/ctypes/test/test_cfuncs.py (original)
+++ packages/ctypes/branches/upstream/current/ctypes/test/test_cfuncs.py Mon Jun 19 12:31:53 2006
@@ -7,7 +7,7 @@
import _ctypes_test
class CFunctions(unittest.TestCase):
- _dll = cdll.load(_ctypes_test.__file__)
+ _dll = CDLL(_ctypes_test.__file__)
def S(self):
return c_longlong.in_dll(self._dll, "last_tf_arg_s").value
@@ -179,7 +179,7 @@
def __getattr__(self, name):
if name[:2] == '__' and name[-2:] == '__':
raise AttributeError, name
- func = self._FuncPtr("s_" + name, self)
+ func = self._FuncPtr(("s_" + name, self))
setattr(self, name, func)
return func
Modified: packages/ctypes/branches/upstream/current/ctypes/test/test_checkretval.py
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/ctypes/test/test_checkretval.py?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/ctypes/test/test_checkretval.py (original)
+++ packages/ctypes/branches/upstream/current/ctypes/test/test_checkretval.py Mon Jun 19 12:31:53 2006
@@ -3,18 +3,18 @@
from ctypes import *
+class CHECKED(c_int):
+ def _check_retval_(value):
+ # Receives a CHECKED instance.
+ return str(value.value)
+ _check_retval_ = staticmethod(_check_retval_)
+
class Test(unittest.TestCase):
def test_checkretval(self):
- class CHECKED(c_int):
- def _check_retval_(value):
- # Receives a CHECKED instance.
- return str(value.value)
- _check_retval_ = staticmethod(_check_retval_)
-
import _ctypes_test
- dll = cdll.load(_ctypes_test.__file__)
+ dll = CDLL(_ctypes_test.__file__)
self.failUnlessEqual(42, dll._testfunc_p_p(42))
dll._testfunc_p_p.restype = CHECKED
Added: packages/ctypes/branches/upstream/current/ctypes/test/test_find.py
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/ctypes/test/test_find.py?rev=940&op=file
==============================================================================
--- packages/ctypes/branches/upstream/current/ctypes/test/test_find.py (added)
+++ packages/ctypes/branches/upstream/current/ctypes/test/test_find.py Mon Jun 19 12:31:53 2006
@@ -1,0 +1,90 @@
+import unittest
+import os, sys
+from ctypes import *
+from ctypes.util import find_library
+from ctypes.test import is_resource_enabled
+
+if sys.platform == "win32":
+ lib_gl = find_library("OpenGL32")
+ lib_glu = find_library("Glu32")
+ lib_glut = find_library("glut32")
+ lib_gle = None
+elif sys.platform == "darwin":
+ lib_gl = lib_glu = find_library("OpenGL")
+ lib_glut = find_library("GLUT")
+ lib_gle = None
+else:
+ lib_gl = find_library("GL")
+ lib_glu = find_library("GLU")
+ lib_glut = find_library("glut")
+ lib_gle = find_library("gle")
+
+## print, for debugging
+if is_resource_enabled("printing"):
+ if lib_gl or lib_glu or lib_glut or lib_gle:
+ print "OpenGL libraries:"
+ for item in (("GL", lib_gl),
+ ("GLU", lib_glu),
+ ("glut", lib_glut),
+ ("gle", lib_gle)):
+ print "\t", item
+
+
+# On some systems, loading the OpenGL libraries needs the RTLD_GLOBAL mode.
+class Test_OpenGL_libs(unittest.TestCase):
+ def setUp(self):
+ self.gl = self.glu = self.gle = self.glut = None
+ if lib_gl:
+ self.gl = CDLL(lib_gl, mode=RTLD_GLOBAL)
+ if lib_glu:
+ self.glu = CDLL(lib_glu, RTLD_GLOBAL)
+ if lib_glut:
+ self.glut = CDLL(lib_glut)
+ if lib_gle:
+ self.gle = CDLL(lib_gle)
+
+ if lib_gl:
+ def test_gl(self):
+ if self.gl:
+ self.gl.glClearIndex
+
+ if lib_glu:
+ def test_glu(self):
+ if self.glu:
+ self.glu.gluBeginCurve
+
+ if lib_glut:
+ def test_glut(self):
+ if self.glut:
+ self.glut.glutWireTetrahedron
+
+ if lib_gle:
+ def test_gle(self):
+ if self.gle:
+ self.gle.gleGetJoinStyle
+
+##if os.name == "posix" and sys.platform != "darwin":
+
+## # On platforms where the default shared library suffix is '.so',
+## # at least some libraries can be loaded as attributes of the cdll
+## # object, since ctypes now tries loading the lib again
+## # with '.so' appended of the first try fails.
+## #
+## # Won't work for libc, unfortunately. OTOH, it isn't
+## # needed for libc since this is already mapped into the current
+## # process (?)
+## #
+## # On MAC OSX, it won't work either, because dlopen() needs a full path,
+## # and the default suffix is either none or '.dylib'.
+
+## class LoadLibs(unittest.TestCase):
+## def test_libm(self):
+## import math
+## libm = cdll.libm
+## sqrt = libm.sqrt
+## sqrt.argtypes = (c_double,)
+## sqrt.restype = c_double
+## self.failUnlessEqual(sqrt(2), math.sqrt(2))
+
+if __name__ == "__main__":
+ unittest.main()
Modified: packages/ctypes/branches/upstream/current/ctypes/test/test_funcptr.py
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/ctypes/test/test_funcptr.py?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/ctypes/test/test_funcptr.py (original)
+++ packages/ctypes/branches/upstream/current/ctypes/test/test_funcptr.py Mon Jun 19 12:31:53 2006
@@ -8,7 +8,7 @@
WINFUNCTYPE = CFUNCTYPE
import _ctypes_test
-lib = cdll.load(_ctypes_test.__file__)
+lib = CDLL(_ctypes_test.__file__)
class CFuncPtrTestCase(unittest.TestCase):
def test_basic(self):
@@ -122,6 +122,6 @@
self.failUnlessEqual(strtok(None, "\n"), "b")
self.failUnlessEqual(strtok(None, "\n"), "c")
self.failUnlessEqual(strtok(None, "\n"), None)
-
+
if __name__ == '__main__':
unittest.main()
Modified: packages/ctypes/branches/upstream/current/ctypes/test/test_functions.py
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/ctypes/test/test_functions.py?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/ctypes/test/test_functions.py (original)
+++ packages/ctypes/branches/upstream/current/ctypes/test/test_functions.py Mon Jun 19 12:31:53 2006
@@ -15,9 +15,12 @@
WINFUNCTYPE = CFUNCTYPE
import _ctypes_test
-dll = cdll.load(_ctypes_test.__file__)
+dll = CDLL(_ctypes_test.__file__)
if sys.platform == "win32":
- windll = windll.load(_ctypes_test.__file__)
+ windll = WinDLL(_ctypes_test.__file__)
+
+class POINT(Structure):
+ _fields_ = [("x", c_int), ("y", c_int)]
class FunctionTestCase(unittest.TestCase):
@@ -28,14 +31,14 @@
# But in early versions of _ctypes.c, the result of tp_new
# wasn't checked, and it even crashed Python.
# Found by Greg Chapman.
-
+
try:
class X(object, Array):
_length_ = 5
_type_ = "i"
except TypeError:
pass
-
+
from _ctypes import _Pointer
try:
@@ -91,6 +94,7 @@
def test_intresult(self):
f = dll._testfunc_i_bhilfd
f.argtypes = [c_byte, c_short, c_int, c_long, c_float, c_double]
+ f.restype = c_int
result = f(1, 2, 3, 4, 5.0, 6.0)
self.failUnlessEqual(result, 21)
self.failUnlessEqual(type(result), int)
@@ -105,7 +109,7 @@
result = f(1, 2, 3, 4, 5.0, 6.0)
self.failUnlessEqual(result, 21)
self.failUnlessEqual(type(result), int)
-
+
result = f(1, 2, 3, 0x10004, 5.0, 6.0)
self.failUnlessEqual(result, 21)
self.failUnlessEqual(type(result), int)
@@ -124,7 +128,7 @@
result = f(-1, -2, -3, -4, -5.0, -6.0)
self.failUnlessEqual(result, -21)
self.failUnlessEqual(type(result), float)
-
+
def test_doubleresult(self):
f = dll._testfunc_d_bhilfd
f.argtypes = [c_byte, c_short, c_int, c_long, c_float, c_double]
@@ -136,7 +140,7 @@
result = f(-1, -2, -3, -4, -5.0, -6.0)
self.failUnlessEqual(result, -21)
self.failUnlessEqual(type(result), float)
-
+
def test_longlongresult(self):
try:
c_longlong
@@ -226,7 +230,7 @@
self.failUnlessEqual(args, expected)
################################################################
-
+
def test_callbacks(self):
f = dll._testfunc_callback_i_if
@@ -237,7 +241,7 @@
def callback(value):
#print "called back with", value
return value
-
+
cb = MyCallback(callback)
result = f(-10, cb)
self.failUnlessEqual(result, -18)
@@ -247,7 +251,7 @@
cb = MyCallback(callback)
result = f(-10, cb)
self.failUnlessEqual(result, -18)
-
+
AnotherCallback = WINFUNCTYPE(c_int, c_int, c_int, c_int, c_int)
# check that the prototype works: we call f with wrong
@@ -271,7 +275,7 @@
#print "called back with", value
self.failUnlessEqual(type(value), int)
return value
-
+
cb = MyCallback(callback)
result = f(-10, cb)
self.failUnlessEqual(result, -18)
@@ -298,9 +302,6 @@
self.assertRaises(ValueError, c_int.in_dll, dll, "_xxx_yyy")
def test_byval(self):
-
- class POINT(Structure):
- _fields_ = [("x", c_int), ("y", c_int)]
# without prototype
ptin = POINT(1, 2)
Modified: packages/ctypes/branches/upstream/current/ctypes/test/test_keeprefs.py
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/ctypes/test/test_keeprefs.py?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/ctypes/test/test_keeprefs.py (original)
+++ packages/ctypes/branches/upstream/current/ctypes/test/test_keeprefs.py Mon Jun 19 12:31:53 2006
@@ -130,7 +130,7 @@
("b", POINTER(POINT))]
r = RECT()
p1 = POINT(1, 2)
-
+
r.a = pointer(p1)
r.b = pointer(p1)
## from pprint import pprint as pp
@@ -140,5 +140,10 @@
r.a[0].x = 42
r.a[0].y = 99
+ # to avoid leaking when tests are run several times
+ # clean up the types left in the cache.
+ from ctypes import _pointer_type_cache
+ del _pointer_type_cache[POINT]
+
if __name__ == "__main__":
unittest.main()
Modified: packages/ctypes/branches/upstream/current/ctypes/test/test_libc.py
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/ctypes/test/test_libc.py?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/ctypes/test/test_libc.py (original)
+++ packages/ctypes/branches/upstream/current/ctypes/test/test_libc.py Mon Jun 19 12:31:53 2006
@@ -4,7 +4,7 @@
from ctypes import *
import _ctypes_test
-lib = cdll.load(_ctypes_test.__file__)
+lib = CDLL(_ctypes_test.__file__)
class LibTest(unittest.TestCase):
def test_sqrt(self):
Modified: packages/ctypes/branches/upstream/current/ctypes/test/test_loading.py
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/ctypes/test/test_loading.py?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/ctypes/test/test_loading.py (original)
+++ packages/ctypes/branches/upstream/current/ctypes/test/test_loading.py Mon Jun 19 12:31:53 2006
@@ -1,41 +1,84 @@
from ctypes import *
import sys, unittest
import os, StringIO
+from ctypes.util import find_library
+from ctypes.test import is_resource_enabled
+
+libc_name = None
+if os.name == "nt":
+ libc_name = "msvcrt"
+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"):
+ print "libc_name is", libc_name
class LoaderTest(unittest.TestCase):
unknowndll = "xxrandomnamexx"
- def test_load(self):
- if os.name == "nt":
- name = "msvcrt"
- elif os.name == "ce":
- name = "coredll"
- elif sys.platform == "darwin":
- name = "libc.dylib"
- elif sys.platform.startswith("freebsd"):
- name = "libc.so"
- elif sys.platform == "sunos5":
- name = "libc.so"
- else:
- name = "libc.so.6"
- cdll.load(name)
- self.assertRaises(OSError, cdll.load, self.unknowndll)
+ if libc_name is not None:
+ def test_load(self):
+ CDLL(libc_name)
+ CDLL(os.path.basename(libc_name))
+ self.assertRaises(OSError, CDLL, self.unknowndll)
- def test_load_version(self):
- version = "6"
- name = "c"
- if sys.platform == "linux2":
- cdll.load_version(name, version)
+ if libc_name is not None and os.path.basename(libc_name) == "libc.so.6":
+ def test_load_version(self):
+ cdll.LoadLibrary("libc.so.6")
# linux uses version, libc 9 should not exist
- self.assertRaises(OSError, cdll.load_version, name, "9")
- self.assertRaises(OSError, cdll.load_version, self.unknowndll, "")
+ self.assertRaises(OSError, cdll.LoadLibrary, "libc.so.9")
+ self.assertRaises(OSError, cdll.LoadLibrary, self.unknowndll)
- if os.name == "posix" and sys.platform != "sunos5":
- def test_find(self):
- name = "c"
- cdll.find(name)
- self.assertRaises(OSError, cdll.find, self.unknowndll)
+ def test_find(self):
+ for name in ("c", "m"):
+ lib = find_library(name)
+ if lib:
+ cdll.LoadLibrary(lib)
+ CDLL(lib)
+
+ if os.name in ("nt", "ce"):
+ def test_load_library(self):
+ print find_library("kernel32")
+ print find_library("user32")
+
+ if os.name == "nt":
+ windll.kernel32.GetModuleHandleW
+ windll["kernel32"].GetModuleHandleW
+ windll.LoadLibrary("kernel32").GetModuleHandleW
+ WinDLL("kernel32").GetModuleHandleW
+ elif os.name == "ce":
+ windll.coredll.GetModuleHandleW
+ windll["coredll"].GetModuleHandleW
+ windll.LoadLibrary("coredll").GetModuleHandleW
+ WinDLL("coredll").GetModuleHandleW
+
+ def test_load_ordinal_functions(self):
+ import _ctypes_test
+ dll = WinDLL(_ctypes_test.__file__)
+ # We load the same function both via ordinal and name
+ func_ord = dll[2]
+ 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))
+
+ self.failUnlessRaises(AttributeError, dll.__getitem__, 1234)
if __name__ == "__main__":
unittest.main()
Modified: packages/ctypes/branches/upstream/current/ctypes/test/test_macholib.py
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/ctypes/test/test_macholib.py?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/ctypes/test/test_macholib.py (original)
+++ packages/ctypes/branches/upstream/current/ctypes/test/test_macholib.py Mon Jun 19 12:31:53 2006
@@ -36,13 +36,13 @@
from ctypes.macholib.dyld import dyld_find
def find_lib(name):
- possible = ['lib'+name+'.dylib', name+'.dylib', name+'.framework/'+name]
- for dylib in possible:
- try:
- return os.path.realpath(dyld_find(dylib))
- except ValueError:
- pass
- raise ValueError, "%s not found" % (name,)
+ possible = ['lib'+name+'.dylib', name+'.dylib', name+'.framework/'+name]
+ for dylib in possible:
+ try:
+ return os.path.realpath(dyld_find(dylib))
+ except ValueError:
+ pass
+ raise ValueError, "%s not found" % (name,)
class MachOTest(unittest.TestCase):
if sys.platform == "darwin":
Modified: packages/ctypes/branches/upstream/current/ctypes/test/test_numbers.py
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/ctypes/test/test_numbers.py?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/ctypes/test/test_numbers.py (original)
+++ packages/ctypes/branches/upstream/current/ctypes/test/test_numbers.py Mon Jun 19 12:31:53 2006
@@ -34,14 +34,14 @@
else:
unsigned_types.append(c_ulonglong)
signed_types.append(c_longlong)
-
+
unsigned_ranges = valid_ranges(*unsigned_types)
signed_ranges = valid_ranges(*signed_types)
################################################################
class NumberTestCase(unittest.TestCase):
-
+
def test_default_init(self):
# default values are set to zero
for t in signed_types + unsigned_types + float_types:
@@ -132,7 +132,7 @@
# and alignment of an instance
self.failUnlessEqual((code, alignment(t())),
(code, align))
-
+
def test_int_from_address(self):
from array import array
for t in signed_types + unsigned_types:
@@ -152,7 +152,7 @@
# changing the value at the memory location changes v's value also
a[0] = 42
self.failUnlessEqual(v.value, a[0])
-
+
def test_float_from_address(self):
from array import array
@@ -168,7 +168,7 @@
def test_char_from_address(self):
from ctypes import c_char
from array import array
-
+
a = array('c', 'x')
v = c_char.from_address(a.buffer_info()[0])
self.failUnlessEqual(v.value, a[0])
@@ -185,7 +185,7 @@
## def test_perf(self):
## check_perf()
-
+
from ctypes import _SimpleCData
class c_int_S(_SimpleCData):
_type_ = "i"
@@ -227,7 +227,7 @@
# c_int(): 3.35 us
# c_int(999): 3.34 us
# c_int_S(): 3.23 us
-# c_int_S(999): 3.24 us
+# c_int_S(999): 3.24 us
# Python 2.2 -OO, win2k, P4 700 MHz:
#
Modified: packages/ctypes/branches/upstream/current/ctypes/test/test_parameters.py
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/ctypes/test/test_parameters.py?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/ctypes/test/test_parameters.py (original)
+++ packages/ctypes/branches/upstream/current/ctypes/test/test_parameters.py Mon Jun 19 12:31:53 2006
@@ -18,7 +18,7 @@
pass
else:
set_conversion_mode(*self.prev_conv_mode)
-
+
def test_subclasses(self):
from ctypes import c_void_p, c_char_p
Modified: packages/ctypes/branches/upstream/current/ctypes/test/test_pointers.py
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/ctypes/test/test_pointers.py?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/ctypes/test/test_pointers.py (original)
+++ packages/ctypes/branches/upstream/current/ctypes/test/test_pointers.py Mon Jun 19 12:31:53 2006
@@ -11,7 +11,7 @@
class PointersTestCase(unittest.TestCase):
def test_pointer_crash(self):
-
+
class A(POINTER(c_ulong)):
pass
@@ -20,7 +20,7 @@
self.failUnlessRaises(TypeError, A, c_ulong(33))
def test_pass_pointers(self):
- dll = cdll.load(_ctypes_test.__file__)
+ dll = CDLL(_ctypes_test.__file__)
func = dll._testfunc_p_p
func.restype = c_long
@@ -35,7 +35,7 @@
self.failUnlessEqual(res[0], 12345678)
def test_change_pointers(self):
- dll = cdll.load(_ctypes_test.__file__)
+ dll = CDLL(_ctypes_test.__file__)
func = dll._testfunc_p_p
i = c_int(87654)
@@ -70,7 +70,7 @@
return 0
callback = PROTOTYPE(func)
- dll = cdll.load(_ctypes_test.__file__)
+ dll = CDLL(_ctypes_test.__file__)
# This function expects a function pointer,
# and calls this with an integer pointer as parameter.
# The int pointer points to a table containing the numbers 1..10
@@ -84,7 +84,7 @@
## print self.result
doit(callback)
## print self.result
-
+
def test_basics(self):
from operator import delitem
for ct, pt in zip(ctype_types, python_types):
@@ -132,7 +132,7 @@
self.assertRaises(TypeError, len, p)
self.failUnlessEqual(p[0], 42)
self.failUnlessEqual(p.contents.value, 42)
-
+
def test_incomplete(self):
lpcell = POINTER("cell")
class cell(Structure):
@@ -156,7 +156,7 @@
def test_charpp( self ):
"""Test that a character pointer-to-pointer is correctly passed"""
- dll = cdll.load(_ctypes_test.__file__)
+ dll = CDLL(_ctypes_test.__file__)
func = dll._testfunc_c_p_p
func.restype = c_char_p
argv = (c_char_p * 2)()
@@ -166,6 +166,18 @@
result = func( byref(argc), argv )
assert result == 'world', result
-
+ def test_bug_1467852(self):
+ # http://sourceforge.net/tracker/?func=detail&atid=532154&aid=1467852&group_id=71702
+ x = c_int(5)
+ dummy = []
+ for i in range(32000):
+ dummy.append(c_int(i))
+ y = c_int(6)
+ p = pointer(x)
+ pp = pointer(p)
+ q = pointer(y)
+ pp[0] = q # <==
+ self.failUnlessEqual(p[0], 6)
+
if __name__ == '__main__':
unittest.main()
Modified: packages/ctypes/branches/upstream/current/ctypes/test/test_prototypes.py
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/ctypes/test/test_prototypes.py?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/ctypes/test/test_prototypes.py (original)
+++ packages/ctypes/branches/upstream/current/ctypes/test/test_prototypes.py Mon Jun 19 12:31:53 2006
@@ -22,7 +22,20 @@
# In this case, there would have to be an additional reference to the argument...
import _ctypes_test
-testdll = cdll.load(_ctypes_test.__file__)
+testdll = CDLL(_ctypes_test.__file__)
+
+# Return machine address `a` as a (possibly long) non-negative integer.
+# Starting with Python 2.5, id(anything) is always non-negative, and
+# the ctypes addressof() inherits that via PyLong_FromVoidPtr().
+def positive_address(a):
+ if a >= 0:
+ return a
+ # View the bits in `a` as unsigned instead.
+ import struct
+ num_bits = struct.calcsize("P") * 8 # num bits in native machine address
+ a += 1L << num_bits
+ assert a >= 0
+ return a
def c_wbuffer(init):
n = len(init) + 1
@@ -43,8 +56,9 @@
ci = c_int(0)
func.argtypes = POINTER(c_int),
- self.failUnlessEqual(addressof(ci), func(byref(ci)))
-
+ self.failUnlessEqual(positive_address(addressof(ci)),
+ positive_address(func(byref(ci))))
+
func.argtypes = c_char_p,
self.assertRaises(ArgumentError, func, byref(ci))
@@ -73,7 +87,7 @@
func = testdll._testfunc_p_p
func.restype = c_char_p
func.argtypes = c_char_p,
-
+
self.failUnlessEqual(None, func(None))
self.failUnlessEqual("123", func("123"))
self.failUnlessEqual(None, func(c_char_p(None)))
Modified: packages/ctypes/branches/upstream/current/ctypes/test/test_random_things.py
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/ctypes/test/test_random_things.py?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/ctypes/test/test_random_things.py (original)
+++ packages/ctypes/branches/upstream/current/ctypes/test/test_random_things.py Mon Jun 19 12:31:53 2006
@@ -51,16 +51,14 @@
def test_IntegerDivisionError(self):
cb = CFUNCTYPE(c_int, c_int)(callback_func)
out = self.capture_stderr(cb, 0)
- self.failUnlessEqual(out.splitlines()[-1],
- "ZeroDivisionError: "
- "integer division or modulo by zero")
+ self.failUnlessEqual(out.splitlines()[-1][:19],
+ "ZeroDivisionError: ")
def test_FloatDivisionError(self):
cb = CFUNCTYPE(c_int, c_double)(callback_func)
out = self.capture_stderr(cb, 0.0)
- self.failUnlessEqual(out.splitlines()[-1],
- "ZeroDivisionError: "
- "float division")
+ self.failUnlessEqual(out.splitlines()[-1][:19],
+ "ZeroDivisionError: ")
def test_TypeErrorDivisionError(self):
cb = CFUNCTYPE(c_int, c_char_p)(callback_func)
Modified: packages/ctypes/branches/upstream/current/ctypes/test/test_refcounts.py
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/ctypes/test/test_refcounts.py?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/ctypes/test/test_refcounts.py (original)
+++ packages/ctypes/branches/upstream/current/ctypes/test/test_refcounts.py Mon Jun 19 12:31:53 2006
@@ -6,7 +6,7 @@
OtherCallback = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_int, ctypes.c_ulonglong)
import _ctypes_test
-dll = ctypes.cdll.load(_ctypes_test.__file__)
+dll = ctypes.CDLL(_ctypes_test.__file__)
class RefcountTestCase(unittest.TestCase):
@@ -48,7 +48,7 @@
# and may release it again
del f
self.failUnless(grc(func) >= 2)
-
+
# but now it must be gone
gc.collect()
self.failUnless(grc(func) == 2)
@@ -57,14 +57,14 @@
_fields_ = [("a", OtherCallback)]
x = X()
x.a = OtherCallback(func)
-
+
# the CFuncPtr instance holds atr least one refcount on func:
self.failUnless(grc(func) > 2)
# and may release it again
del x
self.failUnless(grc(func) >= 2)
-
+
# and now it must be gone again
gc.collect()
self.failUnlessEqual(grc(func), 2)
@@ -80,7 +80,7 @@
del f
gc.collect()
self.failUnlessEqual(grc(func), 2)
-
+
class AnotherLeak(unittest.TestCase):
def test_callback(self):
import sys
@@ -89,7 +89,7 @@
def func(a, b):
return a * b * 2
f = proto(func)
-
+
a = sys.getrefcount(ctypes.c_int)
f(1, 2)
self.failUnlessEqual(sys.getrefcount(ctypes.c_int), a)
Modified: packages/ctypes/branches/upstream/current/ctypes/test/test_repr.py
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/ctypes/test/test_repr.py?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/ctypes/test/test_repr.py (original)
+++ packages/ctypes/branches/upstream/current/ctypes/test/test_repr.py Mon Jun 19 12:31:53 2006
@@ -1,23 +1,28 @@
from ctypes import *
import unittest
-nums = [c_byte, c_short, c_int, c_long, c_longlong,
+subclasses = []
+for base in [c_byte, c_short, c_int, c_long, c_longlong,
c_ubyte, c_ushort, c_uint, c_ulong, c_ulonglong,
- c_float, c_double]
+ c_float, c_double]:
+ class X(base):
+ pass
+ subclasses.append(X)
+
+class X(c_char):
+ pass
+
+# This test checks if the __repr__ is correct for subclasses of simple types
class ReprTest(unittest.TestCase):
def test_numbers(self):
- for typ in nums:
- self.failUnless(repr(typ(42)).startswith(typ.__name__))
- class X(typ):
- pass
- self.failUnlessEqual("<X object at", repr(X(42))[:12])
+ for typ in subclasses:
+ base = typ.__bases__[0]
+ self.failUnless(repr(base(42)).startswith(base.__name__))
+ self.failUnlessEqual("<X object at", repr(typ(42))[:12])
def test_char(self):
self.failUnlessEqual("c_char('x')", repr(c_char('x')))
-
- class X(c_char):
- pass
self.failUnlessEqual("<X object at", repr(X('x'))[:12])
if __name__ == "__main__":
Modified: packages/ctypes/branches/upstream/current/ctypes/test/test_returnfuncptrs.py
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/ctypes/test/test_returnfuncptrs.py?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/ctypes/test/test_returnfuncptrs.py (original)
+++ packages/ctypes/branches/upstream/current/ctypes/test/test_returnfuncptrs.py Mon Jun 19 12:31:53 2006
@@ -8,7 +8,7 @@
def test_with_prototype(self):
# The _ctypes_test shared lib/dll exports quite some functions for testing.
# The get_strchr function returns a *pointer* to the C strchr function.
- dll = cdll.load(_ctypes_test.__file__)
+ dll = CDLL(_ctypes_test.__file__)
get_strchr = dll.get_strchr
get_strchr.restype = CFUNCTYPE(c_char_p, c_char_p, c_char)
strchr = get_strchr()
@@ -16,9 +16,9 @@
self.failUnlessEqual(strchr("abcdef", "x"), None)
self.assertRaises(ArgumentError, strchr, "abcdef", 3)
self.assertRaises(TypeError, strchr, "abcdef")
-
+
def test_without_prototype(self):
- dll = cdll.load(_ctypes_test.__file__)
+ dll = CDLL(_ctypes_test.__file__)
get_strchr = dll.get_strchr
# the default 'c_int' would not work on systems where sizeof(int) != sizeof(void *)
get_strchr.restype = c_void_p
Added: packages/ctypes/branches/upstream/current/ctypes/test/test_sizes.py
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/ctypes/test/test_sizes.py?rev=940&op=file
==============================================================================
--- packages/ctypes/branches/upstream/current/ctypes/test/test_sizes.py (added)
+++ packages/ctypes/branches/upstream/current/ctypes/test/test_sizes.py Mon Jun 19 12:31:53 2006
@@ -1,0 +1,27 @@
+# Test specifically-sized containers.
+
+import unittest
+from ctypes import *
+
+class SizesTestCase(unittest.TestCase):
+ def test_8(self):
+ self.failUnlessEqual(1, sizeof(c_int8))
+ self.failUnlessEqual(1, sizeof(c_uint8))
+
+ def test_16(self):
+ self.failUnlessEqual(2, sizeof(c_int16))
+ self.failUnlessEqual(2, sizeof(c_uint16))
+
+ def test_32(self):
+ self.failUnlessEqual(4, sizeof(c_int32))
+ self.failUnlessEqual(4, sizeof(c_uint32))
+
+ def test_64(self):
+ self.failUnlessEqual(8, sizeof(c_int64))
+ self.failUnlessEqual(8, sizeof(c_uint64))
+
+ def test_size_t(self):
+ self.failUnlessEqual(sizeof(c_void_p), sizeof(c_size_t))
+
+if __name__ == "__main__":
+ unittest.main()
Modified: packages/ctypes/branches/upstream/current/ctypes/test/test_slicing.py
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/ctypes/test/test_slicing.py?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/ctypes/test/test_slicing.py (original)
+++ packages/ctypes/branches/upstream/current/ctypes/test/test_slicing.py Mon Jun 19 12:31:53 2006
@@ -37,7 +37,7 @@
def test_char_ptr(self):
s = "abcdefghijklmnopqrstuvwxyz\0"
- dll = cdll.load(_ctypes_test.__file__)
+ dll = CDLL(_ctypes_test.__file__)
dll.my_strdup.restype = POINTER(c_char)
res = dll.my_strdup(s)
self.failUnlessEqual(res[:len(s)], s)
@@ -65,7 +65,7 @@
def test_wchar_ptr(self):
s = u"abcdefghijklmnopqrstuvwxyz\0"
- dll = cdll.load(_ctypes_test.__file__)
+ dll = CDLL(_ctypes_test.__file__)
dll.my_wcsdup.restype = POINTER(c_wchar)
dll.my_wcsdup.argtypes = POINTER(c_wchar),
res = dll.my_wcsdup(s)
Modified: packages/ctypes/branches/upstream/current/ctypes/test/test_stringptr.py
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/ctypes/test/test_stringptr.py?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/ctypes/test/test_stringptr.py (original)
+++ packages/ctypes/branches/upstream/current/ctypes/test/test_stringptr.py Mon Jun 19 12:31:53 2006
@@ -3,7 +3,7 @@
import _ctypes_test
-lib = cdll.load(_ctypes_test.__file__)
+lib = CDLL(_ctypes_test.__file__)
class StringPtrTestCase(unittest.TestCase):
Modified: packages/ctypes/branches/upstream/current/ctypes/test/test_strings.py
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/ctypes/test/test_strings.py?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/ctypes/test/test_strings.py (original)
+++ packages/ctypes/branches/upstream/current/ctypes/test/test_strings.py Mon Jun 19 12:31:53 2006
@@ -46,7 +46,7 @@
BUF = c_char * 4
buf = BUF()
## print c_char_p.from_param(buf)
-
+
def test_param_2(self):
BUF = c_char * 4
buf = BUF()
@@ -103,9 +103,9 @@
def XX_test_sized_strings(self):
- # New in releases later than 0.4.0:
+ # New in releases later than 0.4.0:
self.assertRaises(TypeError, c_string, None)
-
+
# New in releases later than 0.4.0:
# c_string(number) returns an empty string of size number
self.failUnless(len(c_string(32).raw) == 32)
@@ -181,7 +181,7 @@
# One char too long values:
self.assertRaises(ValueError, setattr, cs, "value", u"1234567")
-
+
def run_test(rep, msg, func, arg):
items = range(rep)
from time import clock
Modified: packages/ctypes/branches/upstream/current/ctypes/test/test_structures.py
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/ctypes/test/test_structures.py?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/ctypes/test/test_structures.py (original)
+++ packages/ctypes/branches/upstream/current/ctypes/test/test_structures.py Mon Jun 19 12:31:53 2006
@@ -56,7 +56,7 @@
"f": c_float,
"d": c_double,
}
-
+
def test_simple_structs(self):
for code, tp in self.formats.items():
class X(Structure):
@@ -90,7 +90,7 @@
("b", Y)]
self.failUnlessEqual(alignment(SI), max(alignment(Y), alignment(X)))
self.failUnlessEqual(sizeof(SI), calcsize("3s0i 3si 0i"))
-
+
class IS(Structure):
_fields_ = [("b", Y),
("a", X)]
@@ -215,7 +215,7 @@
# too long
self.assertRaises(ValueError, Person, "1234567", 5)
-
+
def test_keyword_initializers(self):
class POINT(Structure):
_fields_ = [("x", c_int), ("y", c_int)]
@@ -291,13 +291,23 @@
cls, msg = self.get_except(Person, "Someone", (1, 2))
self.failUnlessEqual(cls, RuntimeError)
- self.failUnlessEqual(msg,
- "(Phone) exceptions.TypeError: "
- "expected string or Unicode object, int found")
+ # In Python 2.5, Exception is a new-style class, and the repr changed
+ if issubclass(Exception, object):
+ self.failUnlessEqual(msg,
+ "(Phone) <class 'exceptions.TypeError'>: "
+ "expected string or Unicode object, int found")
+ else:
+ self.failUnlessEqual(msg,
+ "(Phone) exceptions.TypeError: "
+ "expected string or Unicode object, int found")
cls, msg = self.get_except(Person, "Someone", ("a", "b", "c"))
self.failUnlessEqual(cls, RuntimeError)
- self.failUnlessEqual(msg, "(Phone) exceptions.ValueError: too many initializers")
+ if issubclass(Exception, object):
+ self.failUnlessEqual(msg,
+ "(Phone) <class 'exceptions.ValueError'>: too many initializers")
+ else:
+ self.failUnlessEqual(msg, "(Phone) exceptions.ValueError: too many initializers")
def get_except(self, func, *args):
@@ -305,7 +315,7 @@
func(*args)
except Exception, detail:
return detail.__class__, str(detail)
-
+
## def test_subclass_creation(self):
## meta = type(Structure)
@@ -363,4 +373,3 @@
if __name__ == '__main__':
unittest.main()
-
Added: packages/ctypes/branches/upstream/current/ctypes/test/test_unaligned_structures.py
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/ctypes/test/test_unaligned_structures.py?rev=940&op=file
==============================================================================
--- packages/ctypes/branches/upstream/current/ctypes/test/test_unaligned_structures.py (added)
+++ packages/ctypes/branches/upstream/current/ctypes/test/test_unaligned_structures.py Mon Jun 19 12:31:53 2006
@@ -1,0 +1,45 @@
+import sys, unittest
+from ctypes import *
+
+structures = []
+byteswapped_structures = []
+
+
+if sys.byteorder == "little":
+ SwappedStructure = BigEndianStructure
+else:
+ SwappedStructure = LittleEndianStructure
+
+for typ in [c_short, c_int, c_long, c_longlong,
+ c_float, c_double,
+ c_ushort, c_uint, c_ulong, c_ulonglong]:
+ class X(Structure):
+ _pack_ = 1
+ _fields_ = [("pad", c_byte),
+ ("value", typ)]
+ class Y(SwappedStructure):
+ _pack_ = 1
+ _fields_ = [("pad", c_byte),
+ ("value", typ)]
+ structures.append(X)
+ byteswapped_structures.append(Y)
+
+class TestStructures(unittest.TestCase):
+ def test_native(self):
+ for typ in structures:
+## print typ.value
+ self.failUnlessEqual(typ.value.offset, 1)
+ o = typ()
+ o.value = 4
+ self.failUnlessEqual(o.value, 4)
+
+ def test_swapped(self):
+ for typ in byteswapped_structures:
+## print >> sys.stderr, typ.value
+ self.failUnlessEqual(typ.value.offset, 1)
+ o = typ()
+ o.value = 4
+ self.failUnlessEqual(o.value, 4)
+
+if __name__ == '__main__':
+ unittest.main()
Modified: packages/ctypes/branches/upstream/current/ctypes/test/test_unicode.py
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/ctypes/test/test_unicode.py?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/ctypes/test/test_unicode.py (original)
+++ packages/ctypes/branches/upstream/current/ctypes/test/test_unicode.py Mon Jun 19 12:31:53 2006
@@ -8,7 +8,7 @@
pass
else:
import _ctypes_test
- dll = ctypes.cdll.load(_ctypes_test.__file__)
+ dll = ctypes.CDLL(_ctypes_test.__file__)
wcslen = dll.my_wcslen
wcslen.argtypes = [ctypes.c_wchar_p]
@@ -66,7 +66,7 @@
self.failUnlessEqual(buf[:], u"ab\0\0\0\0")
import _ctypes_test
- func = ctypes.cdll.load(_ctypes_test.__file__)._testfunc_p_p
+ func = ctypes.CDLL(_ctypes_test.__file__)._testfunc_p_p
class StringTestCase(UnicodeTestCase):
def setUp(self):
Modified: packages/ctypes/branches/upstream/current/ctypes/test/test_values.py
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/ctypes/test/test_values.py?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/ctypes/test/test_values.py (original)
+++ packages/ctypes/branches/upstream/current/ctypes/test/test_values.py Mon Jun 19 12:31:53 2006
@@ -10,7 +10,7 @@
class ValuesTestCase(unittest.TestCase):
def test_an_integer(self):
- ctdll = cdll.load(_ctypes_test.__file__)
+ ctdll = CDLL(_ctypes_test.__file__)
an_integer = c_int.in_dll(ctdll, "an_integer")
x = an_integer.value
self.failUnlessEqual(x, ctdll.get_an_integer())
@@ -18,7 +18,7 @@
self.failUnlessEqual(x*2, ctdll.get_an_integer())
def test_undefined(self):
- ctdll = cdll.load(_ctypes_test.__file__)
+ ctdll = CDLL(_ctypes_test.__file__)
self.assertRaises(ValueError, c_int.in_dll, ctdll, "Undefined_Symbol")
class Win_ValuesTestCase(unittest.TestCase):
Modified: packages/ctypes/branches/upstream/current/ctypes/test/test_win32.py
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/ctypes/test/test_win32.py?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/ctypes/test/test_win32.py (original)
+++ packages/ctypes/branches/upstream/current/ctypes/test/test_win32.py Mon Jun 19 12:31:53 2006
@@ -43,22 +43,22 @@
class Structures(unittest.TestCase):
- def test_struct_by_value(self):
- class POINT(Structure):
- _fields_ = [("x", c_long),
- ("y", c_long)]
+ def test_struct_by_value(self):
+ class POINT(Structure):
+ _fields_ = [("x", c_long),
+ ("y", c_long)]
- class RECT(Structure):
- _fields_ = [("left", c_long),
- ("top", c_long),
- ("right", c_long),
- ("bottom", c_long)]
+ class RECT(Structure):
+ _fields_ = [("left", c_long),
+ ("top", c_long),
+ ("right", c_long),
+ ("bottom", c_long)]
- dll = cdll.load(_ctypes_test.__file__)
+ dll = CDLL(_ctypes_test.__file__)
- pt = POINT(10, 10)
- rect = RECT(0, 0, 20, 20)
- self.failUnlessEqual(1, dll.PointInRect(byref(rect), pt))
+ pt = POINT(10, 10)
+ rect = RECT(0, 0, 20, 20)
+ self.failUnlessEqual(1, dll.PointInRect(byref(rect), pt))
if __name__ == '__main__':
unittest.main()
Modified: packages/ctypes/branches/upstream/current/ctypes/util.py
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/ctypes/util.py?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/ctypes/util.py (original)
+++ packages/ctypes/branches/upstream/current/ctypes/util.py Mon Jun 19 12:31:53 2006
@@ -1,1 +1,122 @@
-# ctypes.util is no longer used.
+import sys, os
+import ctypes
+
+# find_library(name) returns the pathname of a library, or None.
+if os.name == "nt":
+ def find_library(name):
+ # See MSDN for the REAL search order.
+ for directory in os.environ['PATH'].split(os.pathsep):
+ fname = os.path.join(directory, name)
+ if os.path.exists(fname):
+ return fname
+ if fname.lower().endswith(".dll"):
+ continue
+ fname = fname + ".dll"
+ if os.path.exists(fname):
+ return fname
+ return None
+
+if os.name == "ce":
+ # search path according to MSDN:
+ # - absolute path specified by filename
+ # - The .exe launch directory
+ # - the Windows directory
+ # - ROM dll files (where are they?)
+ # - OEM specified search path: HKLM\Loader\SystemPath
+ def find_library(name):
+ return name
+
+if os.name == "posix" and sys.platform == "darwin":
+ from ctypes.macholib.dyld import dyld_find as _dyld_find
+ def find_library(name):
+ possible = ['lib%s.dylib' % name,
+ '%s.dylib' % name,
+ '%s.framework/%s' % (name, name)]
+ for name in possible:
+ try:
+ return _dyld_find(name)
+ except ValueError:
+ continue
+ return None
+
+elif os.name == "posix":
+ # Andreas Degert's find functions, using gcc, /sbin/ldconfig, objdump
+ import re, tempfile
+
+ def _findLib_gcc(name):
+ expr = '[^\(\)\s]*lib%s\.[^\(\)\s]*' % name
+ cmd = 'if type gcc &>/dev/null; then CC=gcc; else CC=cc; fi;' \
+ '$CC -Wl,-t -o /dev/null 2>&1 -l' + name
+ try:
+ fdout, outfile = tempfile.mkstemp()
+ fd = os.popen(cmd)
+ trace = fd.read()
+ err = fd.close()
+ finally:
+ try:
+ os.unlink(outfile)
+ except OSError, e:
+ if e.errno != errno.ENOENT:
+ raise
+ res = re.search(expr, trace)
+ if not res:
+ return None
+ return res.group(0)
+
+ def _findLib_ld(name):
+ expr = '/[^\(\)\s]*lib%s\.[^\(\)\s]*' % name
+ res = re.search(expr, os.popen('/sbin/ldconfig -p 2>/dev/null').read())
+ if not res:
+ # Hm, this works only for libs needed by the python executable.
+ cmd = 'ldd %s 2>/dev/null' % sys.executable
+ res = re.search(expr, os.popen(cmd).read())
+ if not res:
+ return None
+ return res.group(0)
+
+ def _get_soname(f):
+ cmd = "objdump -p -j .dynamic 2>/dev/null " + f
+ res = re.search(r'\sSONAME\s+([^\s]+)', os.popen(cmd).read())
+ if not res:
+ return None
+ return res.group(1)
+
+ def find_library(name):
+ lib = _findLib_ld(name) or _findLib_gcc(name)
+ if not lib:
+ return None
+ return _get_soname(lib)
+
+################################################################
+# test code
+
+def test():
+ from ctypes import cdll
+ if os.name == "nt":
+ print cdll.msvcrt
+ print cdll.load("msvcrt")
+ print find_library("msvcrt")
+
+ if os.name == "posix":
+ # find and load_version
+ print find_library("m")
+ print find_library("c")
+ print find_library("bz2")
+
+ # getattr
+## print cdll.m
+## print cdll.bz2
+
+ # load
+ if sys.platform == "darwin":
+ print cdll.LoadLibrary("libm.dylib")
+ print cdll.LoadLibrary("libcrypto.dylib")
+ print cdll.LoadLibrary("libSystem.dylib")
+ print cdll.LoadLibrary("System.framework/System")
+ else:
+ print cdll.LoadLibrary("libm.so")
+ print cdll.LoadLibrary("libcrypt.so")
+ print find_library("crypt")
+
+if __name__ == "__main__":
+ test()
Added: packages/ctypes/branches/upstream/current/ctypes/wintypes.py
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/ctypes/wintypes.py?rev=940&op=file
==============================================================================
--- packages/ctypes/branches/upstream/current/ctypes/wintypes.py (added)
+++ packages/ctypes/branches/upstream/current/ctypes/wintypes.py Mon Jun 19 12:31:53 2006
@@ -1,0 +1,97 @@
+# XXX This module needs cleanup.
+
+from ctypes import *
+
+DWORD = c_ulong
+WORD = c_ushort
+BYTE = c_byte
+
+ULONG = c_ulong
+LONG = c_long
+
+LARGE_INTEGER = c_longlong
+ULARGE_INTEGER = c_ulonglong
+
+
+HANDLE = c_ulong # in the header files: void *
+
+HWND = HANDLE
+HDC = HANDLE
+HMODULE = HANDLE
+HINSTANCE = HANDLE
+HRGN = HANDLE
+HTASK = HANDLE
+HKEY = HANDLE
+HPEN = HANDLE
+HGDIOBJ = HANDLE
+HMENU = HANDLE
+
+LCID = DWORD
+
+WPARAM = c_uint
+LPARAM = c_long
+
+BOOL = c_long
+VARIANT_BOOL = c_short
+
+LPCOLESTR = LPOLESTR = OLESTR = c_wchar_p
+LPCWSTR = LPWSTR = c_wchar_p
+
+LPCSTR = LPSTR = c_char_p
+
+class RECT(Structure):
+ _fields_ = [("left", c_long),
+ ("top", c_long),
+ ("right", c_long),
+ ("bottom", c_long)]
+RECTL = RECT
+
+class POINT(Structure):
+ _fields_ = [("x", c_long),
+ ("y", c_long)]
+POINTL = POINT
+
+class SIZE(Structure):
+ _fields_ = [("cx", c_long),
+ ("cy", c_long)]
+SIZEL = SIZE
+
+def RGB(red, green, blue):
+ return red + (green << 8) + (blue << 16)
+
+class FILETIME(Structure):
+ _fields_ = [("dwLowDateTime", DWORD),
+ ("dwHighDateTime", DWORD)]
+
+class MSG(Structure):
+ _fields_ = [("hWnd", HWND),
+ ("message", c_uint),
+ ("wParam", WPARAM),
+ ("lParam", LPARAM),
+ ("time", DWORD),
+ ("pt", POINT)]
+MAX_PATH = 260
+
+class WIN32_FIND_DATAA(Structure):
+ _fields_ = [("dwFileAttributes", DWORD),
+ ("ftCreationTime", FILETIME),
+ ("ftLastAccessTime", FILETIME),
+ ("ftLastWriteTime", FILETIME),
+ ("nFileSizeHigh", DWORD),
+ ("nFileSizeLow", DWORD),
+ ("dwReserved0", DWORD),
+ ("dwReserved1", DWORD),
+ ("cFileName", c_char * MAX_PATH),
+ ("cAlternameFileName", c_char * 14)]
+
+class WIN32_FIND_DATAW(Structure):
+ _fields_ = [("dwFileAttributes", DWORD),
+ ("ftCreationTime", FILETIME),
+ ("ftLastAccessTime", FILETIME),
+ ("ftLastWriteTime", FILETIME),
+ ("nFileSizeHigh", DWORD),
+ ("nFileSizeLow", DWORD),
+ ("dwReserved0", DWORD),
+ ("dwReserved1", DWORD),
+ ("cFileName", c_wchar * MAX_PATH),
+ ("cAlternameFileName", c_wchar * 14)]
Added: packages/ctypes/branches/upstream/current/docs/manual/markup.py
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/docs/manual/markup.py?rev=940&op=file
==============================================================================
--- packages/ctypes/branches/upstream/current/docs/manual/markup.py (added)
+++ packages/ctypes/branches/upstream/current/docs/manual/markup.py Mon Jun 19 12:31:53 2006
@@ -1,0 +1,146 @@
+# The following dictionary lists all names marked up as ``code`` in
+# the rest documentation. It specifies how it should be marked up in
+# LaTeX. Running mkpydoc.py writes missing entried into the
+# 'missing.py' file, which should be used to update this specs:
+codemarkup = {
+
+ # types
+ 'c_char': 'class',
+ 'c_wchar': 'class',
+
+ 'c_byte': 'class',
+ 'c_ubyte': 'class',
+
+ 'c_short': 'class',
+ 'c_ushort': 'class',
+
+ 'c_int': 'class',
+ 'c_uint': 'class',
+ 'c_long': 'class',
+ 'c_ulong': 'class',
+ 'c_longlong': 'class',
+ 'c_ulonglong': 'class',
+
+ 'c_void_p': 'class',
+ 'c_char_p': 'class',
+ 'c_wchar_p': 'class',
+
+ 'c_float': 'class',
+ 'c_double': 'class',
+
+ 'LibraryLoader': 'class',
+
+ 'Structure': 'class',
+ 'BigEndianStructure': 'class',
+ 'BigEndianUnion': 'class',
+ 'LittleEndianStructure': 'class',
+ 'LittleEndianUnion': 'class',
+
+ 'Union': 'class',
+
+ 'HRESULT': 'class',
+
+ 'CDLL': 'class',
+ 'OleDLL': 'class',
+ 'PyDLL': 'class',
+ 'WinDLL': 'class',
+
+
+ # instances
+ 'pythonapi': 'var',
+ 'windll': 'var',
+ 'cdll': 'var',
+ 'oledll': 'var',
+ 'pydll': 'var',
+
+ # constants
+ 'RTLD_GLOBAL': 'var',
+ 'RTLD_LOCAL': 'var',
+
+ # arguments (from inline code fragments)
+ 'dst': 'var',
+ 'init': 'var',
+ 'lib': 'var',
+ 'libname': 'var',
+ 'mode': 'var',
+ 'name': 'var',
+ 'iid': 'var',
+ 'index': 'var',
+ 'paramflags': 'var',
+ 'version': 'var',
+ 'outargs': 'var',
+ 'c': 'var',
+ 'count': 'var',
+ 'code': 'var',
+
+ # methods
+ 'LoadLibrary': 'method',
+ 'find': 'method',
+ 'load': 'method',
+ 'load_library': 'method',
+ 'load_version': 'method',
+
+ 'from_address': 'method',
+ 'from_param': 'method',
+ 'in_dll': 'method',
+
+ '__getattr__': 'method',
+ '__getitem__': 'method',
+
+ # members
+ 'restype': 'member',
+ 'argtypes': 'member',
+ 'errcheck': 'member',
+
+ '_fields_': 'member',
+ '_pack_': 'member',
+ '__ctype_be__': 'member',
+ '__ctype_le__': 'member',
+ '__ctypes_from_outparam__': 'member',
+ '_as_parameter_': 'member',
+ '_b_base_': 'member',
+ '_b_needsfree_': 'member',
+
+ '_handle': 'member',
+ '_name': 'member',
+ '_objects': 'member',
+ '_type_': 'member',
+
+ # functions
+ 'PyString_FromString': 'function',
+ 'PyString_FromStringAndSize': 'function',
+ 'PyUnicode_FromWideString': 'function',
+
+ 'DllCanUnloadNow()': 'function',
+ 'FormatError': 'function',
+ 'GetLastError()': 'function',
+
+ 'memmove': 'function',
+ 'memset': 'function',
+ 'qsort': 'function',
+
+ 'CFUNCTYPE': 'function',
+ 'WINFUNCTYPE': 'function',
+
+ 'byref': 'function',
+ 'create_string_buffer()': 'function',
+
+ # random things
+ 'NULL': 'code',
+ 'None': 'code',
+ '_': 'code',
+ '__stdcall': 'code',
+ 'atoi': 'code',
+ 'c_int.__ctype_be__': 'code',
+ 'char': 'code',
+ 'dlopen': 'code',
+ 'dlopen()': 'code',
+ 'void': 'code',
+ 'wchar_t': 'code',
+ 'wcslen': 'code',
+ 'x': 'code',
+ 'y': 'code',
+
+ 'WindowsError': 'class',
+
+}
Added: packages/ctypes/branches/upstream/current/docs/manual/mkpydoc.py
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/docs/manual/mkpydoc.py?rev=940&op=file
==============================================================================
--- packages/ctypes/branches/upstream/current/docs/manual/mkpydoc.py (added)
+++ packages/ctypes/branches/upstream/current/docs/manual/mkpydoc.py Mon Jun 19 12:31:53 2006
@@ -1,0 +1,307 @@
+#!/usr/bin/env python
+# Convert the ctypes docs to LaTeX for use in Python docs
+
+# This script is a hacked version taken from the Optik SVN repository.
+
+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
+
+# python 2.3
+if not hasattr(__builtins__,"set"):
+ import sets
+ set = sets.Set
+if not hasattr(__builtins__,"sorted"):
+ def sorted(list):
+ if hasattr(list,"sort"):
+ return list.sort()
+ # maybe it is sorted
+ return list
+
+from markup import codemarkup
+missing = set()
+
+class PyLaTeXWriter(LaTeXWriter):
+ def __init__(self):
+ LaTeXWriter.__init__(self)
+ self.translator_class = PyLaTeXTranslator
+
+class PyLaTeXTranslator(LaTeXTranslator):
+ remap_title = {
+ }
+
+ # 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 = "theller at python.net"
+ 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__)
+ ]
+ # TODO definitions get from latexwriter
+ # TODO definitions must be guarded if multiple modules are included
+ self.definitions = [
+ "\\newlength{\\locallinewidth}\n"
+ "\\setlength{\\locallinewidth}{\\linewidth}\n"
+ ]
+ def astext(self):
+ return ''.join(self.definitions +
+ 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 = codemarkup.get(text)
+ if cmd is None:
+## print "warning: unrecognized code word %r" % text
+ missing.add(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
+
+ 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("tutorial.txt", "tutorial.tex")
+ convert("tutorial.txt", "../../../trunk/Doc/lib/libctypes.tex")
+ if missing:
+ mod = open("missing.py", "w")
+ mod.write("# possible markups:\n")
+ mod.write("# module, code, method, class, function, member, var. Are there more?\n")
+ mod.write("codemarkup = {\n")
+ keys = sorted(missing)
+ for name in keys:
+ mod.write(" '%s': 'code',\n" % name)
+ mod.write("}\n")
+ mod.close()
+
+main()
Added: packages/ctypes/branches/upstream/current/docs/manual/tutorial.html
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/docs/manual/tutorial.html?rev=940&op=file
==============================================================================
--- packages/ctypes/branches/upstream/current/docs/manual/tutorial.html (added)
+++ packages/ctypes/branches/upstream/current/docs/manual/tutorial.html Mon Jun 19 12:31:53 2006
@@ -1,0 +1,1060 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<meta name="generator" content="Docutils 0.3.7: http://docutils.sourceforge.net/" />
+<title></title>
+<link rel="stylesheet" href="default.css" type="text/css" />
+</head>
+<body>
+<div class="document">
+<p><tt class="docutils literal"><span class="pre">ctypes</span></tt> is a foreign function library for Python.</p>
+<div class="section" id="ctypes-tutorial">
+<h1><a name="ctypes-tutorial">ctypes tutorial</a></h1>
+<p>This tutorial describes version 0.9.9 of <tt class="docutils literal"><span class="pre">ctypes</span></tt>.</p>
+<p>Note: The code samples in this tutorial uses <tt class="docutils literal"><span class="pre">doctest</span></tt> to make sure
+that they actually work. Since some code samples behave differently
+under Linux, Windows, or Mac OS X, they contain doctest directives in
+comments.</p>
+<p>Note: Quite some code samples references the ctypes <tt class="docutils literal"><span class="pre">c_int</span></tt> type.
+This type is an alias to the <tt class="docutils literal"><span class="pre">c_long</span></tt> type on 32-bit systems. So,
+you should not be confused if <tt class="docutils literal"><span class="pre">c_long</span></tt> is printed if you would
+expect <tt class="docutils literal"><span class="pre">c_int</span></tt> - they are actually the same type.</p>
+<div class="section" id="loading-dynamic-link-libraries">
+<h2><a name="loading-dynamic-link-libraries">Loading dynamic link libraries</a></h2>
+<p><tt class="docutils literal"><span class="pre">ctypes</span></tt> exports the <tt class="docutils literal"><span class="pre">cdll</span></tt>, and on Windows also <tt class="docutils literal"><span class="pre">windll</span></tt> and
+<tt class="docutils literal"><span class="pre">oledll</span></tt> objects to load dynamic link libraries.</p>
+<p>You load libraries by accessing them as attributes of these objects.
+<tt class="docutils literal"><span class="pre">cdll</span></tt> loads libraries which export functions using the standard
+<tt class="docutils literal"><span class="pre">cdecl</span></tt> calling convention, while <tt class="docutils literal"><span class="pre">windll</span></tt> libraries call
+functions using the <tt class="docutils literal"><span class="pre">stdcall</span></tt> calling convention. <tt class="docutils literal"><span class="pre">oledll</span></tt> also
+uses the <tt class="docutils literal"><span class="pre">stdcall</span></tt> calling convention, and assumes the functions
+return a Windows <tt class="docutils literal"><span class="pre">HRESULT</span></tt> error code. The error code is used to
+automatically raise <tt class="docutils literal"><span class="pre">WindowsError</span></tt> Python exceptions when the
+function call fails.</p>
+<p>Here are some examples for Windows, note that <tt class="docutils literal"><span class="pre">msvcrt</span></tt> is the MS
+standard C library containing most standard C functions, and uses the
+cdecl calling convention:</p>
+<pre class="literal-block">
+>>> from ctypes import *
+>>> print windll.kernel32 # doctest: +WINDOWS
+<WinDLL 'kernel32', handle ... at ...>
+>>> print cdll.msvcrt # doctest: +WINDOWS
+<CDLL 'msvcrt', handle ... at ...>
+>>> libc = cdll.msvcrt # doctest: +WINDOWS
+>>>
+</pre>
+<p>Windows appends the usual '.dll' file suffix automatically.</p>
+<p>On Linux, it is required to specify the filename <em>including</em> the
+extension to load a library, so attribute access does not work.
+Either the <tt class="docutils literal"><span class="pre">LoadLibrary</span></tt> method of the dll loaders should be used,
+or you should load the library by creating an instance of CDLL by
+calling the constructor:</p>
+<pre class="literal-block">
+>>> cdll.LoadLibrary("libc.so.6") # doctest: +LINUX
+<CDLL 'libc.so.6', handle ... at ...>
+>>> libc = CDLL("libc.so.6") # doctest: +LINUX
+>>> libc # doctest: +LINUX
+<CDLL 'libc.so.6', handle ... at ...>
+>>>
+</pre>
+<p>XXX Add section for Mac OS X.</p>
+</div>
+<div class="section" id="accessing-functions-from-loaded-dlls">
+<h2><a name="accessing-functions-from-loaded-dlls">Accessing functions from loaded dlls</a></h2>
+<p>Functions are accessed as attributes of dll objects:</p>
+<pre class="literal-block">
+>>> from ctypes import *
+>>> libc.printf
+<_FuncPtr object at 0x...>
+>>> print windll.kernel32.GetModuleHandleA # doctest: +WINDOWS
+<_FuncPtr object at 0x...>
+>>> print windll.kernel32.MyOwnFunction # doctest: +WINDOWS
+Traceback (most recent call last):
+ File "<stdin>", line 1, in ?
+ File "ctypes.py", line 239, in __getattr__
+ func = _StdcallFuncPtr(name, self)
+AttributeError: function 'MyOwnFunction' not found
+>>>
+</pre>
+<p>Note that win32 system dlls like <tt class="docutils literal"><span class="pre">kernel32</span></tt> and <tt class="docutils literal"><span class="pre">user32</span></tt> often
+export ANSI as well as UNICODE versions of a function. The UNICODE
+version is exported with an <tt class="docutils literal"><span class="pre">W</span></tt> appended to the name, while the ANSI
+version is exported with an <tt class="docutils literal"><span class="pre">A</span></tt> appended to the name. The win32
+<tt class="docutils literal"><span class="pre">GetModuleHandle</span></tt> function, which returns a <em>module handle</em> for a
+given module name, has the following C prototype, and a macro is used
+to expose one of them as <tt class="docutils literal"><span class="pre">GetModuleHandle</span></tt> depending on whether
+UNICODE is defined or not:</p>
+<pre class="literal-block">
+/* ANSI version */
+HMODULE GetModuleHandleA(LPCSTR lpModuleName);
+/* UNICODE version */
+HMODULE GetModuleHandleW(LPCWSTR lpModuleName);
+</pre>
+<p><tt class="docutils literal"><span class="pre">windll</span></tt> does not try to select one of them by magic, you must
+access the version you need by specifying <tt class="docutils literal"><span class="pre">GetModuleHandleA</span></tt> or
+<tt class="docutils literal"><span class="pre">GetModuleHandleW</span></tt> explicitely, and then call it with normal strings
+or unicode strings respectively.</p>
+<p>Sometimes, dlls export functions with names which aren't valid Python
+identifiers, like <tt class="docutils literal"><span class="pre">"??2@YAPAXI@Z"</span></tt>. In this case you have to use
+<tt class="docutils literal"><span class="pre">getattr</span></tt> to retrieve the function:</p>
+<pre class="literal-block">
+>>> getattr(cdll.msvcrt, "??2@YAPAXI@Z") # doctest: +WINDOWS
+<_FuncPtr object at 0x...>
+>>>
+</pre>
+<p>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:</p>
+<pre class="literal-block">
+>>> cdll.kernel32[1] # doctest: +WINDOWS
+<_FuncPtr object at 0x...>
+>>> cdll.kernel32[0] # doctest: +WINDOWS
+Traceback (most recent call last):
+ File "<stdin>", line 1, in ?
+ File "ctypes.py", line 310, in __getitem__
+ func = _StdcallFuncPtr(name, self)
+AttributeError: function ordinal 0 not found
+>>>
+</pre>
+</div>
+<div class="section" id="calling-functions">
+<h2><a name="calling-functions">Calling functions</a></h2>
+<p>You can call these functions like any other Python callable. This
+example uses the <tt class="docutils literal"><span class="pre">time()</span></tt> function, which returns system time in
+seconds since the UNIX epoch, and the <tt class="docutils literal"><span class="pre">GetModuleHandleA()</span></tt> function,
+which returns a win32 module handle.</p>
+<p>This example calls both functions with a NULL pointer (<tt class="docutils literal"><span class="pre">None</span></tt> should
+be used as the NULL pointer):</p>
+<pre class="literal-block">
+>>> print libc.time(None)
+114...
+>>> print hex(windll.kernel32.GetModuleHandleA(None)) # doctest: +WINDOWS
+0x1d000000
+>>>
+</pre>
+<p><tt class="docutils literal"><span class="pre">ctypes</span></tt> tries to protect you from calling functions with the wrong
+number of arguments. Unfortunately this only works on Windows. It
+does this by examining the stack after the function returns:</p>
+<pre class="literal-block">
+>>> windll.kernel32.GetModuleHandleA() # doctest: +WINDOWS
+Traceback (most recent call last):
+ File "<stdin>", line 1, in ?
+ValueError: Procedure probably called with not enough arguments (4 bytes missing)
+>>> windll.kernel32.GetModuleHandleA(0, 0) # doctest: +WINDOWS
+Traceback (most recent call last):
+ File "<stdin>", line 1, in ?
+ValueError: Procedure probably called with too many arguments (4 bytes in excess)
+>>>
+</pre>
+<p>On Windows, <tt class="docutils literal"><span class="pre">ctypes</span></tt> uses win32 structured exception handling to
+prevent crashes from general protection faults when functions are
+called with invalid argument values:</p>
+<pre class="literal-block">
+>>> windll.kernel32.GetModuleHandleA(32) # doctest: +WINDOWS
+Traceback (most recent call last):
+ File "<stdin>", line 1, in ?
+WindowsError: exception: access violation reading 0x00000020
+>>>
+</pre>
+<p>There are, however, enough ways to crash Python with <tt class="docutils literal"><span class="pre">ctypes</span></tt>, so
+you should be careful anyway.</p>
+<p>Python integers, strings and unicode strings are the only objects that
+can directly be used as parameters in these function calls.</p>
+<p>Before we move on calling functions with other parameter types, we
+have to learn more about <tt class="docutils literal"><span class="pre">ctypes</span></tt> data types.</p>
+</div>
+<div class="section" id="simple-data-types">
+<h2><a name="simple-data-types">Simple data types</a></h2>
+<p><tt class="docutils literal"><span class="pre">ctypes</span></tt> defines a number of primitive C compatible data types :</p>
+<blockquote>
+<table border="1" class="docutils">
+<colgroup>
+<col width="31%" />
+<col width="47%" />
+<col width="22%" />
+</colgroup>
+<thead valign="bottom">
+<tr><th>ctypes type</th>
+<th>C type</th>
+<th>Python type</th>
+</tr>
+</thead>
+<tbody valign="top">
+<tr><td><tt class="docutils literal"><span class="pre">c_char</span></tt></td>
+<td><tt class="docutils literal"><span class="pre">char</span></tt></td>
+<td>character</td>
+</tr>
+<tr><td><tt class="docutils literal"><span class="pre">c_byte</span></tt></td>
+<td><tt class="docutils literal"><span class="pre">char</span></tt></td>
+<td>integer</td>
+</tr>
+<tr><td><tt class="docutils literal"><span class="pre">c_ubyte</span></tt></td>
+<td><tt class="docutils literal"><span class="pre">unsigned</span> <span class="pre">char</span></tt></td>
+<td>integer</td>
+</tr>
+<tr><td><tt class="docutils literal"><span class="pre">c_short</span></tt></td>
+<td><tt class="docutils literal"><span class="pre">short</span></tt></td>
+<td>integer</td>
+</tr>
+<tr><td><tt class="docutils literal"><span class="pre">c_ushort</span></tt></td>
+<td><tt class="docutils literal"><span class="pre">unsigned</span> <span class="pre">short</span></tt></td>
+<td>integer</td>
+</tr>
+<tr><td><tt class="docutils literal"><span class="pre">c_int</span></tt></td>
+<td><tt class="docutils literal"><span class="pre">int</span></tt></td>
+<td>integer</td>
+</tr>
+<tr><td><tt class="docutils literal"><span class="pre">c_uint</span></tt></td>
+<td><tt class="docutils literal"><span class="pre">unsigned</span> <span class="pre">int</span></tt></td>
+<td>integer</td>
+</tr>
+<tr><td><tt class="docutils literal"><span class="pre">c_long</span></tt></td>
+<td><tt class="docutils literal"><span class="pre">long</span></tt></td>
+<td>integer</td>
+</tr>
+<tr><td><tt class="docutils literal"><span class="pre">c_ulong</span></tt></td>
+<td><tt class="docutils literal"><span class="pre">unsigned</span> <span class="pre">long</span></tt></td>
+<td>long</td>
+</tr>
+<tr><td><tt class="docutils literal"><span class="pre">c_longlong</span></tt></td>
+<td><tt class="docutils literal"><span class="pre">__int64</span></tt> or
+<tt class="docutils literal"><span class="pre">long</span> <span class="pre">long</span></tt></td>
+<td>long</td>
+</tr>
+<tr><td><tt class="docutils literal"><span class="pre">c_ulonglong</span></tt></td>
+<td><tt class="docutils literal"><span class="pre">unsigned</span> <span class="pre">__int64</span></tt> or
+<tt class="docutils literal"><span class="pre">unsigned</span> <span class="pre">long</span> <span class="pre">long</span></tt></td>
+<td>long</td>
+</tr>
+<tr><td><tt class="docutils literal"><span class="pre">c_float</span></tt></td>
+<td><tt class="docutils literal"><span class="pre">float</span></tt></td>
+<td>float</td>
+</tr>
+<tr><td><tt class="docutils literal"><span class="pre">c_double</span></tt></td>
+<td><tt class="docutils literal"><span class="pre">double</span></tt></td>
+<td>float</td>
+</tr>
+<tr><td><tt class="docutils literal"><span class="pre">c_char_p</span></tt></td>
+<td><tt class="docutils literal"><span class="pre">char</span> <span class="pre">*</span></tt>
+(NUL terminated)</td>
+<td>string or
+<tt class="docutils literal"><span class="pre">None</span></tt></td>
+</tr>
+<tr><td><tt class="docutils literal"><span class="pre">c_wchar_p</span></tt></td>
+<td><tt class="docutils literal"><span class="pre">wchar_t</span> <span class="pre">*</span></tt>
+(NUL terminated)</td>
+<td>unicode or
+<tt class="docutils literal"><span class="pre">None</span></tt></td>
+</tr>
+<tr><td><tt class="docutils literal"><span class="pre">c_void_p</span></tt></td>
+<td><tt class="docutils literal"><span class="pre">void</span> <span class="pre">*</span></tt></td>
+<td>integer or
+<tt class="docutils literal"><span class="pre">None</span></tt></td>
+</tr>
+</tbody>
+</table>
+</blockquote>
+<p>All these types can be created by calling them with an optional
+initializer of the correct type and value:</p>
+<pre class="literal-block">
+>>> c_int()
+c_long(0)
+>>> c_char_p("Hello, World")
+c_char_p('Hello, World')
+>>> c_ushort(-3)
+c_ushort(65533)
+>>>
+</pre>
+<p>Since these types are mutable, their value can also be changed
+afterwards:</p>
+<pre class="literal-block">
+>>> i = c_int(42)
+>>> print i
+c_long(42)
+>>> print i.value
+42
+>>> i.value = -99
+>>> print i.value
+-99
+>>>
+</pre>
+<p>Assigning a new value to instances of the pointer types <tt class="docutils literal"><span class="pre">c_char_p</span></tt>,
+<tt class="docutils literal"><span class="pre">c_wchar_p</span></tt>, and <tt class="docutils literal"><span class="pre">c_void_p</span></tt> changes the <em>memory location</em> they
+point to, <em>not the contents</em> of the memory block (of course not,
+because Python strings are immutable):</p>
+<pre class="literal-block">
+>>> s = "Hello, World"
+>>> c_s = c_char_p(s)
+>>> print c_s
+c_char_p('Hello, World')
+>>> c_s.value = "Hi, there"
+>>> print c_s
+c_char_p('Hi, there')
+>>> print s # first string is unchanged
+Hello, World
+</pre>
+<p>You should be careful, however, not to pass them to functions
+expecting pointers to mutable memory. If you need mutable memory
+blocks, ctypes has a <tt class="docutils literal"><span class="pre">create_string_buffer</span></tt> function which creates
+these in various ways. The current memory block contents can be
+accessed (or changed) with the <tt class="docutils literal"><span class="pre">raw</span></tt> property, if you want to access
+it as NUL terminated string, use the <tt class="docutils literal"><span class="pre">string</span></tt> property:</p>
+<pre class="literal-block">
+>>> from ctypes import *
+>>> p = create_string_buffer(3) # create a 3 byte buffer, initialized to NUL bytes
+>>> print sizeof(p), repr(p.raw)
+3 '\x00\x00\x00'
+>>> p = create_string_buffer("Hello") # create a buffer containing a NUL terminated string
+>>> print sizeof(p), repr(p.raw)
+6 'Hello\x00'
+>>> print repr(p.value)
+'Hello'
+>>> p = create_string_buffer("Hello", 10) # create a 10 byte buffer
+>>> print sizeof(p), repr(p.raw)
+10 'Hello\x00\x00\x00\x00\x00'
+>>> p.value = "Hi"
+>>> print sizeof(p), repr(p.raw)
+10 'Hi\x00lo\x00\x00\x00\x00\x00'
+>>>
+</pre>
+<p>The <tt class="docutils literal"><span class="pre">create_string_buffer</span></tt> function replaces the <tt class="docutils literal"><span class="pre">c_buffer</span></tt>
+function (which is still available as an alias), as well as the
+<tt class="docutils literal"><span class="pre">c_string</span></tt> function from earlier ctypes releases. To create a
+mutable memory block containing unicode characters of the C type
+<tt class="docutils literal"><span class="pre">wchar_t</span></tt> use the <tt class="docutils literal"><span class="pre">create_unicode_buffer</span></tt> function.</p>
+</div>
+<div class="section" id="calling-functions-continued">
+<h2><a name="calling-functions-continued">Calling functions, continued</a></h2>
+<p>Note that printf prints to the real standard output channel, <em>not</em> to
+<tt class="docutils literal"><span class="pre">sys.stdout</span></tt>, so these examples will only work at the console
+prompt, not from within <em>IDLE</em> or <em>PythonWin</em>:</p>
+<pre class="literal-block">
+>>> printf = libc.printf
+>>> printf("Hello, %s\n", "World!")
+Hello, World!
+14
+>>> printf("Hello, %S", u"World!")
+Hello, World!
+13
+>>> printf("%d bottles of beer\n", 42)
+42 bottles of beer
+19
+>>> printf("%f bottles of beer\n", 42.5)
+Traceback (most recent call last):
+ File "<stdin>", line 1, in ?
+ArgumentError: argument 2: exceptions.TypeError: Don't know how to convert parameter 2
+>>>
+</pre>
+<p>As has been mentioned before, all Python types except integers,
+strings, and unicode strings have to be wrapped in their corresponding
+<tt class="docutils literal"><span class="pre">ctypes</span></tt> type, so that they can be converted to the required C data
+type:</p>
+<pre class="literal-block">
+>>> printf("An int %d, a double %f\n", 1234, c_double(3.14))
+Integer 1234, double 3.1400001049
+31
+>>>
+</pre>
+</div>
+<div class="section" id="calling-functions-with-your-own-custom-data-types">
+<h2><a name="calling-functions-with-your-own-custom-data-types">Calling functions with your own custom data types</a></h2>
+<p>You can also customize <tt class="docutils literal"><span class="pre">ctypes</span></tt> argument conversion to allow
+instances of your own classes be used as function arguments.
+<tt class="docutils literal"><span class="pre">ctypes</span></tt> looks for an <tt class="docutils literal"><span class="pre">_as_parameter_</span></tt> attribute and uses this as
+the function argument. Of course, it must be one of integer, string,
+or unicode:</p>
+<pre class="literal-block">
+>>> class Bottles(object):
+... def __init__(self, number):
+... self._as_parameter_ = number
+...
+>>> bottles = Bottles(42)
+>>> printf("%d bottles of beer\n", bottles)
+42 bottles of beer
+19
+>>>
+</pre>
+<p>If you don't want to store the instance's data in the
+<tt class="docutils literal"><span class="pre">_as_parameter_</span></tt> instance variable, you could define a <tt class="docutils literal"><span class="pre">property</span></tt>
+which makes the data avaiblable.</p>
+</div>
+<div class="section" id="specifying-the-required-argument-types-function-prototypes">
+<h2><a name="specifying-the-required-argument-types-function-prototypes">Specifying the required argument types (function prototypes)</a></h2>
+<p>It is possible to specify the required argument types of functions
+exported from DLLs by setting the <tt class="docutils literal"><span class="pre">argtypes</span></tt> attribute.</p>
+<p><tt class="docutils literal"><span class="pre">argtypes</span></tt> must be a sequence of C data types (the <tt class="docutils literal"><span class="pre">printf</span></tt>
+function is probably not a good example here, because it takes a
+variable number and different types of parameters depending on the
+format string, on the other hand this is quite handy to experiment
+with this feature):</p>
+<pre class="literal-block">
+>>> printf.argtypes = [c_char_p, c_char_p, c_int, c_double]
+>>> printf("String '%s', Int %d, Double %f\n", "Hi", 10, 2.2)
+String 'Hi', Int 10, Double 2.200000
+37
+>>>
+</pre>
+<p>Specifying a format protects against incompatible argument types (just
+as a prototype for a C function), and tries to convert the arguments
+to valid types:</p>
+<pre class="literal-block">
+>>> printf("%d %d %d", 1, 2, 3)
+Traceback (most recent call last):
+ File "<stdin>", line 1, in ?
+ArgumentError: argument 2: exceptions.TypeError: wrong type
+>>> printf("%s %d %f", "X", 2, 3)
+X 2 3.00000012
+12
+>>>
+</pre>
+<p>If you have defined your own classes which you pass to function calls,
+you have to implement a <tt class="docutils literal"><span class="pre">from_param</span></tt> class method for them to be
+able to use them in the <tt class="docutils literal"><span class="pre">argtypes</span></tt> sequence. The <tt class="docutils literal"><span class="pre">from_param</span></tt>
+class method receives the Python object passed to the function call,
+it should do a typecheck or whatever is needed to make sure this
+object is acceptable, and then return the object itself, it's
+<tt class="docutils literal"><span class="pre">_as_parameter_</span></tt> attribute, or whatever you want to pass as the C
+function argument in this case. Again, the result should be an
+integer, string, unicode, a <tt class="docutils literal"><span class="pre">ctypes</span></tt> instance, or something having
+the <tt class="docutils literal"><span class="pre">_as_parameter_</span></tt> attribute.</p>
+</div>
+<div class="section" id="return-types">
+<h2><a name="return-types">Return types</a></h2>
+<p>By default functions are assumed to return integers. Other return
+types can be specified by setting the <tt class="docutils literal"><span class="pre">restype</span></tt> attribute of the
+function object.</p>
+<p>Here is a more advanced example, it uses the strchr function, which
+expects a string pointer and a char, and returns a pointer to a
+string:</p>
+<pre class="literal-block">
+>>> strchr = libc.strchr
+>>> strchr("abcdef", ord("d")) # doctest: +SKIP
+8059983
+>>> strchr.restype = c_char_p # c_char_p is a pointer to a string
+>>> strchr("abcdef", ord("d"))
+'def'
+>>> print strchr("abcdef", ord("x"))
+None
+>>>
+</pre>
+<p>If you want to avoid the <tt class="docutils literal"><span class="pre">ord("x")</span></tt> calls above, you can set the
+<tt class="docutils literal"><span class="pre">argtypes</span></tt> attribute, and the second argument will be converted from
+a single character Python string into a C char:</p>
+<pre class="literal-block">
+>>> strchr.restype = c_char_p
+>>> strchr.argtypes = [c_char_p, c_char]
+>>> strchr("abcdef", "d")
+'def'
+>>> strchr("abcdef", "def")
+Traceback (most recent call last):
+ File "<stdin>", line 1, in ?
+ArgumentError: argument 2: exceptions.TypeError: one character string expected
+>>> print strchr("abcdef", "x")
+None
+>>> strchr("abcdef", "d")
+'def'
+>>>
+</pre>
+<p>XXX Mention the <tt class="docutils literal"><span class="pre">errcheck</span></tt> protocol...</p>
+<p>You can also use a callable Python object (a function or a class for
+example) as the <tt class="docutils literal"><span class="pre">restype</span></tt> attribute. It will be called with the
+<tt class="docutils literal"><span class="pre">integer</span></tt> 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:</p>
+<pre class="literal-block">
+>>> GetModuleHandle = windll.kernel32.GetModuleHandleA # doctest: +WINDOWS
+>>> def ValidHandle(value):
+... if value == 0:
+... raise WinError()
+... return value
+...
+>>>
+>>> GetModuleHandle.restype = ValidHandle # doctest: +WINDOWS
+>>> GetModuleHandle(None) # doctest: +WINDOWS
+486539264
+>>> GetModuleHandle("something silly") # doctest: +WINDOWS +IGNORE_EXCEPTION_DETAIL
+Traceback (most recent call last):
+ File "<stdin>", line 1, in ?
+ File "<stdin>", line 3, in ValidHandle
+WindowsError: [Errno 126] The specified module could not be found.
+>>>
+</pre>
+<p><tt class="docutils literal"><span class="pre">WinError</span></tt> is a function which will call Windows <tt class="docutils literal"><span class="pre">FormatMessage()</span></tt>
+api to get the string representation of an error code, and <em>returns</em>
+an exception. <tt class="docutils literal"><span class="pre">WinError</span></tt> takes an optional error code parameter, if
+no one is used, it calls <tt class="docutils literal"><span class="pre">GetLastError()</span></tt> to retrieve it.</p>
+</div>
+<div class="section" id="passing-pointers-or-passing-parameters-by-reference">
+<h2><a name="passing-pointers-or-passing-parameters-by-reference">Passing pointers (or: passing parameters by reference)</a></h2>
+<p>Sometimes a C api function expects a <em>pointer</em> to a data type as
+parameter, probably to write into the corresponding location, or if
+the data is too large to be passed by value. This is also known as
+<em>passing parameters by reference</em>.</p>
+<p><tt class="docutils literal"><span class="pre">ctypes</span></tt> exports the <tt class="docutils literal"><span class="pre">byref</span></tt> function which is used to pass
+parameters by reference. The same effect can be achieved with the
+<tt class="docutils literal"><span class="pre">pointer</span></tt> function, although <tt class="docutils literal"><span class="pre">pointer</span></tt> does a lot more work since
+it constructs a real pointer object, so it is faster to use <tt class="docutils literal"><span class="pre">byref</span></tt>
+if you don't need the pointer object in Python itself:</p>
+<pre class="literal-block">
+>>> i = c_int()
+>>> f = c_float()
+>>> s = create_string_buffer('\000' * 32)
+>>> print i.value, f.value, repr(s.value)
+0 0.0 ''
+>>> libc.sscanf("1 3.14 Hello", "%d %f %s",
+... byref(i), byref(f), s)
+3
+>>> print i.value, f.value, repr(s.value)
+1 3.1400001049 'Hello'
+>>>
+</pre>
+</div>
+<div class="section" id="structures-and-unions">
+<h2><a name="structures-and-unions">Structures and unions</a></h2>
+<p>Structures and unions must derive from the <tt class="docutils literal"><span class="pre">Structure</span></tt> and <tt class="docutils literal"><span class="pre">Union</span></tt>
+base classes which are defined in the <tt class="docutils literal"><span class="pre">ctypes</span></tt> module. Each subclass
+must define a <tt class="docutils literal"><span class="pre">_fields_</span></tt> attribute. <tt class="docutils literal"><span class="pre">_fields_</span></tt> must be a list of
+<em>2-tuples</em>, containing a <em>field name</em> and a <em>field type</em>.</p>
+<p>The field type must be a <tt class="docutils literal"><span class="pre">ctypes</span></tt> type like <tt class="docutils literal"><span class="pre">c_int</span></tt>, or any other
+derived <tt class="docutils literal"><span class="pre">ctypes</span></tt> type: structure, union, array, pointer.</p>
+<p>Here is a simple example of a POINT structure, which contains two
+integers named <tt class="docutils literal"><span class="pre">x</span></tt> and <tt class="docutils literal"><span class="pre">y</span></tt>, and also shows how to initialize a
+structure in the constructor:</p>
+<pre class="literal-block">
+>>> from ctypes import *
+>>> class POINT(Structure):
+... _fields_ = [("x", c_int),
+... ("y", c_int)]
+...
+>>> point = POINT(10, 20)
+>>> print point.x, point.y
+10 20
+>>> point = POINT(y=5)
+>>> print point.x, point.y
+0 5
+>>> POINT(1, 2, 3)
+Traceback (most recent call last):
+ File "<stdin>", line 1, in ?
+ValueError: too many initializers
+>>>
+</pre>
+<p>You can, however, build much more complicated structures. Structures
+can itself contain other structures by using a structure as a field
+type.</p>
+<p>Here is a RECT structure which contains two POINTs named <tt class="docutils literal"><span class="pre">upperleft</span></tt>
+and <tt class="docutils literal"><span class="pre">lowerright</span></tt></p>
+<pre class="literal-block">
+>>> class RECT(Structure):
+... _fields_ = [("upperleft", POINT),
+... ("lowerright", POINT)]
+...
+>>> rc = RECT(point)
+>>> print rc.upperleft.x, rc.upperleft.y
+0 5
+>>> print rc.lowerright.x, rc.lowerright.y
+0 0
+>>>
+</pre>
+<p>Nested structures can also be initialized in the constructor in
+several ways:</p>
+<pre class="literal-block">
+>>> r = RECT(POINT(1, 2), POINT(3, 4))
+>>> r = RECT((1, 2), (3, 4))
+</pre>
+<p>Fields descriptors can be retrieved from the <em>class</em>, they are useful
+for debugging because they can provide useful information:</p>
+<pre class="literal-block">
+>>> print POINT.x
+<Field type=c_long, ofs=0, size=4>
+>>> print POINT.y
+<Field type=c_long, ofs=4, size=4>
+>>>
+</pre>
+</div>
+<div class="section" id="structure-union-alignment-and-byte-order">
+<h2><a name="structure-union-alignment-and-byte-order">Structure/union alignment and byte order</a></h2>
+<p>By default, Structure and Union fields are aligned in the same way the
+C compiler does it. It is possible to override this behaviour be
+specifying a <tt class="docutils literal"><span class="pre">_pack_</span></tt> class attribute in the subclass
+definition. This must be set to a positive integer and specifies the
+maximum alignment for the fields. This is what <tt class="docutils literal"><span class="pre">#pragma</span> <span class="pre">pack(n)</span></tt>
+also does in MSVC.</p>
+<p><tt class="docutils literal"><span class="pre">ctypes</span></tt> uses the native byte order for Structures and Unions. To
+build structures with non-native byte order, you can use one of the
+BigEndianStructure, LittleEndianStructure, BigEndianUnion, and
+LittleEndianUnion base classes. These classes cannot contain pointer
+fields.</p>
+</div>
+<div class="section" id="bit-fields-in-structures-and-unions">
+<h2><a name="bit-fields-in-structures-and-unions">Bit fields in structures and unions</a></h2>
+<p>It is possible to create structures and unions containing bit fields.
+Bit fields are only possible for integer fields, the bit width is
+specified as the third item in the <tt class="docutils literal"><span class="pre">_fields_</span></tt> tuples:</p>
+<pre class="literal-block">
+>>> class Int(Structure):
+... _fields_ = [("first_16", c_int, 16),
+... ("second_16", c_int, 16)]
+...
+>>> print Int.first_16
+<Field type=c_long, ofs=0:0, bits=16>
+>>> print Int.second_16
+<Field type=c_long, ofs=0:16, bits=16>
+>>>
+</pre>
+</div>
+<div class="section" id="arrays">
+<h2><a name="arrays">Arrays</a></h2>
+<p>Arrays are sequences, containing a fixed number of instances of the
+same type.</p>
+<p>The recommended way to create array types is by multiplying a data
+type with a positive integer:</p>
+<pre class="literal-block">
+TenPointsArrayType = POINT * 10
+</pre>
+<p>Here is an example of an somewhat artifical data type, a structure
+containing 4 POINTs among other stuff:</p>
+<pre class="literal-block">
+>>> from ctypes import *
+>>> class POINT(Structure):
+... _fields_ = ("x", c_int), ("y", c_int)
+...
+>>> class MyStruct(Structure):
+... _fields_ = [("a", c_int),
+... ("b", c_float),
+... ("point_array", POINT * 4)]
+>>>
+>>> print len(MyStruct().point_array)
+4
+</pre>
+<p>Instances are created in the usual way, by calling the class:</p>
+<pre class="literal-block">
+arr = TenPointsArrayType()
+for pt in arr:
+ print pt.x, pt.y
+</pre>
+<p>The above code print a series of <tt class="docutils literal"><span class="pre">0</span> <span class="pre">0</span></tt> lines, because the array
+contents is initialized to zeros.</p>
+<p>Initializers of the correct type can also be specified:</p>
+<pre class="literal-block">
+>>> from ctypes import *
+>>> TenIntegers = c_int * 10
+>>> ii = TenIntegers(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
+>>> print ii
+<c_long_Array_10 object at 0x...>
+>>> for i in ii: print i,
+...
+1 2 3 4 5 6 7 8 9 10
+>>>
+</pre>
+</div>
+<div class="section" id="pointers">
+<h2><a name="pointers">Pointers</a></h2>
+<p>Pointer instances are created by calling the <tt class="docutils literal"><span class="pre">pointer</span></tt> function on a
+<tt class="docutils literal"><span class="pre">ctypes</span></tt> type:</p>
+<pre class="literal-block">
+>>> from ctypes import *
+>>> i = c_int(42)
+>>> pi = pointer(i)
+>>>
+</pre>
+<p>XXX XXX Not correct: use indexing, not the contents atribute</p>
+<p>Pointer instances have a <tt class="docutils literal"><span class="pre">contents</span></tt> attribute which returns the
+ctypes' type pointed to, the <tt class="docutils literal"><span class="pre">c_int(42)</span></tt> in the above case:</p>
+<pre class="literal-block">
+>>> pi.contents
+c_long(42)
+>>>
+</pre>
+<p>Assigning another <tt class="docutils literal"><span class="pre">c_int</span></tt> instance to the pointer's contents
+attribute would cause the pointer to point to the memory location
+where this is stored:</p>
+<pre class="literal-block">
+>>> pi.contents = c_int(99)
+>>> pi.contents
+c_long(99)
+>>>
+</pre>
+<p>Pointer instances can also be indexed with integers:</p>
+<pre class="literal-block">
+>>> pi[0]
+99
+>>>
+</pre>
+<p>XXX What is this???
+Assigning to an integer index changes the pointed to value:</p>
+<pre class="literal-block">
+>>> i2 = pi[0]
+>>> i2
+99
+>>> pi[0] = 22
+>>> i2
+99
+>>>
+</pre>
+<p>It is also possible to use indexes different from 0, but you must know
+what you're doing when you use this: You access or change arbitrary
+memory locations when you do this. Generally you only use this feature
+if you receive a pointer from a C function, and you <em>know</em> that the
+pointer actually points to an array instead of a single item.</p>
+</div>
+<div class="section" id="pointer-classes-types">
+<h2><a name="pointer-classes-types">Pointer classes/types</a></h2>
+<p>Behind the scenes, the <tt class="docutils literal"><span class="pre">pointer</span></tt> function does more than simply
+create pointer instances, it has to create pointer <em>types</em> first.
+This is done with the <tt class="docutils literal"><span class="pre">POINTER</span></tt> function, which accepts any
+<tt class="docutils literal"><span class="pre">ctypes</span></tt> type, and returns a new type:</p>
+<pre class="literal-block">
+>>> PI = POINTER(c_int)
+>>> PI
+<class 'ctypes.LP_c_long'>
+>>> PI(42) # doctest: +IGNORE_EXCEPTION_DETAIL
+Traceback (most recent call last):
+ File "<stdin>", line 1, in ?
+TypeError: expected c_long instead of int
+>>> PI(c_int(42))
+<ctypes.LP_c_long object at 0x...>
+>>>
+</pre>
+</div>
+<div class="section" id="incomplete-types">
+<h2><a name="incomplete-types">Incomplete Types</a></h2>
+<p><em>Incomplete Types</em> are structures, unions or arrays whose members are
+not yet specified. In C, they are specified by forward declarations, which
+are defined later:</p>
+<pre class="literal-block">
+struct cell; /* forward declaration */
+
+struct {
+ char *name;
+ struct cell *next;
+} cell;
+</pre>
+<p>The straightforward translation into ctypes code would be this, but it
+does not work:</p>
+<pre class="literal-block">
+>>> class cell(Structure):
+... _fields_ = [("name", c_char_p),
+... ("next", POINTER(cell))]
+...
+Traceback (most recent call last):
+ File "<stdin>", line 1, in ?
+ File "<stdin>", line 2, in cell
+NameError: name 'cell' is not defined
+>>>
+</pre>
+<p>because the new <tt class="docutils literal"><span class="pre">class</span> <span class="pre">cell</span></tt> is not available in the class statement
+itself. In <tt class="docutils literal"><span class="pre">ctypes</span></tt>, we can define the <tt class="docutils literal"><span class="pre">cell</span></tt> class and set the
+<tt class="docutils literal"><span class="pre">_fields_</span></tt> attribute later, after the class statement:</p>
+<pre class="literal-block">
+>>> from ctypes import *
+>>> class cell(Structure):
+... pass
+...
+>>> cell._fields_ = [("name", c_char_p),
+... ("next", POINTER(cell))]
+>>>
+</pre>
+<p>Lets try it. We create two instances of <tt class="docutils literal"><span class="pre">cell</span></tt>, and let them point
+to each other, and finally follow the pointer chain a few times:</p>
+<pre class="literal-block">
+>>> c1 = cell()
+>>> c1.name = "foo"
+>>> c2 = cell()
+>>> c2.name = "bar"
+>>> c1.next = pointer(c2)
+>>> c2.next = pointer(c1)
+>>> p = c1
+>>> for i in range(8):
+... print p.name,
+... p = p.next[0]
+...
+foo bar foo bar foo bar foo bar
+>>>
+</pre>
+</div>
+<div class="section" id="callback-functions">
+<h2><a name="callback-functions">Callback functions</a></h2>
+<p><tt class="docutils literal"><span class="pre">ctypes</span></tt> allows to create C callable function pointers from Python
+callables. These are sometimes called <em>callback functions</em>.</p>
+<p>First, you must create a class for the callback function, the class
+knows the calling convention, the return type, and the number and
+types of arguments this function will receive.</p>
+<p>The CFUNCTYPE factory function creates types for callback functions
+using the normal cdecl calling convention, and, on Windows, the
+WINFUNCTYPE factory function creates types for callback functions
+using the stdcall calling convention.</p>
+<p>Both of these factory functions are called with the result type as
+first argument, and the callback functions expected argument types as
+the remaining arguments.</p>
+<p>I will present an example here which uses the standard C library's
+<tt class="docutils literal"><span class="pre">qsort</span></tt> function, this is used to sort items with the help of a
+callback function. <tt class="docutils literal"><span class="pre">qsort</span></tt> will be used to sort an array of
+integers:</p>
+<pre class="literal-block">
+>>> IntArray5 = c_int * 5
+>>> ia = IntArray5(5, 1, 7, 33, 99)
+>>> qsort = libc.qsort
+>>> qsort.restype = None
+>>>
+</pre>
+<p><tt class="docutils literal"><span class="pre">qsort</span></tt> must be called with a pointer to the data to sort, the
+number of items in the data array, the size of one item, and a pointer
+to the comparison function, the callback. The callback will then be
+called with two pointers to items, and it must return a negative
+integer if the first item is smaller than the second, a zero if they
+are equal, and a positive integer else.</p>
+<p>So our callback function receives pointers to integers, and must
+return an integer. First we create the <tt class="docutils literal"><span class="pre">type</span></tt> for the callback
+function:</p>
+<pre class="literal-block">
+>>> CMPFUNC = CFUNCTYPE(c_int, POINTER(c_int), POINTER(c_int))
+>>>
+</pre>
+<p>For the first implementation of the callback function, we simply print
+the arguments we get, and return 0 (incremental development ;-):</p>
+<pre class="literal-block">
+>>> def py_cmp_func(a, b):
+... print "py_cmp_func", a, b
+... return 0
+...
+>>>
+</pre>
+<p>Create the C callable callback:</p>
+<pre class="literal-block">
+>>> cmp_func = CMPFUNC(py_cmp_func)
+>>>
+</pre>
+<p>And we're ready to go:</p>
+<pre class="literal-block">
+>>> qsort(ia, len(ia), sizeof(c_int), cmp_func) # doctest: +WINDOWS
+py_cmp_func <ctypes.LP_c_long object at 0x00...> <ctypes.LP_c_long object at 0x00...>
+py_cmp_func <ctypes.LP_c_long object at 0x00...> <ctypes.LP_c_long object at 0x00...>
+py_cmp_func <ctypes.LP_c_long object at 0x00...> <ctypes.LP_c_long object at 0x00...>
+py_cmp_func <ctypes.LP_c_long object at 0x00...> <ctypes.LP_c_long object at 0x00...>
+py_cmp_func <ctypes.LP_c_long object at 0x00...> <ctypes.LP_c_long object at 0x00...>
+py_cmp_func <ctypes.LP_c_long object at 0x00...> <ctypes.LP_c_long object at 0x00...>
+py_cmp_func <ctypes.LP_c_long object at 0x00...> <ctypes.LP_c_long object at 0x00...>
+py_cmp_func <ctypes.LP_c_long object at 0x00...> <ctypes.LP_c_long object at 0x00...>
+py_cmp_func <ctypes.LP_c_long object at 0x00...> <ctypes.LP_c_long object at 0x00...>
+py_cmp_func <ctypes.LP_c_long object at 0x00...> <ctypes.LP_c_long object at 0x00...>
+>>>
+</pre>
+<p>We know how to access the contents of a pointer, so lets redefine our callback:</p>
+<pre class="literal-block">
+>>> def py_cmp_func(a, b):
+... print "py_cmp_func", a[0], b[0]
+... return 0
+...
+>>> cmp_func = CMPFUNC(py_cmp_func)
+>>>
+</pre>
+<p>Here is what we get on Windows:</p>
+<pre class="literal-block">
+>>> qsort(ia, len(ia), sizeof(c_int), cmp_func) # doctest: +WINDOWS
+py_cmp_func 7 1
+py_cmp_func 33 1
+py_cmp_func 99 1
+py_cmp_func 5 1
+py_cmp_func 7 5
+py_cmp_func 33 5
+py_cmp_func 99 5
+py_cmp_func 7 99
+py_cmp_func 33 99
+py_cmp_func 7 33
+>>>
+</pre>
+<p>It is funny to see that on linux the sort function seems to work much
+more efficient, it is doing less comparisons:</p>
+<pre class="literal-block">
+>>> qsort(ia, len(ia), sizeof(c_int), cmp_func) # doctest: +LINUX
+py_cmp_func 5 1
+py_cmp_func 33 99
+py_cmp_func 7 33
+py_cmp_func 5 7
+py_cmp_func 1 7
+>>>
+</pre>
+<p>Ah, we're nearly done! The last step is to actually compare the two
+items and return a useful result:</p>
+<pre class="literal-block">
+>>> def py_cmp_func(a, b):
+... print "py_cmp_func", a[0], b[0]
+... return a[0] - b[0]
+...
+>>>
+</pre>
+<p>Final run on Windows:</p>
+<pre class="literal-block">
+>>> qsort(ia, len(ia), sizeof(c_int), CMPFUNC(py_cmp_func)) # doctest: +WINDOWS
+py_cmp_func 33 7
+py_cmp_func 99 33
+py_cmp_func 5 99
+py_cmp_func 1 99
+py_cmp_func 33 7
+py_cmp_func 1 33
+py_cmp_func 5 33
+py_cmp_func 5 7
+py_cmp_func 1 7
+py_cmp_func 5 1
+>>>
+</pre>
+<p>and on Linux:</p>
+<pre class="literal-block">
+>>> qsort(ia, len(ia), sizeof(c_int), CMPFUNC(py_cmp_func)) # doctest: +LINUX
+py_cmp_func 5 1
+py_cmp_func 33 99
+py_cmp_func 7 33
+py_cmp_func 1 7
+py_cmp_func 5 7
+>>>
+</pre>
+<p>So, our array sorted now:</p>
+<pre class="literal-block">
+>>> for i in ia: print i,
+...
+1 5 7 33 99
+>>>
+</pre>
+<p><strong>Important note for callback functions:</strong></p>
+<p>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.</p>
+</div>
+<div class="section" id="accessing-values-exported-from-dlls">
+<h2><a name="accessing-values-exported-from-dlls">Accessing values exported from dlls</a></h2>
+<p>Sometimes, a dll not only exports functions, it also exports
+values. An example in the Python library itself is the
+<tt class="docutils literal"><span class="pre">Py_OptimizeFlag</span></tt>, an integer set to 0, 1, or 2, depending on the
+<tt class="docutils literal"><span class="pre">-O</span></tt> or <tt class="docutils literal"><span class="pre">-OO</span></tt> flag given on startup.</p>
+<p><tt class="docutils literal"><span class="pre">ctypes</span></tt> can access values like this with the <tt class="docutils literal"><span class="pre">in_dll</span></tt> class
+methods of the type. <tt class="docutils literal"><span class="pre">pythonapi</span></tt> ìs a predefined symbol giving
+access to the Python C api:</p>
+<pre class="literal-block">
+>>> opt_flag = c_int.in_dll(pythonapi, "Py_OptimizeFlag")
+>>> print opt_flag
+c_long(0)
+>>>
+</pre>
+<p>If the interpreter would have been started with <tt class="docutils literal"><span class="pre">-O</span></tt>, the sample
+would have printed <tt class="docutils literal"><span class="pre">c_long(1)</span></tt>, or <tt class="docutils literal"><span class="pre">c_long(2)</span></tt> if <tt class="docutils literal"><span class="pre">-OO</span></tt> would have
+been specified.</p>
+<p>An extended example which also demonstrates the use of pointers
+accesses the <tt class="docutils literal"><span class="pre">PyImport_FrozenModules</span></tt> pointer exported by Python.</p>
+<p>Quoting the Python docs: <em>This pointer is initialized to point to an
+array of ``struct _frozen`` records, terminated by one whose members
+are all NULL or zero. When a frozen module is imported, it is searched
+in this table. Third-party code could play tricks with this to provide
+a dynamically created collection of frozen modules.</em></p>
+<p>So manipulating this pointer could even prove useful. To restrict the
+example size, we show only how this table can be read with
+<tt class="docutils literal"><span class="pre">ctypes</span></tt>:</p>
+<pre class="literal-block">
+>>> from ctypes import *
+>>>
+>>> class struct_frozen(Structure):
+... _fields_ = [("name", c_char_p),
+... ("code", POINTER(c_ubyte)),
+... ("size", c_int)]
+...
+>>>
+</pre>
+<p>We have defined the <tt class="docutils literal"><span class="pre">struct</span> <span class="pre">_frozen</span></tt> data type, so we can get the
+pointer to the table:</p>
+<pre class="literal-block">
+>>> FrozenTable = POINTER(struct_frozen)
+>>> table = FrozenTable.in_dll(pythonapi, "PyImport_FrozenModules")
+>>>
+</pre>
+<p>Since <tt class="docutils literal"><span class="pre">table</span></tt> is a <tt class="docutils literal"><span class="pre">pointer</span></tt> to the array of <tt class="docutils literal"><span class="pre">struct_frozen</span></tt>
+records, we can iterate over it, but we just have to make sure that
+our loop terminates, because pointers have no size. Sooner or later it
+would probably crash with an access violation or whatever, so it's
+better to break out of the loop when we hit the NULL entry:</p>
+<pre class="literal-block">
+>>> for item in table:
+... print item.name, item.size
+... if item.name is None:
+... break
+...
+__hello__ 104
+__phello__ -104
+__phello__.spam 104
+None 0
+>>>
+</pre>
+<p>The fact that standard Python has a frozen module and a frozen package
+(indicated by the negative size member) is not wellknown, it is only
+used for testing. Try it out with <tt class="docutils literal"><span class="pre">import</span> <span class="pre">__hello__</span></tt> for example.</p>
+<p>XXX Describe how to access the <tt class="docutils literal"><span class="pre">code</span></tt> member fields, which contain
+the byte code for the modules.</p>
+</div>
+<div class="section" id="surprises">
+<h2><a name="surprises">Surprises</a></h2>
+<p>There are some edges in <tt class="docutils literal"><span class="pre">ctypes</span></tt> where you may be expect something
+else than what actually happens.</p>
+<p>Consider the following example:</p>
+<pre class="literal-block">
+>>> from ctypes import *
+>>> class POINT(Structure):
+... _fields_ = ("x", c_int), ("y", c_int)
+...
+>>> class RECT(Structure):
+... _fields_ = ("a", POINT), ("b", POINT)
+...
+>>> p1 = POINT(1, 2)
+>>> p2 = POINT(3, 4)
+>>> rc = RECT(p1, p2)
+>>> print rc.a.x, rc.a.y, rc.b.x, rc.b.y
+1 2 3 4
+>>> # now swap the two points
+>>> rc.a, rc.b = rc.b, rc.a
+>>> print rc.a.x, rc.a.y, rc.b.x, rc.b.y
+3 4 3 4
+</pre>
+<p>Hm. We certainly expected the last statement to print <tt class="docutils literal"><span class="pre">3</span> <span class="pre">4</span> <span class="pre">1</span> <span class="pre">2</span></tt>.
+What happended? Here are the steps of the <tt class="docutils literal"><span class="pre">rc.a,</span> <span class="pre">rc.b</span> <span class="pre">=</span> <span class="pre">rc.b,</span> <span class="pre">rc.a</span></tt>
+line above:</p>
+<pre class="literal-block">
+>>> temp0, temp1 = rc.b, rc.a
+>>> rc.a = temp0
+>>> rc.b = temp1
+</pre>
+<p>Note that <tt class="docutils literal"><span class="pre">temp0</span></tt> and <tt class="docutils literal"><span class="pre">temp1</span></tt> are objects still using the internal
+buffer of the <tt class="docutils literal"><span class="pre">rc</span></tt> object above. So executing <tt class="docutils literal"><span class="pre">rc.a</span> <span class="pre">=</span> <span class="pre">temp0</span></tt>
+copies the buffer contents of <tt class="docutils literal"><span class="pre">temp0</span></tt> into <tt class="docutils literal"><span class="pre">rc</span></tt> 's buffer. This,
+in turn, changes the contents of <tt class="docutils literal"><span class="pre">temp1</span></tt>. So, the last assignment
+<tt class="docutils literal"><span class="pre">rc.b</span> <span class="pre">=</span> <span class="pre">temp1</span></tt>, doesn't have the expected effect.</p>
+<p>Keep in mind that retrieving subobjects from Structure, Unions, and
+Arrays doesn't <em>copy</em> the subobject, instead it retrieves a wrapper
+object accessing the root-object's underlying buffer.</p>
+<p>Another example that may behave different from what one would expect is this:</p>
+<pre class="literal-block">
+>>> s = c_char_p()
+>>> s.value = "abc def ghi"
+>>> s.value
+'abc def ghi'
+>>> s.value is s.value
+False
+>>>
+</pre>
+<p>Why is it printing <tt class="docutils literal"><span class="pre">False</span></tt>? ctypes instances are objects containing
+a memory block plus some descriptors accessing the contents of the
+memory. Storing a Python object in the memory block does not store
+the object itself, instead the <tt class="docutils literal"><span class="pre">contents</span></tt> of the object is stored.
+Accessing the contents again constructs a new Python each time!</p>
+</div>
+<div class="section" id="bugs-todo-and-non-implemented-things">
+<h2><a name="bugs-todo-and-non-implemented-things">Bugs, ToDo and non-implemented things</a></h2>
+<p>Enumeration types are not implemented. You can do it easily yourself,
+using <tt class="docutils literal"><span class="pre">c_int</span></tt> as the base class.</p>
+<p><tt class="docutils literal"><span class="pre">long</span> <span class="pre">double</span></tt> is not implemented.</p>
+<!-- Local Variables:
+compile-command: "make.bat"
+End: -->
+</div>
+</div>
+</div>
+</body>
+</html>
Modified: packages/ctypes/branches/upstream/current/docs/manual/tutorial.txt
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/docs/manual/tutorial.txt?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/docs/manual/tutorial.txt (original)
+++ packages/ctypes/branches/upstream/current/docs/manual/tutorial.txt Mon Jun 19 12:31:53 2006
@@ -1,221 +1,249 @@
+``ctypes`` is a foreign function library for Python.
+
ctypes tutorial
-
- "overview":index.html :: tutorial :: "codegenerator":codegen.html ::
- "reference":reference.html :: "faq":faq.html
-
- ( Work in progress: "COM":com.html :: "COM sample":sum_sample.html )
-
- This tutorial describes version 0.6.3 of 'ctypes'. There have been
- quite some changes to version 0.4.x, the most important are
- listed "here":changes.html.
-
- Loading dynamic link libraries
-
- 'ctypes' exports the 'cdll', and on Windows also 'windll'
- and 'oledll' objects to load dynamic link libraries.
-
- You load libraries by accessing them as attributes of these
- objects. 'cdll' loads libraries which export functions using the
- standard 'cdecl' calling convention, while 'windll' libraries call
- functions using the 'stdcall' calling convention. 'oledll' also
- uses the 'stdcall' calling convention, and assumes the functions
- return a Windows 'HRESULT' error code. The error code is used to
- automatically raise 'WindowsError' Python exceptions when the
- function call fails.
-
- Here are some examples for Windows, note that 'msvcrt' is the MS
- standard C library containing most standard C functions, and uses
- the cdecl calling convention::
+===============
+
+This tutorial describes version 0.9.9 of ``ctypes``.
+
+Note: The code samples in this tutorial uses ``doctest`` to make sure
+that they actually work. Since some code samples behave differently
+under Linux, Windows, or Mac OS X, they contain doctest directives in
+comments.
+
+Note: Quite some code samples references the ctypes ``c_int`` type.
+This type is an alias to the ``c_long`` type on 32-bit systems. So,
+you should not be confused if ``c_long`` is printed if you would
+expect ``c_int`` - they are actually the same type.
+
+Loading dynamic link libraries
+------------------------------
+
+``ctypes`` exports the ``cdll``, and on Windows also ``windll`` and
+``oledll`` objects to load dynamic link libraries.
+
+You load libraries by accessing them as attributes of these objects.
+``cdll`` loads libraries which export functions using the standard
+``cdecl`` calling convention, while ``windll`` libraries call
+functions using the ``stdcall`` calling convention. ``oledll`` also
+uses the ``stdcall`` calling convention, and assumes the functions
+return a Windows ``HRESULT`` error code. The error code is used to
+automatically raise ``WindowsError`` Python exceptions when the
+function call fails.
+
+Here are some examples for Windows, note that ``msvcrt`` is the MS
+standard C library containing most standard C functions, and uses the
+cdecl calling convention::
>>> from ctypes import *
- >>> print windll.kernel32
- <WinDLL 'kernel32', handle 77e80000 at 7ecfe8>
- >>> print cdll.msvcrt
- <CDLL 'msvcrt', handle 78000000 at 80b010>
-
- In principle the same way should work on Linux, but most of the
- time it seems required to specify the search path in this way. So
- this example shows also how to load libraries by specifying their
- filename::
-
- >>> from ctypes import *
- >>> libc = cdll.LoadLibrary("/lib/libc.so.6")
- <CDLL '/lib/libc.so.6', handle 40018c28 at 4019978c>
- >>>
-
- This tutorial uses windows in its examples, however, functions
- from the standard C library like 'strchr' and 'printf' should also
- work on Linux and other systems.
-
- Accessing functions from loaded dlls
-
- Functions are accessed as attributes of dll objects::
+ >>> print windll.kernel32 # doctest: +WINDOWS
+ <WinDLL 'kernel32', handle ... at ...>
+ >>> print cdll.msvcrt # doctest: +WINDOWS
+ <CDLL 'msvcrt', handle ... at ...>
+ >>> libc = cdll.msvcrt # doctest: +WINDOWS
+ >>>
+
+Windows appends the usual '.dll' file suffix automatically.
+
+On Linux, it is required to specify the filename *including* the
+extension to load a library, so attribute access does not work.
+Either the ``LoadLibrary`` method of the dll loaders should be used,
+or you should load the library by creating an instance of CDLL by
+calling the constructor::
+
+ >>> cdll.LoadLibrary("libc.so.6") # doctest: +LINUX
+ <CDLL 'libc.so.6', handle ... at ...>
+ >>> libc = CDLL("libc.so.6") # doctest: +LINUX
+ >>> libc # doctest: +LINUX
+ <CDLL 'libc.so.6', handle ... at ...>
+ >>>
+
+XXX Add section for Mac OS X.
+
+Accessing functions from loaded dlls
+------------------------------------
+
+Functions are accessed as attributes of dll objects::
>>> from ctypes import *
- >>> print cdll.msvcrt.printf
- <ctypes._CdeclFuncPtr object ar 0x00905F68>
- >>> print windll.kernel32.GetModuleHandleA
- <ctypes._StdcallFuncPtr object ar 0x008E6D28>
- >>> print windll.kernel32.MyOwnFunction
+ >>> libc.printf
+ <_FuncPtr object at 0x...>
+ >>> print windll.kernel32.GetModuleHandleA # doctest: +WINDOWS
+ <_FuncPtr object at 0x...>
+ >>> print windll.kernel32.MyOwnFunction # doctest: +WINDOWS
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "ctypes.py", line 239, in __getattr__
func = _StdcallFuncPtr(name, self)
- Attribute: function 'MyOwnFunction' not found
-
- ctypes version 0.6.2 and above raise AttributeErrors when a symbol
- is not found in a dll, before ValueError was raised.
-
- Note that win32 system dlls like 'kernel32' and 'user32' often
- export ANSI as well as UNICODE versions of a function. The UNICODE
- version is exported with an 'W' appended to the name, while the
- ANSI version is exported with an 'A' appended to the name. The
- win32 'GetModuleHandle' function, which returns a *module handle*
- for a given module name, has the following C prototype, and a
- macro is used to expose one of them as 'GetModuleHandle' depending
- on whether UNICODE is defined or not::
+ AttributeError: function 'MyOwnFunction' not found
+ >>>
+
+Note that win32 system dlls like ``kernel32`` and ``user32`` often
+export ANSI as well as UNICODE versions of a function. The UNICODE
+version is exported with an ``W`` appended to the name, while the ANSI
+version is exported with an ``A`` appended to the name. The win32
+``GetModuleHandle`` function, which returns a *module handle* for a
+given module name, has the following C prototype, and a macro is used
+to expose one of them as ``GetModuleHandle`` depending on whether
+UNICODE is defined or not::
/* ANSI version */
HMODULE GetModuleHandleA(LPCSTR lpModuleName);
/* UNICODE version */
HMODULE GetModuleHandleW(LPCWSTR lpModuleName);
- 'windll' does not try to select one of them by magic, you must
- access the version you need by specifying 'GetModuleHandleA' or
- 'GetModuleHandleW' explicitely, and then call it with normal
- strings or unicode strings respectively.
-
- Sometimes, dlls export functions with names which aren't valid
- Python identifiers, like '"??2 at YAPAXI@Z"'. In this case you have
- to use 'getattr' to retrieve the function (XXX Better example?)::
-
- >>> getattr(cdll.msvcrt, "??2 at YAPAXI@Z")
- <ctypes._CdeclFuncPtr object at 0x00905EE0>
- >>>
-
-
- Calling functions
-
- You can call these functions like any other Python callable. This
- example uses the 'time()' function, which returns system time in
- seconds since the UNIX epoch, and the 'GetModuleHandleA()'
- function, which returns a win32 module handle.
-
- This example calls both functions with a NULL pointer ('None'
- should be used as the NULL pointer)::
-
- >>> from ctypes import *
- >>> print cdll.msvcrt.time(None)
- 1048777320
- >>> print hex(windll.kernel32.GetModuleHandleA(None))
- 0x1d000000
-
- 'ctypes' tries at its best to protect you from calling functions
- with the wrong number of arguments. Unfortunately this only works
- on Windows. It does this by examining the stack after the function
- returns::
-
- >>> windll.kernel32.GetModuleHandleA()
+``windll`` does not try to select one of them by magic, you must
+access the version you need by specifying ``GetModuleHandleA`` or
+``GetModuleHandleW`` explicitely, and then call it with normal strings
+or unicode strings respectively.
+
+Sometimes, dlls export functions with names which aren't valid Python
+identifiers, like ``"??2 at YAPAXI@Z"``. In this case you have to use
+``getattr`` to retrieve the function::
+
+ >>> getattr(cdll.msvcrt, "??2 at YAPAXI@Z") # doctest: +WINDOWS
+ <_FuncPtr object at 0x...>
+ >>>
+
+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
+ <_FuncPtr object at 0x...>
+ >>> cdll.kernel32[0] # doctest: +WINDOWS
Traceback (most recent call last):
File "<stdin>", line 1, in ?
- ValueError: Procedure probably called with not enough arguments
- >>> windll.kernel32.GetModuleHandleA(0, 0)
+ File "ctypes.py", line 310, in __getitem__
+ func = _StdcallFuncPtr(name, self)
+ AttributeError: function ordinal 0 not found
+ >>>
+
+Calling functions
+-----------------
+
+You can call these functions like any other Python callable. This
+example uses the ``time()`` function, which returns system time in
+seconds since the UNIX epoch, and the ``GetModuleHandleA()`` function,
+which returns a win32 module handle.
+
+This example calls both functions with a NULL pointer (``None`` should
+be used as the NULL pointer)::
+
+ >>> print libc.time(None)
+ 114...
+ >>> print hex(windll.kernel32.GetModuleHandleA(None)) # doctest: +WINDOWS
+ 0x1d000000
+ >>>
+
+``ctypes`` tries to protect you from calling functions with the wrong
+number of arguments. Unfortunately this only works on Windows. It
+does this by examining the stack after the function returns::
+
+ >>> windll.kernel32.GetModuleHandleA() # doctest: +WINDOWS
Traceback (most recent call last):
File "<stdin>", line 1, in ?
- ValueError: Procedure probably called with too many arguments
- >>>
-
- On Windows, 'ctypes' uses win32 structured exception handling to
- prevent crashes from general protection faults when functions are
- called with invalid argument values::
-
- >>> windll.kernel32.GetModuleHandleA(32)
+ ValueError: Procedure probably called with not enough arguments (4 bytes missing)
+ >>> windll.kernel32.GetModuleHandleA(0, 0) # doctest: +WINDOWS
Traceback (most recent call last):
File "<stdin>", line 1, in ?
- WindowsError: exception: access violation
- >>>
-
- There are, however, enough ways to crash Python with 'ctypes',
- so you should be careful anyway.
-
- Python integers, strings and unicode strings are the only objects
- that can directly be used as parameters in these function calls.
-
- Before we move on calling functions with other parameter types, we
- have to learn more about 'ctypes' data types.
-
- Simple data types
-
- 'ctypes' defines a number of primitive C compatible data types :
-
- |---------------------------------------------|
- |ctypes' type |C type |Python type|
- |=============================================|
- |'c_char' |'char' |character |
- |---------------------------------------------|
- |'c_byte' |'char' |integer |
- |---------------------------------------------|
- |'c_ubyte' |'unsigned char' |integer |
- |---------------------------------------------|
- |'c_short' |'short' |integer |
- |---------------------------------------------|
- |'c_ushort' |'unsigned short' |integer |
- |---------------------------------------------|
- |'c_int' |'int' |integer |
- |---------------------------------------------|
- |'c_uint' |'unsigned int' |integer |
- |---------------------------------------------|
- |'c_long' |'long' |integer |
- |---------------------------------------------|
- |'c_ulong' |'unsigned long' |long |
- |---------------------------------------------|
- |'c_longlong' |'__int64' or |long |
- | |'long long' | |
- |---------------------------------------------|
- |'c_ulonglong'|'unsigned __int64' or|long |
- | |'unsigned long long'| |
- |---------------------------------------------|
- |'c_float' |'float' |float |
- |---------------------------------------------|
- |'c_double' |'double' |float |
- |---------------------------------------------|
- |'c_char_p' |'char *' |string or |
- | |(NUL terminated) |'None' |
- |---------------------------------------------|
- |'c_wchar_p' |'wchar_t *' |unicode or |
- | |(NUL terminated) |'None' |
- |---------------------------------------------|
- |'c_void_p' |'void *' |integer or |
- | | |'None' |
- |---------------------------------------------|
-
- All these types can be created by calling them with an optional
- initializer of the correct type and value::
-
- >>> c_int()
- c_int(0)
- >>> c_char_p("Hello World")
- c_char_p('Hello, World')
- >>> c_uint(-3)
+ ValueError: Procedure probably called with too many arguments (4 bytes in excess)
+ >>>
+
+On Windows, ``ctypes`` uses win32 structured exception handling to
+prevent crashes from general protection faults when functions are
+called with invalid argument values::
+
+ >>> windll.kernel32.GetModuleHandleA(32) # doctest: +WINDOWS
Traceback (most recent call last):
File "<stdin>", line 1, in ?
- ValueError: Value out of range
+ WindowsError: exception: access violation reading 0x00000020
+ >>>
+
+There are, however, enough ways to crash Python with ``ctypes``, so
+you should be careful anyway.
+
+Python integers, strings and unicode strings are the only objects that
+can directly be used as parameters in these function calls.
+
+Before we move on calling functions with other parameter types, we
+have to learn more about ``ctypes`` data types.
+
+Simple data types
+-----------------
+
+``ctypes`` defines a number of primitive C compatible data types :
+
+ +---------------+-----------------------+-----------+
+ |ctypes type |C type |Python type|
+ +===============+=======================+===========+
+ |``c_char`` |``char`` |character |
+ +---------------+-----------------------+-----------+
+ |``c_byte`` |``char`` |integer |
+ +---------------+-----------------------+-----------+
+ |``c_ubyte`` |``unsigned char`` |integer |
+ +---------------+-----------------------+-----------+
+ |``c_short`` |``short`` |integer |
+ +---------------+-----------------------+-----------+
+ |``c_ushort`` |``unsigned short`` |integer |
+ +---------------+-----------------------+-----------+
+ |``c_int`` |``int`` |integer |
+ +---------------+-----------------------+-----------+
+ |``c_uint`` |``unsigned int`` |integer |
+ +---------------+-----------------------+-----------+
+ |``c_long`` |``long`` |integer |
+ +---------------+-----------------------+-----------+
+ |``c_ulong`` |``unsigned long`` |long |
+ +---------------+-----------------------+-----------+
+ |``c_longlong`` |``__int64`` or |long |
+ | |``long long`` | |
+ +---------------+-----------------------+-----------+
+ |``c_ulonglong``|``unsigned __int64`` or|long |
+ | |``unsigned long long`` | |
+ +---------------+-----------------------+-----------+
+ |``c_float`` |``float`` |float |
+ +---------------+-----------------------+-----------+
+ |``c_double`` |``double`` |float |
+ +---------------+-----------------------+-----------+
+ |``c_char_p`` |``char *`` |string or |
+ | |(NUL terminated) |``None`` |
+ +---------------+-----------------------+-----------+
+ |``c_wchar_p`` |``wchar_t *`` |unicode or |
+ | |(NUL terminated) |``None`` |
+ +---------------+-----------------------+-----------+
+ |``c_void_p`` |``void *`` |integer or |
+ | | |``None`` |
+ +---------------+-----------------------+-----------+
+
+
+
+All these types can be created by calling them with an optional
+initializer of the correct type and value::
+
+ >>> c_int()
+ c_long(0)
+ >>> c_char_p("Hello, World")
+ c_char_p('Hello, World')
+ >>> c_ushort(-3)
+ c_ushort(65533)
+ >>>
- Since these types are mutable, their value can also be changed afterwards::
+Since these types are mutable, their value can also be changed
+afterwards::
>>> i = c_int(42)
>>> print i
- c_int(42)
+ c_long(42)
>>> print i.value
42
>>> i.value = -99
>>> print i.value
-99
-
- Assigning a new value to instances of the pointer types
- 'c_char_p', 'c_wchar_p', and 'c_void_p' changes the *memory
- location* they point to, *not the contents* of the memory block
- (of course not, because Python strings are immutable)::
+ >>>
+
+Assigning a new value to instances of the pointer types ``c_char_p``,
+``c_wchar_p``, and ``c_void_p`` changes the *memory location* they
+point to, *not the contents* of the memory block (of course not,
+because Python strings are immutable)::
>>> s = "Hello, World"
>>> c_s = c_char_p(s)
@@ -225,14 +253,14 @@
>>> print c_s
c_char_p('Hi, there')
>>> print s # first string is unchanged
- Hello, World
-
- You should be careful, however, not to pass them to functions
- expecting pointers to mutable memory. If you need mutable memory
- blocks, ctypes has a 'create_string_buffer' function which creates these in
- various ways. The current memory block contents can be accessed
- (or changed) with the 'raw' property, if you want to access it as
- NUL terminated string, use the 'string' property::
+ Hello, World
+
+You should be careful, however, not to pass them to functions
+expecting pointers to mutable memory. If you need mutable memory
+blocks, ctypes has a ``create_string_buffer`` function which creates
+these in various ways. The current memory block contents can be
+accessed (or changed) with the ``raw`` property, if you want to access
+it as NUL terminated string, use the ``string`` property::
>>> from ctypes import *
>>> p = create_string_buffer(3) # create a 3 byte buffer, initialized to NUL bytes
@@ -251,129 +279,124 @@
10 'Hi\x00lo\x00\x00\x00\x00\x00'
>>>
- The 'create_string_buffer' function replaces the 'c_buffer'
- function (which is still available as an alias to the new
- function), as well as the 'c_string' function from earlier ctypes
- releases. To create a mutable memory block containing unicode
- characters of the C type 'wchar_t' use the 'create_unicode_buffer'
- function.
-
- Calling functions, continued
-
- Note that printf prints to the real standard output channel, *not*
- to 'sys.stdout', so these examples will only work at the console
- prompt, not from within *IDLE* or *PythonWin*::
-
- >>> from ctypes import *; printf = cdll.msvcrt.printf
+The ``create_string_buffer`` function replaces the ``c_buffer``
+function (which is still available as an alias), as well as the
+``c_string`` function from earlier ctypes releases. To create a
+mutable memory block containing unicode characters of the C type
+``wchar_t`` use the ``create_unicode_buffer`` function.
+
+Calling functions, continued
+----------------------------
+
+Note that printf prints to the real standard output channel, *not* to
+``sys.stdout``, so these examples will only work at the console
+prompt, not from within *IDLE* or *PythonWin*::
+
+ >>> printf = libc.printf
>>> printf("Hello, %s\n", "World!")
Hello, World!
14
- >>> printf("Hello, %S", u"World!") # Note the upper case S!
+ >>> printf("Hello, %S", u"World!")
Hello, World!
- 14
+ 13
>>> printf("%d bottles of beer\n", 42)
42 bottles of beer
19
>>> printf("%f bottles of beer\n", 42.5)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
- TypeError: Don't know how to convert parameter 2
- >>>
-
- As has been mentioned before, all Python types except intergers,
- strings, and unicode strings have to be wrapped in their
- corresponding 'ctypes' type, so that they can be converted to the
- required C data type::
-
- >>> from ctypes import *
- >>> printf = cdll.msvcrt.printf
+ ArgumentError: argument 2: exceptions.TypeError: Don't know how to convert parameter 2
+ >>>
+
+As has been mentioned before, all Python types except integers,
+strings, and unicode strings have to be wrapped in their corresponding
+``ctypes`` type, so that they can be converted to the required C data
+type::
+
>>> printf("An int %d, a double %f\n", 1234, c_double(3.14))
Integer 1234, double 3.1400001049
- 34
- >>>
-
- Calling functions with your own custom data types
-
- You can also customize 'ctypes' argument conversion to allow
- instances of your own classes be used as function arguments.
- 'ctypes' looks for an '_as_parameter_' attribute and uses this as
- the function argument. Of course, it must be one of integer,
- string, or unicode::
+ 31
+ >>>
+
+Calling functions with your own custom data types
+-------------------------------------------------
+
+You can also customize ``ctypes`` argument conversion to allow
+instances of your own classes be used as function arguments.
+``ctypes`` looks for an ``_as_parameter_`` attribute and uses this as
+the function argument. Of course, it must be one of integer, string,
+or unicode::
>>> class Bottles(object):
... def __init__(self, number):
... self._as_parameter_ = number
...
>>> bottles = Bottles(42)
- >>> from ctypes import *
- >>> printf = cdll.msvcrt.printf
>>> printf("%d bottles of beer\n", bottles)
42 bottles of beer
19
>>>
- If you don't want to store the instance's data in the
- '_as_parameter_' instance variable, you could define a 'property'
- which makes the data avaiblable.
-
- Specifying the required argument types (function prototypes)
-
- It is possible to specify the required argument types of functions
- exported from DLLs by setting the 'argtypes' attribute.
-
- 'argtypes' must be a sequence of C data types (the 'printf'
- function is probably not a good example here, because it takes a
- variable number and different types of parameters depending on the
- format string, on the other hand this is quite handy to experiment
- with this feature)::
-
- >>> from ctypes import *
- >>> printf = cdll.msvcrt.printf
+If you don't want to store the instance's data in the
+``_as_parameter_`` instance variable, you could define a ``property``
+which makes the data avaiblable.
+
+Specifying the required argument types (function prototypes)
+------------------------------------------------------------
+
+It is possible to specify the required argument types of functions
+exported from DLLs by setting the ``argtypes`` attribute.
+
+``argtypes`` must be a sequence of C data types (the ``printf``
+function is probably not a good example here, because it takes a
+variable number and different types of parameters depending on the
+format string, on the other hand this is quite handy to experiment
+with this feature)::
+
>>> printf.argtypes = [c_char_p, c_char_p, c_int, c_double]
>>> printf("String '%s', Int %d, Double %f\n", "Hi", 10, 2.2)
String 'Hi', Int 10, Double 2.200000
-
- Specifying a format protects against incompatible argument types
- (just as a prototype for a C function), and tries to convert the
- arguments to valid types::
+ 37
+ >>>
+
+Specifying a format protects against incompatible argument types (just
+as a prototype for a C function), and tries to convert the arguments
+to valid types::
>>> printf("%d %d %d", 1, 2, 3)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
- TypeError: string expected instead of int instance
+ ArgumentError: argument 2: exceptions.TypeError: wrong type
>>> printf("%s %d %f", "X", 2, 3)
X 2 3.00000012
- >>>
-
- If you have defined your own classes which you pass to function
- calls, you have to implement a 'from_param' class method for them
- to be able to use them in the 'argtypes' sequence. The
- 'from_param' class method receives the Python object passed to the
- function call, it should do a typecheck or whatever is needed to
- make sure this object is acceptable, and then return the object
- itself, it's '_as_parameter_' attribute, or whatever you want to
- pass as the C function argument in this case. Again, the result
- should be an integer, string, unicode, a 'ctypes' instance, or
- something having the '_as_parameter_' attribute.
-
-
- Return types
-
- By default functions are assumed to return integers. Other return
- types can be specified by setting the 'restype' attribute of the
- function object.
-
- Allowed values for 'restype' are simple data types like 'c_int',
- 'c_long', 'c_char' and so on as well as pointers to other data
- types. Functions returning structures are not yet supported.
-
- Here is a more advanced example, it uses the strchr function,
- which expects a string pointer and a char, and returns a pointer
- to a string::
-
- >>> from ctypes import *
- >>> strchr = cdll.msvcrt.strchr
- >>> strchr("abcdef", ord("d"))
+ 12
+ >>>
+
+If you have defined your own classes which you pass to function calls,
+you have to implement a ``from_param`` class method for them to be
+able to use them in the ``argtypes`` sequence. The ``from_param``
+class method receives the Python object passed to the function call,
+it should do a typecheck or whatever is needed to make sure this
+object is acceptable, and then return the object itself, it's
+``_as_parameter_`` attribute, or whatever you want to pass as the C
+function argument in this case. Again, the result should be an
+integer, string, unicode, a ``ctypes`` instance, or something having
+the ``_as_parameter_`` attribute.
+
+
+Return types
+------------
+
+By default functions are assumed to return integers. Other return
+types can be specified by setting the ``restype`` attribute of the
+function object.
+
+Here is a more advanced example, it uses the strchr function, which
+expects a string pointer and a char, and returns a pointer to a
+string::
+
+ >>> strchr = libc.strchr
+ >>> strchr("abcdef", ord("d")) # doctest: +SKIP
8059983
>>> strchr.restype = c_char_p # c_char_p is a pointer to a string
>>> strchr("abcdef", ord("d"))
@@ -382,105 +405,95 @@
None
>>>
- If you want to avoid the 'ord("x")' calls above, you can set the
- 'argtypes' attribute, and the second argument will be converted
- from a single character Python string into a C char::
-
- >>> from ctypes import *
- >>> msvcrt = cdll.msvcrt
- >>> msvcrt.strchr.restype = "s"
- >>> msvcrt.strchr.argtypes = [c_char_p, c_char]
- >>> msvcrt.strchr("abcdef", "d")
+If you want to avoid the ``ord("x")`` calls above, you can set the
+``argtypes`` attribute, and the second argument will be converted from
+a single character Python string into a C char::
+
+ >>> strchr.restype = c_char_p
+ >>> strchr.argtypes = [c_char_p, c_char]
+ >>> strchr("abcdef", "d")
'def'
- >>> msvcrt.strchr("abcdef", "def")
+ >>> strchr("abcdef", "def")
Traceback (most recent call last):
File "<stdin>", line 1, in ?
- TypeError: one character string expected
- >>> print msvcrt.strchr("abcdef", "x")
+ ArgumentError: argument 2: exceptions.TypeError: one character string expected
+ >>> print strchr("abcdef", "x")
None
- >>> print msvcrt.strchr("abcdef", "d")
- "def"
+ >>> strchr("abcdef", "d")
+ 'def'
>>>
-
- 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::
-
- >>> from ctypes import *
- >>> GetModuleHandle = windll.kernel32.GetModuleHandleA
+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
>>> def ValidHandle(value):
... if value == 0:
... raise WinError()
... return value
...
>>>
- >>> GetModuleHandle.restype = ValidHandle
- >>> GetModuleHandle(None)
+ >>> GetModuleHandle.restype = ValidHandle # doctest: +WINDOWS
+ >>> GetModuleHandle(None) # doctest: +WINDOWS
486539264
- >>> GetModuleHandle("something silly")
+ >>> GetModuleHandle("something silly") # doctest: +WINDOWS +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "<stdin>", line 3, in ValidHandle
WindowsError: [Errno 126] The specified module could not be found.
>>>
- 'WinError' is a function which will call Windows 'FormatMessage()'
- api to get the string representation of an error code, and
- *returns* an exception. 'WinError' takes an optional error code
- parameter, if no one is used, it calls 'GetLastError()' to
- retrieve it.
-
- Passing pointers (or: passing parameters by reference)
-
- Sometimes a C api function expects a *pointer* to a data type as
- parameter, probably to write into the corresponding location, or
- if the data is too large to be passed by value. This is also known
- as *passing parameters by reference*.
-
- 'ctypes' exports the 'byref' function which is used to pass
- parameters by reference. The same effect can be achieved with the
- 'pointer' function, although 'pointer' does a lot more work since
- it constructs a real pointer object, so it is faster to use
- 'byref' if you don't need the pointer object in Python itself::
-
- >>> from ctypes import *
- >>> msvcrt = cdll.msvcrt
+``WinError`` is a function which will call Windows ``FormatMessage()``
+api to get the string representation of an error code, and *returns*
+an exception. ``WinError`` takes an optional error code parameter, if
+no one is used, it calls ``GetLastError()`` to retrieve it.
+
+Passing pointers (or: passing parameters by reference)
+------------------------------------------------------
+
+Sometimes a C api function expects a *pointer* to a data type as
+parameter, probably to write into the corresponding location, or if
+the data is too large to be passed by value. This is also known as
+*passing parameters by reference*.
+
+``ctypes`` exports the ``byref`` function which is used to pass
+parameters by reference. The same effect can be achieved with the
+``pointer`` function, although ``pointer`` does a lot more work since
+it constructs a real pointer object, so it is faster to use ``byref``
+if you don't need the pointer object in Python itself::
+
>>> i = c_int()
>>> f = c_float()
>>> s = create_string_buffer('\000' * 32)
>>> print i.value, f.value, repr(s.value)
- 0 0.0 ''
- >>> msvcrt.sscanf("1 3.14 Hello", "%d %f %s",
- ... byref(i), byref(f), s)
+ 0 0.0 ''
+ >>> libc.sscanf("1 3.14 Hello", "%d %f %s",
+ ... byref(i), byref(f), s)
3
>>> print i.value, f.value, repr(s.value)
1 3.1400001049 'Hello'
-
- **Note**
-
- It seems to be a difficult issue, the mailing list gets quite
- some questions about how to call functions expecting pointers.
- If you have suggestions for improvements for the preceeding
- section, please post to
- "ctypes-users":mailto:ctypes-users at lists.sourceforge.net.
-
- Structures and Unions
-
- Structures and unions must derive from the 'Structure' and 'Union'
- base classes which are defined in the 'ctypes' module. Each
- subclass must define a '_fields_' attribute. '_fields_' must be a
- list of *2-tuples*, containing a *field name* and a *field type*.
-
- The field type must be a 'ctypes' type like 'c_int', or any other
- derived 'ctypes' type: structure, union, array, pointer.
-
- Here is a simple example of a POINT structure, which contains two
- integers named 'x' and 'y', and also shows how to initialize a
- structure in the constructor::
+ >>>
+
+Structures and unions
+---------------------
+
+Structures and unions must derive from the ``Structure`` and ``Union``
+base classes which are defined in the ``ctypes`` module. Each subclass
+must define a ``_fields_`` attribute. ``_fields_`` must be a list of
+*2-tuples*, containing a *field name* and a *field type*.
+
+The field type must be a ``ctypes`` type like ``c_int``, or any other
+derived ``ctypes`` type: structure, union, array, pointer.
+
+Here is a simple example of a POINT structure, which contains two
+integers named ``x`` and ``y``, and also shows how to initialize a
+structure in the constructor::
>>> from ctypes import *
>>> class POINT(Structure):
@@ -499,12 +512,12 @@
ValueError: too many initializers
>>>
- You can, however, build much more complicated
- structures. Structures can itself contain other structures by
- using a structure as a field type.
-
- Here is a RECT structure which contains two POINTs named
- 'upperleft' and 'lowerright' ::
+You can, however, build much more complicated structures. Structures
+can itself contain other structures by using a structure as a field
+type.
+
+Here is a RECT structure which contains two POINTs named ``upperleft``
+and ``lowerright`` ::
>>> class RECT(Structure):
... _fields_ = [("upperleft", POINT),
@@ -512,50 +525,75 @@
...
>>> rc = RECT(point)
>>> print rc.upperleft.x, rc.upperleft.y
- 10 20
+ 0 5
>>> print rc.lowerright.x, rc.lowerright.y
0 0
>>>
- Nested structures can also be initialized in the constructor in
- several ways::
+Nested structures can also be initialized in the constructor in
+several ways::
>>> r = RECT(POINT(1, 2), POINT(3, 4))
>>> r = RECT((1, 2), (3, 4))
- Fields descriptors can be retrieved from the *class*, they have
- readonly 'size' and 'offset' attributes describing the size in
- bytes and the offset of this field from the beginning of the
- internal memory buffer::
-
- >>> print POINT.x.size, POINT.x.offset
- 0 4
- >>> print POINT.y.size, POINT.y.offset
- 4 4
- >>>
-
- Structure and Union fields are normally aligned in the same way
- the C compiler would do it by default. It is possible to override
- this behaviour be specifying a '_pack_' class attribute in the
- subclass, it must be set to a positive integer and specifies the
- maximum alignment for the fields. I believe this is what '#pragma
- pack(n)' also does in MSVC.
-
- **New in version 0.6.2**: Structures and unions can also be passed
- *by value* to function calls.
-
- Arrays
-
- Arrays are sequences, containing a fixed number of instances of
- the same type.
-
- The recommended way to create array types is by multiplying a data
- type with a positive integer::
-
- TenPointsArray = POINT * 10
-
- Here is an example of an somewhat artifical data type, a structure
- containing 4 POINTs among other stuff::
+Fields descriptors can be retrieved from the *class*, they are useful
+for debugging because they can provide useful information::
+
+ >>> print POINT.x
+ <Field type=c_long, ofs=0, size=4>
+ >>> print POINT.y
+ <Field type=c_long, ofs=4, size=4>
+ >>>
+
+
+Structure/union alignment and byte order
+----------------------------------------
+
+By default, Structure and Union fields are aligned in the same way the
+C compiler does it. It is possible to override this behaviour be
+specifying a ``_pack_`` class attribute in the subclass
+definition. This must be set to a positive integer and specifies the
+maximum alignment for the fields. This is what ``#pragma pack(n)``
+also does in MSVC.
+
+``ctypes`` uses the native byte order for Structures and Unions. To
+build structures with non-native byte order, you can use one of the
+BigEndianStructure, LittleEndianStructure, BigEndianUnion, and
+LittleEndianUnion base classes. These classes cannot contain pointer
+fields.
+
+
+Bit fields in structures and unions
+-----------------------------------
+
+It is possible to create structures and unions containing bit fields.
+Bit fields are only possible for integer fields, the bit width is
+specified as the third item in the ``_fields_`` tuples::
+
+ >>> class Int(Structure):
+ ... _fields_ = [("first_16", c_int, 16),
+ ... ("second_16", c_int, 16)]
+ ...
+ >>> print Int.first_16
+ <Field type=c_long, ofs=0:0, bits=16>
+ >>> print Int.second_16
+ <Field type=c_long, ofs=0:16, bits=16>
+ >>>
+
+
+Arrays
+------
+
+Arrays are sequences, containing a fixed number of instances of the
+same type.
+
+The recommended way to create array types is by multiplying a data
+type with a positive integer::
+
+ TenPointsArrayType = POINT * 10
+
+Here is an example of an somewhat artifical data type, a structure
+containing 4 POINTs among other stuff::
>>> from ctypes import *
>>> class POINT(Structure):
@@ -563,122 +601,121 @@
...
>>> class MyStruct(Structure):
... _fields_ = [("a", c_int),
- ... ("b", float),
+ ... ("b", c_float),
... ("point_array", POINT * 4)]
>>>
>>> print len(MyStruct().point_array)
4
- Instances are created in the usual way, by calling the class::
-
- arr = TenPointsArray()
+Instances are created in the usual way, by calling the class::
+
+ arr = TenPointsArrayType()
for pt in arr:
print pt.x, pt.y
- The above code print a series of '0 0' lines, because the array
- contents is initialized to zeros.
-
- Initializers of the correct type can also be specified::
+The above code print a series of ``0 0`` lines, because the array
+contents is initialized to zeros.
+
+Initializers of the correct type can also be specified::
>>> from ctypes import *
>>> TenIntegers = c_int * 10
>>> ii = TenIntegers(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
- <__main__.c_int_Array_10 object at 0x009119F0>
+ >>> print ii
+ <c_long_Array_10 object at 0x...>
>>> for i in ii: print i,
...
1 2 3 4 5 6 7 8 9 10
>>>
- Pointers
-
- Pointer instances are created by calling the 'pointer' function
- on a 'ctypes' type::
+Pointers
+--------
+
+Pointer instances are created by calling the ``pointer`` function on a
+``ctypes`` type::
>>> from ctypes import *
>>> i = c_int(42)
>>> pi = pointer(i)
>>>
- Pointer instances have a 'contents' attribute which returns the
- ctypes' type pointed to, the 'c_int(42)' in the above case::
+XXX XXX Not correct: use indexing, not the contents atribute
+
+Pointer instances have a ``contents`` attribute which returns the
+ctypes' type pointed to, the ``c_int(42)`` in the above case::
>>> pi.contents
- c_int(42)
- >>>
-
- Assigning another 'c_int' instance to the pointer's contents
- attribute would cause the pointer to point to the memory location
- where this is stored::
+ c_long(42)
+ >>>
+
+Assigning another ``c_int`` instance to the pointer's contents
+attribute would cause the pointer to point to the memory location
+where this is stored::
>>> pi.contents = c_int(99)
>>> pi.contents
- c_int(99)
- >>>
-
- Pointer instances can also be indexed with integers::
+ c_long(99)
+ >>>
+
+Pointer instances can also be indexed with integers::
>>> pi[0]
99
>>>
- Assigning to an integer index changes the pointed to value::
+XXX What is this???
+Assigning to an integer index changes the pointed to value::
>>> i2 = pi[0]
>>> i2
- c_int(99)
+ 99
>>> pi[0] = 22
>>> i2
- c_int(22)
- >>>
-
- It is also possible to use indexes different from 0, but you must
- know what you're doing when you use this: You access or change
- arbitrary memory locations when you do this. Generally you only
- use this feature if you receive a pointer from a C function, and
- you *know* that the pointer actually points to an array instead
- of a single item.
-
- Pointer classes/types
-
- Behind the scenes, the 'pointer' function does more than simply
- create pointer instances, it has to create pointer *types* first.
- This is done with the 'POINTER' function, which accepts any
- 'ctypes' type, and returns a new type::
-
- >>> from ctypes import *
+ 99
+ >>>
+
+It is also possible to use indexes different from 0, but you must know
+what you're doing when you use this: You access or change arbitrary
+memory locations when you do this. Generally you only use this feature
+if you receive a pointer from a C function, and you *know* that the
+pointer actually points to an array instead of a single item.
+
+Pointer classes/types
+---------------------
+
+Behind the scenes, the ``pointer`` function does more than simply
+create pointer instances, it has to create pointer *types* first.
+This is done with the ``POINTER`` function, which accepts any
+``ctypes`` type, and returns a new type::
+
>>> PI = POINTER(c_int)
>>> PI
- <class 'ctypes.LP_c_int>
- >>> PI(42)
+ <class 'ctypes.LP_c_long'>
+ >>> PI(42) # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
File "<stdin>", line 1, in ?
- TypeError: expected c_int instead of int
+ TypeError: expected c_long instead of int
>>> PI(c_int(42))
- <ctypes.LP_c_int object at 0x008ECCE8>
- >>>
-
- Incomplete Types
-
- **Note:** This code actually works now with ctypes 0.6.3
-
- *Incomplete Types* are structures, unions or arrays whose members
- are not yet specified. In the 'ctypes' context, you can create
- types representing pointers to these incomplete types by passing
- their name (as a string) to the POINTER function, and complete the
- result subclass later.
-
- Consider this example (C-code)::
-
- struct cell;
-
- struct {
- char *name;
- struct cell *next;
- } cell;
-
- The straightforward translation into ctypes code would be this,
- but it does not work::
+ <ctypes.LP_c_long object at 0x...>
+ >>>
+
+Incomplete Types
+----------------
+
+*Incomplete Types* are structures, unions or arrays whose members are
+not yet specified. In C, they are specified by forward declarations, which
+are defined later::
+
+ struct cell; /* forward declaration */
+
+ struct {
+ char *name;
+ struct cell *next;
+ } cell;
+
+The straightforward translation into ctypes code would be this, but it
+does not work::
>>> class cell(Structure):
... _fields_ = [("name", c_char_p),
@@ -690,32 +727,27 @@
NameError: name 'cell' is not defined
>>>
- because the new 'class cell' is not available in the class
- statement itself.
-
- We can do it by creating an *incomplete pointer type* by
- calling POINTER with the class _name_, and later setting the
- complete type after it is defined::
+because the new ``class cell`` is not available in the class statement
+itself. In ``ctypes``, we can define the ``cell`` class and set the
+``_fields_`` attribute later, after the class statement::
>>> from ctypes import *
- >>> lpcell = POINTER("cell")
>>> class cell(Structure):
- ... _fields_ = [("name", c_char_p),
- ... ("next", lpcell)]
+ ... pass
...
- >>> SetPointerType(lpcell, cell)
- >>>
-
- Lets try it. We create two instances of 'cell', and let them
- point to each other, and finally follow the pointer chain a few
- times::
+ >>> cell._fields_ = [("name", c_char_p),
+ ... ("next", POINTER(cell))]
+ >>>
+
+Lets try it. We create two instances of ``cell``, and let them point
+to each other, and finally follow the pointer chain a few times::
>>> c1 = cell()
>>> c1.name = "foo"
>>> c2 = cell()
>>> c2.name = "bar"
>>> c1.next = pointer(c2)
- >>> c2.next = pointer(c2)
+ >>> c2.next = pointer(c1)
>>> p = c1
>>> for i in range(8):
... print p.name,
@@ -725,54 +757,52 @@
>>>
- Callback functions
-
- (This example is too long, I should have used a shorter
- array)
-
- 'ctypes' allows to create C callable function pointers from Python
- callables. These are sometimes called *callback functions*.
-
- First, you must create a class for the callback function, the
- class knows the calling convention, the result type the function
- has to return, and the number and types of the arguments this
- function will receive.
-
- 'ctypes' provides the CFUNCTYPE factory function to create types
- for callback functions using the normal cdecl calling convention,
- and, on Windows, the WINFUNCTYPE factory function to create types
- for callback functions using the stdcall calling convention.
-
- Both of these factory functions are called with the result type as
- first argument, and the callback functions expected argument types
- as the remaining arguments.
-
- I will present an example here which uses the standard C library's
- 'qsort' function, this is used to sort items with the help of a
- callback function. 'qsort' will be used to sort an array of integers::
+Callback functions
+------------------
+
+``ctypes`` allows to create C callable function pointers from Python
+callables. These are sometimes called *callback functions*.
+
+First, you must create a class for the callback function, the class
+knows the calling convention, the return type, and the number and
+types of arguments this function will receive.
+
+The CFUNCTYPE factory function creates types for callback functions
+using the normal cdecl calling convention, and, on Windows, the
+WINFUNCTYPE factory function creates types for callback functions
+using the stdcall calling convention.
+
+Both of these factory functions are called with the result type as
+first argument, and the callback functions expected argument types as
+the remaining arguments.
+
+I will present an example here which uses the standard C library's
+``qsort`` function, this is used to sort items with the help of a
+callback function. ``qsort`` will be used to sort an array of
+integers::
- >>> from ctypes import *
- >>> IntArray10 = c_int * 10
- >>> ia = IntArray10(5, 4, 3, 1, 7, 9, 33, 2, 99, 0)
- >>> qsort = cdll.msvcrt.qsort
- >>>
-
- 'qsort' must be called with a pointer to the data to sort, the
- number of items in the data array, the size of one item, and the
- sort function, which is the callback. The callback function will
- then be called with two pointers to items, and it must return a
- negative integer if the first item is smaller than the second, a 0
- if they are equal, and a positive integer else.
-
- So our callback function receives pointers to integers, and must
- return an integer. First we create the 'type' for the callback
- function::
+ >>> IntArray5 = c_int * 5
+ >>> ia = IntArray5(5, 1, 7, 33, 99)
+ >>> qsort = libc.qsort
+ >>> qsort.restype = None
+ >>>
+
+``qsort`` must be called with a pointer to the data to sort, the
+number of items in the data array, the size of one item, and a pointer
+to the comparison function, the callback. The callback will then be
+called with two pointers to items, and it must return a negative
+integer if the first item is smaller than the second, a zero if they
+are equal, and a positive integer else.
+
+So our callback function receives pointers to integers, and must
+return an integer. First we create the ``type`` for the callback
+function::
>>> CMPFUNC = CFUNCTYPE(c_int, POINTER(c_int), POINTER(c_int))
>>>
- For the first implementation of the callback function, we simply
- print the arguments we get, and return 0 (incremental development)::
+For the first implementation of the callback function, we simply print
+the arguments we get, and return 0 (incremental development ;-)::
>>> def py_cmp_func(a, b):
... print "py_cmp_func", a, b
@@ -780,161 +810,143 @@
...
>>>
- Create the C callable function::
+Create the C callable callback::
>>> cmp_func = CMPFUNC(py_cmp_func)
>>>
- And we're ready to go::
-
- >>> qsort(ia, len(ia), sizeof(c_int), cmp_func)
- py_cmp_func <ctypes.LP_c_int object at 0x009127E8> <ctypes.LP_c_int object at 0x00927DF8>
- py_cmp_func <ctypes.LP_c_int object at 0x009127E8> <ctypes.LP_c_int object at 0x00927DF8>
- py_cmp_func <ctypes.LP_c_int object at 0x009127E8> <ctypes.LP_c_int object at 0x00927DF8>
- py_cmp_func <ctypes.LP_c_int object at 0x009127E8> <ctypes.LP_c_int object at 0x00927DF8>
- py_cmp_func <ctypes.LP_c_int object at 0x009127E8> <ctypes.LP_c_int object at 0x00927DF8>
- py_cmp_func <ctypes.LP_c_int object at 0x009127E8> <ctypes.LP_c_int object at 0x00927DF8>
- py_cmp_func <ctypes.LP_c_int object at 0x009127E8> <ctypes.LP_c_int object at 0x00927DF8>
- py_cmp_func <ctypes.LP_c_int object at 0x009127E8> <ctypes.LP_c_int object at 0x00927DF8>
- py_cmp_func <ctypes.LP_c_int object at 0x009127E8> <ctypes.LP_c_int object at 0x00927DF8>
- py_cmp_func <ctypes.LP_c_int object at 0x009127E8> <ctypes.LP_c_int object at 0x00927DF8>
- py_cmp_func <ctypes.LP_c_int object at 0x009127E8> <ctypes.LP_c_int object at 0x00927DF8>
- py_cmp_func <ctypes.LP_c_int object at 0x009127E8> <ctypes.LP_c_int object at 0x00927DF8>
- py_cmp_func <ctypes.LP_c_int object at 0x009127E8> <ctypes.LP_c_int object at 0x00927DF8>
- py_cmp_func <ctypes.LP_c_int object at 0x009127E8> <ctypes.LP_c_int object at 0x00927DF8>
- py_cmp_func <ctypes.LP_c_int object at 0x009127E8> <ctypes.LP_c_int object at 0x00927DF8>
- py_cmp_func <ctypes.LP_c_int object at 0x009127E8> <ctypes.LP_c_int object at 0x00927DF8>
- py_cmp_func <ctypes.LP_c_int object at 0x009127E8> <ctypes.LP_c_int object at 0x00927DF8>
- py_cmp_func <ctypes.LP_c_int object at 0x009127E8> <ctypes.LP_c_int object at 0x00927DF8>
- py_cmp_func <ctypes.LP_c_int object at 0x009127E8> <ctypes.LP_c_int object at 0x00927DF8>
- -1
- >>>
-
- We know how to access the contents of a pointer, so lets redefine our callback::
-
- >>> def py_cmp_func(a, b):
- ... print "py_cmp_func", a[0], b[0]
- ... return 0
- ...
- >>> cmp_func = CMPFUNC(py_cmp_func)
- >>> qsort(ia, len(ia), sizeof(c_int), cmp_func)
- py_cmp_func 5 9
- py_cmp_func 5 0
- py_cmp_func 9 0
- py_cmp_func 4 9
- py_cmp_func 3 9
- py_cmp_func 1 9
- py_cmp_func 7 9
- py_cmp_func 33 9
- py_cmp_func 2 9
- py_cmp_func 99 9
- py_cmp_func 0 9
- py_cmp_func 99 9
- py_cmp_func 99 9
- py_cmp_func 2 9
- py_cmp_func 33 9
- py_cmp_func 7 9
- py_cmp_func 1 9
- py_cmp_func 3 9
- py_cmp_func 4 9
- -1
- >>>
-
- Ah, we're nearly done! Last refinements::
-
- >>> def py_cmp_func(a, b):
- ... print "py_cmp_func", a[0], b[0]
- ... return a[0] - b[0]
- ...
- >>> qsort(ia, len(ia), sizeof(c_int), CMPFUNC(py_cmp_func))
- py_cmp_func 5 9
- py_cmp_func 5 0
- py_cmp_func 9 5
- py_cmp_func 4 5
- py_cmp_func 3 5
- py_cmp_func 1 5
- py_cmp_func 7 5
- py_cmp_func 99 5
- py_cmp_func 2 5
- py_cmp_func 33 5
- py_cmp_func 33 5
- py_cmp_func 2 5
- py_cmp_func 7 33
- py_cmp_func 99 33
- py_cmp_func 9 99
- py_cmp_func 7 33
- py_cmp_func 9 33
- py_cmp_func 7 9
- py_cmp_func 4 0
- py_cmp_func 3 4
- py_cmp_func 1 4
- py_cmp_func 2 4
- py_cmp_func 2 0
- py_cmp_func 3 2
- py_cmp_func 1 3
- py_cmp_func 2 0
- py_cmp_func 1 2
- py_cmp_func 1 0
- -1
- >>>
-
- So, is our array sorted now::
-
- >>> for i in ia: print i,
- ...
- 0 1 2 3 4 5 7 9 33 99
- >>>
-
- Yep, it worked!
-
- A warning for callback functions
-
- **Important Note**:
-
- 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.
-
- Accessing values exported from dlls
-
- Sometimes, a dll not only exports functions, it also exports
- values. Examples in the Python dll itself are the
- 'Py_OptimizeFlag', an integer set to 0, 1, or 2, depending on the
- '-O' or '-OO' flag given on startup.
-
- Starting with version 0.6.1, 'ctypes' can access values like this
- with the 'in_dll' class methods of the types. The following
- examples only work on Windows::
+And we're ready to go::
+
+ >>> qsort(ia, len(ia), sizeof(c_int), cmp_func) # doctest: +WINDOWS
+ py_cmp_func <ctypes.LP_c_long object at 0x00...> <ctypes.LP_c_long object at 0x00...>
+ py_cmp_func <ctypes.LP_c_long object at 0x00...> <ctypes.LP_c_long object at 0x00...>
+ py_cmp_func <ctypes.LP_c_long object at 0x00...> <ctypes.LP_c_long object at 0x00...>
+ py_cmp_func <ctypes.LP_c_long object at 0x00...> <ctypes.LP_c_long object at 0x00...>
+ py_cmp_func <ctypes.LP_c_long object at 0x00...> <ctypes.LP_c_long object at 0x00...>
+ py_cmp_func <ctypes.LP_c_long object at 0x00...> <ctypes.LP_c_long object at 0x00...>
+ py_cmp_func <ctypes.LP_c_long object at 0x00...> <ctypes.LP_c_long object at 0x00...>
+ py_cmp_func <ctypes.LP_c_long object at 0x00...> <ctypes.LP_c_long object at 0x00...>
+ py_cmp_func <ctypes.LP_c_long object at 0x00...> <ctypes.LP_c_long object at 0x00...>
+ py_cmp_func <ctypes.LP_c_long object at 0x00...> <ctypes.LP_c_long object at 0x00...>
+ >>>
+
+We know how to access the contents of a pointer, so lets redefine our callback::
+
+ >>> def py_cmp_func(a, b):
+ ... print "py_cmp_func", a[0], b[0]
+ ... return 0
+ ...
+ >>> cmp_func = CMPFUNC(py_cmp_func)
+ >>>
+
+Here is what we get on Windows::
+
+ >>> qsort(ia, len(ia), sizeof(c_int), cmp_func) # doctest: +WINDOWS
+ py_cmp_func 7 1
+ py_cmp_func 33 1
+ py_cmp_func 99 1
+ py_cmp_func 5 1
+ py_cmp_func 7 5
+ py_cmp_func 33 5
+ py_cmp_func 99 5
+ py_cmp_func 7 99
+ py_cmp_func 33 99
+ py_cmp_func 7 33
+ >>>
+
+It is funny to see that on linux the sort function seems to work much
+more efficient, it is doing less comparisons::
+
+ >>> qsort(ia, len(ia), sizeof(c_int), cmp_func) # doctest: +LINUX
+ py_cmp_func 5 1
+ py_cmp_func 33 99
+ py_cmp_func 7 33
+ py_cmp_func 5 7
+ py_cmp_func 1 7
+ >>>
+
+Ah, we're nearly done! The last step is to actually compare the two
+items and return a useful result::
+
+ >>> def py_cmp_func(a, b):
+ ... print "py_cmp_func", a[0], b[0]
+ ... return a[0] - b[0]
+ ...
+ >>>
+
+Final run on Windows::
+
+ >>> qsort(ia, len(ia), sizeof(c_int), CMPFUNC(py_cmp_func)) # doctest: +WINDOWS
+ py_cmp_func 33 7
+ py_cmp_func 99 33
+ py_cmp_func 5 99
+ py_cmp_func 1 99
+ py_cmp_func 33 7
+ py_cmp_func 1 33
+ py_cmp_func 5 33
+ py_cmp_func 5 7
+ py_cmp_func 1 7
+ py_cmp_func 5 1
+ >>>
+
+and on Linux::
+
+ >>> qsort(ia, len(ia), sizeof(c_int), CMPFUNC(py_cmp_func)) # doctest: +LINUX
+ py_cmp_func 5 1
+ py_cmp_func 33 99
+ py_cmp_func 7 33
+ py_cmp_func 1 7
+ py_cmp_func 5 7
+ >>>
+
+So, our array sorted now::
+
+ >>> for i in ia: print i,
+ ...
+ 1 5 7 33 99
+ >>>
+
+**Important note for callback functions:**
+
+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.
+
+Accessing values exported from dlls
+-----------------------------------
+
+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.
+
+``ctypes`` can access values like this with the ``in_dll`` class
+methods of the type. ``pythonapi`` ìs a predefined symbol giving
+access to the Python C api::
+
+ >>> opt_flag = c_int.in_dll(pythonapi, "Py_OptimizeFlag")
+ >>> print opt_flag
+ c_long(0)
+ >>>
+
+If the interpreter would have been started with ``-O``, the sample
+would have printed ``c_long(1)``, or ``c_long(2)`` if ``-OO`` would have
+been specified.
+
+An extended example which also demonstrates the use of pointers
+accesses the ``PyImport_FrozenModules`` pointer exported by Python.
+
+Quoting the Python docs: *This pointer is initialized to point to an
+array of ``struct _frozen`` records, terminated by one whose members
+are all NULL or zero. When a frozen module is imported, it is searched
+in this table. Third-party code could play tricks with this to provide
+a dynamically created collection of frozen modules.*
+
+So manipulating this pointer could even prove useful. To restrict the
+example size, we show only how this table can be read with
+``ctypes``::
>>> from ctypes import *
- >>> pydll = cdll.python22
- >>> opt_flag = c_int.in_dll(pydll, "Py_OptimizeFlag")
- >>> print opt_flag
- c_int(0)
- >>>
-
- If the interpreter would have been started with '-O', the sample
- would have printed 'c_int(1)', or 'c_int(2)' if '-OO' would have
- been specified.
-
- A somewhat extended example which also demontrates the use of
- pointers accesses the 'PyImport_FrozenModules' pointer exported by
- Python.
-
- Quoting the Python docs: *This pointer is initialized to point to
- an array of 'struct _frozen' records, terminated by one whose
- members are all NULL or zero. When a frozen module is imported, it
- is searched in this table. Third-party code could play tricks with
- this to provide a dynamically created collection of frozen
- modules.*
-
- So manipulating this pointer could even prove useful. To restrict
- the example size, we show only how this table can be read with
- 'ctypes'::
-
- >>> from ctypes import *
- >>> pydll = cdll.python22
>>>
>>> class struct_frozen(Structure):
... _fields_ = [("name", c_char_p),
@@ -943,48 +955,48 @@
...
>>>
- We have 'loaded' the Python dll and defined the 'struct _frozen'
- data type, so we can get the pointer to the table::
+We have defined the ``struct _frozen`` data type, so we can get the
+pointer to the table::
>>> FrozenTable = POINTER(struct_frozen)
- >>> table = FrozenTable.in_dll(pdll, "PyImport_FrozenModules")
- >>>
-
- Since 'table' is a 'pointer' to the 'struct_frozen' records, we
- can iterate over it, we just have to make sure that our loop
- terminates, because pointers have no size. Sooner or later it
- would probably crash with an access violation or whatever, so it's
- better to break out of the loop when we hit the NULL entry::
+ >>> table = FrozenTable.in_dll(pythonapi, "PyImport_FrozenModules")
+ >>>
+
+Since ``table`` is a ``pointer`` to the array of ``struct_frozen``
+records, we can iterate over it, but we just have to make sure that
+our loop terminates, because pointers have no size. Sooner or later it
+would probably crash with an access violation or whatever, so it's
+better to break out of the loop when we hit the NULL entry::
>>> for item in table:
... print item.name, item.size
... if item.name is None:
... break
...
- __hello__ 100
- __phello__ -100
- __phello__.spam 100
+ __hello__ 104
+ __phello__ -104
+ __phello__.spam 104
None 0
>>>
- The fact that standard Python has a frozen module and a frozen
- package (indicated by the negative size member) is not wellknown,
- AFAIK it is 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
-
- There are some corners in 'ctypes' where you may be expect
- something else than what actually happens.
-
- Consider the following example::
+The fact that standard Python has a frozen module and a frozen package
+(indicated by the negative size member) is not wellknown, it is only
+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
+---------
+
+There are some edges in ``ctypes`` where you may be expect something
+else than what actually happens.
+
+Consider the following example::
>>> from ctypes import *
>>> class POINT(Structure):
- ... _fields_ = ("x", "i"), ("y", "i")
+ ... _fields_ = ("x", c_int), ("y", c_int)
...
>>> class RECT(Structure):
... _fields_ = ("a", POINT), ("b", POINT)
@@ -999,42 +1011,51 @@
>>> print rc.a.x, rc.a.y, rc.b.x, rc.b.y
3 4 3 4
- Hm. We certainly expected the last statement to print '3 4 1 2'.
- What happended? Here are the steps of the 'rc.a, rc.b = rc.b,
- rc.a' line above::
+Hm. We certainly expected the last statement to print ``3 4 1 2``.
+What happended? Here are the steps of the ``rc.a, rc.b = rc.b, rc.a``
+line above::
>>> temp0, temp1 = rc.b, rc.a
>>> rc.a = temp0
>>> rc.b = temp1
- Note that 'temp0' and 'temp1' are objects still using the internal
- buffer of the 'rc' object above. So executing 'rc.a = temp0'
- copies the buffer contents of 'temp0' into 'rc' 's buffer. This, in turn,
- changes the contents of 'temp1'. So, the last assignment 'rc.b = temp1',
- doesn't have the expected effect.
-
- Keep in mind that retrieving subobjects from Structure, Unions,
- and Arrays doesn't *copy* the subobject, it does more retrieve a
- wrapper object accessing the root-object's underlying buffer.
-
-
- Bugs, ToDo and non-implemented things
-
- Bitfields are not implemented.
-
- Enumeration types are not implemented. You can do it easily
- yourself, using 'c_int' as the base class.
-
- 'long double' is not implemented.
-
-<!-- no longer true: You cannot pass structures to functions as arguments, and you
- cannot set them as return type (only pointers).
--->
-<!-- no longer true? Callback functions implemented in Python can *only* return integers.
--->
-
-<!--
+Note that ``temp0`` and ``temp1`` are objects still using the internal
+buffer of the ``rc`` object above. So executing ``rc.a = temp0``
+copies the buffer contents of ``temp0`` into ``rc`` 's buffer. This,
+in turn, changes the contents of ``temp1``. So, the last assignment
+``rc.b = temp1``, doesn't have the expected effect.
+
+Keep in mind that retrieving subobjects from Structure, Unions, and
+Arrays doesn't *copy* the subobject, instead it retrieves a wrapper
+object accessing the root-object's underlying buffer.
+
+
+Another example that may behave different from what one would expect is this::
+
+ >>> s = c_char_p()
+ >>> s.value = "abc def ghi"
+ >>> s.value
+ 'abc def ghi'
+ >>> s.value is s.value
+ False
+ >>>
+
+Why is it printing ``False``? ctypes instances are objects containing
+a memory block plus some descriptors accessing the contents of the
+memory. Storing a Python object in the memory block does not store
+the object itself, instead the ``contents`` of the object is stored.
+Accessing the contents again constructs a new Python each time!
+
+
+Bugs, ToDo and non-implemented things
+-------------------------------------
+
+Enumeration types are not implemented. You can do it easily yourself,
+using ``c_int`` as the base class.
+
+``long double`` is not implemented.
+
+..
Local Variables:
- compile-command: "make_html"
+ compile-command: "make.bat"
End:
--->
Modified: packages/ctypes/branches/upstream/current/setup.py
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/setup.py?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/setup.py (original)
+++ packages/ctypes/branches/upstream/current/setup.py Mon Jun 19 12:31:53 2006
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# $Id: setup.py,v 1.122.2.15 2006/02/14 19:02:39 theller Exp $
+# $Id: setup.py,v 1.140 2006/04/14 15:49:33 theller Exp $
#
#
@@ -11,7 +11,7 @@
LIBFFI_SOURCES='source/libffi'
-__version__ = "0.9.9.3"
+__version__ = "0.9.9.6"
################################################################
@@ -30,6 +30,7 @@
from distutils.command import install_data
from distutils.dir_util import mkpath
from distutils.util import get_platform
+from distutils.cygwinccompiler import Mingw32CCompiler
################################################################
# Manipulate the environment for the build process.
@@ -60,10 +61,7 @@
self.build_base = 'build'
self.use_resources = ""
self.refcounts = False
- if sys.platform == "win32":
- self.tests = "ctypes.test,comtypes.test"
- else:
- self.tests = "ctypes.test"
+ self.tests = "ctypes.test"
# initialize_options()
@@ -82,8 +80,8 @@
ctypes.test.use_resources.extend(self.use_resources)
for name in self.tests:
- package = __import__(name, globals(), locals(), ['*'])
- print "Testing package", name
+ package = __import__(name, globals(), locals(), ['*'])
+ print "Testing package", name, (sys.version, sys.platform, os.name)
ctypes.test.run_tests(package,
"test_*.py",
self.verbose,
@@ -128,6 +126,20 @@
# Add .S (preprocessed assembly) to C compiler source extensions.
self.compiler.src_extensions.append('.S')
+ if sys.platform == "win32":
+ 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')
+ for ext in self.extensions:
+ if ext.name == "_ctypes":
+ ext.sources.remove("source/libffi_msvc/win32.c")
+ else:
+ for ext in self.extensions:
+ if ext.name == "_ctypes":
+ ext.sources.remove("source/libffi_msvc/win32.S")
+ ext.extra_link_args = []
build_ext.build_ext.build_extensions(self)
@@ -197,15 +209,15 @@
clean.clean.run(self)
class my_install_data(install_data.install_data):
- """A custom install_data command, which will install it's files
- into the standard directories (normally lib/site-packages).
- """
- def finalize_options(self):
- if self.install_dir is None:
- installobj = self.distribution.get_command_obj('install')
- self.install_dir = installobj.install_lib
- print 'Installing data files to %s' % self.install_dir
- install_data.install_data.finalize_options(self)
+ """A custom install_data command, which will install it's files
+ into the standard directories (normally lib/site-packages).
+ """
+ def finalize_options(self):
+ if self.install_dir is None:
+ installobj = self.distribution.get_command_obj('install')
+ self.install_dir = installobj.install_lib
+ print 'Installing data files to %s' % self.install_dir
+ install_data.install_data.finalize_options(self)
################################################################
# Specify the _ctypes extension
@@ -227,15 +239,48 @@
# types.c is no longer needed, ffi_type defs are in cfield.c
"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):
+ extra_compile_args = []
+ # enable 64-bit portability warnings
+## extra_compile_args = ["/Wp64"]
+ else:
+ extra_compile_args = []
+
+ # Extra arguments passed to linker from MinGW,
+ # will be removed, in my_build_ext, if compiler <> MinGW
+ extra_link_args = []
+
+ # In MinGW32, the first linker option should be:
+ # -Xlinker --enable-stdcall-fixup
+ # but here this option is split into two options to
+ # force distutils not to surroud the entire option
+ # with double quotes as it sees a space in it. So:
+
+ extra_link_args.extend(["-Xlinker", "--enable-stdcall-fixup",
+
+ # In MinGW32, the --kill-at linker option forces MinGW to
+ # remove the @XY decoration from function names, hence making
+ # the stdcall functions of _ctypes_test and those tested in
+ # test_cfuns.py behave similarly to the one compiled in MSVC.
+
+ "-Wl,--kill-at"])
+
extensions = [Extension("_ctypes",
+ extra_compile_args = extra_compile_args,
+ extra_link_args = extra_link_args,
export_symbols=["DllGetClassObject,PRIVATE",
"DllCanUnloadNow,PRIVATE"],
- libraries=["ole32", "user32", "oleaut32"],
+ libraries=["ole32", "user32", "oleaut32", "uuid"],
include_dirs=["source/libffi_msvc"],
**kw),
Extension("_ctypes_test",
+ extra_compile_args = extra_compile_args,
+ extra_link_args = extra_link_args,
libraries=["oleaut32", "user32"],
sources=["source/_ctypes_test.c"],
include_dirs=["source/libffi_msvc"],
@@ -268,24 +313,9 @@
################################################################
# the ctypes package
#
-packages = ["ctypes", "ctypes.wrap", "ctypes.macholib", "ctypes.test"]
-package_dir = {}
-
-################################################################
-# options for distutils
-#
-setup_options = {}
-
-if sys.platform == 'win32':
- # Use different MANIFEST templates, to minimize the distribution
- # size. Also, the MANIFEST templates behave differently on
- # Windows and Linux (distutils bug?).
- # Finally, force rebuilding the MANIFEST file
-
- setup_options["sdist"] = {"template": "MANIFEST.windows.in", "force_manifest": 1}
-else:
- setup_options["sdist"] = {"template": "MANIFEST.other.in", "force_manifest": 1}
-data_files = []
+packages = ["ctypes",
+ "ctypes.macholib",
+ "ctypes.test"]
################################################################
# pypi classifiers
@@ -306,14 +336,14 @@
################################################################
# main section
#
+##from ce import ce_install_lib
+
if __name__ == '__main__':
setup(name="ctypes",
## entry_points = {"console_scripts" : ["xml2py = ctypes.wrap.xml2py:main",
## "h2xml = ctypes.wrap.h2xml:main"]},
ext_modules = extensions,
- package_dir = package_dir,
packages = packages,
- data_files = data_files,
classifiers = classifiers,
@@ -325,10 +355,12 @@
license="MIT License",
url="http://starship.python.net/crew/theller/ctypes.html",
platforms=["windows", "Linux", "MacOS X", "Solaris", "FreeBSD"],
-
+
cmdclass = {'test': test, 'build_py': my_build_py, 'build_ext': my_build_ext,
- 'clean': my_clean, 'install_data': my_install_data},
- options = setup_options
+ 'clean': my_clean, 'install_data': my_install_data,
+## 'ce_install_lib': ce_install_lib
+ },
+
)
## Local Variables:
Modified: packages/ctypes/branches/upstream/current/source/_ctypes.c
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/source/_ctypes.c?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/source/_ctypes.c (original)
+++ packages/ctypes/branches/upstream/current/source/_ctypes.c Mon Jun 19 12:31:53 2006
@@ -105,6 +105,10 @@
#include <ffi.h>
#ifdef MS_WIN32
#include <windows.h>
+#include <malloc.h>
+#ifndef IS_INTRESOURCE
+#define IS_INTRESOURCE(x) (((size_t)(x) >> 16) == 0)
+#endif
# ifdef _WIN32_WCE
/* Unlike desktop Windows, WinCE has both W and A variants of
GetProcAddress, but the default W version is not what we want */
@@ -112,7 +116,7 @@
# define GetProcAddress GetProcAddressA
# endif
#else
-#include <dlfcn.h>
+#include "ctypes_dlfcn.h"
#endif
#include "ctypes.h"
@@ -257,7 +261,7 @@
return NULL;
}
#else
- address = (void *)dlsym(handle, name);
+ address = (void *)ctypes_dlsym(handle, name);
if (!address) {
PyErr_Format(PyExc_ValueError,
#ifdef __CYGWIN__
@@ -265,7 +269,7 @@
"symbol '%s' not found (%s) ",
name,
#endif
- dlerror());
+ ctypes_dlerror());
return NULL;
}
#endif
@@ -285,6 +289,7 @@
if (PyCArg_CheckExact(value)) {
PyCArgObject *p = (PyCArgObject *)value;
PyObject *ob = p->obj;
+ const char *ob_name;
StgDictObject *dict;
dict = PyType_stgdict(type);
@@ -296,10 +301,10 @@
Py_INCREF(value);
return value;
}
+ ob_name = (ob) ? ob->ob_type->tp_name : "???";
PyErr_Format(PyExc_TypeError,
"expected %s instance instead of pointer to %s",
- ((PyTypeObject *)type)->tp_name,
- ob->ob_type->tp_name);
+ ((PyTypeObject *)type)->tp_name, ob_name);
return NULL;
}
#if 1
@@ -335,7 +340,7 @@
};
static PyObject *
-CDataType_repeat(PyObject *self, int length)
+CDataType_repeat(PyObject *self, Py_ssize_t length)
{
return CreateArrayType(self, length);
}
@@ -506,12 +511,12 @@
static int
PointerType_SetProto(StgDictObject *stgdict, PyObject *proto)
{
- if (proto && !PyType_Check(proto)) {
+ if (!proto || !PyType_Check(proto)) {
PyErr_SetString(PyExc_TypeError,
"_type_ must be a type");
return -1;
}
- if (proto && !PyType_stgdict(proto)) {
+ if (!PyType_stgdict(proto)) {
PyErr_SetString(PyExc_TypeError,
"_type_ must have storage info");
return -1;
@@ -543,8 +548,8 @@
return NULL;
stgdict->size = sizeof(void *);
stgdict->align = getentry("P")->pffi_type->alignment;
- stgdict->length = 2;
- stgdict->ffi_type = ffi_type_pointer;
+ stgdict->length = 1;
+ stgdict->ffi_type_pointer = ffi_type_pointer;
proto = PyDict_GetItemString(typedict, "_type_"); /* Borrowed ref */
if (proto && -1 == PointerType_SetProto(stgdict, proto)) {
@@ -695,7 +700,7 @@
CharArray_set_raw(CDataObject *self, PyObject *value)
{
char *ptr;
- int size;
+ Py_ssize_t size;
if (PyBuffer_Check(value)) {
size = value->ob_type->tp_as_buffer->bf_getreadbuffer(value, 0, (void *)&ptr);
if (size < 0)
@@ -899,7 +904,7 @@
PyObject *typedict;
int length;
- int itemsize, itemalign, itemlen;
+ int itemsize, itemalign;
typedict = PyTuple_GetItem(args, 2);
if (!typedict)
@@ -936,7 +941,6 @@
itemsize = itemdict->size;
itemalign = itemdict->align;
- itemlen = itemdict->length;
stgdict->size = itemsize * length;
stgdict->align = itemalign;
@@ -945,7 +949,7 @@
stgdict->proto = proto;
/* Arrays are passed as pointers to function calls. */
- stgdict->ffi_type = ffi_type_pointer;
+ stgdict->ffi_type_pointer = ffi_type_pointer;
/* create the new instance (which is a class,
since we are a metatype!) */
@@ -1219,6 +1223,19 @@
return value;
}
}
+/* function pointer */
+ if (CFuncPtrObject_Check(value)) {
+ PyCArgObject *parg;
+ CFuncPtrObject *func;
+ func = (CFuncPtrObject *)value;
+ parg = new_CArgObject();
+ parg->pffi_type = &ffi_type_pointer;
+ parg->tag = 'P';
+ Py_INCREF(value);
+ parg->value.p = *(void **)func->b_ptr;
+ parg->obj = value;
+ return (PyObject *)parg;
+ }
/* c_char_p, c_wchar_p */
stgd = PyObject_stgdict(value);
if (stgd && CDataObject_Check(value) && stgd->proto && PyString_Check(stgd->proto)) {
@@ -1264,9 +1281,13 @@
PyTypeObject *result;
StgDictObject *stgdict;
PyObject *name = PyTuple_GET_ITEM(args, 0);
- PyObject *swapped_args = PyTuple_New(PyTuple_GET_SIZE(args));
+ PyObject *swapped_args;
static PyObject *suffix;
- int i;
+ Py_ssize_t i;
+
+ swapped_args = PyTuple_New(PyTuple_GET_SIZE(args));
+ if (!swapped_args)
+ return NULL;
if (suffix == NULL)
#ifdef WORDS_BIGENDIAN
@@ -1275,8 +1296,10 @@
suffix = PyString_FromString("_be");
#endif
- Py_INCREF(suffix);
- PyString_ConcatAndDel(&name, suffix);
+ Py_INCREF(name);
+ PyString_Concat(&name, suffix);
+ if (name == NULL)
+ return NULL;
PyTuple_SET_ITEM(swapped_args, 0, name);
for (i=1; i<PyTuple_GET_SIZE(args); ++i) {
@@ -1297,7 +1320,7 @@
if (!stgdict) /* XXX leaks result! */
return NULL;
- stgdict->ffi_type = *fmt->pffi_type;
+ stgdict->ffi_type_pointer = *fmt->pffi_type;
stgdict->align = fmt->pffi_type->alignment;
stgdict->length = 0;
stgdict->size = fmt->pffi_type->size;
@@ -1355,7 +1378,7 @@
fmt = getentry(PyString_AS_STRING(proto));
- stgdict->ffi_type = *fmt->pffi_type;
+ stgdict->ffi_type_pointer = *fmt->pffi_type;
stgdict->align = fmt->pffi_type->alignment;
stgdict->length = 0;
stgdict->size = fmt->pffi_type->size;
@@ -1450,6 +1473,7 @@
PyObject_SetAttrString(swapped, "__ctype_le__", (PyObject *)result);
PyObject_SetAttrString(swapped, "__ctype_be__", swapped);
#endif
+ Py_DECREF(swapped);
};
return (PyObject *)result;
@@ -1624,7 +1648,7 @@
stgdict->size = sizeof(void *);
stgdict->setfunc = NULL;
stgdict->getfunc = NULL;
- stgdict->ffi_type = ffi_type_pointer;
+ stgdict->ffi_type_pointer = ffi_type_pointer;
ob = PyDict_GetItemString((PyObject *)stgdict, "_flags_");
if (!ob || !PyInt_Check(ob)) {
@@ -1789,13 +1813,11 @@
{
char string[256]; /* XXX is that enough? */
char *cp = string;
- int len;
*cp++ = index + '0';
while (target->b_base) {
*cp++ = target->b_index + '0';
target = target->b_base;
}
- len = cp - string;
return PyString_FromStringAndSize(string, cp-string);
}
/* Keep a reference to 'keep' in the 'target', at index 'index' */
@@ -1806,7 +1828,7 @@
* key int the root object's _objects dict.
*/
static int
-KeepRef(CDataObject *target, int index, PyObject *keep)
+KeepRef(CDataObject *target, Py_ssize_t index, PyObject *keep)
{
int result;
CDataObject *ob;
@@ -1845,8 +1867,10 @@
static int
CData_clear(CDataObject *self)
{
+ StgDictObject *dict = PyObject_stgdict((PyObject *)self);
Py_CLEAR(self->b_objects);
- if (self->b_needsfree)
+ if ((self->b_needsfree)
+ && ((size_t)dict->size > sizeof(self->b_value)))
PyMem_Free(self->b_ptr);
self->b_ptr = NULL;
Py_CLEAR(self->b_base);
@@ -1873,8 +1897,9 @@
{ NULL },
};
-static int CData_GetBuffer(CDataObject *self, int seg, void **pptr)
-{
+static Py_ssize_t CData_GetBuffer(PyObject *_self, Py_ssize_t seg, void **pptr)
+{
+ CDataObject *self = (CDataObject *)_self;
if (seg != 0) {
/* Hm. Must this set an exception? */
return -1;
@@ -1883,7 +1908,7 @@
return self->b_size;
}
-static int CData_GetSegcount(CDataObject *self, int *lenp)
+static Py_ssize_t CData_GetSegcount(PyObject *_self, Py_ssize_t *lenp)
{
if (lenp)
*lenp = 1;
@@ -1891,10 +1916,10 @@
}
static PyBufferProcs CData_as_buffer = {
- (getreadbufferproc)CData_GetBuffer,
- (getwritebufferproc)CData_GetBuffer,
- (getsegcountproc)CData_GetSegcount,
- (getcharbufferproc)NULL,
+ CData_GetBuffer,
+ CData_GetBuffer,
+ CData_GetSegcount,
+ NULL,
};
/*
@@ -1967,15 +1992,15 @@
static void CData_MallocBuffer(CDataObject *obj, StgDictObject *dict)
{
- if (dict->size <= sizeof(obj->b_value)) {
+ if ((size_t)dict->size <= sizeof(obj->b_value)) {
/* No need to call malloc, can use the default buffer */
obj->b_ptr = (char *)&obj->b_value;
- obj->b_needsfree = 0;
+ obj->b_needsfree = 1;
} else {
/* In python 2.4, and ctypes 0.9.6, the malloc call took about
33% of the creation time for c_int().
*/
- obj->b_ptr = PyMem_Malloc(dict->size);
+ obj->b_ptr = (char *)PyMem_Malloc(dict->size);
obj->b_needsfree = 1;
memset(obj->b_ptr, 0, dict->size);
}
@@ -1983,7 +2008,7 @@
}
PyObject *
-CData_FromBaseObj(PyObject *type, PyObject *base, int index, char *adr)
+CData_FromBaseObj(PyObject *type, PyObject *base, Py_ssize_t index, char *adr)
{
CDataObject *cmem;
StgDictObject *dict;
@@ -2040,7 +2065,7 @@
if (!pd)
return NULL;
assert(CDataObject_Check(pd));
- pd->b_ptr = buf;
+ pd->b_ptr = (char *)buf;
pd->b_length = dict->length;
pd->b_size = dict->size;
return (PyObject *)pd;
@@ -2062,7 +2087,7 @@
PyObject *
CData_get(PyObject *type, GETFUNC getfunc, PyObject *src,
- int index, int size, char *adr)
+ Py_ssize_t index, Py_ssize_t size, char *adr)
{
StgDictObject *dict;
if (getfunc)
@@ -2079,7 +2104,7 @@
*/
static PyObject *
_CData_set(CDataObject *dst, PyObject *type, SETFUNC setfunc, PyObject *value,
- int size, char *ptr)
+ Py_ssize_t size, char *ptr)
{
CDataObject *src;
@@ -2175,7 +2200,7 @@
*/
int
CData_set(PyObject *dst, PyObject *type, SETFUNC setfunc, PyObject *value,
- int index, int size, char *ptr)
+ Py_ssize_t index, Py_ssize_t size, char *ptr)
{
CDataObject *mem = (CDataObject *)dst;
PyObject *result;
@@ -2383,6 +2408,11 @@
address = (PPROC)GetProcAddress(handle, name);
if (address)
return address;
+
+ if (((size_t)name & ~0xFFFF) == 0) {
+ return NULL;
+ }
+
/* It should not happen that dict is NULL, but better be safe */
if (dict==NULL || dict->flags & FUNCFLAG_CDECL)
return address;
@@ -2391,7 +2421,7 @@
funcname -> _funcname@<n>
where n is 0, 4, 8, 12, ..., 128
*/
- mangled_name = _alloca(strlen(name) + 1 + 1 + 1 + 3); /* \0 _ @ %d */
+ 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);
address = (PPROC)GetProcAddress(handle, mangled_name);
@@ -2488,6 +2518,28 @@
return 1;
}
+static int
+_get_name(PyObject *obj, char **pname)
+{
+#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;
+ }
+#endif
+ if (PyString_Check(obj) || PyUnicode_Check(obj)) {
+ *pname = PyString_AsString(obj);
+ return *pname ? 1 : 0;
+ }
+ PyErr_SetString(PyExc_TypeError,
+ "function name must be string or integer");
+ return 0;
+}
+
+
static PyObject *
CFuncPtr_FromDll(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
@@ -2499,7 +2551,7 @@
void *handle;
PyObject *paramflags = NULL;
- if (!PyArg_ParseTuple(args, "sO|O", &name, &dll, ¶mflags))
+ if (!PyArg_ParseTuple(args, "(O&O)|O", _get_name, &name, &dll, ¶mflags))
return NULL;
if (paramflags == Py_None)
paramflags = NULL;
@@ -2524,13 +2576,18 @@
#ifdef MS_WIN32
address = FindAddress(handle, name, (PyObject *)type);
if (!address) {
- PyErr_Format(PyExc_AttributeError,
- "function '%s' not found",
- name);
+ if (!IS_INTRESOURCE(name))
+ PyErr_Format(PyExc_AttributeError,
+ "function '%s' not found",
+ name);
+ else
+ PyErr_Format(PyExc_AttributeError,
+ "function ordinal %d not found",
+ (WORD)(size_t)name);
return NULL;
}
#else
- address = (PPROC)dlsym(handle, name);
+ address = (PPROC)ctypes_dlsym(handle, name);
if (!address) {
PyErr_Format(PyExc_AttributeError,
#ifdef __CYGWIN__
@@ -2538,7 +2595,7 @@
"function '%s' not found (%s) ",
name,
#endif
- dlerror());
+ ctypes_dlerror());
return NULL;
}
#endif
@@ -2603,8 +2660,9 @@
"O" - must be a callable, creates a C callable function
two or more argument forms (the third argument is a paramflags tuple)
- "sO|O" - function name, dll object (with an integer handle)
- "is|O" - vtable index, method name, creates callable calling COM vtbl
+ "(sO)|..." - (function name, dll object (with an integer handle)), paramflags
+ "(iO)|..." - (function ordinal, dll object (with an integer handle)), paramflags
+ "is|..." - vtable index, method name, creates callable calling COM vtbl
*/
static PyObject *
CFuncPtr_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
@@ -2612,19 +2670,18 @@
CFuncPtrObject *self;
PyObject *callable;
StgDictObject *dict;
- THUNK thunk;
+ ffi_info *thunk;
if (PyTuple_GET_SIZE(args) == 0)
return GenericCData_new(type, args, kwds);
- /* Shouldn't the following better be done in __init__? */
- if (2 <= PyTuple_GET_SIZE(args)) {
+ if (1 <= PyTuple_GET_SIZE(args) && PyTuple_Check(PyTuple_GET_ITEM(args, 0)))
+ return CFuncPtr_FromDll(type, args, kwds);
+
#ifdef MS_WIN32
- if (PyInt_Check(PyTuple_GET_ITEM(args, 0)))
- return CFuncPtr_FromVtblIndex(type, args, kwds);
+ if (2 <= PyTuple_GET_SIZE(args) && PyInt_Check(PyTuple_GET_ITEM(args, 0)))
+ return CFuncPtr_FromVtblIndex(type, args, kwds);
#endif
- return CFuncPtr_FromDll(type, args, kwds);
- }
if (1 == PyTuple_GET_SIZE(args)
&& (PyInt_Check(PyTuple_GET_ITEM(args, 0))
@@ -2781,7 +2838,7 @@
static PyObject *
_build_callargs(CFuncPtrObject *self, PyObject *argtypes,
PyObject *inargs, PyObject *kwds,
- int *poutmask, int *pinoutmask, int *pnumretvals)
+ int *poutmask, int *pinoutmask, unsigned int *pnumretvals)
{
PyObject *paramflags = self->paramflags;
PyObject *callargs;
@@ -2835,8 +2892,14 @@
switch (flag & (PARAMFLAG_FIN | PARAMFLAG_FOUT | PARAMFLAG_FLCID)) {
case PARAMFLAG_FIN | PARAMFLAG_FLCID:
- /* ['in', 'lcid'] parameter. Always taken from defval */
- Py_INCREF(defval);
+ /* ['in', 'lcid'] parameter. Always taken from defval,
+ if given, else the integer 0. */
+ if (defval == NULL) {
+ defval = PyInt_FromLong(0);
+ if (defval == NULL)
+ goto error;
+ } else
+ Py_INCREF(defval);
PyTuple_SET_ITEM(callargs, i, defval);
break;
case (PARAMFLAG_FIN | PARAMFLAG_FOUT):
@@ -2939,9 +3002,10 @@
*/
static PyObject *
_build_result(PyObject *result, PyObject *callargs,
- int outmask, int inoutmask, int numretvals)
-{
- int i, index, bit;
+ int outmask, int inoutmask, unsigned int numretvals)
+{
+ unsigned int i, index;
+ int bit;
PyObject *tup = NULL;
if (callargs == NULL)
@@ -2952,6 +3016,7 @@
}
Py_DECREF(result);
+ /* tup will not be allocated if numretvals == 1 */
/* allocate tuple to hold the result */
if (numretvals > 1) {
tup = PyTuple_New(numretvals);
@@ -3009,7 +3074,7 @@
int inoutmask;
int outmask;
- int numretvals;
+ unsigned int numretvals;
assert(dict); /* if not, it's a bug */
restype = self->restype ? self->restype : dict->restype;
@@ -3145,13 +3210,11 @@
Py_CLEAR(self->converters);
Py_CLEAR(self->paramflags);
- if (self->b_needsfree)
- PyMem_Free(self->b_ptr);
- self->b_ptr = NULL;
-
- if (self->thunk)
- FreeCallback(self->thunk);
- self->thunk = NULL;
+ if (self->thunk) {
+ FreeClosure(self->thunk->pcl);
+ PyMem_Free(self->thunk);
+ self->thunk = NULL;
+ }
return CData_clear((CDataObject *)self);
}
@@ -3245,7 +3308,7 @@
parg->tag = 'V';
stgdict = PyObject_stgdict((PyObject *)self);
- parg->pffi_type = &stgdict->ffi_type;
+ parg->pffi_type = &stgdict->ffi_type_pointer;
/* For structure parameters (by value), parg->value doesn't contain the structure
data itself, instead parg->value.p *points* to the structure's data
See also _ctypes.c, function _call_function_pointer().
@@ -3279,6 +3342,8 @@
if (!fields) {
PyErr_Clear();
fields = PyTuple_New(0);
+ if (!fields)
+ return -1;
}
if (PyTuple_GET_SIZE(args) > PySequence_Length(fields)) {
@@ -3320,7 +3385,7 @@
if (kwds) {
PyObject *key, *value;
- int pos = 0;
+ Py_ssize_t pos = 0;
while(PyDict_Next(kwds, &pos, &key, &value)) {
if (-1 == PyObject_SetAttr(self, key, value))
return -1;
@@ -3449,8 +3514,9 @@
}
static PyObject *
-Array_item(CDataObject *self, int index)
-{
+Array_item(PyObject *_self, Py_ssize_t index)
+{
+ CDataObject *self = (CDataObject *)_self;
int offset, size;
StgDictObject *stgdict;
@@ -3473,12 +3539,13 @@
}
static PyObject *
-Array_slice(CDataObject *self, int ilow, int ihigh)
-{
+Array_slice(PyObject *_self, Py_ssize_t ilow, Py_ssize_t ihigh)
+{
+ CDataObject *self = (CDataObject *)_self;
StgDictObject *stgdict, *itemdict;
PyObject *proto;
PyListObject *np;
- int i, len;
+ Py_ssize_t i, len;
if (ilow < 0)
ilow = 0;
@@ -3508,15 +3575,16 @@
return NULL;
for (i = 0; i < len; i++) {
- PyObject *v = Array_item(self, i+ilow);
+ PyObject *v = Array_item(_self, i+ilow);
PyList_SET_ITEM(np, i, v);
}
return (PyObject *)np;
}
static int
-Array_ass_item(CDataObject *self, int index, PyObject *value)
-{
+Array_ass_item(PyObject *_self, Py_ssize_t index, PyObject *value)
+{
+ CDataObject *self = (CDataObject *)_self;
int size, offset;
StgDictObject *stgdict;
char *ptr;
@@ -3542,8 +3610,9 @@
}
static int
-Array_ass_slice(CDataObject *self, int ilow, int ihigh, PyObject *value)
-{
+Array_ass_slice(PyObject *_self, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *value)
+{
+ CDataObject *self = (CDataObject *)_self;
int i, len;
if (value == NULL) {
@@ -3574,7 +3643,7 @@
int result;
if (item == NULL)
return -1;
- result = Array_ass_item(self, i+ilow, item);
+ result = Array_ass_item(_self, i+ilow, item);
Py_DECREF(item);
if (result == -1)
return -1;
@@ -3582,20 +3651,21 @@
return 0;
}
-static int
-Array_length(CDataObject *self)
-{
+static Py_ssize_t
+Array_length(PyObject *_self)
+{
+ CDataObject *self = (CDataObject *)_self;
return self->b_length;
}
static PySequenceMethods Array_as_sequence = {
- (inquiry)Array_length, /* sq_length; */
+ 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; */
+ Array_item, /* sq_item; */
+ Array_slice, /* sq_slice; */
+ Array_ass_item, /* sq_ass_item; */
+ Array_ass_slice, /* sq_ass_slice; */
0, /* sq_contains; */
0, /* sq_inplace_concat; */
@@ -3666,7 +3736,7 @@
};
PyObject *
-CreateArrayType(PyObject *itemtype, int length)
+CreateArrayType(PyObject *itemtype, Py_ssize_t length)
{
static PyObject *cache;
PyObject *key;
@@ -3678,7 +3748,11 @@
if (cache == NULL)
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;
result = PyDict_GetItem(cache, key);
@@ -3693,11 +3767,20 @@
"Expected a type object");
return NULL;
}
- sprintf(name, "%.200s_Array_%d",
+#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,
"_length_",
@@ -3871,7 +3954,7 @@
name = PyString_FromString(self->ob_type->tp_name);
if (name == NULL) {
- Py_DECREF(name);
+ Py_DECREF(val);
return NULL;
}
@@ -3934,11 +4017,11 @@
Pointer_Type
*/
static PyObject *
-Pointer_item(CDataObject *self, int index)
-{
+Pointer_item(PyObject *_self, Py_ssize_t index)
+{
+ CDataObject *self = (CDataObject *)_self;
int size, offset;
StgDictObject *stgdict, *itemdict;
- PyObject *base;
PyObject *proto;
if (*(void **)self->b_ptr == NULL) {
@@ -3957,18 +4040,14 @@
size = itemdict->size;
offset = index * itemdict->size;
- /* XXX explain! */
- if (index != 0)
- base = NULL;
- else
- base = (PyObject *)self;
- return CData_get(stgdict->proto, stgdict->getfunc, base,
+ return CData_get(stgdict->proto, stgdict->getfunc, (PyObject *)self,
index, size, (*(char **)self->b_ptr) + offset);
}
static int
-Pointer_ass_item(CDataObject *self, int index, PyObject *value)
-{
+Pointer_ass_item(PyObject *_self, Py_ssize_t index, PyObject *value)
+{
+ CDataObject *self = (CDataObject *)_self;
int size;
StgDictObject *stgdict;
@@ -4109,12 +4188,13 @@
}
static PyObject *
-Pointer_slice(CDataObject *self, int ilow, int ihigh)
-{
+Pointer_slice(PyObject *_self, Py_ssize_t ilow, Py_ssize_t ihigh)
+{
+ CDataObject *self = (CDataObject *)_self;
PyListObject *np;
StgDictObject *stgdict, *itemdict;
PyObject *proto;
- int i, len;
+ Py_ssize_t i, len;
if (ilow < 0)
ilow = 0;
@@ -4140,7 +4220,7 @@
return NULL;
for (i = 0; i < len; i++) {
- PyObject *v = Pointer_item(self, i+ilow);
+ PyObject *v = Pointer_item(_self, i+ilow);
PyList_SET_ITEM(np, i, v);
}
return (PyObject *)np;
@@ -4150,9 +4230,9 @@
0, /* inquiry sq_length; */
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; */
+ Pointer_item, /* intargfunc sq_item; */
+ Pointer_slice, /* intintargfunc sq_slice; */
+ Pointer_ass_item, /* intobjargproc sq_ass_item; */
0, /* intintobjargproc sq_ass_slice; */
0, /* objobjproc sq_contains; */
/* Added in release 2.0 */
@@ -4326,13 +4406,51 @@
#endif
static PyObject *
-string_at(const char *ptr, int size)
+string_at(const char *ptr, Py_ssize_t size)
{
if (size == 0)
return PyString_FromString(ptr);
return PyString_FromStringAndSize(ptr, size);
}
+static int
+cast_check_pointertype(PyObject *arg)
+{
+ StgDictObject *dict;
+
+ if (PointerTypeObject_Check(arg))
+ return 1;
+ if (CFuncPtrTypeObject_Check(arg))
+ return 1;
+ dict = PyType_stgdict(arg);
+ if (dict) {
+ if (PyString_Check(dict->proto)
+ && (strchr("sPzUZXO", PyString_AS_STRING(dict->proto)[0]))) {
+ /* simple pointer types, c_void_p, c_wchar_p, BSTR, ... */
+ return 1;
+ }
+ }
+ PyErr_Format(PyExc_TypeError,
+ "cast() argument 2 must be a pointer type, not %s",
+ PyType_Check(arg)
+ ? ((PyTypeObject *)arg)->tp_name
+ : arg->ob_type->tp_name);
+ return 0;
+}
+
+static PyObject *
+cast(void *ptr, PyObject *ctype)
+{
+ CDataObject *result;
+ if (0 == cast_check_pointertype(ctype))
+ return NULL;
+ result = (CDataObject *)PyObject_CallFunctionObjArgs(ctype, NULL);
+ if (result == NULL)
+ return NULL;
+ /* Should we assert that result is a pointer type? */
+ memcpy(result->b_ptr, &ptr, sizeof(void *));
+ return (PyObject *)result;
+}
#ifdef CTYPES_UNICODE
static PyObject *
@@ -4344,7 +4462,7 @@
}
#endif
-DL_EXPORT(void)
+PyMODINIT_FUNC
init_ctypes(void)
{
PyObject *m;
@@ -4463,19 +4581,30 @@
#endif
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.3");
+ PyModule_AddStringConstant(m, "__version__", "0.9.9.6");
PyModule_AddObject(m, "_memmove_addr", PyLong_FromVoidPtr(memmove));
PyModule_AddObject(m, "_memset_addr", PyLong_FromVoidPtr(memset));
PyModule_AddObject(m, "_string_at_addr", PyLong_FromVoidPtr(string_at));
+ PyModule_AddObject(m, "_cast_addr", PyLong_FromVoidPtr(cast));
#ifdef CTYPES_UNICODE
PyModule_AddObject(m, "_wstring_at_addr", PyLong_FromVoidPtr(wstring_at));
#endif
-#ifdef RTLD_LOCAL
+/* If RTLD_LOCAL is not defined (Windows!), set it to zero. */
+#ifndef RTLD_LOCAL
+#define RTLD_LOCAL 0
+#endif
+
+/* If RTLD_GLOBAL is not defined (cygwin), set it to the same value as
+ RTLD_LOCAL.
+*/
+#ifndef RTLD_GLOBAL
+#define RTLD_GLOBAL RTLD_LOCAL
+#endif
+
PyModule_AddObject(m, "RTLD_LOCAL", PyInt_FromLong(RTLD_LOCAL));
PyModule_AddObject(m, "RTLD_GLOBAL", PyInt_FromLong(RTLD_GLOBAL));
-#endif
PyExc_ArgError = PyErr_NewException("ctypes.ArgumentError", NULL, NULL);
if (PyExc_ArgError) {
Modified: packages/ctypes/branches/upstream/current/source/_ctypes_test.c
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/source/_ctypes_test.c?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/source/_ctypes_test.c (original)
+++ packages/ctypes/branches/upstream/current/source/_ctypes_test.c Mon Jun 19 12:31:53 2006
@@ -51,21 +51,21 @@
*presult = a + b;
}
-EXPORT(int) _testfunc_i_bhilfd(char b, short h, int i, long l, float f, double d)
+EXPORT(int) _testfunc_i_bhilfd(signed char b, short h, int i, long l, float f, double d)
{
// printf("_testfunc_i_bhilfd got %d %d %d %ld %f %f\n",
// b, h, i, l, f, d);
return (int)(b + h + i + l + f + d);
}
-EXPORT(float) _testfunc_f_bhilfd(char b, short h, int i, long l, float f, double d)
+EXPORT(float) _testfunc_f_bhilfd(signed char b, short h, int i, long l, float f, double d)
{
// printf("_testfunc_f_bhilfd got %d %d %d %ld %f %f\n",
// b, h, i, l, f, d);
return (float)(b + h + i + l + f + d);
}
-EXPORT(double) _testfunc_d_bhilfd(char b, short h, int i, long l, float f, double d)
+EXPORT(double) _testfunc_d_bhilfd(signed char b, short h, int i, long l, float f, double d)
{
// printf("_testfunc_d_bhilfd got %d %d %d %ld %f %f\n",
// b, h, i, l, f, d);
@@ -74,7 +74,7 @@
EXPORT(char *) _testfunc_p_p(void *s)
{
- return s;
+ return (char *)s;
}
EXPORT(void *) _testfunc_c_p_p(int *argcp, char **argv)
@@ -89,7 +89,7 @@
EXPORT(char *) my_strdup(char *src)
{
- char *dst = malloc(strlen(src)+1);
+ char *dst = (char *)malloc(strlen(src)+1);
if (!dst)
return NULL;
strcpy(dst, src);
@@ -99,8 +99,8 @@
#ifdef HAVE_WCHAR_H
EXPORT(wchar_t *) my_wcsdup(wchar_t *src)
{
- int len = wcslen(src);
- wchar_t *ptr = malloc((len + 1) * sizeof(wchar_t));
+ size_t len = wcslen(src);
+ wchar_t *ptr = (wchar_t *)malloc((len + 1) * sizeof(wchar_t));
if (ptr == NULL)
return NULL;
memcpy(ptr, src, (len+1) * sizeof(wchar_t));
@@ -152,13 +152,13 @@
}
#ifdef HAVE_LONG_LONG
-EXPORT(PY_LONG_LONG) _testfunc_q_bhilfdq(char b, short h, int i, long l, float f,
+EXPORT(PY_LONG_LONG) _testfunc_q_bhilfdq(signed char b, short h, int i, long l, float f,
double d, PY_LONG_LONG q)
{
return (PY_LONG_LONG)(b + h + i + l + f + d + q);
}
-EXPORT(PY_LONG_LONG) _testfunc_q_bhilfd(char b, short h, int i, long l, float f, double d)
+EXPORT(PY_LONG_LONG) _testfunc_q_bhilfd(signed char b, short h, int i, long l, float f, double d)
{
return (PY_LONG_LONG)(b + h + i + l + f + d);
}
@@ -191,7 +191,7 @@
{
static char message[] = "Hello, World";
if (p) {
- *p = malloc(sizeof(char *));
+ *p = (char **)malloc(sizeof(char *));
printf("malloc returned %p\n", *p);
**p = message;
return 1;
@@ -385,7 +385,7 @@
#define S last_tf_arg_s = (PY_LONG_LONG)c
#define U last_tf_arg_u = (unsigned PY_LONG_LONG)c
-EXPORT(char) tf_b(char c) { S; return c/3; }
+EXPORT(signed char) tf_b(signed char c) { S; return c/3; }
EXPORT(unsigned char) tf_B(unsigned char c) { U; return c/3; }
EXPORT(short) tf_h(short c) { S; return c/3; }
EXPORT(unsigned short) tf_H(unsigned short c) { U; return c/3; }
@@ -399,7 +399,7 @@
EXPORT(double) tf_d(double c) { S; return c/3; }
#ifdef MS_WIN32
-EXPORT(char) __stdcall s_tf_b(char c) { S; return c/3; }
+EXPORT(signed char) __stdcall s_tf_b(signed char c) { S; return c/3; }
EXPORT(unsigned char) __stdcall s_tf_B(unsigned char c) { U; return c/3; }
EXPORT(short) __stdcall s_tf_h(short c) { S; return c/3; }
EXPORT(unsigned short) __stdcall s_tf_H(unsigned short c) { U; return c/3; }
@@ -414,33 +414,33 @@
#endif
/*******/
-EXPORT(char) tf_bb(char x, char c) { S; return c/3; }
-EXPORT(unsigned char) tf_bB(char x, unsigned char c) { U; return c/3; }
-EXPORT(short) tf_bh(char x, short c) { S; return c/3; }
-EXPORT(unsigned short) tf_bH(char x, unsigned short c) { U; return c/3; }
-EXPORT(int) tf_bi(char x, int c) { S; return c/3; }
-EXPORT(unsigned int) tf_bI(char x, unsigned int c) { U; return c/3; }
-EXPORT(long) tf_bl(char x, long c) { S; return c/3; }
-EXPORT(unsigned long) tf_bL(char x, unsigned long c) { U; return c/3; }
-EXPORT(PY_LONG_LONG) tf_bq(char x, PY_LONG_LONG c) { S; return c/3; }
-EXPORT(unsigned PY_LONG_LONG) tf_bQ(char x, unsigned PY_LONG_LONG c) { U; return c/3; }
-EXPORT(float) tf_bf(char x, float c) { S; return c/3; }
-EXPORT(double) tf_bd(char x, double c) { S; return c/3; }
+EXPORT(signed char) tf_bb(signed char x, signed char c) { S; return c/3; }
+EXPORT(unsigned char) tf_bB(signed char x, unsigned char c) { U; return c/3; }
+EXPORT(short) tf_bh(signed char x, short c) { S; return c/3; }
+EXPORT(unsigned short) tf_bH(signed char x, unsigned short c) { U; return c/3; }
+EXPORT(int) tf_bi(signed char x, int c) { S; return c/3; }
+EXPORT(unsigned int) tf_bI(signed char x, unsigned int c) { U; return c/3; }
+EXPORT(long) tf_bl(signed char x, long c) { S; return c/3; }
+EXPORT(unsigned long) tf_bL(signed char x, unsigned long c) { U; return c/3; }
+EXPORT(PY_LONG_LONG) tf_bq(signed char x, PY_LONG_LONG c) { S; return c/3; }
+EXPORT(unsigned PY_LONG_LONG) tf_bQ(signed char x, unsigned PY_LONG_LONG c) { U; return c/3; }
+EXPORT(float) tf_bf(signed char x, float c) { S; return c/3; }
+EXPORT(double) tf_bd(signed char x, double c) { S; return c/3; }
EXPORT(void) tv_i(int c) { S; return; }
#ifdef MS_WIN32
-EXPORT(char) __stdcall s_tf_bb(char x, char c) { S; return c/3; }
-EXPORT(unsigned char) __stdcall s_tf_bB(char x, unsigned char c) { U; return c/3; }
-EXPORT(short) __stdcall s_tf_bh(char x, short c) { S; return c/3; }
-EXPORT(unsigned short) __stdcall s_tf_bH(char x, unsigned short c) { U; return c/3; }
-EXPORT(int) __stdcall s_tf_bi(char x, int c) { S; return c/3; }
-EXPORT(unsigned int) __stdcall s_tf_bI(char x, unsigned int c) { U; return c/3; }
-EXPORT(long) __stdcall s_tf_bl(char x, long c) { S; return c/3; }
-EXPORT(unsigned long) __stdcall s_tf_bL(char x, unsigned long c) { U; return c/3; }
-EXPORT(PY_LONG_LONG) __stdcall s_tf_bq(char x, PY_LONG_LONG c) { S; return c/3; }
-EXPORT(unsigned PY_LONG_LONG) __stdcall s_tf_bQ(char x, unsigned PY_LONG_LONG c) { U; return c/3; }
-EXPORT(float) __stdcall s_tf_bf(char x, float c) { S; return c/3; }
-EXPORT(double) __stdcall s_tf_bd(char x, double c) { S; return c/3; }
+EXPORT(signed char) __stdcall s_tf_bb(signed char x, signed char c) { S; return c/3; }
+EXPORT(unsigned char) __stdcall s_tf_bB(signed char x, unsigned char c) { U; return c/3; }
+EXPORT(short) __stdcall s_tf_bh(signed char x, short c) { S; return c/3; }
+EXPORT(unsigned short) __stdcall s_tf_bH(signed char x, unsigned short c) { U; return c/3; }
+EXPORT(int) __stdcall s_tf_bi(signed char x, int c) { S; return c/3; }
+EXPORT(unsigned int) __stdcall s_tf_bI(signed char x, unsigned int c) { U; return c/3; }
+EXPORT(long) __stdcall s_tf_bl(signed char x, long c) { S; return c/3; }
+EXPORT(unsigned long) __stdcall s_tf_bL(signed char x, unsigned long c) { U; return c/3; }
+EXPORT(PY_LONG_LONG) __stdcall s_tf_bq(signed char x, PY_LONG_LONG c) { S; return c/3; }
+EXPORT(unsigned PY_LONG_LONG) __stdcall s_tf_bQ(signed char x, unsigned PY_LONG_LONG c) { U; return c/3; }
+EXPORT(float) __stdcall s_tf_bf(signed char x, float c) { S; return c/3; }
+EXPORT(double) __stdcall s_tf_bd(signed char x, double c) { S; return c/3; }
EXPORT(void) __stdcall s_tv_i(int c) { S; return; }
#endif
Modified: packages/ctypes/branches/upstream/current/source/callbacks.c
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/source/callbacks.c?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/source/callbacks.c (original)
+++ packages/ctypes/branches/upstream/current/source/callbacks.c Mon Jun 19 12:31:53 2006
@@ -238,10 +238,24 @@
CHECK("'converting callback result'", keep);
break;
}
- /* assert (keep == Py_None); */
- /* XXX We have no way to keep the needed reference XXX */
- /* Should we emit a warning? */
- Py_XDECREF(keep);
+ /* keep is an object we have to keep alive so that the result
+ stays valid. If there is no such object, the setfunc will
+ have returned Py_None.
+
+ If there is such an object, we have no choice than to keep
+ it alive forever - but a refcount and/or memory leak will
+ be the result. EXCEPT when restype is py_object - Python
+ itself knows how to manage the refcount of these objects.
+ */
+ if (keep == NULL) /* Could not convert callback result. */
+ PyErr_WriteUnraisable(Py_None);
+ else if (keep == Py_None) /* Nothing to keep */
+ Py_DECREF(keep);
+ else if (setfunc != getentry("O")->setfunc) {
+ if (-1 == PyErr_Warn(PyExc_RuntimeWarning,
+ "memory leak in callback function."))
+ PyErr_WriteUnraisable(Py_None);
+ }
}
Py_XDECREF(result);
Done:
@@ -249,16 +263,6 @@
PyGILState_Release(state);
}
-
-typedef struct {
- ffi_closure *pcl; /* the C callable */
- ffi_cif cif;
- PyObject *converters;
- PyObject *callable;
- SETFUNC setfunc;
- ffi_type *restype;
- ffi_type *atypes[0];
-} ffi_info;
static void closure_fcn(ffi_cif *cif,
void *resp,
@@ -275,16 +279,10 @@
args);
}
-void FreeCallback(THUNK thunk)
-{
- FreeClosure(((ffi_info *)thunk)->pcl);
- PyMem_Free(thunk);
-}
-
-THUNK AllocFunctionCallback(PyObject *callable,
- PyObject *converters,
- PyObject *restype,
- int is_cdecl)
+ffi_info *AllocFunctionCallback(PyObject *callable,
+ PyObject *converters,
+ PyObject *restype,
+ int is_cdecl)
{
int result;
ffi_info *p;
@@ -299,13 +297,14 @@
}
p->pcl = MallocClosure();
if (p->pcl == NULL) {
- PyMem_Free(p);
PyErr_NoMemory();
- return NULL;
+ goto error;
}
for (i = 0; i < nArgs; ++i) {
PyObject *cnv = PySequence_GetItem(converters, i);
+ if (cnv == NULL)
+ goto error;
p->atypes[i] = GetType(cnv);
Py_DECREF(cnv);
}
@@ -316,12 +315,10 @@
p->restype = &ffi_type_void;
} else {
StgDictObject *dict = PyType_stgdict(restype);
- if (dict == NULL) {
- PyMem_Free(p);
- return NULL;
- }
+ if (dict == NULL)
+ goto error;
p->setfunc = dict->setfunc;
- p->restype = &dict->ffi_type;
+ p->restype = &dict->ffi_type_pointer;
}
cc = FFI_DEFAULT_ABI;
@@ -335,21 +332,26 @@
if (result != FFI_OK) {
PyErr_Format(PyExc_RuntimeError,
"ffi_prep_cif failed with %d", result);
- PyMem_Free(p);
- return NULL;
+ goto error;
}
result = ffi_prep_closure(p->pcl, &p->cif, closure_fcn, p);
if (result != FFI_OK) {
PyErr_Format(PyExc_RuntimeError,
"ffi_prep_closure failed with %d", result);
- PyMem_Free(p);
- return NULL;
+ goto error;
}
p->converters = converters;
p->callable = callable;
-
- return (THUNK)p;
+ return p;
+
+ error:
+ if (p) {
+ if (p->pcl)
+ FreeClosure(p->pcl);
+ PyMem_Free(p);
+ }
+ return NULL;
}
/****************************************************************************
Modified: packages/ctypes/branches/upstream/current/source/callproc.c
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/source/callproc.c?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/source/callproc.c (original)
+++ packages/ctypes/branches/upstream/current/source/callproc.c Mon Jun 19 12:31:53 2006
@@ -60,18 +60,21 @@
#ifdef MS_WIN32
#include <windows.h>
#else
-#include <dlfcn.h>
-#endif
-
-#ifdef MS_WIN32
-#define alloca _alloca
+#include "ctypes_dlfcn.h"
+#endif
+
+#ifdef MS_WIN32
+#include <malloc.h>
#endif
#include <ffi.h>
#include "ctypes.h"
-#ifdef _DEBUG
-#define DEBUG_EXCEPTIONS /* */
+#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
#ifdef MS_WIN32
@@ -96,6 +99,7 @@
return lpMsgBuf;
}
+#ifndef DONT_USE_SEH
void SetException(DWORD code, EXCEPTION_RECORD *pr)
{
TCHAR *lpMsgBuf;
@@ -254,6 +258,7 @@
*record = *ptrs->ExceptionRecord;
return EXCEPTION_EXECUTE_HANDLER;
}
+#endif
static PyObject *
check_hresult(PyObject *self, PyObject *args)
@@ -576,14 +581,14 @@
/* This little trick works correctly with MSVC.
It returns small structures in registers
*/
- if (dict->ffi_type.type == FFI_TYPE_STRUCT) {
- if (dict->ffi_type.size <= 4)
+ if (dict->ffi_type_pointer.type == FFI_TYPE_STRUCT) {
+ if (dict->ffi_type_pointer.size <= 4)
return &ffi_type_sint32;
- else if (dict->ffi_type.size <= 8)
+ else if (dict->ffi_type_pointer.size <= 8)
return &ffi_type_sint64;
}
#endif
- return &dict->ffi_type;
+ return &dict->ffi_type_pointer;
}
@@ -612,8 +617,10 @@
int cc;
#ifdef MS_WIN32
int delta;
+#ifndef DONT_USE_SEH
DWORD dwExceptionCode = 0;
EXCEPTION_RECORD record;
+#endif
#endif
/* XXX check before here */
if (restype == NULL) {
@@ -640,14 +647,14 @@
if ((flags & FUNCFLAG_PYTHONAPI) == 0)
Py_UNBLOCK_THREADS
#ifdef MS_WIN32
-#ifndef DEBUG_EXCEPTIONS
+#ifndef DONT_USE_SEH
__try {
#endif
delta =
#endif
ffi_call(&cif, (void *)pProc, resmem, avalues);
#ifdef MS_WIN32
-#ifndef DEBUG_EXCEPTIONS
+#ifndef DONT_USE_SEH
}
__except (HandleException(GetExceptionInformation(),
&dwExceptionCode, &record)) {
@@ -658,10 +665,12 @@
if ((flags & FUNCFLAG_PYTHONAPI) == 0)
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)
PyErr_Format(PyExc_ValueError,
@@ -715,9 +724,16 @@
if (dict == NULL)
return PyObject_CallFunction(restype, "i", *(int *)result);
- if (dict->getfunc && !IsSimpleSubType(restype))
+ if (dict->getfunc && !IsSimpleSubType(restype)) {
retval = dict->getfunc(result, dict->size);
- else
+ /* If restype is py_object (detected by comparing getfunc with
+ O_get), we have to call Py_DECREF because O_get has already
+ called Py_INCREF.
+ */
+ if (dict->getfunc == getentry("O")->getfunc) {
+ Py_DECREF(retval);
+ }
+ } else
retval = CData_FromBaseObj(restype, NULL, 0, result);
if (!checker || !retval)
@@ -751,6 +767,8 @@
if (cls_str) {
PyString_ConcatAndDel(&s, cls_str);
PyString_ConcatAndDel(&s, PyString_FromString(": "));
+ if (s == NULL)
+ goto error;
} else
PyErr_Clear();
msg_str = PyObject_Str(v);
@@ -759,12 +777,15 @@
else {
PyErr_Clear();
PyString_ConcatAndDel(&s, PyString_FromString("???"));
+ if (s == NULL)
+ goto error;
}
PyErr_SetObject(exc_class, s);
+error:
Py_XDECREF(tp);
Py_XDECREF(v);
Py_XDECREF(tb);
- Py_DECREF(s);
+ Py_XDECREF(s);
}
@@ -1155,10 +1176,10 @@
if (!PyArg_ParseTuple(args, "z|i:dlopen", &name, &mode))
return NULL;
mode |= RTLD_NOW;
- handle = dlopen(name, mode);
+ handle = ctypes_dlopen(name, mode);
if (!handle) {
PyErr_SetString(PyExc_OSError,
- dlerror());
+ ctypes_dlerror());
return NULL;
}
return PyLong_FromVoidPtr(handle);
@@ -1172,7 +1193,7 @@
return NULL;
if (dlclose(handle)) {
PyErr_SetString(PyExc_OSError,
- dlerror());
+ ctypes_dlerror());
return NULL;
}
Py_INCREF(Py_None);
@@ -1187,10 +1208,10 @@
if (!PyArg_ParseTuple(args, "is:dlsym", &handle, &name))
return NULL;
- ptr = dlsym(handle, name);
+ ptr = ctypes_dlsym(handle, name);
if (!ptr) {
PyErr_SetString(PyExc_OSError,
- dlerror());
+ ctypes_dlerror());
return NULL;
}
return Py_BuildValue("i", ptr);
@@ -1356,7 +1377,7 @@
converter(PyObject *obj, void **address)
{
*address = PyLong_AsVoidPtr(obj);
- return address != NULL;
+ return *address != NULL;
}
static PyObject *
@@ -1416,71 +1437,7 @@
}
#endif
-static char cast_doc[] =
-"cast(cobject, ctype) -> ctype-instance\n\
-\n\
-Create an instance of ctype, and copy the internal memory buffer\n\
-of cobject to the new instance. Should be used to cast one type\n\
-of pointer to another type of pointer.\n\
-Doesn't work correctly with ctypes integers.\n";
-
-static int cast_check_pointertype(PyObject *arg, PyObject **pobj)
-{
- StgDictObject *dict;
-
- if (PointerTypeObject_Check(arg)) {
- *pobj = arg;
- return 1;
- }
- dict = PyType_stgdict(arg);
- if (dict) {
- if (PyString_Check(dict->proto)
- && (strchr("sPzUZXO", PyString_AS_STRING(dict->proto)[0]))) {
- /* simple pointer types, c_void_p, c_wchar_p, BSTR, ... */
- *pobj = arg;
- return 1;
- }
- }
- if (PyType_Check(arg)) {
- PyErr_Format(PyExc_TypeError,
- "cast() argument 2 must be a pointer type, not %s",
- ((PyTypeObject *)arg)->tp_name);
- } else {
- PyErr_Format(PyExc_TypeError,
- "cast() argument 2 must be a pointer type, not a %s",
- arg->ob_type->tp_name);
- }
- return 0;
-}
-
-static PyObject *cast(PyObject *self, PyObject *args)
-{
- PyObject *obj, *ctype;
- struct argument a;
- CDataObject *result;
-
- /* We could and should allow array types for the second argument
- also, but we cannot use the simple memcpy below for them. */
- if (!PyArg_ParseTuple(args, "OO&:cast", &obj, &cast_check_pointertype, &ctype))
- return NULL;
- if (-1 == ConvParam(obj, 1, &a))
- return NULL;
- result = (CDataObject *)PyObject_CallFunctionObjArgs(ctype, NULL);
- if (result == NULL) {
- Py_XDECREF(a.keep);
- return NULL;
- }
- // result->b_size
- // a.ffi_type->size
- memcpy(result->b_ptr, &a.value,
- min(result->b_size, (int)a.ffi_type->size));
- Py_XDECREF(a.keep);
- return (PyObject *)result;
-}
-
-
PyMethodDef module_methods[] = {
- {"cast", cast, METH_VARARGS, cast_doc},
#ifdef CTYPES_UNICODE
{"set_conversion_mode", set_conversion_mode, METH_VARARGS, set_conversion_mode_doc},
#endif
Modified: packages/ctypes/branches/upstream/current/source/cfield.c
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/source/cfield.c?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/source/cfield.c (original)
+++ packages/ctypes/branches/upstream/current/source/cfield.c Mon Jun 19 12:31:53 2006
@@ -245,16 +245,26 @@
PyObject *result;
int bits = self->size >> 16;
int size = self->size & 0xFFFF;
- char *name;
+ const char *name;
name = ((PyTypeObject *)self->proto)->tp_name;
if (bits)
- result = PyString_FromFormat("<Field type=%s, ofs=%d:%d, bits=%d>",
- name, self->offset, size, bits);
+ result = PyString_FromFormat(
+#if (PY_VERSION_HEX < 0x02050000)
+ "<Field type=%s, ofs=%d:%d, bits=%d>",
+#else
+ "<Field type=%s, ofs=%zd:%d, bits=%d>",
+#endif
+ name, self->offset, size, bits);
else
- result = PyString_FromFormat("<Field type=%s, ofs=%d, size=%d>",
- name, self->offset, size);
+ result = PyString_FromFormat(
+#if (PY_VERSION_HEX < 0x02050000)
+ "<Field type=%s, ofs=%d, size=%d>",
+#else
+ "<Field type=%s, ofs=%zd, size=%d>",
+#endif
+ name, self->offset, size);
return result;
}
@@ -489,7 +499,7 @@
long val;
if (get_long(value, &val) < 0)
return NULL;
- *(char *)ptr = (char)SET(*(char *)ptr, (char)val, size);
+ *(signed char *)ptr = (signed char)SET(*(signed char *)ptr, (signed char)val, size);
_RET(value);
}
@@ -497,7 +507,7 @@
static PyObject *
b_get(void *ptr, unsigned size)
{
- char val = *(char *)ptr;
+ signed char val = *(signed char *)ptr;
GET_BITFIELD(val, size);
return PyInt_FromLong(val);
}
@@ -526,9 +536,12 @@
h_set(void *ptr, PyObject *value, unsigned size)
{
long val;
+ short x;
if (get_long(value, &val) < 0)
return NULL;
- *(short *)ptr = (short)SET(*(short *)ptr, (short)val, size);
+ memcpy(&x, ptr, sizeof(x));
+ x = SET(x, (short)val, size);
+ memcpy(ptr, &x, sizeof(x));
_RET(value);
}
@@ -540,37 +553,43 @@
short field;
if (get_long(value, &val) < 0)
return NULL;
- field = SWAP_2(*(short *)ptr);
+ memcpy(&field, ptr, sizeof(field));
+ field = SWAP_2(field);
field = SET(field, (short)val, size);
- *(short *)ptr = SWAP_2(field);
+ field = SWAP_2(field);
+ memcpy(ptr, &field, sizeof(field));
_RET(value);
}
static PyObject *
h_get(void *ptr, unsigned size)
{
- short val = *(short *)ptr;
+ short val;
+ memcpy(&val, ptr, sizeof(val));
+ GET_BITFIELD(val, size);
+ return PyInt_FromLong((long)val);
+}
+
+static PyObject *
+h_get_sw(void *ptr, unsigned size)
+{
+ short val;
+ memcpy(&val, ptr, sizeof(val));
+ val = SWAP_2(val);
GET_BITFIELD(val, size);
return PyInt_FromLong(val);
}
static PyObject *
-h_get_sw(void *ptr, unsigned size)
-{
- short val = *(short *)ptr;
- val = SWAP_2(val);
- GET_BITFIELD(val, size);
- return PyInt_FromLong(val);
-}
-
-static PyObject *
H_set(void *ptr, PyObject *value, unsigned size)
{
unsigned long val;
+ unsigned short x;
if (get_ulong(value, &val) < 0)
return NULL;
- *(unsigned short *)ptr = (unsigned short)SET(*(unsigned short *)ptr,
- (unsigned short)val, size);
+ memcpy(&x, ptr, sizeof(x));
+ x = SET(x, (unsigned short)val, size);
+ memcpy(ptr, &x, sizeof(x));
_RET(value);
}
@@ -581,9 +600,11 @@
unsigned short field;
if (get_ulong(value, &val) < 0)
return NULL;
- field = SWAP_2(*(unsigned short *)ptr);
+ memcpy(&field, ptr, sizeof(field));
+ field = SWAP_2(field);
field = SET(field, (unsigned short)val, size);
- *(unsigned short *)ptr = SWAP_2(field);
+ field = SWAP_2(field);
+ memcpy(ptr, &field, sizeof(field));
_RET(value);
}
@@ -591,7 +612,8 @@
static PyObject *
H_get(void *ptr, unsigned size)
{
- unsigned short val = *(unsigned short *)ptr;
+ unsigned short val;
+ memcpy(&val, ptr, sizeof(val));
GET_BITFIELD(val, size);
return PyInt_FromLong(val);
}
@@ -599,7 +621,8 @@
static PyObject *
H_get_sw(void *ptr, unsigned size)
{
- unsigned short val = *(unsigned short *)ptr;
+ unsigned short val;
+ memcpy(&val, ptr, sizeof(val));
val = SWAP_2(val);
GET_BITFIELD(val, size);
return PyInt_FromLong(val);
@@ -609,9 +632,12 @@
i_set(void *ptr, PyObject *value, unsigned size)
{
long val;
+ int x;
if (get_long(value, &val) < 0)
return NULL;
- *(int *)ptr = (int)SET(*(int *)ptr, (int)val, size);
+ memcpy(&x, ptr, sizeof(x));
+ x = SET(x, (int)val, size);
+ memcpy(ptr, &x, sizeof(x));
_RET(value);
}
@@ -622,9 +648,11 @@
int field;
if (get_long(value, &val) < 0)
return NULL;
- field = SWAP_INT(*(int *)ptr);
+ memcpy(&field, ptr, sizeof(field));
+ field = SWAP_INT(field);
field = SET(field, (int)val, size);
- *(int *)ptr = SWAP_INT(field);
+ field = SWAP_INT(field);
+ memcpy(ptr, &field, sizeof(field));
_RET(value);
}
@@ -632,7 +660,8 @@
static PyObject *
i_get(void *ptr, unsigned size)
{
- int val = *(int *)ptr;
+ int val;
+ memcpy(&val, ptr, sizeof(val));
GET_BITFIELD(val, size);
return PyInt_FromLong(val);
}
@@ -640,7 +669,8 @@
static PyObject *
i_get_sw(void *ptr, unsigned size)
{
- int val = *(int *)ptr;
+ int val;
+ memcpy(&val, ptr, sizeof(val));
val = SWAP_INT(val);
GET_BITFIELD(val, size);
return PyInt_FromLong(val);
@@ -674,9 +704,12 @@
I_set(void *ptr, PyObject *value, unsigned size)
{
unsigned long val;
+ unsigned int x;
if (get_ulong(value, &val) < 0)
return NULL;
- *(unsigned int *)ptr = (unsigned int)SET(*(unsigned int *)ptr, (unsigned int)val, size);
+ memcpy(&x, ptr, sizeof(x));
+ x = SET(x, (unsigned int)val, size);
+ memcpy(ptr, &x, sizeof(x));
_RET(value);
}
@@ -687,9 +720,10 @@
unsigned int field;
if (get_ulong(value, &val) < 0)
return NULL;
- field = SWAP_INT(*(unsigned int *)ptr);
+ memcpy(&field, ptr, sizeof(field));
field = (unsigned int)SET(field, (unsigned int)val, size);
- *(unsigned int *)ptr = SWAP_INT(field);
+ field = SWAP_INT(field);
+ memcpy(ptr, &field, sizeof(field));
_RET(value);
}
@@ -697,7 +731,8 @@
static PyObject *
I_get(void *ptr, unsigned size)
{
- unsigned int val = *(unsigned int *)ptr;
+ unsigned int val;
+ memcpy(&val, ptr, sizeof(val));
GET_BITFIELD(val, size);
return PyLong_FromUnsignedLong(val);
}
@@ -705,7 +740,8 @@
static PyObject *
I_get_sw(void *ptr, unsigned size)
{
- unsigned int val = *(unsigned int *)ptr;
+ unsigned int val;
+ memcpy(&val, ptr, sizeof(val));
val = SWAP_INT(val);
GET_BITFIELD(val, size);
return PyLong_FromUnsignedLong(val);
@@ -715,9 +751,12 @@
l_set(void *ptr, PyObject *value, unsigned size)
{
long val;
+ long x;
if (get_long(value, &val) < 0)
return NULL;
- *(long *)ptr = (long)SET(*(long *)ptr, val, size);
+ memcpy(&x, ptr, sizeof(x));
+ x = SET(x, val, size);
+ memcpy(ptr, &x, sizeof(x));
_RET(value);
}
@@ -728,9 +767,11 @@
long field;
if (get_long(value, &val) < 0)
return NULL;
- field = SWAP_LONG(*(long *)ptr);
+ memcpy(&field, ptr, sizeof(field));
+ field = SWAP_LONG(field);
field = (long)SET(field, val, size);
- *(long *)ptr = SWAP_LONG(field);
+ field = SWAP_LONG(field);
+ memcpy(ptr, &field, sizeof(field));
_RET(value);
}
@@ -738,7 +779,8 @@
static PyObject *
l_get(void *ptr, unsigned size)
{
- long val = *(long *)ptr;
+ long val;
+ memcpy(&val, ptr, sizeof(val));
GET_BITFIELD(val, size);
return PyInt_FromLong(val);
}
@@ -746,7 +788,8 @@
static PyObject *
l_get_sw(void *ptr, unsigned size)
{
- long val = *(long *)ptr;
+ long val;
+ memcpy(&val, ptr, sizeof(val));
val = SWAP_LONG(val);
GET_BITFIELD(val, size);
return PyInt_FromLong(val);
@@ -756,9 +799,12 @@
L_set(void *ptr, PyObject *value, unsigned size)
{
unsigned long val;
+ unsigned long x;
if (get_ulong(value, &val) < 0)
return NULL;
- *(unsigned long *)ptr = (unsigned long)SET(*(unsigned long *)ptr, val, size);
+ memcpy(&x, ptr, sizeof(x));
+ x = SET(x, val, size);
+ memcpy(ptr, &x, sizeof(x));
_RET(value);
}
@@ -769,9 +815,11 @@
unsigned long field;
if (get_ulong(value, &val) < 0)
return NULL;
- field = SWAP_LONG(*(unsigned long *)ptr);
+ memcpy(&field, ptr, sizeof(field));
+ field = SWAP_LONG(field);
field = (unsigned long)SET(field, val, size);
- *(unsigned long *)ptr = SWAP_LONG(field);
+ field = SWAP_LONG(field);
+ memcpy(ptr, &field, sizeof(field));
_RET(value);
}
@@ -779,7 +827,8 @@
static PyObject *
L_get(void *ptr, unsigned size)
{
- unsigned long val = *(unsigned long *)ptr;
+ unsigned long val;
+ memcpy(&val, ptr, sizeof(val));
GET_BITFIELD(val, size);
return PyLong_FromUnsignedLong(val);
}
@@ -787,7 +836,8 @@
static PyObject *
L_get_sw(void *ptr, unsigned size)
{
- unsigned long val = *(unsigned long *)ptr;
+ unsigned long val;
+ memcpy(&val, ptr, sizeof(val));
val = SWAP_LONG(val);
GET_BITFIELD(val, size);
return PyLong_FromUnsignedLong(val);
@@ -798,9 +848,12 @@
q_set(void *ptr, PyObject *value, unsigned size)
{
PY_LONG_LONG val;
+ PY_LONG_LONG x;
if (get_longlong(value, &val) < 0)
return NULL;
- *(PY_LONG_LONG *)ptr = (PY_LONG_LONG)SET(*(PY_LONG_LONG *)ptr, val, size);
+ memcpy(&x, ptr, sizeof(x));
+ x = SET(x, val, size);
+ memcpy(ptr, &x, sizeof(x));
_RET(value);
}
@@ -811,16 +864,19 @@
PY_LONG_LONG field;
if (get_longlong(value, &val) < 0)
return NULL;
- field = SWAP_8(*(PY_LONG_LONG *)ptr);
+ memcpy(&field, ptr, sizeof(field));
+ field = SWAP_8(field);
field = (PY_LONG_LONG)SET(field, val, size);
- *(PY_LONG_LONG *)ptr = SWAP_8(field);
+ field = SWAP_8(field);
+ memcpy(ptr, &field, sizeof(field));
_RET(value);
}
static PyObject *
q_get(void *ptr, unsigned size)
{
- PY_LONG_LONG val = *(PY_LONG_LONG *)ptr;
+ PY_LONG_LONG val;
+ memcpy(&val, ptr, sizeof(val));
GET_BITFIELD(val, size);
return PyLong_FromLongLong(val);
}
@@ -828,7 +884,8 @@
static PyObject *
q_get_sw(void *ptr, unsigned size)
{
- PY_LONG_LONG val = *(PY_LONG_LONG *)ptr;
+ PY_LONG_LONG val;
+ memcpy(&val, ptr, sizeof(val));
val = SWAP_8(val);
GET_BITFIELD(val, size);
return PyLong_FromLongLong(val);
@@ -838,9 +895,12 @@
Q_set(void *ptr, PyObject *value, unsigned size)
{
unsigned PY_LONG_LONG val;
+ unsigned PY_LONG_LONG x;
if (get_ulonglong(value, &val) < 0)
return NULL;
- *(unsigned PY_LONG_LONG *)ptr = (unsigned PY_LONG_LONG)SET(*(unsigned PY_LONG_LONG *)ptr, val, size);
+ memcpy(&x, ptr, sizeof(x));
+ x = SET(x, val, size);
+ memcpy(ptr, &x, sizeof(x));
_RET(value);
}
@@ -851,16 +911,19 @@
unsigned PY_LONG_LONG field;
if (get_ulonglong(value, &val) < 0)
return NULL;
- field = SWAP_8(*(unsigned PY_LONG_LONG *)ptr);
+ memcpy(&field, ptr, sizeof(field));
+ field = SWAP_8(field);
field = (unsigned PY_LONG_LONG)SET(field, val, size);
- *(unsigned PY_LONG_LONG *)ptr = SWAP_8(field);
+ field = SWAP_8(field);
+ memcpy(ptr, &field, sizeof(field));
_RET(value);
}
static PyObject *
Q_get(void *ptr, unsigned size)
{
- unsigned PY_LONG_LONG val = *(unsigned PY_LONG_LONG *)ptr;
+ unsigned PY_LONG_LONG val;
+ memcpy(&val, ptr, sizeof(val));
GET_BITFIELD(val, size);
return PyLong_FromUnsignedLongLong(val);
}
@@ -868,7 +931,8 @@
static PyObject *
Q_get_sw(void *ptr, unsigned size)
{
- unsigned PY_LONG_LONG val = *(unsigned PY_LONG_LONG *)ptr;
+ unsigned PY_LONG_LONG val;
+ memcpy(&val, ptr, sizeof(val));
val = SWAP_8(val);
GET_BITFIELD(val, size);
return PyLong_FromUnsignedLongLong(val);
@@ -893,14 +957,16 @@
value->ob_type->tp_name);
return NULL;
}
- *(double *)ptr = x;
+ memcpy(ptr, &x, sizeof(double));
_RET(value);
}
static PyObject *
d_get(void *ptr, unsigned size)
{
- return PyFloat_FromDouble(*(double *)ptr);
+ double val;
+ memcpy(&val, ptr, sizeof(val));
+ return PyFloat_FromDouble(val);
}
static PyObject *
@@ -947,14 +1013,16 @@
value->ob_type->tp_name);
return NULL;
}
- *(float *)ptr = x;
+ memcpy(ptr, &x, sizeof(x));
_RET(value);
}
static PyObject *
f_get(void *ptr, unsigned size)
{
- return PyFloat_FromDouble(*(float *)ptr);
+ float val;
+ memcpy(&val, ptr, sizeof(val));
+ return PyFloat_FromDouble(val);
}
static PyObject *
@@ -989,6 +1057,16 @@
#endif
}
+/*
+ py_object refcounts:
+
+ 1. If we have a py_object instance, O_get must Py_INCREF the returned
+ object, of course. If O_get is called from a function result, no py_object
+ instance is created - so callproc.c::GetResult has to call Py_DECREF.
+
+ 2. The memory block in py_object owns a refcount. So, py_object must call
+ Py_DECREF on destruction. Maybe only when b_needsfree is non-zero.
+*/
static PyObject *
O_get(void *ptr, unsigned size)
{
@@ -1000,12 +1078,14 @@
"PyObject is NULL?");
return NULL;
}
+ Py_INCREF(ob);
return ob;
}
static PyObject *
O_set(void *ptr, PyObject *value, unsigned size)
{
+ /* Hm, does the memory block need it's own refcount or not? */
*(PyObject **)ptr = value;
Py_INCREF(value);
return value;
@@ -1295,6 +1375,7 @@
if (-1 == PyUnicode_AsWideChar((PyUnicodeObject *)value,
buffer, PyUnicode_GET_SIZE(value))) {
Py_DECREF(value);
+ Py_DECREF(keep);
return NULL;
}
Py_DECREF(value);
Modified: packages/ctypes/branches/upstream/current/source/ctypes.h
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/source/ctypes.h?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/source/ctypes.h (original)
+++ packages/ctypes/branches/upstream/current/source/ctypes.h Mon Jun 19 12:31:53 2006
@@ -1,4 +1,8 @@
/******************************************************************/
+
+#if (PY_VERSION_HEX < 0x02050000)
+typedef int Py_ssize_t;
+#endif
#ifndef MS_WIN32
#define max(a, b) ((a) > (b) ? (a) : (b))
@@ -17,8 +21,9 @@
#define PY_LONG_LONG LONG_LONG
#endif
-typedef int (*THUNK)(void);
typedef struct tagCDataObject CDataObject;
+typedef PyObject *(* GETFUNC)(void *, unsigned size);
+typedef PyObject *(* SETFUNC)(void *, PyObject *value, unsigned size);
/* A default buffer in CDataObject, which can be used for small C types. If
this buffer is too small, PyMem_Malloc will be called to create a larger one,
@@ -50,13 +55,23 @@
char *b_ptr; /* pointer to memory block */
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
+ 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 */
union value b_value;
};
+
+typedef struct {
+ ffi_closure *pcl; /* the C callable */
+ ffi_cif cif;
+ PyObject *converters;
+ PyObject *callable;
+ SETFUNC setfunc;
+ ffi_type *restype;
+ ffi_type *atypes[0];
+} ffi_info;
typedef struct {
/* First part identical to tagCDataObject */
@@ -64,15 +79,15 @@
char *b_ptr; /* pointer to memory block */
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
+ 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 */
union value b_value;
/* end of tagCDataObject, additional fields follow */
- THUNK thunk;
+ ffi_info *thunk;
PyObject *callable;
/* These two fields will override the ones in the type's stgdict if
@@ -94,8 +109,8 @@
#define StgDict_Check(v) PyObject_TypeCheck(v, &StgDict_Type)
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);
+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);
@@ -118,7 +133,7 @@
int pack, int is_big_endian);
extern PyObject *CData_AtAddress(PyObject *type, void *buf);
-extern PyObject *CData_FromBytes(PyObject *type, char *data, int length);
+extern PyObject *CData_FromBytes(PyObject *type, char *data, Py_ssize_t length);
extern PyTypeObject ArrayType_Type;
extern PyTypeObject Array_Type;
@@ -137,21 +152,16 @@
#define StructTypeObject_Check(v) PyObject_TypeCheck(v, &StructType_Type)
extern PyObject *
-CreateArrayType(PyObject *itemtype, int length);
+CreateArrayType(PyObject *itemtype, Py_ssize_t length);
extern void init_callbacks_in_module(PyObject *m);
-extern THUNK AllocFunctionCallback(PyObject *callable,
- PyObject *converters,
- PyObject *restype,
- int stdcall);
-extern void FreeCallback(THUNK);
-
extern PyMethodDef module_methods[];
-typedef PyObject *(* GETFUNC)(void *, unsigned size);
-typedef PyObject *(* SETFUNC)(void *, PyObject *value, unsigned size);
-
+extern ffi_info *AllocFunctionCallback(PyObject *callable,
+ PyObject *converters,
+ PyObject *restype,
+ int stdcall);
/* a table entry describing a predefined ctypes type */
struct fielddesc {
char code;
@@ -164,9 +174,9 @@
typedef struct {
PyObject_HEAD
- int offset;
- int size;
- int index; /* Index into CDataObject's
+ Py_ssize_t offset;
+ Py_ssize_t size;
+ Py_ssize_t index; /* Index into CDataObject's
object array */
PyObject *proto; /* a type or NULL */
GETFUNC getfunc; /* getter function if proto is NULL */
@@ -185,10 +195,10 @@
too much risk to change that now, and there are other fields which doen't
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;
+ Py_ssize_t size; /* number of bytes */
+ Py_ssize_t align; /* alignment requirements */
+ Py_ssize_t length; /* number of fields */
+ ffi_type ffi_type_pointer;
PyObject *proto; /* Only for Pointer/ArrayObject */
SETFUNC setfunc; /* Only for simple objects */
GETFUNC getfunc; /* Only for simple objects */
@@ -298,17 +308,17 @@
extern PyObject *
CData_get(PyObject *type, GETFUNC getfunc, PyObject *src,
- int index, int size, char *ptr);
+ Py_ssize_t index, Py_ssize_t size, char *ptr);
extern int
CData_set(PyObject *dst, PyObject *type, SETFUNC setfunc, PyObject *value,
- int index, int size, char *ptr);
+ Py_ssize_t index, Py_ssize_t size, char *ptr);
extern void Extend_Error_Info(PyObject *exc_class, char *fmt, ...);
struct basespec {
CDataObject *base;
- int index;
+ Py_ssize_t index;
char *adr;
};
@@ -374,7 +384,7 @@
extern void _AddTraceback(char *, char *, int);
-extern PyObject *CData_FromBaseObj(PyObject *type, PyObject *base, int index, char *adr);
+extern PyObject *CData_FromBaseObj(PyObject *type, PyObject *base, Py_ssize_t index, char *adr);
/* XXX better name needed! */
extern int IsSimpleSubType(PyObject *obj);
Added: packages/ctypes/branches/upstream/current/source/ctypes_dlfcn.h
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/source/ctypes_dlfcn.h?rev=940&op=file
==============================================================================
--- packages/ctypes/branches/upstream/current/source/ctypes_dlfcn.h (added)
+++ packages/ctypes/branches/upstream/current/source/ctypes_dlfcn.h Mon Jun 19 12:31:53 2006
@@ -1,0 +1,29 @@
+/******************************************************************/
+
+#ifndef _CTYPES_DLFCN_H_
+#define _CTYPES_DLFCN_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#ifndef MS_WIN32
+
+#include <dlfcn.h>
+
+#ifndef CTYPES_DARWIN_DLFCN
+
+#define ctypes_dlsym dlsym
+#define ctypes_dlerror dlerror
+#define ctypes_dlopen dlopen
+#define ctypes_dlclose dlclose
+#define ctypes_dladdr dladdr
+
+#endif /* !CTYPES_DARWIN_DLFCN */
+
+#endif /* !MS_WIN32 */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* _CTYPES_DLFCN_H_ */
Modified: packages/ctypes/branches/upstream/current/source/darwin/dlfcn.h
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/source/darwin/dlfcn.h?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/source/darwin/dlfcn.h (original)
+++ packages/ctypes/branches/upstream/current/source/darwin/dlfcn.h Mon Jun 19 12:31:53 2006
@@ -31,6 +31,8 @@
#ifndef _DLFCN_H_
#define _DLFCN_H_
+#include <AvailabilityMacros.h>
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -48,11 +50,21 @@
} Dl_info;
+#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_2
+#warning CTYPES_DARWIN_DLFCN
+#define CTYPES_DARWIN_DLFCN
+extern void * (*ctypes_dlopen)(const char *path, int mode);
+extern void * (*ctypes_dlsym)(void * handle, const char *symbol);
+extern const char * (*ctypes_dlerror)(void);
+extern int (*ctypes_dlclose)(void * handle);
+extern int (*ctypes_dladdr)(const void *, Dl_info *);
+#else
extern void * dlopen(const char *path, int mode);
extern void * dlsym(void * handle, const char *symbol);
extern const char * dlerror(void);
extern int dlclose(void * handle);
-extern int dladdr(void *, Dl_info *);
+extern int dladdr(const void *, Dl_info *);
+#endif
#define RTLD_LAZY 0x1
#define RTLD_NOW 0x2
@@ -61,6 +73,9 @@
#define RTLD_NOLOAD 0x10
#define RTLD_NODELETE 0x80
+/* These are from the Mac OS X 10.4 headers */
+#define RTLD_NEXT ((void *) -1) /* Search subsequent objects. */
+#define RTLD_DEFAULT ((void *) -2) /* Use default search algorithm. */
#ifdef __cplusplus
}
Modified: packages/ctypes/branches/upstream/current/source/darwin/dlfcn_simple.c
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/source/darwin/dlfcn_simple.c?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/source/darwin/dlfcn_simple.c (original)
+++ packages/ctypes/branches/upstream/current/source/darwin/dlfcn_simple.c Mon Jun 19 12:31:53 2006
@@ -37,15 +37,46 @@
#include <stdarg.h>
#include <limits.h>
#include <mach-o/dyld.h>
+#include <AvailabilityMacros.h>
#include "dlfcn.h"
+#ifdef CTYPES_DARWIN_DLFCN
+
#define ERR_STR_LEN 256
+#ifndef MAC_OS_X_VERSION_10_3
+#define MAC_OS_X_VERSION_10_3 1030
+#endif
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
+#define DARWIN_HAS_DLOPEN
+extern void * dlopen(const char *path, int mode) __attribute__((weak_import));
+extern void * dlsym(void * handle, const char *symbol) __attribute__((weak_import));
+extern const char * dlerror(void) __attribute__((weak_import));
+extern int dlclose(void * handle) __attribute__((weak_import));
+extern int dladdr(const void *, Dl_info *) __attribute__((weak_import));
+#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3 */
+
+#ifndef DARWIN_HAS_DLOPEN
+#define dlopen darwin_dlopen
+#define dlsym darwin_dlsym
+#define dlerror darwin_dlerror
+#define dlclose darwin_dlclose
+#define dladdr darwin_dladdr
+#endif
+
+void * (*ctypes_dlopen)(const char *path, int mode);
+void * (*ctypes_dlsym)(void * handle, const char *symbol);
+const char * (*ctypes_dlerror)(void);
+int (*ctypes_dlclose)(void * handle);
+int (*ctypes_dladdr)(const void *, Dl_info *);
+
+#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_3
+/* Mac OS X 10.3+ has dlopen, so strip all this dead code to avoid warnings */
+
static void *dlsymIntern(void *handle, const char *symbol);
static const char *error(int setget, const char *str, ...);
-
-
/* Set and get the error string for use by dlerror */
static const char *error(int setget, const char *str, ...)
@@ -74,8 +105,8 @@
return retval;
}
-/* dlopen */
-void *dlopen(const char *path, int mode)
+/* darwin_dlopen */
+static void *darwin_dlopen(const char *path, int mode)
{
void *module = 0;
NSObjectFileImage ofi = 0;
@@ -114,9 +145,9 @@
}
/* dlsymIntern is used by dlsym to find the symbol */
-void *dlsymIntern(void *handle, const char *symbol)
-{
- NSSymbol *nssym = 0;
+static void *dlsymIntern(void *handle, const char *symbol)
+{
+ NSSymbol nssym = 0;
/* If the handle is -1, if is the app global context */
if (handle == (void *)-1)
{
@@ -157,12 +188,12 @@
return NSAddressOfSymbol(nssym);
}
-const char *dlerror(void)
+static const char *darwin_dlerror(void)
{
return error(1, (char *)NULL);
}
-int dlclose(void *handle)
+static int darwin_dlclose(void *handle)
{
if ((((struct mach_header *)handle)->magic == MH_MAGIC) ||
(((struct mach_header *)handle)->magic == MH_CIGAM))
@@ -180,7 +211,7 @@
/* dlsym, prepend the underscore and call dlsymIntern */
-void *dlsym(void *handle, const char *symbol)
+static void *darwin_dlsym(void *handle, const char *symbol)
{
static char undersym[257]; /* Saves calls to malloc(3) */
int sym_len = strlen(symbol);
@@ -208,3 +239,34 @@
}
return value;
}
+
+static int darwin_dladdr(const void *handle, Dl_info *info) {
+ return 0;
+}
+#endif /* MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_3 */
+
+#if __GNUC__ < 4
+#pragma CALL_ON_LOAD ctypes_dlfcn_init
+#else
+static void __attribute__ ((constructor)) ctypes_dlfcn_init(void);
+static
+#endif
+void ctypes_dlfcn_init(void) {
+ if (dlopen != NULL) {
+ ctypes_dlsym = dlsym;
+ ctypes_dlopen = dlopen;
+ ctypes_dlerror = dlerror;
+ ctypes_dlclose = dlclose;
+ ctypes_dladdr = dladdr;
+ } else {
+#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_3
+ ctypes_dlsym = darwin_dlsym;
+ ctypes_dlopen = darwin_dlopen;
+ ctypes_dlerror = darwin_dlerror;
+ ctypes_dlclose = darwin_dlclose;
+ ctypes_dladdr = darwin_dladdr;
+#endif /* MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_3 */
+ }
+}
+
+#endif /* CTYPES_DARWIN_DLFCN */
Propchange: packages/ctypes/branches/upstream/current/source/libffi/config.guess
------------------------------------------------------------------------------
--- svn:executable (original)
+++ svn:executable Mon Jun 19 12:31:53 2006
@@ -1,0 +1,1 @@
+*
Propchange: packages/ctypes/branches/upstream/current/source/libffi/config.sub
------------------------------------------------------------------------------
--- svn:executable (original)
+++ svn:executable Mon Jun 19 12:31:53 2006
@@ -1,0 +1,1 @@
+*
Modified: packages/ctypes/branches/upstream/current/source/libffi/configure
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/source/libffi/configure?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/source/libffi/configure (original)
+++ packages/ctypes/branches/upstream/current/source/libffi/configure Mon Jun 19 12:31:53 2006
@@ -3490,6 +3490,7 @@
i*86-*-beos*) TARGET=X86; TARGETDIR=x86;;
i*86-*-freebsd* | i*86-*-kfreebsd*-gnu) TARGET=X86; TARGETDIR=x86;;
i*86-*-netbsdelf* | i*86-*-knetbsd*-gnu) TARGET=X86; TARGETDIR=x86;;
+i*86-*-openbsd*) TARGET=X86; TARGETDIR=x86;;
i*86-*-rtems*) TARGET=X86; TARGETDIR=x86;;
i*86-*-win32*) TARGET=X86_WIN32; TARGETDIR=x86;;
i*86-*-cygwin*) TARGET=X86_WIN32; TARGETDIR=x86;;
Propchange: packages/ctypes/branches/upstream/current/source/libffi/configure
------------------------------------------------------------------------------
--- svn:executable (original)
+++ svn:executable Mon Jun 19 12:31:53 2006
@@ -1,0 +1,1 @@
+*
Modified: packages/ctypes/branches/upstream/current/source/libffi/configure.ac
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/source/libffi/configure.ac?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/source/libffi/configure.ac (original)
+++ packages/ctypes/branches/upstream/current/source/libffi/configure.ac Mon Jun 19 12:31:53 2006
@@ -28,6 +28,7 @@
i*86-*-beos*) TARGET=X86; TARGETDIR=x86;;
i*86-*-freebsd* | i*86-*-kfreebsd*-gnu) TARGET=X86; TARGETDIR=x86;;
i*86-*-netbsdelf* | i*86-*-knetbsd*-gnu) TARGET=X86; TARGETDIR=x86;;
+i*86-*-openbsd*) TARGET=X86; TARGETDIR=x86;;
i*86-*-rtems*) TARGET=X86; TARGETDIR=x86;;
i*86-*-win32*) TARGET=X86_WIN32; TARGETDIR=x86;;
i*86-*-cygwin*) TARGET=X86_WIN32; TARGETDIR=x86;;
Modified: packages/ctypes/branches/upstream/current/source/libffi/fficonfig.py.in
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/source/libffi/fficonfig.py.in?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/source/libffi/fficonfig.py.in (original)
+++ packages/ctypes/branches/upstream/current/source/libffi/fficonfig.py.in Mon Jun 19 12:31:53 2006
@@ -31,5 +31,6 @@
ffi_sources = [os.path.join('@srcdir@', f) for f in ffi_sources]
ffi_cflags = '@CFLAGS@'
+# I think this may no longer be needed:
if sys.platform == "openbsd3":
ffi_cflags += " -fno-stack-protector"
Modified: packages/ctypes/branches/upstream/current/source/libffi/include/ffi.h.in
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/source/libffi/include/ffi.h.in?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/source/libffi/include/ffi.h.in (original)
+++ packages/ctypes/branches/upstream/current/source/libffi/include/ffi.h.in Mon Jun 19 12:31:53 2006
@@ -188,7 +188,7 @@
} ffi_raw;
void ffi_raw_call (/*@dependent@*/ ffi_cif *cif,
- void (*fn)(),
+ void (*fn)(void),
/*@out@*/ void *rvalue,
/*@dependent@*/ ffi_raw *avalue);
@@ -201,7 +201,7 @@
/* longs and doubles are followed by an empty 64-bit word. */
void ffi_java_raw_call (/*@dependent@*/ ffi_cif *cif,
- void (*fn)(),
+ void (*fn)(void),
/*@out@*/ void *rvalue,
/*@dependent@*/ ffi_raw *avalue);
@@ -270,7 +270,7 @@
/*@dependent@*/ ffi_type **atypes);
void ffi_call(/*@dependent@*/ ffi_cif *cif,
- void (*fn)(),
+ void (*fn)(void),
/*@out@*/ void *rvalue,
/*@dependent@*/ void **avalue);
Propchange: packages/ctypes/branches/upstream/current/source/libffi/install-sh
------------------------------------------------------------------------------
--- svn:executable (original)
+++ svn:executable Mon Jun 19 12:31:53 2006
@@ -1,0 +1,1 @@
+*
Modified: packages/ctypes/branches/upstream/current/source/libffi/src/alpha/osf.S
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/source/libffi/src/alpha/osf.S?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/source/libffi/src/alpha/osf.S (original)
+++ packages/ctypes/branches/upstream/current/source/libffi/src/alpha/osf.S Mon Jun 19 12:31:53 2006
@@ -3,7 +3,7 @@
Alpha/OSF Foreign Function Interface
- $Id: osf.S,v 1.1.2.2 2006/02/01 20:31:51 perky Exp $
+ $Id: osf.S,v 1.2 2006/03/03 20:24:26 theller Exp $
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Modified: packages/ctypes/branches/upstream/current/source/libffi/src/frv/eabi.S
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/source/libffi/src/frv/eabi.S?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/source/libffi/src/frv/eabi.S (original)
+++ packages/ctypes/branches/upstream/current/source/libffi/src/frv/eabi.S Mon Jun 19 12:31:53 2006
@@ -3,7 +3,7 @@
FR-V Assembly glue.
- $Id: eabi.S,v 1.1.2.4 2006/02/01 20:31:51 perky Exp $
+ $Id: eabi.S,v 1.2 2006/03/03 20:24:46 theller Exp $
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Modified: packages/ctypes/branches/upstream/current/source/libffi/src/powerpc/darwin_closure.S
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/source/libffi/src/powerpc/darwin_closure.S?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/source/libffi/src/powerpc/darwin_closure.S (original)
+++ packages/ctypes/branches/upstream/current/source/libffi/src/powerpc/darwin_closure.S Mon Jun 19 12:31:53 2006
@@ -246,7 +246,7 @@
/* END(ffi_closure_ASM) */
.data
-.section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support
+.section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms
EH_frame1:
.set L$set$0,LECIE1-LSCIE1
.long L$set$0 ; Length of Common Information Entry
Modified: packages/ctypes/branches/upstream/current/source/libffi/src/x86/ffi.c
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/source/libffi/src/x86/ffi.c?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/source/libffi/src/x86/ffi.c (original)
+++ packages/ctypes/branches/upstream/current/source/libffi/src/x86/ffi.c Mon Jun 19 12:31:53 2006
@@ -121,7 +121,7 @@
switch (cif->rtype->type)
{
case FFI_TYPE_VOID:
-#ifndef X86_WIN32
+#if !defined(X86_WIN32) && !defined(__OpenBSD__) && !defined(__FreeBSD__)
case FFI_TYPE_STRUCT:
#endif
case FFI_TYPE_SINT64:
@@ -135,7 +135,7 @@
cif->flags = FFI_TYPE_SINT64;
break;
-#ifdef X86_WIN32
+#if defined(X86_WIN32) || defined(__OpenBSD__) || defined(__FreeBSD__)
case FFI_TYPE_STRUCT:
if (cif->rtype->size == 1)
{
Added: packages/ctypes/branches/upstream/current/source/libffi_arm_wince/debug.c
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/source/libffi_arm_wince/debug.c?rev=940&op=file
==============================================================================
--- packages/ctypes/branches/upstream/current/source/libffi_arm_wince/debug.c (added)
+++ packages/ctypes/branches/upstream/current/source/libffi_arm_wince/debug.c Mon Jun 19 12:31:53 2006
@@ -1,0 +1,59 @@
+/* -----------------------------------------------------------------------
+ debug.c - Copyright (c) 1996 Red Hat, Inc.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#include <ffi.h>
+#include <ffi_common.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+/* General debugging routines */
+
+void ffi_stop_here(void)
+{
+ /* This function is only useful for debugging purposes.
+ Place a breakpoint on ffi_stop_here to be notified of
+ significant events. */
+}
+
+/* This function should only be called via the FFI_ASSERT() macro */
+
+void ffi_assert(char *expr, char *file, int line)
+{
+ fprintf(stderr, "ASSERTION FAILURE: %s at %s:%d\n", expr, file, line);
+ ffi_stop_here();
+ abort();
+}
+
+/* Perform a sanity check on an ffi_type structure */
+
+void ffi_type_test(ffi_type *a, char *file, int line)
+{
+ FFI_ASSERT_AT(a != NULL, file, line);
+
+ /*@-usedef@*/
+ FFI_ASSERT_AT(a->type <= FFI_TYPE_LAST, file, line);
+ FFI_ASSERT_AT(a->type == FFI_TYPE_VOID || a->size > 0, file, line);
+ FFI_ASSERT_AT(a->type == FFI_TYPE_VOID || a->alignment > 0, file, line);
+ FFI_ASSERT_AT(a->type != FFI_TYPE_STRUCT || a->elements != NULL, file, line);
+ /*@=usedef@*/
+}
Added: packages/ctypes/branches/upstream/current/source/libffi_arm_wince/ffi.c
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/source/libffi_arm_wince/ffi.c?rev=940&op=file
==============================================================================
--- packages/ctypes/branches/upstream/current/source/libffi_arm_wince/ffi.c (added)
+++ packages/ctypes/branches/upstream/current/source/libffi_arm_wince/ffi.c Mon Jun 19 12:31:53 2006
@@ -1,0 +1,310 @@
+/* -----------------------------------------------------------------------
+ ffi.c - Copyright (c) 1998 Red Hat, Inc.
+
+ ARM Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#include <ffi.h>
+#include <ffi_common.h>
+
+#include <stdlib.h>
+
+#ifdef _WIN32_WCE
+#pragma warning (disable : 4142) /* benign redefinition of type */
+#include <windows.h>
+#endif
+
+/* ffi_prep_args is called by the assembly routine once stack space
+ has been allocated for the function's arguments */
+
+/*@-exportheader@*/
+void ffi_prep_args(char *stack, extended_cif *ecif)
+/*@=exportheader@*/
+{
+ register unsigned int i;
+ register void **p_argv;
+ register char *argp;
+ register ffi_type **p_arg;
+
+ argp = stack;
+
+ if ( ecif->cif->rtype->type == FFI_TYPE_STRUCT ) {
+ *(void **) argp = ecif->rvalue;
+ argp += 4;
+ }
+
+ p_argv = ecif->avalue;
+
+ for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types;
+ (i != 0);
+ i--, p_arg++)
+ {
+ size_t z;
+ size_t argalign = (*p_arg)->alignment;
+
+#ifdef _WIN32_WCE
+ if (argalign > 4)
+ argalign = 4;
+#endif
+ /* Align if necessary */
+ if ((argalign - 1) & (unsigned) argp) {
+ argp = (char *) ALIGN(argp, argalign);
+ }
+
+ z = (*p_arg)->size;
+ if (z < sizeof(int))
+ {
+ z = sizeof(int);
+ switch ((*p_arg)->type)
+ {
+ case FFI_TYPE_SINT8:
+ *(signed int *) argp = (signed int)*(SINT8 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_UINT8:
+ *(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_SINT16:
+ *(signed int *) argp = (signed int)*(SINT16 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_UINT16:
+ *(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_STRUCT:
+ /* *p_argv may not be aligned for a UINT32 */
+ memcpy(argp, *p_argv, z);
+ break;
+
+ default:
+ FFI_ASSERT(0);
+ }
+ }
+ else if (z == sizeof(int))
+ {
+ *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv);
+ }
+ else
+ {
+ memcpy(argp, *p_argv, z);
+ }
+ p_argv++;
+ argp += z;
+ }
+
+ return;
+}
+
+/* Perform machine dependent cif processing */
+ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
+{
+ /* Set the return type flag */
+ switch (cif->rtype->type)
+ {
+ case FFI_TYPE_VOID:
+ case FFI_TYPE_STRUCT:
+ case FFI_TYPE_FLOAT:
+ case FFI_TYPE_DOUBLE:
+ case FFI_TYPE_SINT64:
+ cif->flags = (unsigned) cif->rtype->type;
+ break;
+
+ case FFI_TYPE_UINT64:
+ cif->flags = FFI_TYPE_SINT64;
+ break;
+
+ default:
+ cif->flags = FFI_TYPE_INT;
+ break;
+ }
+
+ return FFI_OK;
+}
+
+/*@-declundef@*/
+/*@-exportheader@*/
+extern void ffi_call_SYSV(void (*)(char *, extended_cif *),
+ /*@out@*/ extended_cif *,
+ unsigned, unsigned,
+ /*@out@*/ unsigned *,
+ void (*fn)());
+/*@=declundef@*/
+/*@=exportheader@*/
+
+/* Return type changed from void for ctypes */
+int ffi_call(/*@dependent@*/ ffi_cif *cif,
+ void (*fn)(),
+ /*@out@*/ void *rvalue,
+ /*@dependent@*/ void **avalue)
+{
+ extended_cif ecif;
+
+ ecif.cif = cif;
+ ecif.avalue = avalue;
+
+ /* If the return value is a struct and we don't have a return */
+ /* value address then we need to make one */
+
+ if ((rvalue == NULL) &&
+ (cif->rtype->type == FFI_TYPE_STRUCT))
+ {
+ /*@-sysunrecog@*/
+ ecif.rvalue = alloca(cif->rtype->size);
+ /*@=sysunrecog@*/
+ }
+ else
+ ecif.rvalue = rvalue;
+
+
+ switch (cif->abi)
+ {
+ case FFI_SYSV:
+ /*@-usedef@*/
+ ffi_call_SYSV(ffi_prep_args, &ecif, cif->bytes,
+ cif->flags, ecif.rvalue, fn);
+ /*@=usedef@*/
+ break;
+ default:
+ FFI_ASSERT(0);
+ break;
+ }
+ /* I think calculating the real stack pointer delta is not useful
+ because stdcall is not supported */
+ return 0;
+}
+
+/** private members **/
+
+static void ffi_prep_incoming_args_SYSV (char *stack, void **ret,
+ void** args, ffi_cif* cif);
+
+/* This function is called by ffi_closure_SYSV in sysv.asm */
+
+unsigned int
+ffi_closure_SYSV_inner (ffi_closure *closure, char *in_args, void *rvalue)
+{
+ ffi_cif *cif = closure->cif;
+ void **out_args;
+
+ out_args = (void **) alloca(cif->nargs * sizeof (void *));
+
+ /* this call will initialize out_args, such that each
+ * element in that array points to the corresponding
+ * value on the stack; and if the function returns
+ * a structure, it will re-set rvalue to point to the
+ * structure return address. */
+
+ ffi_prep_incoming_args_SYSV(in_args, &rvalue, out_args, cif);
+
+ (closure->fun)(cif, rvalue, out_args, closure->user_data);
+
+ /* Tell ffi_closure_SYSV what the returntype is */
+ return cif->flags;
+}
+
+/*@-exportheader@*/
+static void
+ffi_prep_incoming_args_SYSV(char *stack, void **rvalue,
+ void **avalue, ffi_cif *cif)
+/*@=exportheader@*/
+{
+ unsigned int i;
+ void **p_argv;
+ char *argp;
+ ffi_type **p_arg;
+
+ argp = stack;
+
+ if ( cif->rtype->type == FFI_TYPE_STRUCT ) {
+ *rvalue = *(void **) argp;
+ argp += 4;
+ }
+
+ p_argv = avalue;
+
+ for (i = cif->nargs, p_arg = cif->arg_types; (i != 0); i--, p_arg++)
+ {
+ size_t z;
+ size_t argalign = (*p_arg)->alignment;
+
+#ifdef _WIN32_WCE
+ if (argalign > 4)
+ argalign = 4;
+#endif
+ /* Align if necessary */
+ if ((argalign - 1) & (unsigned) argp) {
+ argp = (char *) ALIGN(argp, argalign);
+ }
+
+ z = (*p_arg)->size;
+ if (z < sizeof(int))
+ z = sizeof(int);
+
+ *p_argv = (void*) argp;
+
+ p_argv++;
+ argp += z;
+ }
+}
+
+/*
+ add ip, pc, #-8 ; ip = address of this trampoline == address of ffi_closure
+ ldr pc, [pc, #-4] ; jump to __fun
+ DCD __fun
+*/
+#define FFI_INIT_TRAMPOLINE(TRAMP,FUN) \
+{ \
+ unsigned int *__tramp = (unsigned int *)(TRAMP); \
+ __tramp[0] = 0xe24fc008; /* add ip, pc, #-8 */ \
+ __tramp[1] = 0xe51ff004; /* ldr pc, [pc, #-4] */ \
+ __tramp[2] = (unsigned int)(FUN); \
+ }
+
+/* the cif must already be prep'ed */
+
+/* defined in sysv.asm */
+void ffi_closure_SYSV(void);
+
+ffi_status
+ffi_prep_closure (ffi_closure* closure,
+ ffi_cif* cif,
+ void (*fun)(ffi_cif*,void*,void**,void*),
+ void *user_data)
+{
+ FFI_ASSERT (cif->abi == FFI_SYSV);
+
+ FFI_INIT_TRAMPOLINE (&closure->tramp[0], &ffi_closure_SYSV);
+
+ closure->cif = cif;
+ closure->user_data = user_data;
+ closure->fun = fun;
+
+#ifdef _WIN32_WCE
+ /* This is important to allow calling the trampoline safely */
+ FlushInstructionCache(GetCurrentProcess(), 0, 0);
+#endif
+
+ return FFI_OK;
+}
+
Added: packages/ctypes/branches/upstream/current/source/libffi_arm_wince/ffi.h
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/source/libffi_arm_wince/ffi.h?rev=940&op=file
==============================================================================
--- packages/ctypes/branches/upstream/current/source/libffi_arm_wince/ffi.h (added)
+++ packages/ctypes/branches/upstream/current/source/libffi_arm_wince/ffi.h Mon Jun 19 12:31:53 2006
@@ -1,0 +1,317 @@
+/* -----------------------------------------------------------------*-C-*-
+ libffi 2.00-beta-wince - Copyright (c) 1996-2003 Red Hat, Inc.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+
+ ----------------------------------------------------------------------- */
+
+/* -------------------------------------------------------------------
+ The basic API is described in the README file.
+
+ The raw API is designed to bypass some of the argument packing
+ and unpacking on architectures for which it can be avoided.
+
+ The closure API allows interpreted functions to be packaged up
+ inside a C function pointer, so that they can be called as C functions,
+ with no understanding on the client side that they are interpreted.
+ It can also be used in other cases in which it is necessary to package
+ up a user specified parameter and a function pointer as a single
+ function pointer.
+
+ The closure API must be implemented in order to get its functionality,
+ e.g. for use by gij. Routines are provided to emulate the raw API
+ if the underlying platform doesn't allow faster implementation.
+
+ More details on the raw and cloure API can be found in:
+
+ http://gcc.gnu.org/ml/java/1999-q3/msg00138.html
+
+ and
+
+ http://gcc.gnu.org/ml/java/1999-q3/msg00174.html
+ -------------------------------------------------------------------- */
+
+#ifndef LIBFFI_H
+#define LIBFFI_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Specify which architecture libffi is configured for. */
+/*#define @TARGET@*/
+
+/* ---- System configuration information --------------------------------- */
+
+#include <ffitarget.h>
+
+#ifndef LIBFFI_ASM
+
+#include <stddef.h>
+#include <limits.h>
+
+/* LONG_LONG_MAX is not always defined (not if STRICT_ANSI, for example).
+ But we can find it either under the correct ANSI name, or under GNU
+ C's internal name. */
+#ifdef LONG_LONG_MAX
+# define FFI_LONG_LONG_MAX LONG_LONG_MAX
+#else
+# ifdef LLONG_MAX
+# define FFI_LONG_LONG_MAX LLONG_MAX
+# else
+# ifdef __GNUC__
+# define FFI_LONG_LONG_MAX __LONG_LONG_MAX__
+# endif
+# ifdef _MSC_VER
+# define FFI_LONG_LONG_MAX _I64_MAX
+# endif
+# endif
+#endif
+
+#if SCHAR_MAX == 127
+# define ffi_type_uchar ffi_type_uint8
+# define ffi_type_schar ffi_type_sint8
+#else
+ #error "char size not supported"
+#endif
+
+#if SHRT_MAX == 32767
+# define ffi_type_ushort ffi_type_uint16
+# define ffi_type_sshort ffi_type_sint16
+#elif SHRT_MAX == 2147483647
+# define ffi_type_ushort ffi_type_uint32
+# define ffi_type_sshort ffi_type_sint32
+#else
+ #error "short size not supported"
+#endif
+
+#if INT_MAX == 32767
+# define ffi_type_uint ffi_type_uint16
+# define ffi_type_sint ffi_type_sint16
+#elif INT_MAX == 2147483647
+# define ffi_type_uint ffi_type_uint32
+# define ffi_type_sint ffi_type_sint32
+#elif INT_MAX == 9223372036854775807
+# define ffi_type_uint ffi_type_uint64
+# define ffi_type_sint ffi_type_sint64
+#else
+ #error "int size not supported"
+#endif
+
+#define ffi_type_ulong ffi_type_uint64
+#define ffi_type_slong ffi_type_sint64
+#if LONG_MAX == 2147483647
+# if FFI_LONG_LONG_MAX != 9223372036854775807
+ #error "no 64-bit data type supported"
+# endif
+#elif LONG_MAX != 9223372036854775807
+ #error "long size not supported"
+#endif
+
+/* The closure code assumes that this works on pointers, i.e. a size_t */
+/* can hold a pointer. */
+
+typedef struct _ffi_type
+{
+ size_t size;
+ unsigned short alignment;
+ unsigned short type;
+ /*@null@*/ struct _ffi_type **elements;
+} ffi_type;
+
+/* These are defined in types.c */
+extern ffi_type ffi_type_void;
+extern ffi_type ffi_type_uint8;
+extern ffi_type ffi_type_sint8;
+extern ffi_type ffi_type_uint16;
+extern ffi_type ffi_type_sint16;
+extern ffi_type ffi_type_uint32;
+extern ffi_type ffi_type_sint32;
+extern ffi_type ffi_type_uint64;
+extern ffi_type ffi_type_sint64;
+extern ffi_type ffi_type_float;
+extern ffi_type ffi_type_double;
+extern ffi_type ffi_type_longdouble;
+extern ffi_type ffi_type_pointer;
+
+
+typedef enum {
+ FFI_OK = 0,
+ FFI_BAD_TYPEDEF,
+ FFI_BAD_ABI
+} ffi_status;
+
+typedef unsigned FFI_TYPE;
+
+typedef struct {
+ ffi_abi abi;
+ unsigned nargs;
+ /*@dependent@*/ ffi_type **arg_types;
+ /*@dependent@*/ ffi_type *rtype;
+ unsigned bytes;
+ unsigned flags;
+#ifdef FFI_EXTRA_CIF_FIELDS
+ FFI_EXTRA_CIF_FIELDS;
+#endif
+} ffi_cif;
+
+/* ---- Definitions for the raw API -------------------------------------- */
+
+#ifndef FFI_SIZEOF_ARG
+# if LONG_MAX == 2147483647
+# define FFI_SIZEOF_ARG 4
+# elif LONG_MAX == 9223372036854775807
+# define FFI_SIZEOF_ARG 8
+# endif
+#endif
+
+typedef union {
+ ffi_sarg sint;
+ ffi_arg uint;
+ float flt;
+ char data[FFI_SIZEOF_ARG];
+ void* ptr;
+} ffi_raw;
+
+void ffi_raw_call (/*@dependent@*/ ffi_cif *cif,
+ void (*fn)(),
+ /*@out@*/ void *rvalue,
+ /*@dependent@*/ ffi_raw *avalue);
+
+void ffi_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw);
+void ffi_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args);
+size_t ffi_raw_size (ffi_cif *cif);
+
+/* This is analogous to the raw API, except it uses Java parameter */
+/* packing, even on 64-bit machines. I.e. on 64-bit machines */
+/* longs and doubles are followed by an empty 64-bit word. */
+
+void ffi_java_raw_call (/*@dependent@*/ ffi_cif *cif,
+ void (*fn)(),
+ /*@out@*/ void *rvalue,
+ /*@dependent@*/ ffi_raw *avalue);
+
+void ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw);
+void ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args);
+size_t ffi_java_raw_size (ffi_cif *cif);
+
+/* ---- Definitions for closures ----------------------------------------- */
+
+#if FFI_CLOSURES
+
+typedef struct {
+ char tramp[FFI_TRAMPOLINE_SIZE];
+ ffi_cif *cif;
+ void (*fun)(ffi_cif*,void*,void**,void*);
+ void *user_data;
+} ffi_closure;
+
+ffi_status
+ffi_prep_closure (ffi_closure*,
+ ffi_cif *,
+ void (*fun)(ffi_cif*,void*,void**,void*),
+ void *user_data);
+
+typedef struct {
+ char tramp[FFI_TRAMPOLINE_SIZE];
+
+ ffi_cif *cif;
+
+#if !FFI_NATIVE_RAW_API
+
+ /* if this is enabled, then a raw closure has the same layout
+ as a regular closure. We use this to install an intermediate
+ handler to do the transaltion, void** -> ffi_raw*. */
+
+ void (*translate_args)(ffi_cif*,void*,void**,void*);
+ void *this_closure;
+
+#endif
+
+ void (*fun)(ffi_cif*,void*,ffi_raw*,void*);
+ void *user_data;
+
+} ffi_raw_closure;
+
+ffi_status
+ffi_prep_raw_closure (ffi_raw_closure*,
+ ffi_cif *cif,
+ void (*fun)(ffi_cif*,void*,ffi_raw*,void*),
+ void *user_data);
+
+ffi_status
+ffi_prep_java_raw_closure (ffi_raw_closure*,
+ ffi_cif *cif,
+ void (*fun)(ffi_cif*,void*,ffi_raw*,void*),
+ void *user_data);
+
+#endif /* FFI_CLOSURES */
+
+/* ---- Public interface definition -------------------------------------- */
+
+ffi_status ffi_prep_cif(/*@out@*/ /*@partial@*/ ffi_cif *cif,
+ ffi_abi abi,
+ unsigned int nargs,
+ /*@dependent@*/ /*@out@*/ /*@partial@*/ ffi_type *rtype,
+ /*@dependent@*/ ffi_type **atypes);
+
+/* Return type changed from void for ctypes */
+int ffi_call(/*@dependent@*/ ffi_cif *cif,
+ void (*fn)(),
+ /*@out@*/ void *rvalue,
+ /*@dependent@*/ void **avalue);
+
+/* Useful for eliminating compiler warnings */
+#define FFI_FN(f) ((void (*)())f)
+
+/* ---- Definitions shared with assembly code ---------------------------- */
+
+#endif
+
+/* If these change, update src/mips/ffitarget.h. */
+#define FFI_TYPE_VOID 0
+#define FFI_TYPE_INT 1
+#define FFI_TYPE_FLOAT 2
+#define FFI_TYPE_DOUBLE 3
+#if 0 /*@HAVE_LONG_DOUBLE@*/
+#define FFI_TYPE_LONGDOUBLE 4
+#else
+#define FFI_TYPE_LONGDOUBLE FFI_TYPE_DOUBLE
+#endif
+#define FFI_TYPE_UINT8 5
+#define FFI_TYPE_SINT8 6
+#define FFI_TYPE_UINT16 7
+#define FFI_TYPE_SINT16 8
+#define FFI_TYPE_UINT32 9
+#define FFI_TYPE_SINT32 10
+#define FFI_TYPE_UINT64 11
+#define FFI_TYPE_SINT64 12
+#define FFI_TYPE_STRUCT 13
+#define FFI_TYPE_POINTER 14
+
+/* This should always refer to the last type code (for sanity checks) */
+#define FFI_TYPE_LAST FFI_TYPE_POINTER
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
Added: packages/ctypes/branches/upstream/current/source/libffi_arm_wince/ffi_common.h
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/source/libffi_arm_wince/ffi_common.h?rev=940&op=file
==============================================================================
--- packages/ctypes/branches/upstream/current/source/libffi_arm_wince/ffi_common.h (added)
+++ packages/ctypes/branches/upstream/current/source/libffi_arm_wince/ffi_common.h Mon Jun 19 12:31:53 2006
@@ -1,0 +1,111 @@
+/* -----------------------------------------------------------------------
+ ffi_common.h - Copyright (c) 1996 Red Hat, Inc.
+
+ Common internal definitions and macros. Only necessary for building
+ libffi.
+ ----------------------------------------------------------------------- */
+
+#ifndef FFI_COMMON_H
+#define FFI_COMMON_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#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. */
+#if STDC_HEADERS
+# include <string.h>
+#else
+# ifndef HAVE_MEMCPY
+# define memcpy(d, s, n) bcopy ((s), (d), (n))
+# endif
+#endif
+
+#if defined(FFI_DEBUG)
+#include <stdio.h>
+#endif
+
+#ifdef FFI_DEBUG
+/*@exits@*/ void ffi_assert(/*@temp@*/ char *expr, /*@temp@*/ char *file, int line);
+void ffi_stop_here(void);
+void ffi_type_test(/*@temp@*/ /*@out@*/ ffi_type *a, /*@temp@*/ char *file, int line);
+
+#define FFI_ASSERT(x) ((x) ? (void)0 : ffi_assert(#x, __FILE__,__LINE__))
+#define FFI_ASSERT_AT(x, f, l) ((x) ? 0 : ffi_assert(#x, (f), (l)))
+#define FFI_ASSERT_VALID_TYPE(x) ffi_type_test (x, __FILE__, __LINE__)
+#else
+#define FFI_ASSERT(x)
+#define FFI_ASSERT_AT(x, f, l)
+#define FFI_ASSERT_VALID_TYPE(x)
+#endif
+
+#define ALIGN(v, a) (((((size_t) (v))-1) | ((a)-1))+1)
+
+/* Perform machine dependent cif processing */
+ffi_status ffi_prep_cif_machdep(ffi_cif *cif);
+
+/* Extended cif, used in callback from assembly routine */
+typedef struct
+{
+ /*@dependent@*/ ffi_cif *cif;
+ /*@dependent@*/ void *rvalue;
+ /*@dependent@*/ void **avalue;
+} extended_cif;
+
+/* Terse sized type definitions. */
+#if defined(__GNUC__)
+
+typedef unsigned int UINT8 __attribute__((__mode__(__QI__)));
+typedef signed int SINT8 __attribute__((__mode__(__QI__)));
+typedef unsigned int UINT16 __attribute__((__mode__(__HI__)));
+typedef signed int SINT16 __attribute__((__mode__(__HI__)));
+typedef unsigned int UINT32 __attribute__((__mode__(__SI__)));
+typedef signed int SINT32 __attribute__((__mode__(__SI__)));
+typedef unsigned int UINT64 __attribute__((__mode__(__DI__)));
+typedef signed int SINT64 __attribute__((__mode__(__DI__)));
+
+#elif defined(_MSC_VER)
+
+typedef unsigned __int8 UINT8;
+typedef signed __int8 SINT8;
+typedef unsigned __int16 UINT16;
+typedef signed __int16 SINT16;
+typedef unsigned __int32 UINT32;
+typedef signed __int32 SINT32;
+typedef unsigned __int64 UINT64;
+typedef signed __int64 SINT64;
+
+#else
+#error "Need typedefs here"
+#endif
+
+typedef float FLOAT32;
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+
Added: packages/ctypes/branches/upstream/current/source/libffi_arm_wince/fficonfig.h
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/source/libffi_arm_wince/fficonfig.h?rev=940&op=file
==============================================================================
--- packages/ctypes/branches/upstream/current/source/libffi_arm_wince/fficonfig.h (added)
+++ packages/ctypes/branches/upstream/current/source/libffi_arm_wince/fficonfig.h Mon Jun 19 12:31:53 2006
@@ -1,0 +1,152 @@
+/* fficonfig.h created manually for Windows CE on ARM */
+/* fficonfig.h.in. Generated from configure.ac by autoheader. */
+
+/* 1234 = LIL_ENDIAN, 4321 = BIGENDIAN */
+#define BYTEORDER 1234
+
+/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
+ systems. This function is required for `alloca.c' support on those systems.
+ */
+/* #undef CRAY_STACKSEG_END */
+
+/* Define to 1 if using `alloca.c'. */
+/* #undef C_ALLOCA */
+
+/* Define to the flags needed for the .section .eh_frame directive. */
+/* #undef EH_FRAME_FLAGS */
+
+/* Define this if you want extra debugging. */
+#ifdef DEBUG /* Defined by the project settings for Debug builds */
+#define FFI_DEBUG
+#else
+#undef FFI_DEBUG
+#endif
+
+/* Define this is you do not want support for the raw API. */
+/* #undef FFI_NO_RAW_API */
+
+/* Define this is you do not want support for aggregate types. */
+/* #undef FFI_NO_STRUCTS */
+
+/* Define to 1 if you have `alloca', as a function or macro. */
+#define HAVE_ALLOCA 1
+
+/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
+ */
+/* #undef HAVE_ALLOCA_H */
+
+/* Define if your assembler supports .register. */
+/* #undef HAVE_AS_REGISTER_PSEUDO_OP */
+
+/* Define if your assembler and linker support unaligned PC relative relocs.
+ */
+/* #undef HAVE_AS_SPARC_UA_PCREL */
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+/* #undef HAVE_INTTYPES_H */
+
+/* Define if you have the long double type and it is bigger than a double */
+/* This differs from the MSVC build, but even there it should not be defined */
+/* #undef HAVE_LONG_DOUBLE */
+
+/* Define to 1 if you have the `memcpy' function. */
+#define HAVE_MEMCPY 1
+
+/* Define to 1 if you have the <memory.h> header file. */
+/* WinCE has this but I don't think we need to use it */
+/* #undef HAVE_MEMORY_H */
+
+/* Define to 1 if you have the `mmap' function. */
+/* #undef HAVE_MMAP */
+
+/* Define if mmap with MAP_ANON(YMOUS) works. */
+/* #undef HAVE_MMAP_ANON */
+
+/* Define if mmap of /dev/zero works. */
+/* #undef HAVE_MMAP_DEV_ZERO */
+
+/* Define if read-only mmap of a plain file works. */
+/* #undef HAVE_MMAP_FILE */
+
+/* Define if .eh_frame sections should be read-only. */
+/* #undef HAVE_RO_EH_FRAME */
+
+/* Define to 1 if you have the <stdint.h> header file. */
+/* #undef HAVE_STDINT_H */
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+/* #undef HAVE_STRINGS_H */
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the <sys/mman.h> header file. */
+/* #undef HAVE_SYS_MMAN_H */
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+/* #undef HAVE_SYS_STAT_H */
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+/* #undef HAVE_SYS_TYPES_H */
+
+/* Define to 1 if you have the <unistd.h> header file. */
+/* #undef HAVE_UNISTD_H */
+
+/* Define if the host machine stores words of multi-word integers in
+ big-endian order. */
+/* #undef HOST_WORDS_BIG_ENDIAN */
+
+/* Define to 1 if your C compiler doesn't accept -c and -o together. */
+/* #undef NO_MINUS_C_MINUS_O */
+
+/* Name of package */
+/* #undef PACKAGE */
+
+/* Define to the address where bug reports for this package should be sent. */
+/* #undef PACKAGE_BUGREPORT */
+
+/* Define to the full name of this package. */
+/* #undef PACKAGE_NAME */
+
+/* Define to the full name and version of this package. */
+/* #undef PACKAGE_STRING */
+
+/* Define to the one symbol short name of this package. */
+/* #undef PACKAGE_TARNAME */
+
+/* Define to the version of this package. */
+/* #undef PACKAGE_VERSION */
+
+/* The number of bytes in type double */
+#define SIZEOF_DOUBLE 8
+
+/* The number of bytes in type long double */
+#define SIZEOF_LONG_DOUBLE 8
+
+/* If using the C implementation of alloca, define if you know the
+ direction of stack growth for your system; otherwise it will be
+ automatically deduced at run-time.
+ STACK_DIRECTION > 0 => grows toward higher addresses
+ STACK_DIRECTION < 0 => grows toward lower addresses
+ STACK_DIRECTION = 0 => direction of growth unknown */
+/* #undef STACK_DIRECTION */
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Define this if you are using Purify and want to suppress spurious messages.
+ */
+/* #undef USING_PURIFY */
+
+/* Version number of package */
+/* #undef VERSION */
+
+/* whether byteorder is bigendian */
+/* #undef WORDS_BIGENDIAN */
+
+#define alloca _alloca
+
+#define abort() exit(999)
Added: packages/ctypes/branches/upstream/current/source/libffi_arm_wince/ffitarget.h
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/source/libffi_arm_wince/ffitarget.h?rev=940&op=file
==============================================================================
--- packages/ctypes/branches/upstream/current/source/libffi_arm_wince/ffitarget.h (added)
+++ packages/ctypes/branches/upstream/current/source/libffi_arm_wince/ffitarget.h Mon Jun 19 12:31:53 2006
@@ -1,0 +1,49 @@
+/* -----------------------------------------------------------------*-C-*-
+ ffitarget.h - Copyright (c) 1996-2003 Red Hat, Inc.
+ Target configuration macros for ARM.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+
+ ----------------------------------------------------------------------- */
+
+#ifndef LIBFFI_TARGET_H
+#define LIBFFI_TARGET_H
+
+#ifndef LIBFFI_ASM
+typedef unsigned long ffi_arg;
+typedef signed long ffi_sarg;
+
+typedef enum ffi_abi {
+ FFI_FIRST_ABI = 0,
+ FFI_SYSV,
+ FFI_DEFAULT_ABI = FFI_SYSV,
+ FFI_LAST_ABI = FFI_DEFAULT_ABI + 1
+} ffi_abi;
+#endif
+
+/* ---- Definitions for closures ----------------------------------------- */
+
+#define FFI_CLOSURES 1
+#define FFI_TRAMPOLINE_SIZE 12
+
+#define FFI_NATIVE_RAW_API 0
+
+#endif
+
Added: packages/ctypes/branches/upstream/current/source/libffi_arm_wince/prep_cif.c
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/source/libffi_arm_wince/prep_cif.c?rev=940&op=file
==============================================================================
--- packages/ctypes/branches/upstream/current/source/libffi_arm_wince/prep_cif.c (added)
+++ packages/ctypes/branches/upstream/current/source/libffi_arm_wince/prep_cif.c Mon Jun 19 12:31:53 2006
@@ -1,0 +1,175 @@
+/* -----------------------------------------------------------------------
+ prep_cif.c - Copyright (c) 1996, 1998 Red Hat, Inc.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#include <ffi.h>
+#include <ffi_common.h>
+#include <stdlib.h>
+
+
+/* Round up to FFI_SIZEOF_ARG. */
+
+#define STACK_ARG_SIZE(x) ALIGN(x, FFI_SIZEOF_ARG)
+
+/* Perform machine independent initialization of aggregate type
+ specifications. */
+
+static ffi_status initialize_aggregate(/*@out@*/ ffi_type *arg)
+{
+ ffi_type **ptr;
+
+ FFI_ASSERT(arg != NULL);
+
+ /*@-usedef@*/
+
+ FFI_ASSERT(arg->elements != NULL);
+ FFI_ASSERT(arg->size == 0);
+ FFI_ASSERT(arg->alignment == 0);
+
+ ptr = &(arg->elements[0]);
+
+ while ((*ptr) != NULL)
+ {
+ if (((*ptr)->size == 0) && (initialize_aggregate((*ptr)) != FFI_OK))
+ return FFI_BAD_TYPEDEF;
+
+ /* Perform a sanity check on the argument type */
+ FFI_ASSERT_VALID_TYPE(*ptr);
+
+ arg->size = ALIGN(arg->size, (*ptr)->alignment);
+ arg->size += (*ptr)->size;
+
+ arg->alignment = (arg->alignment > (*ptr)->alignment) ?
+ arg->alignment : (*ptr)->alignment;
+
+ ptr++;
+ }
+
+ /* Structure size includes tail padding. This is important for
+ structures that fit in one register on ABIs like the PowerPC64
+ Linux ABI that right justify small structs in a register.
+ It's also needed for nested structure layout, for example
+ struct A { long a; char b; }; struct B { struct A x; char y; };
+ should find y at an offset of 2*sizeof(long) and result in a
+ total size of 3*sizeof(long). */
+ arg->size = ALIGN (arg->size, arg->alignment);
+
+ if (arg->size == 0)
+ return FFI_BAD_TYPEDEF;
+ else
+ return FFI_OK;
+
+ /*@=usedef@*/
+}
+
+/* Perform machine independent ffi_cif preparation, then call
+ machine dependent routine. */
+
+ffi_status ffi_prep_cif(/*@out@*/ /*@partial@*/ ffi_cif *cif,
+ ffi_abi abi, unsigned int nargs,
+ /*@dependent@*/ /*@out@*/ /*@partial@*/ ffi_type *rtype,
+ /*@dependent@*/ ffi_type **atypes)
+{
+ unsigned bytes = 0;
+ unsigned int i;
+ ffi_type **ptr;
+
+ FFI_ASSERT(cif != NULL);
+ FFI_ASSERT((abi > FFI_FIRST_ABI) && (abi <= FFI_DEFAULT_ABI));
+
+ cif->abi = abi;
+ cif->arg_types = atypes;
+ cif->nargs = nargs;
+ cif->rtype = rtype;
+
+ cif->flags = 0;
+
+ /* Initialize the return type if necessary */
+ /*@-usedef@*/
+ if ((cif->rtype->size == 0) && (initialize_aggregate(cif->rtype) != FFI_OK))
+ return FFI_BAD_TYPEDEF;
+ /*@=usedef@*/
+
+ /* Perform a sanity check on the return type */
+ FFI_ASSERT_VALID_TYPE(cif->rtype);
+
+ /* x86-64 and s390 stack space allocation is handled in prep_machdep. */
+#if !defined M68K && !defined __x86_64__ && !defined S390
+ /* Make space for the return structure pointer */
+ if (cif->rtype->type == FFI_TYPE_STRUCT
+ /* MSVC returns small structures in registers. But we have a different
+ workaround: pretend int32 or int64 return type, and converting to
+ structure afterwards. */
+#ifdef SPARC
+ && (cif->abi != FFI_V9 || cif->rtype->size > 32)
+#endif
+ )
+ bytes = STACK_ARG_SIZE(sizeof(void*));
+#endif
+
+ for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++)
+ {
+
+ /* Initialize any uninitialized aggregate type definitions */
+ if (((*ptr)->size == 0) && (initialize_aggregate((*ptr)) != FFI_OK))
+ return FFI_BAD_TYPEDEF;
+
+ /* Perform a sanity check on the argument type, do this
+ check after the initialization. */
+ FFI_ASSERT_VALID_TYPE(*ptr);
+
+#if !defined __x86_64__ && !defined S390
+#ifdef SPARC
+ if (((*ptr)->type == FFI_TYPE_STRUCT
+ && ((*ptr)->size > 16 || cif->abi != FFI_V9))
+ || ((*ptr)->type == FFI_TYPE_LONGDOUBLE
+ && cif->abi != FFI_V9))
+ bytes += sizeof(void*);
+ else
+#endif
+ {
+#ifndef _MSC_VER
+ /* Don't know if this is a libffi bug or not. At least on
+ Windows with MSVC, function call parameters are *not*
+ aligned in the same way as structure fields are, they are
+ only aligned in integer boundaries.
+
+ This doesn't do any harm for cdecl functions and closures,
+ since the caller cleans up the stack, but it is wrong for
+ stdcall functions where the callee cleans.
+ */
+
+ /* Add any padding if necessary */
+ if (((*ptr)->alignment - 1) & bytes)
+ bytes = ALIGN(bytes, (*ptr)->alignment);
+
+#endif
+ bytes += STACK_ARG_SIZE((*ptr)->size);
+ }
+#endif
+ }
+
+ cif->bytes = bytes;
+
+ /* Perform machine dependent cif processing */
+ return ffi_prep_cif_machdep(cif);
+}
Added: packages/ctypes/branches/upstream/current/source/libffi_arm_wince/sysv.asm
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/source/libffi_arm_wince/sysv.asm?rev=940&op=file
==============================================================================
--- packages/ctypes/branches/upstream/current/source/libffi_arm_wince/sysv.asm (added)
+++ packages/ctypes/branches/upstream/current/source/libffi_arm_wince/sysv.asm Mon Jun 19 12:31:53 2006
@@ -1,0 +1,228 @@
+; -----------------------------------------------------------------------
+; sysv.S - Copyright (c) 1998 Red Hat, Inc.
+;
+; ARM Foreign Function Interface
+;
+; Permission is hereby granted, free of charge, to any person obtaining
+; a copy of this software and associated documentation files (the
+; ``Software''), to deal in the Software without restriction, including
+; without limitation the rights to use, copy, modify, merge, publish,
+; distribute, sublicense, and/or sell copies of the Software, and to
+; permit persons to whom the Software is furnished to do so, subject to
+; the following conditions:
+;
+; The above copyright notice and this permission notice shall be included
+; in all copies or substantial portions of the Software.
+;
+; THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+; OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+; IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+; OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+; ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+; OTHER DEALINGS IN THE SOFTWARE.
+; ----------------------------------------------------------------------- */
+
+;#define LIBFFI_ASM
+;#include <fficonfig.h>
+;#include <ffi.h>
+;#ifdef HAVE_MACHINE_ASM_H
+;#include <machine/asm.h>
+;#else
+;#ifdef __USER_LABEL_PREFIX__
+;#define CONCAT1(a, b) CONCAT2(a, b)
+;#define CONCAT2(a, b) a ## b
+
+;/* Use the right prefix for global labels. */
+;#define CNAME(x) CONCAT1 (__USER_LABEL_PREFIX__, x)
+;#else
+;#define CNAME(x) x
+;#endif
+;#define ENTRY(x) .globl CNAME(x); .type CNAME(x),%function; CNAME(x):
+;#endif
+
+
+FFI_TYPE_VOID EQU 0
+FFI_TYPE_INT EQU 1
+FFI_TYPE_FLOAT EQU 2
+FFI_TYPE_DOUBLE EQU 3
+;FFI_TYPE_LONGDOUBLE EQU 4
+FFI_TYPE_UINT8 EQU 5
+FFI_TYPE_SINT8 EQU 6
+FFI_TYPE_UINT16 EQU 7
+FFI_TYPE_SINT16 EQU 8
+FFI_TYPE_UINT32 EQU 9
+FFI_TYPE_SINT32 EQU 10
+FFI_TYPE_UINT64 EQU 11
+FFI_TYPE_SINT64 EQU 12
+FFI_TYPE_STRUCT EQU 13
+FFI_TYPE_POINTER EQU 14
+
+; WinCE always uses software floating point (I think)
+__SOFTFP__ EQU {TRUE}
+
+
+ AREA |.text|, CODE, ARM ; .text
+
+
+ ; a1: ffi_prep_args
+ ; a2: &ecif
+ ; a3: cif->bytes
+ ; a4: fig->flags
+ ; sp+0: ecif.rvalue
+ ; sp+4: fn
+
+ ; This assumes we are using gas.
+;ENTRY(ffi_call_SYSV)
+
+ EXPORT |ffi_call_SYSV|
+
+|ffi_call_SYSV| PROC
+
+ ; Save registers
+ stmfd sp!, {a1-a4, fp, lr}
+ mov fp, sp
+
+ ; Make room for all of the new args.
+ sub sp, fp, a3
+
+ ; Place all of the ffi_prep_args in position
+ mov ip, a1
+ mov a1, sp
+ ; a2 already set
+
+ ; And call
+ mov lr, pc
+ mov pc, ip
+
+ ; move first 4 parameters in registers
+ ldr a1, [sp, #0]
+ ldr a2, [sp, #4]
+ ldr a3, [sp, #8]
+ ldr a4, [sp, #12]
+
+ ; and adjust stack
+ ldr ip, [fp, #8]
+ cmp ip, #16
+ movge ip, #16
+ add sp, sp, ip
+
+ ; call function
+ mov lr, pc
+ ldr pc, [fp, #28]
+
+ ; Remove the space we pushed for the args
+ mov sp, fp
+
+ ; Load a3 with the pointer to storage for the return value
+ ldr a3, [sp, #24]
+
+ ; Load a4 with the return type code
+ ldr a4, [sp, #12]
+
+ ; If the return value pointer is NULL, assume no return value.
+ cmp a3, #0
+ beq call_epilogue
+
+; return INT
+ cmp a4, #FFI_TYPE_INT
+ streq a1, [a3]
+ beq call_epilogue
+
+; return FLOAT
+ cmp a4, #FFI_TYPE_FLOAT
+ [ __SOFTFP__ ;ifdef __SOFTFP__
+ streq a1, [a3]
+ | ;else
+ stfeqs f0, [a3]
+ ] ;endif
+ beq call_epilogue
+
+; return DOUBLE or LONGDOUBLE
+ cmp a4, #FFI_TYPE_DOUBLE
+ [ __SOFTFP__ ;ifdef __SOFTFP__
+ stmeqia a3, {a1, a2}
+ | ;else
+ stfeqd f0, [a3]
+ ] ;endif
+ beq call_epilogue
+
+; return SINT64 or UINT64
+ cmp a4, #FFI_TYPE_SINT64
+ stmeqia a3, {a1, a2}
+
+call_epilogue
+ ldmfd sp!, {a1-a4, fp, pc}
+
+;.ffi_call_SYSV_end:
+ ;.size CNAME(ffi_call_SYSV),.ffi_call_SYSV_end-CNAME(ffi_call_SYSV)
+ ENDP
+
+
+RESERVE_RETURN EQU 16
+
+ ; This function is called by the trampoline
+ ; It is NOT callable from C
+ ; ip = pointer to struct ffi_closure
+
+ IMPORT |ffi_closure_SYSV_inner|
+
+ EXPORT |ffi_closure_SYSV|
+|ffi_closure_SYSV| PROC
+
+ ; Store the argument registers on the stack
+ stmfd sp!, {a1-a4}
+ ; Push the return address onto the stack
+ stmfd sp!, {lr}
+
+ mov a1, ip ; first arg = address of ffi_closure
+ add a2, sp, #4 ; second arg = sp+4 (points to saved a1)
+
+ ; Allocate space for a non-struct return value
+ sub sp, sp, #RESERVE_RETURN
+ mov a3, sp ; third arg = return value address
+
+ ; static unsigned int
+ ; ffi_closure_SYSV_inner (ffi_closure *closure, char *in_args, void *rvalue)
+ bl ffi_closure_SYSV_inner
+ ; a1 now contains the return type code
+
+ ; At this point the return value is on the stack
+ ; Transfer it to the correct registers if necessary
+
+; return INT
+ cmp a1, #FFI_TYPE_INT
+ ldreq a1, [sp]
+ beq closure_epilogue
+
+; return FLOAT
+ cmp a1, #FFI_TYPE_FLOAT
+ [ __SOFTFP__ ;ifdef __SOFTFP__
+ ldreq a1, [sp]
+ | ;else
+ stfeqs f0, [sp]
+ ] ;endif
+ beq closure_epilogue
+
+; return DOUBLE or LONGDOUBLE
+ cmp a1, #FFI_TYPE_DOUBLE
+ [ __SOFTFP__ ;ifdef __SOFTFP__
+ ldmeqia sp, {a1, a2}
+ | ;else
+ stfeqd f0, [sp]
+ ] ;endif
+ beq closure_epilogue
+
+; return SINT64 or UINT64
+ cmp a1, #FFI_TYPE_SINT64
+ ldmeqia sp, {a1, a2}
+
+closure_epilogue
+ add sp, sp, #RESERVE_RETURN ; remove return value buffer
+ ldmfd sp!, {ip} ; ip = pop return address
+ add sp, sp, #16 ; remove saved argument registers {a1-a4} from the stack
+ mov pc, ip ; return
+
+ ENDP ; ffi_closure_SYSV
+
+ END
Added: packages/ctypes/branches/upstream/current/source/libffi_msvc/ffi.c
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/source/libffi_msvc/ffi.c?rev=940&op=file
==============================================================================
--- packages/ctypes/branches/upstream/current/source/libffi_msvc/ffi.c (added)
+++ packages/ctypes/branches/upstream/current/source/libffi_msvc/ffi.c Mon Jun 19 12:31:53 2006
@@ -1,0 +1,415 @@
+/* -----------------------------------------------------------------------
+ ffi.c - Copyright (c) 1996, 1998, 1999, 2001 Red Hat, Inc.
+ Copyright (c) 2002 Ranjit Mathew
+ Copyright (c) 2002 Bo Thorsen
+ Copyright (c) 2002 Roger Sayle
+
+ x86 Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#include <ffi.h>
+#include <ffi_common.h>
+
+#include <stdlib.h>
+
+/* ffi_prep_args is called by the assembly routine once stack space
+ has been allocated for the function's arguments */
+
+/*@-exportheader@*/
+void ffi_prep_args(char *stack, extended_cif *ecif)
+/*@=exportheader@*/
+{
+ register unsigned int i;
+ register void **p_argv;
+ register char *argp;
+ register ffi_type **p_arg;
+
+ argp = stack;
+
+ if (ecif->cif->rtype->type == FFI_TYPE_STRUCT)
+ {
+ *(void **) argp = ecif->rvalue;
+ argp += 4;
+ }
+
+ p_argv = ecif->avalue;
+
+ for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types;
+ i != 0;
+ i--, p_arg++)
+ {
+ size_t z;
+
+ /* Align if necessary */
+ if ((sizeof(int) - 1) & (unsigned) argp)
+ argp = (char *) ALIGN(argp, sizeof(int));
+
+ z = (*p_arg)->size;
+ if (z < sizeof(int))
+ {
+ z = sizeof(int);
+ switch ((*p_arg)->type)
+ {
+ case FFI_TYPE_SINT8:
+ *(signed int *) argp = (signed int)*(SINT8 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_UINT8:
+ *(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_SINT16:
+ *(signed int *) argp = (signed int)*(SINT16 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_UINT16:
+ *(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_SINT32:
+ *(signed int *) argp = (signed int)*(SINT32 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_UINT32:
+ *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_STRUCT:
+ *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv);
+ break;
+
+ default:
+ FFI_ASSERT(0);
+ }
+ }
+ else
+ {
+ memcpy(argp, *p_argv, z);
+ }
+ p_argv++;
+ argp += z;
+ }
+
+ return;
+}
+
+/* Perform machine dependent cif processing */
+ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
+{
+ /* Set the return type flag */
+ switch (cif->rtype->type)
+ {
+ case FFI_TYPE_VOID:
+ case FFI_TYPE_STRUCT:
+ case FFI_TYPE_SINT64:
+ case FFI_TYPE_FLOAT:
+ case FFI_TYPE_DOUBLE:
+ case FFI_TYPE_LONGDOUBLE:
+ cif->flags = (unsigned) cif->rtype->type;
+ break;
+
+ case FFI_TYPE_UINT64:
+ cif->flags = FFI_TYPE_SINT64;
+ break;
+
+ default:
+ cif->flags = FFI_TYPE_INT;
+ break;
+ }
+
+ return FFI_OK;
+}
+
+/*@-declundef@*/
+/*@-exportheader@*/
+extern int
+ffi_call_SYSV(void (*)(char *, extended_cif *),
+ /*@out@*/ extended_cif *,
+ unsigned, unsigned,
+ /*@out@*/ unsigned *,
+ void (*fn)());
+/*@=declundef@*/
+/*@=exportheader@*/
+
+/*@-declundef@*/
+/*@-exportheader@*/
+extern int
+ffi_call_STDCALL(void (*)(char *, extended_cif *),
+ /*@out@*/ extended_cif *,
+ unsigned, unsigned,
+ /*@out@*/ unsigned *,
+ void (*fn)());
+/*@=declundef@*/
+/*@=exportheader@*/
+
+int
+ffi_call(/*@dependent@*/ ffi_cif *cif,
+ void (*fn)(),
+ /*@out@*/ void *rvalue,
+ /*@dependent@*/ void **avalue)
+{
+ extended_cif ecif;
+
+ ecif.cif = cif;
+ ecif.avalue = avalue;
+
+ /* If the return value is a struct and we don't have a return */
+ /* value address then we need to make one */
+
+ if ((rvalue == NULL) &&
+ (cif->rtype->type == FFI_TYPE_STRUCT))
+ {
+ /*@-sysunrecog@*/
+ ecif.rvalue = alloca(cif->rtype->size);
+ /*@=sysunrecog@*/
+ }
+ else
+ ecif.rvalue = rvalue;
+
+
+ switch (cif->abi)
+ {
+ case FFI_SYSV:
+ /*@-usedef@*/
+ return ffi_call_SYSV(ffi_prep_args, &ecif, cif->bytes,
+ cif->flags, ecif.rvalue, fn);
+ /*@=usedef@*/
+ break;
+
+ case FFI_STDCALL:
+ /*@-usedef@*/
+ return ffi_call_STDCALL(ffi_prep_args, &ecif, cif->bytes,
+ cif->flags, ecif.rvalue, fn);
+ /*@=usedef@*/
+ break;
+
+ default:
+ FFI_ASSERT(0);
+ break;
+ }
+ return -1; /* theller: Hrm. */
+}
+
+
+/** private members **/
+
+static void ffi_prep_incoming_args_SYSV (char *stack, void **ret,
+ void** args, ffi_cif* cif);
+/* This function is jumped to by the trampoline */
+
+static void __fastcall
+ffi_closure_SYSV (ffi_closure *closure, int *argp)
+{
+ // this is our return value storage
+ long double res;
+
+ // our various things...
+ ffi_cif *cif;
+ void **arg_area;
+ unsigned short rtype;
+ void *resp = (void*)&res;
+//#ifdef _MSC_VER
+ void *args = &argp[1];
+//#else
+// void *args = __builtin_dwarf_cfa ();
+//#endif
+
+ cif = closure->cif;
+ arg_area = (void**) alloca (cif->nargs * sizeof (void*));
+
+ /* this call will initialize ARG_AREA, such that each
+ * element in that array points to the corresponding
+ * value on the stack; and if the function returns
+ * a structure, it will re-set RESP to point to the
+ * structure return address. */
+
+ ffi_prep_incoming_args_SYSV(args, (void**)&resp, arg_area, cif);
+
+ (closure->fun) (cif, resp, arg_area, closure->user_data);
+
+ rtype = cif->flags;
+
+#ifdef _MSC_VER
+ /* now, do a generic return based on the value of rtype */
+ if (rtype == FFI_TYPE_INT)
+ {
+ _asm mov eax, resp ;
+ _asm mov eax, [eax] ;
+ }
+ else if (rtype == FFI_TYPE_FLOAT)
+ {
+ _asm mov eax, resp ;
+ _asm fld DWORD PTR [eax] ;
+// asm ("flds (%0)" : : "r" (resp) : "st" );
+ }
+ else if (rtype == FFI_TYPE_DOUBLE)
+ {
+ _asm mov eax, resp ;
+ _asm fld QWORD PTR [eax] ;
+// asm ("fldl (%0)" : : "r" (resp) : "st", "st(1)" );
+ }
+ else if (rtype == FFI_TYPE_LONGDOUBLE)
+ {
+// asm ("fldt (%0)" : : "r" (resp) : "st", "st(1)" );
+ }
+ else if (rtype == FFI_TYPE_SINT64)
+ {
+ _asm mov edx, resp ;
+ _asm mov eax, [edx] ;
+ _asm mov edx, [edx + 4] ;
+// asm ("movl 0(%0),%%eax;"
+// "movl 4(%0),%%edx"
+// : : "r"(resp)
+// : "eax", "edx");
+ }
+#else
+ /* now, do a generic return based on the value of rtype */
+ if (rtype == FFI_TYPE_INT)
+ {
+ asm ("movl (%0),%%eax" : : "r" (resp) : "eax");
+ }
+ else if (rtype == FFI_TYPE_FLOAT)
+ {
+ asm ("flds (%0)" : : "r" (resp) : "st" );
+ }
+ else if (rtype == FFI_TYPE_DOUBLE)
+ {
+ asm ("fldl (%0)" : : "r" (resp) : "st", "st(1)" );
+ }
+ else if (rtype == FFI_TYPE_LONGDOUBLE)
+ {
+ asm ("fldt (%0)" : : "r" (resp) : "st", "st(1)" );
+ }
+ else if (rtype == FFI_TYPE_SINT64)
+ {
+ asm ("movl 0(%0),%%eax;"
+ "movl 4(%0),%%edx"
+ : : "r"(resp)
+ : "eax", "edx");
+ }
+#endif
+}
+
+/*@-exportheader@*/
+static void
+ffi_prep_incoming_args_SYSV(char *stack, void **rvalue,
+ void **avalue, ffi_cif *cif)
+/*@=exportheader@*/
+{
+ register unsigned int i;
+ register void **p_argv;
+ register char *argp;
+ register ffi_type **p_arg;
+
+ argp = stack;
+
+ if ( cif->rtype->type == FFI_TYPE_STRUCT ) {
+ *rvalue = *(void **) argp;
+ argp += 4;
+ }
+
+ p_argv = avalue;
+
+ for (i = cif->nargs, p_arg = cif->arg_types; (i != 0); i--, p_arg++)
+ {
+ size_t z;
+
+ /* Align if necessary */
+ if ((sizeof(int) - 1) & (unsigned) argp) {
+ argp = (char *) ALIGN(argp, sizeof(int));
+ }
+
+ z = (*p_arg)->size;
+
+ /* because we're little endian, this is what it turns into. */
+
+ *p_argv = (void*) argp;
+
+ p_argv++;
+ argp += z;
+ }
+
+ return;
+}
+
+/* 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); \
+ unsigned int __fun = (unsigned int)(FUN); \
+ unsigned int __ctx = (unsigned int)(CTX); \
+ unsigned int __dis = __fun - ((unsigned int) __tramp + 8 + 4); \
+ *(unsigned char*) &__tramp[0] = 0xb9; \
+ *(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 */ \
+ *(unsigned char*) &__tramp[12] = 0xC2; /* ret BYTES */ \
+ *(unsigned short*) &__tramp[13] = BYTES; \
+ }
+
+//#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 */
+
+ffi_status
+ffi_prep_closure (ffi_closure* closure,
+ ffi_cif* cif,
+ void (*fun)(ffi_cif*,void*,void**,void*),
+ void *user_data)
+{
+ short bytes;
+ FFI_ASSERT (cif->abi == FFI_SYSV);
+
+ if (cif->abi == FFI_SYSV)
+ bytes = 0;
+ else if (cif->abi == FFI_STDCALL)
+ bytes = cif->bytes;
+ else
+ return FFI_BAD_ABI;
+
+ FFI_INIT_TRAMPOLINE (&closure->tramp[0],
+ &ffi_closure_SYSV,
+ (void*)closure,
+ bytes);
+ closure->cif = cif;
+ closure->user_data = user_data;
+ closure->fun = fun;
+
+ return FFI_OK;
+}
Added: packages/ctypes/branches/upstream/current/source/libffi_msvc/ffi.h
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/source/libffi_msvc/ffi.h?rev=940&op=file
==============================================================================
--- packages/ctypes/branches/upstream/current/source/libffi_msvc/ffi.h (added)
+++ packages/ctypes/branches/upstream/current/source/libffi_msvc/ffi.h Mon Jun 19 12:31:53 2006
@@ -1,0 +1,317 @@
+/* -----------------------------------------------------------------*-C-*-
+ libffi 2.00-beta - Copyright (c) 1996-2003 Red Hat, Inc.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+
+ ----------------------------------------------------------------------- */
+
+/* -------------------------------------------------------------------
+ The basic API is described in the README file.
+
+ The raw API is designed to bypass some of the argument packing
+ and unpacking on architectures for which it can be avoided.
+
+ The closure API allows interpreted functions to be packaged up
+ inside a C function pointer, so that they can be called as C functions,
+ with no understanding on the client side that they are interpreted.
+ It can also be used in other cases in which it is necessary to package
+ up a user specified parameter and a function pointer as a single
+ function pointer.
+
+ The closure API must be implemented in order to get its functionality,
+ e.g. for use by gij. Routines are provided to emulate the raw API
+ if the underlying platform doesn't allow faster implementation.
+
+ More details on the raw and cloure API can be found in:
+
+ http://gcc.gnu.org/ml/java/1999-q3/msg00138.html
+
+ and
+
+ http://gcc.gnu.org/ml/java/1999-q3/msg00174.html
+ -------------------------------------------------------------------- */
+
+#ifndef LIBFFI_H
+#define LIBFFI_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Specify which architecture libffi is configured for. */
+//XXX #define X86
+
+/* ---- System configuration information --------------------------------- */
+
+#include <ffitarget.h>
+
+#ifndef LIBFFI_ASM
+
+#include <stddef.h>
+#include <limits.h>
+
+/* LONG_LONG_MAX is not always defined (not if STRICT_ANSI, for example).
+ But we can find it either under the correct ANSI name, or under GNU
+ C's internal name. */
+#ifdef LONG_LONG_MAX
+# define FFI_LONG_LONG_MAX LONG_LONG_MAX
+#else
+# ifdef LLONG_MAX
+# define FFI_LONG_LONG_MAX LLONG_MAX
+# else
+# ifdef __GNUC__
+# define FFI_LONG_LONG_MAX __LONG_LONG_MAX__
+# endif
+# ifdef _MSC_VER
+# define FFI_LONG_LONG_MAX _I64_MAX
+# endif
+# endif
+#endif
+
+#if SCHAR_MAX == 127
+# define ffi_type_uchar ffi_type_uint8
+# define ffi_type_schar ffi_type_sint8
+#else
+ #error "char size not supported"
+#endif
+
+#if SHRT_MAX == 32767
+# define ffi_type_ushort ffi_type_uint16
+# define ffi_type_sshort ffi_type_sint16
+#elif SHRT_MAX == 2147483647
+# define ffi_type_ushort ffi_type_uint32
+# define ffi_type_sshort ffi_type_sint32
+#else
+ #error "short size not supported"
+#endif
+
+#if INT_MAX == 32767
+# define ffi_type_uint ffi_type_uint16
+# define ffi_type_sint ffi_type_sint16
+#elif INT_MAX == 2147483647
+# define ffi_type_uint ffi_type_uint32
+# define ffi_type_sint ffi_type_sint32
+#elif INT_MAX == 9223372036854775807
+# define ffi_type_uint ffi_type_uint64
+# define ffi_type_sint ffi_type_sint64
+#else
+ #error "int size not supported"
+#endif
+
+#define ffi_type_ulong ffi_type_uint64
+#define ffi_type_slong ffi_type_sint64
+#if LONG_MAX == 2147483647
+# if FFI_LONG_LONG_MAX != 9223372036854775807
+ #error "no 64-bit data type supported"
+# endif
+#elif LONG_MAX != 9223372036854775807
+ #error "long size not supported"
+#endif
+
+/* The closure code assumes that this works on pointers, i.e. a size_t */
+/* can hold a pointer. */
+
+typedef struct _ffi_type
+{
+ size_t size;
+ unsigned short alignment;
+ unsigned short type;
+ /*@null@*/ struct _ffi_type **elements;
+} ffi_type;
+
+/* These are defined in types.c */
+extern ffi_type ffi_type_void;
+extern ffi_type ffi_type_uint8;
+extern ffi_type ffi_type_sint8;
+extern ffi_type ffi_type_uint16;
+extern ffi_type ffi_type_sint16;
+extern ffi_type ffi_type_uint32;
+extern ffi_type ffi_type_sint32;
+extern ffi_type ffi_type_uint64;
+extern ffi_type ffi_type_sint64;
+extern ffi_type ffi_type_float;
+extern ffi_type ffi_type_double;
+extern ffi_type ffi_type_longdouble;
+extern ffi_type ffi_type_pointer;
+
+
+typedef enum {
+ FFI_OK = 0,
+ FFI_BAD_TYPEDEF,
+ FFI_BAD_ABI
+} ffi_status;
+
+typedef unsigned FFI_TYPE;
+
+typedef struct {
+ ffi_abi abi;
+ unsigned nargs;
+ /*@dependent@*/ ffi_type **arg_types;
+ /*@dependent@*/ ffi_type *rtype;
+ unsigned bytes;
+ unsigned flags;
+#ifdef FFI_EXTRA_CIF_FIELDS
+ FFI_EXTRA_CIF_FIELDS;
+#endif
+} ffi_cif;
+
+/* ---- Definitions for the raw API -------------------------------------- */
+
+#ifndef FFI_SIZEOF_ARG
+# if LONG_MAX == 2147483647
+# define FFI_SIZEOF_ARG 4
+# elif LONG_MAX == 9223372036854775807
+# define FFI_SIZEOF_ARG 8
+# endif
+#endif
+
+typedef union {
+ ffi_sarg sint;
+ ffi_arg uint;
+ float flt;
+ char data[FFI_SIZEOF_ARG];
+ void* ptr;
+} ffi_raw;
+
+void ffi_raw_call (/*@dependent@*/ ffi_cif *cif,
+ void (*fn)(),
+ /*@out@*/ void *rvalue,
+ /*@dependent@*/ ffi_raw *avalue);
+
+void ffi_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw);
+void ffi_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args);
+size_t ffi_raw_size (ffi_cif *cif);
+
+/* This is analogous to the raw API, except it uses Java parameter */
+/* packing, even on 64-bit machines. I.e. on 64-bit machines */
+/* longs and doubles are followed by an empty 64-bit word. */
+
+void ffi_java_raw_call (/*@dependent@*/ ffi_cif *cif,
+ void (*fn)(),
+ /*@out@*/ void *rvalue,
+ /*@dependent@*/ ffi_raw *avalue);
+
+void ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw);
+void ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args);
+size_t ffi_java_raw_size (ffi_cif *cif);
+
+/* ---- Definitions for closures ----------------------------------------- */
+
+#if FFI_CLOSURES
+
+typedef struct {
+ char tramp[FFI_TRAMPOLINE_SIZE];
+ ffi_cif *cif;
+ void (*fun)(ffi_cif*,void*,void**,void*);
+ void *user_data;
+} ffi_closure;
+
+ffi_status
+ffi_prep_closure (ffi_closure*,
+ ffi_cif *,
+ void (*fun)(ffi_cif*,void*,void**,void*),
+ void *user_data);
+
+typedef struct {
+ char tramp[FFI_TRAMPOLINE_SIZE];
+
+ ffi_cif *cif;
+
+#if !FFI_NATIVE_RAW_API
+
+ /* if this is enabled, then a raw closure has the same layout
+ as a regular closure. We use this to install an intermediate
+ handler to do the transaltion, void** -> ffi_raw*. */
+
+ void (*translate_args)(ffi_cif*,void*,void**,void*);
+ void *this_closure;
+
+#endif
+
+ void (*fun)(ffi_cif*,void*,ffi_raw*,void*);
+ void *user_data;
+
+} ffi_raw_closure;
+
+ffi_status
+ffi_prep_raw_closure (ffi_raw_closure*,
+ ffi_cif *cif,
+ void (*fun)(ffi_cif*,void*,ffi_raw*,void*),
+ void *user_data);
+
+ffi_status
+ffi_prep_java_raw_closure (ffi_raw_closure*,
+ ffi_cif *cif,
+ void (*fun)(ffi_cif*,void*,ffi_raw*,void*),
+ void *user_data);
+
+#endif /* FFI_CLOSURES */
+
+/* ---- Public interface definition -------------------------------------- */
+
+ffi_status ffi_prep_cif(/*@out@*/ /*@partial@*/ ffi_cif *cif,
+ ffi_abi abi,
+ unsigned int nargs,
+ /*@dependent@*/ /*@out@*/ /*@partial@*/ ffi_type *rtype,
+ /*@dependent@*/ ffi_type **atypes);
+
+int
+ffi_call(/*@dependent@*/ ffi_cif *cif,
+ void (*fn)(),
+ /*@out@*/ void *rvalue,
+ /*@dependent@*/ void **avalue);
+
+/* Useful for eliminating compiler warnings */
+#define FFI_FN(f) ((void (*)())f)
+
+/* ---- Definitions shared with assembly code ---------------------------- */
+
+#endif
+
+/* If these change, update src/mips/ffitarget.h. */
+#define FFI_TYPE_VOID 0
+#define FFI_TYPE_INT 1
+#define FFI_TYPE_FLOAT 2
+#define FFI_TYPE_DOUBLE 3
+#if 1
+#define FFI_TYPE_LONGDOUBLE 4
+#else
+#define FFI_TYPE_LONGDOUBLE FFI_TYPE_DOUBLE
+#endif
+#define FFI_TYPE_UINT8 5
+#define FFI_TYPE_SINT8 6
+#define FFI_TYPE_UINT16 7
+#define FFI_TYPE_SINT16 8
+#define FFI_TYPE_UINT32 9
+#define FFI_TYPE_SINT32 10
+#define FFI_TYPE_UINT64 11
+#define FFI_TYPE_SINT64 12
+#define FFI_TYPE_STRUCT 13
+#define FFI_TYPE_POINTER 14
+
+/* This should always refer to the last type code (for sanity checks) */
+#define FFI_TYPE_LAST FFI_TYPE_POINTER
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
Added: packages/ctypes/branches/upstream/current/source/libffi_msvc/ffi_common.h
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/source/libffi_msvc/ffi_common.h?rev=940&op=file
==============================================================================
--- packages/ctypes/branches/upstream/current/source/libffi_msvc/ffi_common.h (added)
+++ packages/ctypes/branches/upstream/current/source/libffi_msvc/ffi_common.h Mon Jun 19 12:31:53 2006
@@ -1,0 +1,77 @@
+/* -----------------------------------------------------------------------
+ ffi_common.h - Copyright (c) 1996 Red Hat, Inc.
+
+ Common internal definitions and macros. Only necessary for building
+ libffi.
+ ----------------------------------------------------------------------- */
+
+#ifndef FFI_COMMON_H
+#define FFI_COMMON_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <fficonfig.h>
+#include <malloc.h>
+
+/* Check for the existence of memcpy. */
+#if STDC_HEADERS
+# include <string.h>
+#else
+# ifndef HAVE_MEMCPY
+# define memcpy(d, s, n) bcopy ((s), (d), (n))
+# endif
+#endif
+
+#if defined(FFI_DEBUG)
+#include <stdio.h>
+#endif
+
+#ifdef FFI_DEBUG
+/*@exits@*/ void ffi_assert(/*@temp@*/ char *expr, /*@temp@*/ char *file, int line);
+void ffi_stop_here(void);
+void ffi_type_test(/*@temp@*/ /*@out@*/ ffi_type *a, /*@temp@*/ char *file, int line);
+
+#define FFI_ASSERT(x) ((x) ? (void)0 : ffi_assert(#x, __FILE__,__LINE__))
+#define FFI_ASSERT_AT(x, f, l) ((x) ? 0 : ffi_assert(#x, (f), (l)))
+#define FFI_ASSERT_VALID_TYPE(x) ffi_type_test (x, __FILE__, __LINE__)
+#else
+#define FFI_ASSERT(x)
+#define FFI_ASSERT_AT(x, f, l)
+#define FFI_ASSERT_VALID_TYPE(x)
+#endif
+
+#define ALIGN(v, a) (((((size_t) (v))-1) | ((a)-1))+1)
+
+/* Perform machine dependent cif processing */
+ffi_status ffi_prep_cif_machdep(ffi_cif *cif);
+
+/* Extended cif, used in callback from assembly routine */
+typedef struct
+{
+ /*@dependent@*/ ffi_cif *cif;
+ /*@dependent@*/ void *rvalue;
+ /*@dependent@*/ void **avalue;
+} extended_cif;
+
+/* Terse sized type definitions. */
+typedef unsigned int UINT8 __attribute__((__mode__(__QI__)));
+typedef signed int SINT8 __attribute__((__mode__(__QI__)));
+typedef unsigned int UINT16 __attribute__((__mode__(__HI__)));
+typedef signed int SINT16 __attribute__((__mode__(__HI__)));
+typedef unsigned int UINT32 __attribute__((__mode__(__SI__)));
+typedef signed int SINT32 __attribute__((__mode__(__SI__)));
+typedef unsigned int UINT64 __attribute__((__mode__(__DI__)));
+typedef signed int SINT64 __attribute__((__mode__(__DI__)));
+
+typedef float FLOAT32;
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+
Added: packages/ctypes/branches/upstream/current/source/libffi_msvc/fficonfig.h
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/source/libffi_msvc/fficonfig.h?rev=940&op=file
==============================================================================
--- packages/ctypes/branches/upstream/current/source/libffi_msvc/fficonfig.h (added)
+++ packages/ctypes/branches/upstream/current/source/libffi_msvc/fficonfig.h Mon Jun 19 12:31:53 2006
@@ -1,0 +1,94 @@
+/* fficonfig.h. Originally created by configure, now hand_maintained for MSVC. */
+
+/* fficonfig.h. Generated automatically by configure. */
+/* fficonfig.h.in. Generated automatically from configure.in by autoheader. */
+
+/* Defines for MSVC */
+#define __attribute__(x) /* */
+#define alloca _alloca
+
+/*----------------------------------------------------------------*/
+
+/* Define if using alloca.c. */
+/* #undef C_ALLOCA */
+
+/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
+ This function is required for alloca.c support on those systems. */
+/* #undef CRAY_STACKSEG_END */
+
+/* Define if you have alloca, as a function or macro. */
+#define HAVE_ALLOCA 1
+
+/* Define if you have <alloca.h> and it should be used (not on Ultrix). */
+/* #define HAVE_ALLOCA_H 1 */
+
+/* If using the C implementation of alloca, define if you know the
+ direction of stack growth for your system; otherwise it will be
+ automatically deduced at run-time.
+ STACK_DIRECTION > 0 => grows toward higher addresses
+ STACK_DIRECTION < 0 => grows toward lower addresses
+ STACK_DIRECTION = 0 => direction of growth unknown
+ */
+/* #undef STACK_DIRECTION */
+
+/* Define if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Define if you have the memcpy function. */
+#define HAVE_MEMCPY 1
+
+/* Define if read-only mmap of a plain file works. */
+//#define HAVE_MMAP_FILE 1
+
+/* Define if mmap of /dev/zero works. */
+//#define HAVE_MMAP_DEV_ZERO 1
+
+/* Define if mmap with MAP_ANON(YMOUS) works. */
+//#define HAVE_MMAP_ANON 1
+
+/* The number of bytes in type double */
+#define SIZEOF_DOUBLE 8
+
+/* The number of bytes in type long double */
+#define SIZEOF_LONG_DOUBLE 12
+
+/* Define if you have the long double type and it is bigger than a double */
+#define HAVE_LONG_DOUBLE 1
+
+/* whether byteorder is bigendian */
+/* #undef WORDS_BIGENDIAN */
+
+/* Define if the host machine stores words of multi-word integers in
+ big-endian order. */
+/* #undef HOST_WORDS_BIG_ENDIAN */
+
+/* 1234 = LIL_ENDIAN, 4321 = BIGENDIAN */
+#define BYTEORDER 1234
+
+/* Define if your assembler and linker support unaligned PC relative relocs. */
+/* #undef HAVE_AS_SPARC_UA_PCREL */
+
+/* Define if your assembler supports .register. */
+/* #undef HAVE_AS_REGISTER_PSEUDO_OP */
+
+/* Define if .eh_frame sections should be read-only. */
+/* #undef HAVE_RO_EH_FRAME */
+
+/* Define to the flags needed for the .section .eh_frame directive. */
+/* #define EH_FRAME_FLAGS "aw" */
+
+/* Define to the flags needed for the .section .eh_frame directive. */
+/* #define EH_FRAME_FLAGS "aw" */
+
+/* Define this if you want extra debugging. */
+/* #undef FFI_DEBUG */
+
+/* Define this is you do not want support for aggregate types. */
+/* #undef FFI_NO_STRUCTS */
+
+/* Define this is you do not want support for the raw API. */
+/* #undef FFI_NO_RAW_API */
+
+/* Define this if you are using Purify and want to suppress spurious messages. */
+/* #undef USING_PURIFY */
+
Added: packages/ctypes/branches/upstream/current/source/libffi_msvc/ffitarget.h
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/source/libffi_msvc/ffitarget.h?rev=940&op=file
==============================================================================
--- packages/ctypes/branches/upstream/current/source/libffi_msvc/ffitarget.h (added)
+++ packages/ctypes/branches/upstream/current/source/libffi_msvc/ffitarget.h Mon Jun 19 12:31:53 2006
@@ -1,0 +1,83 @@
+/* -----------------------------------------------------------------*-C-*-
+ ffitarget.h - Copyright (c) 1996-2003 Red Hat, Inc.
+ Target configuration macros for x86 and x86-64.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+
+ ----------------------------------------------------------------------- */
+
+#ifndef LIBFFI_TARGET_H
+#define LIBFFI_TARGET_H
+
+/* ---- System specific configurations ----------------------------------- */
+
+#if defined (X86_64) && defined (__i386__)
+#undef X86_64
+#define X86
+#endif
+
+/* ---- Generic type definitions ----------------------------------------- */
+
+#ifndef LIBFFI_ASM
+typedef unsigned long ffi_arg;
+typedef signed long ffi_sarg;
+
+typedef enum ffi_abi {
+ FFI_FIRST_ABI = 0,
+
+ /* ---- Intel x86 Win32 ---------- */
+ FFI_SYSV,
+ FFI_STDCALL,
+ /* TODO: Add fastcall support for the sake of completeness */
+ FFI_DEFAULT_ABI = FFI_SYSV,
+
+ /* ---- Intel x86 and AMD x86-64 - */
+/* #if !defined(X86_WIN32) && (defined(__i386__) || defined(__x86_64__)) */
+/* FFI_SYSV, */
+/* FFI_UNIX64,*/ /* Unix variants all use the same ABI for x86-64 */
+/* #ifdef __i386__ */
+/* FFI_DEFAULT_ABI = FFI_SYSV, */
+/* #else */
+/* FFI_DEFAULT_ABI = FFI_UNIX64, */
+/* #endif */
+/* #endif */
+
+ FFI_LAST_ABI = FFI_DEFAULT_ABI + 1
+} ffi_abi;
+#endif
+
+/* ---- Definitions for closures ----------------------------------------- */
+
+#define FFI_CLOSURES 1
+
+#ifdef X86_64
+#define FFI_TRAMPOLINE_SIZE 24
+#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
+
+#endif
+
Added: packages/ctypes/branches/upstream/current/source/libffi_msvc/prep_cif.c
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/source/libffi_msvc/prep_cif.c?rev=940&op=file
==============================================================================
--- packages/ctypes/branches/upstream/current/source/libffi_msvc/prep_cif.c (added)
+++ packages/ctypes/branches/upstream/current/source/libffi_msvc/prep_cif.c Mon Jun 19 12:31:53 2006
@@ -1,0 +1,175 @@
+/* -----------------------------------------------------------------------
+ prep_cif.c - Copyright (c) 1996, 1998 Red Hat, Inc.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#include <ffi.h>
+#include <ffi_common.h>
+#include <stdlib.h>
+
+
+/* Round up to FFI_SIZEOF_ARG. */
+
+#define STACK_ARG_SIZE(x) ALIGN(x, FFI_SIZEOF_ARG)
+
+/* Perform machine independent initialization of aggregate type
+ specifications. */
+
+static ffi_status initialize_aggregate(/*@out@*/ ffi_type *arg)
+{
+ ffi_type **ptr;
+
+ FFI_ASSERT(arg != NULL);
+
+ /*@-usedef@*/
+
+ FFI_ASSERT(arg->elements != NULL);
+ FFI_ASSERT(arg->size == 0);
+ FFI_ASSERT(arg->alignment == 0);
+
+ ptr = &(arg->elements[0]);
+
+ while ((*ptr) != NULL)
+ {
+ if (((*ptr)->size == 0) && (initialize_aggregate((*ptr)) != FFI_OK))
+ return FFI_BAD_TYPEDEF;
+
+ /* Perform a sanity check on the argument type */
+ FFI_ASSERT_VALID_TYPE(*ptr);
+
+ arg->size = ALIGN(arg->size, (*ptr)->alignment);
+ arg->size += (*ptr)->size;
+
+ arg->alignment = (arg->alignment > (*ptr)->alignment) ?
+ arg->alignment : (*ptr)->alignment;
+
+ ptr++;
+ }
+
+ /* Structure size includes tail padding. This is important for
+ structures that fit in one register on ABIs like the PowerPC64
+ Linux ABI that right justify small structs in a register.
+ It's also needed for nested structure layout, for example
+ struct A { long a; char b; }; struct B { struct A x; char y; };
+ should find y at an offset of 2*sizeof(long) and result in a
+ total size of 3*sizeof(long). */
+ arg->size = ALIGN (arg->size, arg->alignment);
+
+ if (arg->size == 0)
+ return FFI_BAD_TYPEDEF;
+ else
+ return FFI_OK;
+
+ /*@=usedef@*/
+}
+
+/* Perform machine independent ffi_cif preparation, then call
+ machine dependent routine. */
+
+ffi_status ffi_prep_cif(/*@out@*/ /*@partial@*/ ffi_cif *cif,
+ ffi_abi abi, unsigned int nargs,
+ /*@dependent@*/ /*@out@*/ /*@partial@*/ ffi_type *rtype,
+ /*@dependent@*/ ffi_type **atypes)
+{
+ unsigned bytes = 0;
+ unsigned int i;
+ ffi_type **ptr;
+
+ FFI_ASSERT(cif != NULL);
+ FFI_ASSERT((abi > FFI_FIRST_ABI) && (abi <= FFI_DEFAULT_ABI));
+
+ cif->abi = abi;
+ cif->arg_types = atypes;
+ cif->nargs = nargs;
+ cif->rtype = rtype;
+
+ cif->flags = 0;
+
+ /* Initialize the return type if necessary */
+ /*@-usedef@*/
+ if ((cif->rtype->size == 0) && (initialize_aggregate(cif->rtype) != FFI_OK))
+ return FFI_BAD_TYPEDEF;
+ /*@=usedef@*/
+
+ /* Perform a sanity check on the return type */
+ FFI_ASSERT_VALID_TYPE(cif->rtype);
+
+ /* x86-64 and s390 stack space allocation is handled in prep_machdep. */
+#if !defined M68K && !defined __x86_64__ && !defined S390
+ /* Make space for the return structure pointer */
+ if (cif->rtype->type == FFI_TYPE_STRUCT
+ /* MSVC returns small structures in registers. But we have a different
+ workaround: pretend int32 or int64 return type, and converting to
+ structure afterwards. */
+#ifdef SPARC
+ && (cif->abi != FFI_V9 || cif->rtype->size > 32)
+#endif
+ )
+ bytes = STACK_ARG_SIZE(sizeof(void*));
+#endif
+
+ for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++)
+ {
+
+ /* Initialize any uninitialized aggregate type definitions */
+ if (((*ptr)->size == 0) && (initialize_aggregate((*ptr)) != FFI_OK))
+ return FFI_BAD_TYPEDEF;
+
+ /* Perform a sanity check on the argument type, do this
+ check after the initialization. */
+ FFI_ASSERT_VALID_TYPE(*ptr);
+
+#if !defined __x86_64__ && !defined S390
+#ifdef SPARC
+ if (((*ptr)->type == FFI_TYPE_STRUCT
+ && ((*ptr)->size > 16 || cif->abi != FFI_V9))
+ || ((*ptr)->type == FFI_TYPE_LONGDOUBLE
+ && cif->abi != FFI_V9))
+ bytes += sizeof(void*);
+ else
+#endif
+ {
+#if !defined(_MSC_VER) && !defined(__MINGW32__)
+ /* Don't know if this is a libffi bug or not. At least on
+ Windows with MSVC, function call parameters are *not*
+ aligned in the same way as structure fields are, they are
+ only aligned in integer boundaries.
+
+ This doesn't do any harm for cdecl functions and closures,
+ since the caller cleans up the stack, but it is wrong for
+ stdcall functions where the callee cleans.
+ */
+
+ /* Add any padding if necessary */
+ if (((*ptr)->alignment - 1) & bytes)
+ bytes = ALIGN(bytes, (*ptr)->alignment);
+
+#endif
+ bytes += STACK_ARG_SIZE((*ptr)->size);
+ }
+#endif
+ }
+
+ cif->bytes = bytes;
+
+ /* Perform machine dependent cif processing */
+ return ffi_prep_cif_machdep(cif);
+}
Added: packages/ctypes/branches/upstream/current/source/libffi_msvc/types.c
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/source/libffi_msvc/types.c?rev=940&op=file
==============================================================================
--- packages/ctypes/branches/upstream/current/source/libffi_msvc/types.c (added)
+++ packages/ctypes/branches/upstream/current/source/libffi_msvc/types.c Mon Jun 19 12:31:53 2006
@@ -1,0 +1,104 @@
+/* -----------------------------------------------------------------------
+ types.c - Copyright (c) 1996, 1998 Red Hat, Inc.
+
+ Predefined ffi_types needed by libffi.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#include <ffi.h>
+#include <ffi_common.h>
+
+/* Type definitions */
+
+#define FFI_INTEGRAL_TYPEDEF(n, s, a, t) ffi_type ffi_type_##n = { s, a, t, NULL }
+#define FFI_AGGREGATE_TYPEDEF(n, e) ffi_type ffi_type_##n = { 0, 0, FFI_TYPE_STRUCT, e }
+
+/* Size and alignment are fake here. They must not be 0. */
+FFI_INTEGRAL_TYPEDEF(void, 1, 1, FFI_TYPE_VOID);
+
+FFI_INTEGRAL_TYPEDEF(uint8, 1, 1, FFI_TYPE_UINT8);
+FFI_INTEGRAL_TYPEDEF(sint8, 1, 1, FFI_TYPE_SINT8);
+FFI_INTEGRAL_TYPEDEF(uint16, 2, 2, FFI_TYPE_UINT16);
+FFI_INTEGRAL_TYPEDEF(sint16, 2, 2, FFI_TYPE_SINT16);
+FFI_INTEGRAL_TYPEDEF(uint32, 4, 4, FFI_TYPE_UINT32);
+FFI_INTEGRAL_TYPEDEF(sint32, 4, 4, FFI_TYPE_SINT32);
+FFI_INTEGRAL_TYPEDEF(float, 4, 4, FFI_TYPE_FLOAT);
+
+#if defined ALPHA || defined SPARC64 || defined X86_64 || defined S390X \
+ || defined IA64
+
+FFI_INTEGRAL_TYPEDEF(pointer, 8, 8, FFI_TYPE_POINTER);
+
+#else
+
+FFI_INTEGRAL_TYPEDEF(pointer, 4, 4, FFI_TYPE_POINTER);
+
+#endif
+
+#if defined X86 || defined X86_WIN32 || defined ARM || defined M68K
+
+FFI_INTEGRAL_TYPEDEF(uint64, 8, 4, FFI_TYPE_UINT64);
+FFI_INTEGRAL_TYPEDEF(sint64, 8, 4, FFI_TYPE_SINT64);
+
+#elif defined SH
+
+FFI_INTEGRAL_TYPEDEF(uint64, 8, 4, FFI_TYPE_UINT64);
+FFI_INTEGRAL_TYPEDEF(sint64, 8, 4, FFI_TYPE_SINT64);
+
+#else
+
+FFI_INTEGRAL_TYPEDEF(uint64, 8, 8, FFI_TYPE_UINT64);
+FFI_INTEGRAL_TYPEDEF(sint64, 8, 8, FFI_TYPE_SINT64);
+
+#endif
+
+
+#if defined X86 || defined X86_WIN32 || defined M68K
+
+FFI_INTEGRAL_TYPEDEF(double, 8, 4, FFI_TYPE_DOUBLE);
+FFI_INTEGRAL_TYPEDEF(longdouble, 12, 4, FFI_TYPE_LONGDOUBLE);
+
+#elif defined ARM || defined SH || defined POWERPC_AIX || defined POWERPC_DARWIN
+
+FFI_INTEGRAL_TYPEDEF(double, 8, 4, FFI_TYPE_DOUBLE);
+FFI_INTEGRAL_TYPEDEF(longdouble, 8, 4, FFI_TYPE_LONGDOUBLE);
+
+#elif defined SPARC
+
+FFI_INTEGRAL_TYPEDEF(double, 8, 8, FFI_TYPE_DOUBLE);
+#ifdef SPARC64
+FFI_INTEGRAL_TYPEDEF(longdouble, 16, 16, FFI_TYPE_LONGDOUBLE);
+#else
+FFI_INTEGRAL_TYPEDEF(longdouble, 16, 8, FFI_TYPE_LONGDOUBLE);
+#endif
+
+#elif defined X86_64
+
+FFI_INTEGRAL_TYPEDEF(double, 8, 8, FFI_TYPE_DOUBLE);
+FFI_INTEGRAL_TYPEDEF(longdouble, 16, 16, FFI_TYPE_LONGDOUBLE);
+
+#else
+
+FFI_INTEGRAL_TYPEDEF(double, 8, 8, FFI_TYPE_DOUBLE);
+FFI_INTEGRAL_TYPEDEF(longdouble, 8, 8, FFI_TYPE_LONGDOUBLE);
+
+#endif
+
Added: packages/ctypes/branches/upstream/current/source/libffi_msvc/win32.S
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/source/libffi_msvc/win32.S?rev=940&op=file
==============================================================================
--- packages/ctypes/branches/upstream/current/source/libffi_msvc/win32.S (added)
+++ packages/ctypes/branches/upstream/current/source/libffi_msvc/win32.S Mon Jun 19 12:31:53 2006
@@ -1,0 +1,243 @@
+/* -----------------------------------------------------------------------
+ win32.S - Copyright (c) 1996, 1998, 2001, 2002 Red Hat, Inc.
+ Copyright (c) 2001 John Beniton
+ Copyright (c) 2002 Ranjit Mathew
+
+
+ X86 Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#define LIBFFI_ASM
+#include <fficonfig.h>
+#include <ffi.h>
+
+.text
+
+.globl ffi_prep_args
+
+ # This assumes we are using gas.
+ .balign 16
+.globl _ffi_call_SYSV
+
+_ffi_call_SYSV:
+ 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
+ subl %ecx,%esp
+
+ movl %esp,%eax
+
+ # Place all of the ffi_prep_args in position
+ pushl 12(%ebp)
+ pushl %eax
+ call *8(%ebp)
+
+ # Return stack to previous state and call the function
+ addl $8,%esp
+
+ # FIXME: Align the stack to a 128-bit boundary to avoid
+ # potential performance hits.
+
+ call *28(%ebp)
+
+ # Remove the space we pushed for the args
+ 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
+
+ # If the return value pointer is NULL, assume no return value.
+ cmpl $0,24(%ebp)
+ jne retint
+
+ # Even if there is no space for the return value, we are
+ # obliged to handle floating-point values.
+ cmpl $FFI_TYPE_FLOAT,%ecx
+ jne noretval
+ fstp %st(0)
+
+ jmp epilogue
+
+retint:
+ cmpl $FFI_TYPE_INT,%ecx
+ jne retfloat
+ # Load %ecx with the pointer to storage for the return value
+ movl 24(%ebp),%ecx
+ movl %eax,0(%ecx)
+ jmp epilogue
+
+retfloat:
+ cmpl $FFI_TYPE_FLOAT,%ecx
+ jne retdouble
+ # Load %ecx with the pointer to storage for the return value
+ movl 24(%ebp),%ecx
+ fstps (%ecx)
+ jmp epilogue
+
+retdouble:
+ cmpl $FFI_TYPE_DOUBLE,%ecx
+ jne retlongdouble
+ # Load %ecx with the pointer to storage for the return value
+ movl 24(%ebp),%ecx
+ fstpl (%ecx)
+ jmp epilogue
+
+retlongdouble:
+ cmpl $FFI_TYPE_LONGDOUBLE,%ecx
+ jne retint64
+ # Load %ecx with the pointer to storage for the return value
+ movl 24(%ebp),%ecx
+ fstpt (%ecx)
+ jmp epilogue
+
+retint64:
+ cmpl $FFI_TYPE_SINT64,%ecx
+ jne retstruct
+ # Load %ecx with the pointer to storage for the return value
+ movl 24(%ebp),%ecx
+ movl %eax,0(%ecx)
+ movl %edx,4(%ecx)
+
+retstruct:
+ # Nothing to do!
+
+noretval:
+epilogue:
+ movl %esi,%eax # return the stack pointer detlta in %eax
+ popl %esi # restore previous %esi
+ movl %ebp,%esp
+ popl %ebp
+ ret
+
+.ffi_call_SYSV_end:
+
+ # This assumes we are using gas.
+ .balign 16
+.globl _ffi_call_STDCALL
+
+_ffi_call_STDCALL:
+ 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
+ subl %ecx,%esp
+
+ movl %esp,%eax
+
+ # Place all of the ffi_prep_args in position
+ pushl 12(%ebp)
+ pushl %eax
+ call *8(%ebp)
+
+ # Return stack to previous state and call the function
+ addl $8,%esp
+
+ # FIXME: Align the stack to a 128-bit boundary to avoid
+ # potential performance hits.
+
+ call *28(%ebp)
+
+ sub %esp,%esi # difference in stack
+
+ # stdcall functions pop arguments off the stack themselves
+
+ # Load %ecx with the return type code
+ movl 20(%ebp),%ecx
+
+ # If the return value pointer is NULL, assume no return value.
+ cmpl $0,24(%ebp)
+ jne sc_retint
+
+ # Even if there is no space for the return value, we are
+ # obliged to handle floating-point values.
+ cmpl $FFI_TYPE_FLOAT,%ecx
+ jne sc_noretval
+ fstp %st(0)
+
+ jmp sc_epilogue
+
+sc_retint:
+ cmpl $FFI_TYPE_INT,%ecx
+ jne sc_retfloat
+ # Load %ecx with the pointer to storage for the return value
+ movl 24(%ebp),%ecx
+ movl %eax,0(%ecx)
+ jmp sc_epilogue
+
+sc_retfloat:
+ cmpl $FFI_TYPE_FLOAT,%ecx
+ jne sc_retdouble
+ # Load %ecx with the pointer to storage for the return value
+ movl 24(%ebp),%ecx
+ fstps (%ecx)
+ jmp sc_epilogue
+
+sc_retdouble:
+ cmpl $FFI_TYPE_DOUBLE,%ecx
+ jne sc_retlongdouble
+ # Load %ecx with the pointer to storage for the return value
+ movl 24(%ebp),%ecx
+ fstpl (%ecx)
+ jmp sc_epilogue
+
+sc_retlongdouble:
+ cmpl $FFI_TYPE_LONGDOUBLE,%ecx
+ jne sc_retint64
+ # Load %ecx with the pointer to storage for the return value
+ movl 24(%ebp),%ecx
+ fstpt (%ecx)
+ jmp sc_epilogue
+
+sc_retint64:
+ cmpl $FFI_TYPE_SINT64,%ecx
+ jne sc_retstruct
+ # Load %ecx with the pointer to storage for the return value
+ movl 24(%ebp),%ecx
+ movl %eax,0(%ecx)
+ movl %edx,4(%ecx)
+
+sc_retstruct:
+ # Nothing to do!
+
+sc_noretval:
+sc_epilogue:
+ movl %esi,%eax # return the stack difference
+ popl %esi # restore previous %esi value
+ movl %ebp,%esp
+ popl %ebp
+ ret
+
+.ffi_call_STDCALL_end:
Added: packages/ctypes/branches/upstream/current/source/libffi_msvc/win32.c
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/source/libffi_msvc/win32.c?rev=940&op=file
==============================================================================
--- packages/ctypes/branches/upstream/current/source/libffi_msvc/win32.c (added)
+++ packages/ctypes/branches/upstream/current/source/libffi_msvc/win32.c Mon Jun 19 12:31:53 2006
@@ -1,0 +1,267 @@
+/* -----------------------------------------------------------------------
+ win32.S - Copyright (c) 1996, 1998, 2001, 2002 Red Hat, Inc.
+ Copyright (c) 2001 John Beniton
+ Copyright (c) 2002 Ranjit Mathew
+
+
+ X86 Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+/* theller: almost verbatim translation from gas syntax to MSVC inline
+ assembler code. */
+
+/* theller: ffi_call_SYSV and ffi_call_STDCALL now return an integer - the
+ difference of the stack pointer before and after the function call. If
+ everything is ok, zero is returned. If stdcall functions are passed the
+ wrong number of arguments, the difference will be nonzero. */
+
+#include <ffi.h>
+#include <ffi_common.h>
+
+__declspec(naked) int
+ffi_call_SYSV(void (* prepfunc)(char *, extended_cif *), /* 8 */
+ extended_cif *ecif, /* 12 */
+ unsigned bytes, /* 16 */
+ unsigned flags, /* 20 */
+ unsigned *rvalue, /* 24 */
+ void (*fn)()) /* 28 */
+{
+ _asm {
+ push ebp
+ mov ebp, esp
+
+ push esi // NEW: this register must be preserved across function calls
+// XXX SAVE ESP NOW!
+ mov esi, esp // save stack pointer before the call
+
+// Make room for all of the new args.
+ mov ecx, [ebp+16]
+ sub esp, ecx // sub esp, bytes
+
+ mov eax, esp
+
+// Place all of the ffi_prep_args in position
+ push [ebp + 12] // ecif
+ push eax
+ call [ebp + 8] // prepfunc
+
+// Return stack to previous state and call the function
+ add esp, 8
+// FIXME: Align the stack to a 128-bit boundary to avoid
+// potential performance hits.
+ call [ebp + 28]
+// Remove the space we pushed for the args
+ mov ecx, [ebp + 16]
+ add esp, ecx
+
+// XXX ASSERT THAT ESP IS THE SAME NOW THAN BEFORE!
+ sub esi, esp
+
+// Load %ecx with the return type code
+ mov ecx, [ebp + 20]
+
+// If the return value pointer is NULL, assume no return value.
+/*
+ Intel asm is weird. We have to explicitely specify 'DWORD PTR' in the nexr instruction,
+ otherwise only one BYTE will be compared (instead of a DWORD)!
+ */
+ cmp DWORD PTR [ebp + 24], 0
+ jne sc_retint
+
+// Even if there is no space for the return value, we are
+// obliged to handle floating-point values.
+ cmp ecx, FFI_TYPE_FLOAT
+ jne sc_noretval
+// fstp %st(0)
+ fstp st(0)
+
+ jmp sc_epilogue
+
+sc_retint:
+ cmp ecx, FFI_TYPE_INT
+ jne sc_retfloat
+// # Load %ecx with the pointer to storage for the return value
+ mov ecx, [ebp + 24]
+ mov [ecx + 0], eax
+ jmp sc_epilogue
+
+sc_retfloat:
+ cmp ecx, FFI_TYPE_FLOAT
+ jne sc_retdouble
+// Load %ecx with the pointer to storage for the return value
+ mov ecx, [ebp+24]
+// fstps (%ecx)
+ fstp DWORD PTR [ecx]
+ jmp sc_epilogue
+
+sc_retdouble:
+ cmp ecx, FFI_TYPE_DOUBLE
+ jne sc_retlongdouble
+// movl 24(%ebp),%ecx
+ mov ecx, [ebp+24]
+ fstp QWORD PTR [ecx]
+ jmp sc_epilogue
+
+ jmp sc_retlongdouble // avoid warning about unused label
+sc_retlongdouble:
+ cmp ecx, FFI_TYPE_LONGDOUBLE
+ jne sc_retint64
+// Load %ecx with the pointer to storage for the return value
+ mov ecx, [ebp+24]
+// fstpt (%ecx)
+ fstp QWORD PTR [ecx] /* XXX ??? */
+ jmp sc_epilogue
+
+sc_retint64:
+ cmp ecx, FFI_TYPE_SINT64
+ jne sc_retstruct
+// Load %ecx with the pointer to storage for the return value
+ mov ecx, [ebp+24]
+ mov [ecx+0], eax
+ mov [ecx+4], edx
+
+sc_retstruct:
+// Nothing to do!
+
+sc_noretval:
+sc_epilogue:
+ mov eax, esi
+ pop esi // NEW restore: must be preserved across function calls
+ mov esp, ebp
+ pop ebp
+ ret
+ }
+}
+
+__declspec(naked) int
+ffi_call_STDCALL(void (* prepfunc)(char *, extended_cif *), /* 8 */
+ extended_cif *ecif, /* 12 */
+ unsigned bytes, /* 16 */
+ unsigned flags, /* 20 */
+ unsigned *rvalue, /* 24 */
+ void (*fn)()) /* 28 */
+{
+ _asm {
+ push ebp
+ mov ebp, esp
+
+ push esi // NEW: this register must be preserved across function calls
+
+// XXX SAVE ESP NOW!
+ mov esi, esp
+
+// Make room for all of the new args.
+ mov ecx, [ebp+16]
+ sub esp, ecx
+
+ mov eax, esp
+
+// Place all of the ffi_prep_args in position
+ push [ebp + 12] // ecif
+ push eax
+ call [ebp + 8] // prepfunc
+
+// Return stack to previous state and call the function
+ add esp, 8
+// FIXME: Align the stack to a 128-bit boundary to avoid
+// potential performance hits.
+ call [ebp + 28]
+// stdcall functions pop arguments off the stack themselves
+
+// XXX IS ESP NOW THE SAME AS BEFORE?
+ sub esi, esp
+
+// Load %ecx with the return type code
+ mov ecx, [ebp + 20]
+
+// If the return value pointer is NULL, assume no return value.
+/*
+ Intel asm is weird. We have to explicitely specify 'DWORD PTR' in the nexr instruction,
+ otherwise only one BYTE will be compared (instead of a DWORD)!
+ */
+ cmp DWORD PTR [ebp + 24], 0
+ jne sc_retint
+
+// Even if there is no space for the return value, we are
+// obliged to handle floating-point values.
+ cmp ecx, FFI_TYPE_FLOAT
+ jne sc_noretval
+// fstp %st(0)
+ fstp st(0)
+
+ jmp sc_epilogue
+
+sc_retint:
+ cmp ecx, FFI_TYPE_INT
+ jne sc_retfloat
+// # Load %ecx with the pointer to storage for the return value
+ mov ecx, [ebp + 24]
+ mov [ecx + 0], eax
+ jmp sc_epilogue
+
+sc_retfloat:
+ cmp ecx, FFI_TYPE_FLOAT
+ jne sc_retdouble
+// Load %ecx with the pointer to storage for the return value
+ mov ecx, [ebp+24]
+// fstps (%ecx)
+ fstp DWORD PTR [ecx]
+ jmp sc_epilogue
+
+sc_retdouble:
+ cmp ecx, FFI_TYPE_DOUBLE
+ jne sc_retlongdouble
+// movl 24(%ebp),%ecx
+ mov ecx, [ebp+24]
+ fstp QWORD PTR [ecx]
+ jmp sc_epilogue
+
+ jmp sc_retlongdouble // avoid warning about unused label
+sc_retlongdouble:
+ cmp ecx, FFI_TYPE_LONGDOUBLE
+ jne sc_retint64
+// Load %ecx with the pointer to storage for the return value
+ mov ecx, [ebp+24]
+// fstpt (%ecx)
+ fstp QWORD PTR [ecx] /* XXX ??? */
+ jmp sc_epilogue
+
+sc_retint64:
+ cmp ecx, FFI_TYPE_SINT64
+ jne sc_retstruct
+// Load %ecx with the pointer to storage for the return value
+ mov ecx, [ebp+24]
+ mov [ecx+0], eax
+ mov [ecx+4], edx
+
+sc_retstruct:
+// Nothing to do!
+
+sc_noretval:
+sc_epilogue:
+ mov eax, esi
+ pop esi // NEW restore: must be preserved across function calls
+ mov esp, ebp
+ pop ebp
+ ret
+ }
+}
Modified: packages/ctypes/branches/upstream/current/source/stgdict.c
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/source/stgdict.c?rev=940&op=diff
==============================================================================
--- packages/ctypes/branches/upstream/current/source/stgdict.c (original)
+++ packages/ctypes/branches/upstream/current/source/stgdict.c Mon Jun 19 12:31:53 2006
@@ -38,7 +38,7 @@
StgDict_dealloc(StgDictObject *self)
{
StgDict_clear(self);
- PyMem_Free(self->ffi_type.elements);
+ PyMem_Free(self->ffi_type_pointer.elements);
PyDict_Type.tp_dealloc((PyObject *)self);
}
@@ -49,8 +49,8 @@
int size;
StgDict_clear(dst);
- PyMem_Free(dst->ffi_type.elements);
- dst->ffi_type.elements = NULL;
+ PyMem_Free(dst->ffi_type_pointer.elements);
+ dst->ffi_type_pointer.elements = NULL;
d = (char *)dst;
s = (char *)src;
@@ -64,13 +64,15 @@
Py_XINCREF(dst->restype);
Py_XINCREF(dst->checker);
- if (src->ffi_type.elements == NULL)
+ if (src->ffi_type_pointer.elements == NULL)
return 0;
size = sizeof(ffi_type *) * (src->length + 1);
- dst->ffi_type.elements = PyMem_Malloc(size);
- if (dst->ffi_type.elements == NULL)
- return -1;
- memcpy(dst->ffi_type.elements, src->ffi_type.elements, size);
+ dst->ffi_type_pointer.elements = PyMem_Malloc(size);
+ if (dst->ffi_type_pointer.elements == NULL)
+ return -1;
+ memcpy(dst->ffi_type_pointer.elements,
+ src->ffi_type_pointer.elements,
+ size);
return 0;
}
@@ -234,8 +236,8 @@
stuff is sucessfully finished. */
stgdict->flags |= DICTFLAG_FINAL; /* set final */
- if (stgdict->ffi_type.elements)
- PyMem_Free(stgdict->ffi_type.elements);
+ if (stgdict->ffi_type_pointer.elements)
+ PyMem_Free(stgdict->ffi_type_pointer.elements);
basedict = PyType_stgdict((PyObject *)((PyTypeObject *)type)->tp_base);
if (basedict && !use_broken_old_ctypes_semantics) {
@@ -243,10 +245,12 @@
align = basedict->align;
union_size = 0;
total_align = align ? align : 1;
- stgdict->ffi_type.type = FFI_TYPE_STRUCT;
- stgdict->ffi_type.elements = PyMem_Malloc(sizeof(ffi_type *) * (basedict->length + len + 1));
- memset(stgdict->ffi_type.elements, 0, sizeof(ffi_type *) * (basedict->length + len + 1));
- memcpy(stgdict->ffi_type.elements, basedict->ffi_type.elements,
+ stgdict->ffi_type_pointer.type = FFI_TYPE_STRUCT;
+ stgdict->ffi_type_pointer.elements = PyMem_Malloc(sizeof(ffi_type *) * (basedict->length + len + 1));
+ memset(stgdict->ffi_type_pointer.elements, 0,
+ sizeof(ffi_type *) * (basedict->length + len + 1));
+ memcpy(stgdict->ffi_type_pointer.elements,
+ basedict->ffi_type_pointer.elements,
sizeof(ffi_type *) * (basedict->length));
ffi_ofs = basedict->length;
} else {
@@ -255,9 +259,10 @@
align = 0;
union_size = 0;
total_align = 1;
- stgdict->ffi_type.type = FFI_TYPE_STRUCT;
- stgdict->ffi_type.elements = PyMem_Malloc(sizeof(ffi_type *) * (len + 1));
- memset(stgdict->ffi_type.elements, 0, sizeof(ffi_type *) * (len + 1));
+ stgdict->ffi_type_pointer.type = FFI_TYPE_STRUCT;
+ stgdict->ffi_type_pointer.elements = PyMem_Malloc(sizeof(ffi_type *) * (len + 1));
+ memset(stgdict->ffi_type_pointer.elements, 0,
+ sizeof(ffi_type *) * (len + 1));
ffi_ofs = 0;
}
@@ -283,10 +288,10 @@
i);
return -1;
}
- stgdict->ffi_type.elements[ffi_ofs + i] = &dict->ffi_type;
+ stgdict->ffi_type_pointer.elements[ffi_ofs + i] = &dict->ffi_type_pointer;
dict->flags |= DICTFLAG_FINAL; /* mark field type final */
if (PyTuple_Size(pair) == 3) { /* bits specified */
- switch(dict->ffi_type.type) {
+ switch(dict->ffi_type_pointer.type) {
case FFI_TYPE_UINT8:
case FFI_TYPE_UINT16:
case FFI_TYPE_UINT32:
@@ -357,8 +362,8 @@
/* Adjust the size according to the alignment requirements */
size = ((size + total_align - 1) / total_align) * total_align;
- stgdict->ffi_type.alignment = total_align;
- stgdict->ffi_type.size = size;
+ stgdict->ffi_type_pointer.alignment = total_align;
+ stgdict->ffi_type_pointer.size = size;
stgdict->size = size;
stgdict->align = total_align;
Added: packages/ctypes/branches/upstream/current/wince/_ctypes.vcp
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/wince/_ctypes.vcp?rev=940&op=file
==============================================================================
--- packages/ctypes/branches/upstream/current/wince/_ctypes.vcp (added)
+++ packages/ctypes/branches/upstream/current/wince/_ctypes.vcp Mon Jun 19 12:31:53 2006
@@ -1,0 +1,1766 @@
+# Microsoft eMbedded Visual Tools Project File - Name="_ctypes" - Package Owner=<4>
+# Microsoft eMbedded Visual Tools Generated Build File, Format Version 6.02
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (WCE ARMV4T) Dynamic-Link Library" 0xa402
+# TARGTYPE "Win32 (WCE x86) Dynamic-Link Library" 0x8302
+# TARGTYPE "Win32 (WCE ARMV4) Dynamic-Link Library" 0xa302
+# TARGTYPE "Win32 (WCE ARMV4I) Dynamic-Link Library" 0xa502
+
+CFG=_ctypes - Win32 (WCE ARMV4) Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "_ctypes.vcn".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "_ctypes.vcn" CFG="_ctypes - Win32 (WCE ARMV4) Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "_ctypes - Win32 (WCE ARMV4I) Release" (based on "Win32 (WCE ARMV4I) Dynamic-Link Library")
+!MESSAGE "_ctypes - Win32 (WCE ARMV4I) Debug" (based on "Win32 (WCE ARMV4I) Dynamic-Link Library")
+!MESSAGE "_ctypes - Win32 (WCE ARMV4) Release" (based on "Win32 (WCE ARMV4) Dynamic-Link Library")
+!MESSAGE "_ctypes - Win32 (WCE ARMV4) Debug" (based on "Win32 (WCE ARMV4) Dynamic-Link Library")
+!MESSAGE "_ctypes - Win32 (WCE ARMV4T) Release" (based on "Win32 (WCE ARMV4T) Dynamic-Link Library")
+!MESSAGE "_ctypes - Win32 (WCE ARMV4T) Debug" (based on "Win32 (WCE ARMV4T) Dynamic-Link Library")
+!MESSAGE "_ctypes - Win32 (WCE x86) Release" (based on "Win32 (WCE x86) Dynamic-Link Library")
+!MESSAGE "_ctypes - Win32 (WCE x86) Debug" (based on "Win32 (WCE x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+# PROP ATL_Project 2
+
+!IF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4I) Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "ARMV4IRel"
+# PROP BASE Intermediate_Dir "ARMV4IRel"
+# PROP BASE CPU_ID "{DC70F430-E78B-494F-A9D5-62ADC56443B8}"
+# PROP BASE Platform_ID "{8A9A2F80-6887-11D3-842E-005004848CBA}"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "ARMV4IRel"
+# PROP Intermediate_Dir "ARMV4IRel"
+# PROP CPU_ID "{DC70F430-E78B-494F-A9D5-62ADC56443B8}"
+# PROP Platform_ID "{8A9A2F80-6887-11D3-842E-005004848CBA}"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+RSC=rc.exe
+# ADD BASE RSC /l 0x409 /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "UNICODE" /d "_UNICODE" /d "NDEBUG" /d "$(CePlatform)" /d "THUMB" /d "_THUMB_" /d "ARM" /d "_ARM_" /d "ARMV4I" /r
+# ADD RSC /l 0x409 /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "UNICODE" /d "_UNICODE" /d "NDEBUG" /d "$(CePlatform)" /d "THUMB" /d "_THUMB_" /d "ARM" /d "_ARM_" /d "ARMV4I" /r
+CPP=clarm.exe
+# ADD BASE CPP /nologo /W3 /D _WIN32_WCE=$(CEVersion) /D "ARM" /D "_ARM_" /D "$(CePlatform)" /D "ARMV4I" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_UNICODE" /D "NDEBUG" /D "_USRDLL" /D "_CTYPES_EXPORTS" /YX /QRarch4T /QRinterwork-return /O2 /M$(CECrtMT) /c
+# ADD CPP /nologo /W3 /I "../source/libffi_arm_wince" /D _WIN32_WCE=$(CEVersion) /D "ARM" /D "_ARM_" /D "$(CePlatform)" /D "ARMV4I" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_UNICODE" /D "NDEBUG" /D "_USRDLL" /D "_CTYPES_EXPORTS" /QRarch4T /QRinterwork-return /O2 /M$(CECrtMT) /c
+# SUBTRACT CPP /YX
+MTL=midl.exe
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 commctrl.lib coredll.lib /nologo /base:"0x00100000" /stack:0x10000,0x1000 /entry:"_DllMainCRTStartup" /dll /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /MACHINE:THUMB
+# ADD LINK32 commctrl.lib coredll.lib uuid.lib ole32.lib oleaut32.lib /nologo /base:"0x00100000" /stack:0x10000,0x1000 /entry:"_DllMainCRTStartup" /dll /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /MACHINE:THUMB
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4I) Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "ARMV4IDbg"
+# PROP BASE Intermediate_Dir "ARMV4IDbg"
+# PROP BASE CPU_ID "{DC70F430-E78B-494F-A9D5-62ADC56443B8}"
+# PROP BASE Platform_ID "{8A9A2F80-6887-11D3-842E-005004848CBA}"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "ARMV4IDbg"
+# PROP Intermediate_Dir "ARMV4IDbg"
+# PROP CPU_ID "{DC70F430-E78B-494F-A9D5-62ADC56443B8}"
+# PROP Platform_ID "{8A9A2F80-6887-11D3-842E-005004848CBA}"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+RSC=rc.exe
+# ADD BASE RSC /l 0x409 /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "UNICODE" /d "_UNICODE" /d "DEBUG" /d "$(CePlatform)" /d "THUMB" /d "_THUMB_" /d "ARM" /d "_ARM_" /d "ARMV4I" /r
+# ADD RSC /l 0x409 /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "UNICODE" /d "_UNICODE" /d "DEBUG" /d "$(CePlatform)" /d "THUMB" /d "_THUMB_" /d "ARM" /d "_ARM_" /d "ARMV4I" /r
+CPP=clarm.exe
+# ADD BASE CPP /nologo /W3 /Zi /Od /D "DEBUG" /D _WIN32_WCE=$(CEVersion) /D "ARM" /D "_ARM_" /D "$(CePlatform)" /D "ARMV4I" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_UNICODE" /D "_USRDLL" /D "_CTYPES_EXPORTS" /YX /QRarch4T /QRinterwork-return /M$(CECrtMTDebug) /c
+# ADD CPP /nologo /W3 /Zi /Od /I "../source/libffi_arm_wince" /D "DEBUG" /D _WIN32_WCE=$(CEVersion) /D "ARM" /D "_ARM_" /D "$(CePlatform)" /D "ARMV4I" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_UNICODE" /D "_USRDLL" /D "_CTYPES_EXPORTS" /QRarch4T /QRinterwork-return /M$(CECrtMTDebug) /c
+# SUBTRACT CPP /YX
+MTL=midl.exe
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 commctrl.lib coredll.lib /nologo /base:"0x00100000" /stack:0x10000,0x1000 /entry:"_DllMainCRTStartup" /dll /debug /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /MACHINE:THUMB
+# ADD LINK32 commctrl.lib coredll.lib uuid.lib ole32.lib oleaut32.lib /nologo /base:"0x00100000" /stack:0x10000,0x1000 /entry:"_DllMainCRTStartup" /dll /debug /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /MACHINE:THUMB
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4) Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "ARMV4Rel"
+# PROP BASE Intermediate_Dir "ARMV4Rel"
+# PROP BASE CPU_ID "{ECBEA43D-CD7B-4852-AD55-D4227B5D624B}"
+# PROP BASE Platform_ID "{8A9A2F80-6887-11D3-842E-005004848CBA}"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "ARMV4Rel"
+# PROP Intermediate_Dir "ARMV4Rel"
+# PROP CPU_ID "{ECBEA43D-CD7B-4852-AD55-D4227B5D624B}"
+# PROP Platform_ID "{8A9A2F80-6887-11D3-842E-005004848CBA}"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+RSC=rc.exe
+# ADD BASE RSC /l 0x409 /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "NDEBUG" /d "UNICODE" /d "_UNICODE" /d "$(CePlatform)" /d "ARM" /d "_ARM_" /d "ARMV4" /r
+# ADD RSC /l 0x409 /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "NDEBUG" /d "UNICODE" /d "_UNICODE" /d "$(CePlatform)" /d "ARM" /d "_ARM_" /d "ARMV4" /r
+CPP=clarm.exe
+# ADD BASE CPP /nologo /W3 /D _WIN32_WCE=$(CEVersion) /D "$(CePlatform)" /D "ARM" /D "_ARM_" /D "ARMV4" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_UNICODE" /D "NDEBUG" /D "_USRDLL" /D "_CTYPES_EXPORTS" /YX /O2 /M$(CECrtMT) /c
+# ADD CPP /nologo /W3 /I "../source/libffi_arm_wince" /D _WIN32_WCE=$(CEVersion) /D "$(CePlatform)" /D "ARM" /D "_ARM_" /D "ARMV4" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_UNICODE" /D "NDEBUG" /D "_USRDLL" /D "_CTYPES_EXPORTS" /FAcs /O2 /M$(CECrtMT) /c
+# SUBTRACT CPP /YX
+MTL=midl.exe
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 commctrl.lib coredll.lib /nologo /base:"0x00100000" /stack:0x10000,0x1000 /entry:"_DllMainCRTStartup" /dll /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /align:"4096" /MACHINE:ARM
+# ADD LINK32 uuid.lib ole32.lib commctrl.lib coredll.lib oleaut32.lib /nologo /base:"0x00100000" /stack:0x10000,0x1000 /entry:"_DllMainCRTStartup" /dll /nodefaultlib:"$(CENoDefaultLib)" /out:"ARMV4Rel/_ctypes.pyd" /subsystem:$(CESubsystem) /align:"4096" /MACHINE:ARM
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4) Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "ARMV4Dbg"
+# PROP BASE Intermediate_Dir "ARMV4Dbg"
+# PROP BASE CPU_ID "{ECBEA43D-CD7B-4852-AD55-D4227B5D624B}"
+# PROP BASE Platform_ID "{8A9A2F80-6887-11D3-842E-005004848CBA}"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "ARMV4Dbg"
+# PROP Intermediate_Dir "ARMV4Dbg"
+# PROP CPU_ID "{ECBEA43D-CD7B-4852-AD55-D4227B5D624B}"
+# PROP Platform_ID "{8A9A2F80-6887-11D3-842E-005004848CBA}"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+RSC=rc.exe
+# ADD BASE RSC /l 0x409 /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "DEBUG" /d "UNICODE" /d "_UNICODE" /d "$(CePlatform)" /d "ARM" /d "_ARM_" /d "ARMV4" /r
+# ADD RSC /l 0x409 /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "DEBUG" /d "UNICODE" /d "_UNICODE" /d "$(CePlatform)" /d "ARM" /d "_ARM_" /d "ARMV4" /r
+CPP=clarm.exe
+# ADD BASE CPP /nologo /W3 /Zi /Od /D "DEBUG" /D _WIN32_WCE=$(CEVersion) /D "$(CePlatform)" /D "ARM" /D "_ARM_" /D "ARMV4" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_UNICODE" /D "_USRDLL" /D "_CTYPES_EXPORTS" /YX /M$(CECrtMTDebug) /c
+# ADD CPP /nologo /W3 /WX /Zi /Od /I "../source/libffi_arm_wince" /D "DEBUG" /D _WIN32_WCE=$(CEVersion) /D "$(CePlatform)" /D "ARM" /D "_ARM_" /D "ARMV4" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_UNICODE" /D "_USRDLL" /D "_CTYPES_EXPORTS" /FAs /M$(CECrtMTDebug) /c
+# SUBTRACT CPP /YX
+MTL=midl.exe
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 commctrl.lib coredll.lib /nologo /base:"0x00100000" /stack:0x10000,0x1000 /entry:"_DllMainCRTStartup" /dll /debug /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /align:"4096" /MACHINE:ARM
+# ADD LINK32 commctrl.lib coredll.lib uuid.lib ole32.lib oleaut32.lib /nologo /base:"0x00100000" /stack:0x10000,0x1000 /entry:"_DllMainCRTStartup" /dll /debug /nodefaultlib:"$(CENoDefaultLib)" /out:"ARMV4Dbg/_ctypes.pyd" /subsystem:$(CESubsystem) /align:"4096" /MACHINE:ARM
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4T) Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "ARMV4TRel"
+# PROP BASE Intermediate_Dir "ARMV4TRel"
+# PROP BASE CPU_ID "{F52316A9-3B7C-4FE7-A67F-68350B41240D}"
+# PROP BASE Platform_ID "{8A9A2F80-6887-11D3-842E-005004848CBA}"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "ARMV4TRel"
+# PROP Intermediate_Dir "ARMV4TRel"
+# PROP CPU_ID "{F52316A9-3B7C-4FE7-A67F-68350B41240D}"
+# PROP Platform_ID "{8A9A2F80-6887-11D3-842E-005004848CBA}"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+RSC=rc.exe
+# ADD BASE RSC /l 0x409 /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "UNICODE" /d "_UNICODE" /d "NDEBUG" /d "$(CePlatform)" /d "THUMB" /d "_THUMB_" /d "ARM" /d "_ARM_" /d "ARMV4T" /r
+# ADD RSC /l 0x409 /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "UNICODE" /d "_UNICODE" /d "NDEBUG" /d "$(CePlatform)" /d "THUMB" /d "_THUMB_" /d "ARM" /d "_ARM_" /d "ARMV4T" /r
+CPP=clthumb.exe
+# ADD BASE CPP /nologo /W3 /D _WIN32_WCE=$(CEVersion) /D "ARM" /D "_ARM_" /D "$(CePlatform)" /D "THUMB" /D "_THUMB_" /D "ARMV4T" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_UNICODE" /D "NDEBUG" /D "_USRDLL" /D "_CTYPES_EXPORTS" /YX /QRarch4T /QRinterwork-return /O2 /M$(CECrtMT) /c
+# ADD CPP /nologo /W3 /I "../source/libffi_arm_wince" /D _WIN32_WCE=$(CEVersion) /D "ARM" /D "_ARM_" /D "$(CePlatform)" /D "THUMB" /D "_THUMB_" /D "ARMV4T" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_UNICODE" /D "NDEBUG" /D "_USRDLL" /D "_CTYPES_EXPORTS" /QRarch4T /QRinterwork-return /O2 /M$(CECrtMT) /c
+# SUBTRACT CPP /YX
+MTL=midl.exe
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 commctrl.lib coredll.lib /nologo /base:"0x00100000" /stack:0x10000,0x1000 /entry:"_DllMainCRTStartup" /dll /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /MACHINE:THUMB
+# ADD LINK32 commctrl.lib coredll.lib uuid.lib ole32.lib oleaut32.lib /nologo /base:"0x00100000" /stack:0x10000,0x1000 /entry:"_DllMainCRTStartup" /dll /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /MACHINE:THUMB
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4T) Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "ARMV4TDbg"
+# PROP BASE Intermediate_Dir "ARMV4TDbg"
+# PROP BASE CPU_ID "{F52316A9-3B7C-4FE7-A67F-68350B41240D}"
+# PROP BASE Platform_ID "{8A9A2F80-6887-11D3-842E-005004848CBA}"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "ARMV4TDbg"
+# PROP Intermediate_Dir "ARMV4TDbg"
+# PROP CPU_ID "{F52316A9-3B7C-4FE7-A67F-68350B41240D}"
+# PROP Platform_ID "{8A9A2F80-6887-11D3-842E-005004848CBA}"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+RSC=rc.exe
+# ADD BASE RSC /l 0x409 /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "UNICODE" /d "_UNICODE" /d "DEBUG" /d "$(CePlatform)" /d "THUMB" /d "_THUMB_" /d "ARM" /d "_ARM_" /d "ARMV4T" /r
+# ADD RSC /l 0x409 /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "UNICODE" /d "_UNICODE" /d "DEBUG" /d "$(CePlatform)" /d "THUMB" /d "_THUMB_" /d "ARM" /d "_ARM_" /d "ARMV4T" /r
+CPP=clthumb.exe
+# ADD BASE CPP /nologo /W3 /Zi /Od /D "DEBUG" /D _WIN32_WCE=$(CEVersion) /D "ARM" /D "_ARM_" /D "$(CePlatform)" /D "THUMB" /D "_THUMB_" /D "ARMV4T" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_UNICODE" /D "_USRDLL" /D "_CTYPES_EXPORTS" /YX /QRarch4T /QRinterwork-return /M$(CECrtMTDebug) /c
+# ADD CPP /nologo /W3 /Zi /Od /I "../source/libffi_arm_wince" /D "DEBUG" /D _WIN32_WCE=$(CEVersion) /D "ARM" /D "_ARM_" /D "$(CePlatform)" /D "THUMB" /D "_THUMB_" /D "ARMV4T" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_UNICODE" /D "_USRDLL" /D "_CTYPES_EXPORTS" /QRarch4T /QRinterwork-return /M$(CECrtMTDebug) /c
+# SUBTRACT CPP /YX
+MTL=midl.exe
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 commctrl.lib coredll.lib /nologo /base:"0x00100000" /stack:0x10000,0x1000 /entry:"_DllMainCRTStartup" /dll /debug /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /MACHINE:THUMB
+# ADD LINK32 commctrl.lib coredll.lib uuid.lib ole32.lib oleaut32.lib /nologo /base:"0x00100000" /stack:0x10000,0x1000 /entry:"_DllMainCRTStartup" /dll /debug /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /MACHINE:THUMB
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE x86) Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "X86Rel"
+# PROP BASE Intermediate_Dir "X86Rel"
+# PROP BASE CPU_ID "{D6518FF3-710F-11D3-99F2-00105A0DF099}"
+# PROP BASE Platform_ID "{8A9A2F80-6887-11D3-842E-005004848CBA}"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "X86Rel"
+# PROP Intermediate_Dir "X86Rel"
+# PROP CPU_ID "{D6518FF3-710F-11D3-99F2-00105A0DF099}"
+# PROP Platform_ID "{8A9A2F80-6887-11D3-842E-005004848CBA}"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+RSC=rc.exe
+# ADD BASE RSC /l 0x409 /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "UNICODE" /d "_UNICODE" /d "NDEBUG" /d "$(CePlatform)" /d "_X86_" /d "x86" /d "_i386_" /r
+# ADD RSC /l 0x409 /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "UNICODE" /d "_UNICODE" /d "NDEBUG" /d "$(CePlatform)" /d "_X86_" /d "x86" /d "_i386_" /r
+CPP=cl.exe
+# ADD BASE CPP /nologo /W3 /D _WIN32_WCE=$(CEVersion) /D "$(CePlatform)" /D "_i386_" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_UNICODE" /D "_X86_" /D "x86" /D "NDEBUG" /D "_USRDLL" /D "_CTYPES_EXPORTS" /YX /Gs8192 /GF /O2 /c
+# ADD CPP /nologo /W3 /I "../source/libffi_arm_wince" /D _WIN32_WCE=$(CEVersion) /D "$(CePlatform)" /D "_i386_" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_UNICODE" /D "_X86_" /D "x86" /D "NDEBUG" /D "_USRDLL" /D "_CTYPES_EXPORTS" /Gs8192 /GF /O2 /c
+# SUBTRACT CPP /YX
+MTL=midl.exe
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 commctrl.lib coredll.lib $(CEx86Corelibc) /nologo /base:"0x00100000" /stack:0x10000,0x1000 /entry:"_DllMainCRTStartup" /dll /nodefaultlib:"OLDNAMES.lib" /nodefaultlib:$(CENoDefaultLib) /subsystem:$(CESubsystem) /MACHINE:IX86
+# ADD LINK32 $(CEx86Corelibc) commctrl.lib coredll.lib uuid.lib ole32.lib oleaut32.lib /nologo /base:"0x00100000" /stack:0x10000,0x1000 /entry:"_DllMainCRTStartup" /dll /nodefaultlib:"OLDNAMES.lib" /nodefaultlib:$(CENoDefaultLib) /subsystem:$(CESubsystem) /MACHINE:IX86
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE x86) Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "X86Dbg"
+# PROP BASE Intermediate_Dir "X86Dbg"
+# PROP BASE CPU_ID "{D6518FF3-710F-11D3-99F2-00105A0DF099}"
+# PROP BASE Platform_ID "{8A9A2F80-6887-11D3-842E-005004848CBA}"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "X86Dbg"
+# PROP Intermediate_Dir "X86Dbg"
+# PROP CPU_ID "{D6518FF3-710F-11D3-99F2-00105A0DF099}"
+# PROP Platform_ID "{8A9A2F80-6887-11D3-842E-005004848CBA}"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+RSC=rc.exe
+# ADD BASE RSC /l 0x409 /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "UNICODE" /d "_UNICODE" /d "DEBUG" /d "$(CePlatform)" /d "_X86_" /d "x86" /d "_i386_" /r
+# ADD RSC /l 0x409 /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "UNICODE" /d "_UNICODE" /d "DEBUG" /d "$(CePlatform)" /d "_X86_" /d "x86" /d "_i386_" /r
+CPP=cl.exe
+# ADD BASE CPP /nologo /W3 /Zi /Od /D "DEBUG" /D _WIN32_WCE=$(CEVersion) /D "$(CePlatform)" /D "_i386_" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_UNICODE" /D "_X86_" /D "x86" /D "_USRDLL" /D "_CTYPES_EXPORTS" /YX /Gs8192 /GF /c
+# ADD CPP /nologo /W3 /Zi /Od /I "../source/libffi_arm_wince" /D "DEBUG" /D _WIN32_WCE=$(CEVersion) /D "$(CePlatform)" /D "_i386_" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_UNICODE" /D "_X86_" /D "x86" /D "_USRDLL" /D "_CTYPES_EXPORTS" /Gs8192 /GF /c
+# SUBTRACT CPP /YX
+MTL=midl.exe
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 commctrl.lib coredll.lib $(CEx86Corelibc) /nologo /base:"0x00100000" /stack:0x10000,0x1000 /entry:"_DllMainCRTStartup" /dll /debug /nodefaultlib:"OLDNAMES.lib" /nodefaultlib:$(CENoDefaultLib) /subsystem:$(CESubsystem) /MACHINE:IX86
+# ADD LINK32 $(CEx86Corelibc) commctrl.lib coredll.lib uuid.lib ole32.lib oleaut32.lib /nologo /base:"0x00100000" /stack:0x10000,0x1000 /entry:"_DllMainCRTStartup" /dll /debug /nodefaultlib:"OLDNAMES.lib" /nodefaultlib:$(CENoDefaultLib) /subsystem:$(CESubsystem) /MACHINE:IX86
+
+!ENDIF
+
+# Begin Target
+
+# Name "_ctypes - Win32 (WCE ARMV4I) Release"
+# Name "_ctypes - Win32 (WCE ARMV4I) Debug"
+# Name "_ctypes - Win32 (WCE ARMV4) Release"
+# Name "_ctypes - Win32 (WCE ARMV4) Debug"
+# Name "_ctypes - Win32 (WCE ARMV4T) Release"
+# Name "_ctypes - Win32 (WCE ARMV4T) Debug"
+# Name "_ctypes - Win32 (WCE x86) Release"
+# Name "_ctypes - Win32 (WCE x86) Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\source\_ctypes.c
+
+!IF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4I) Release"
+
+DEP_CPP__CTYP=\
+ "..\source\ctypes.h"\
+ "..\source\libffi_msvc\ffi.h"\
+ "..\source\libffi_msvc\ffitarget.h"\
+
+NODEP_CPP__CTYP=\
+ "..\source\Python.h"\
+ "..\source\structmember.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4I) Debug"
+
+DEP_CPP__CTYP=\
+ "..\source\ctypes.h"\
+ "..\source\libffi_msvc\ffi.h"\
+ "..\source\libffi_msvc\ffitarget.h"\
+
+NODEP_CPP__CTYP=\
+ "..\source\Python.h"\
+ "..\source\structmember.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4) Release"
+
+DEP_CPP__CTYP=\
+ "..\source\ctypes.h"\
+ "..\source\libffi_arm_wince\ffi.h"\
+ "..\source\libffi_arm_wince\ffitarget.h"\
+ {$(INCLUDE)}"abstract.h"\
+ {$(INCLUDE)}"basetsd.h"\
+ {$(INCLUDE)}"boolobject.h"\
+ {$(INCLUDE)}"bufferobject.h"\
+ {$(INCLUDE)}"cellobject.h"\
+ {$(INCLUDE)}"ceval.h"\
+ {$(INCLUDE)}"classobject.h"\
+ {$(INCLUDE)}"cobject.h"\
+ {$(INCLUDE)}"complexobject.h"\
+ {$(INCLUDE)}"descrobject.h"\
+ {$(INCLUDE)}"dictobject.h"\
+ {$(INCLUDE)}"enumobject.h"\
+ {$(INCLUDE)}"fileobject.h"\
+ {$(INCLUDE)}"floatobject.h"\
+ {$(INCLUDE)}"funcobject.h"\
+ {$(INCLUDE)}"import.h"\
+ {$(INCLUDE)}"intobject.h"\
+ {$(INCLUDE)}"intrcheck.h"\
+ {$(INCLUDE)}"iterobject.h"\
+ {$(INCLUDE)}"listobject.h"\
+ {$(INCLUDE)}"longobject.h"\
+ {$(INCLUDE)}"methodobject.h"\
+ {$(INCLUDE)}"modsupport.h"\
+ {$(INCLUDE)}"moduleobject.h"\
+ {$(INCLUDE)}"object.h"\
+ {$(INCLUDE)}"objimpl.h"\
+ {$(INCLUDE)}"patchlevel.h"\
+ {$(INCLUDE)}"pyconfig.h"\
+ {$(INCLUDE)}"pydebug.h"\
+ {$(INCLUDE)}"pyerrors.h"\
+ {$(INCLUDE)}"pyfpe.h"\
+ {$(INCLUDE)}"pymem.h"\
+ {$(INCLUDE)}"pyport.h"\
+ {$(INCLUDE)}"pystate.h"\
+ {$(INCLUDE)}"Python.h"\
+ {$(INCLUDE)}"pythonrun.h"\
+ {$(INCLUDE)}"rangeobject.h"\
+ {$(INCLUDE)}"sliceobject.h"\
+ {$(INCLUDE)}"stringobject.h"\
+ {$(INCLUDE)}"structmember.h"\
+ {$(INCLUDE)}"sysmodule.h"\
+ {$(INCLUDE)}"traceback.h"\
+ {$(INCLUDE)}"tupleobject.h"\
+ {$(INCLUDE)}"unicodeobject.h"\
+ {$(INCLUDE)}"weakrefobject.h"\
+ {$(INCLUDE)}"wince-compatibility.h"\
+
+NODEP_CPP__CTYP=\
+ "..\..\..\PYTHON-2.3.5-WINCE\INCLUDE\unixstuff.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4) Debug"
+
+DEP_CPP__CTYP=\
+ "..\source\ctypes.h"\
+
+NODEP_CPP__CTYP=\
+ "..\..\..\WINCE\PYTHON-2.3.4-WINCE\INCLUDE\unixstuff.h"\
+ "..\source\libffi_arm_wince\ffi.h"\
+ "..\source\libffi_arm_wince\ffitarget.h"\
+ ".\angeobject.h"\
+ ".\asetsd.h"\
+ ".\atchlevel.h"\
+ ".\bject.h"\
+ ".\bjimpl.h"\
+ ".\bstract.h"\
+ ".\eakrefobject.h"\
+ ".\ellobject.h"\
+ ".\escrobject.h"\
+ ".\ethodobject.h"\
+ ".\ictobject.h"\
+ ".\ileobject.h"\
+ ".\ince-compatibility.h"\
+ ".\istobject.h"\
+ ".\lassobject.h"\
+ ".\liceobject.h"\
+ ".\loatobject.h"\
+ ".\mport.h"\
+ ".\nicodeobject.h"\
+ ".\ntobject.h"\
+ ".\ntrcheck.h"\
+ ".\numobject.h"\
+ ".\odsupport.h"\
+ ".\oduleobject.h"\
+ ".\omplexobject.h"\
+ ".\ongobject.h"\
+ ".\oolobject.h"\
+ ".\raceback.h"\
+ ".\terobject.h"\
+ ".\tringobject.h"\
+ ".\tructmember.h"\
+ ".\ufferobject.h"\
+ ".\uncobject.h"\
+ ".\upleobject.h"\
+ ".\val.h"\
+ ".\yconfig.h"\
+ ".\ydebug.h"\
+ ".\yerrors.h"\
+ ".\yfpe.h"\
+ ".\ymem.h"\
+ ".\yport.h"\
+ ".\ysmodule.h"\
+ ".\ystate.h"\
+ ".\ython.h"\
+ ".\ythonrun.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4T) Release"
+
+DEP_CPP__CTYP=\
+ "..\source\ctypes.h"\
+ "..\source\libffi_msvc\ffi.h"\
+ "..\source\libffi_msvc\ffitarget.h"\
+
+NODEP_CPP__CTYP=\
+ "..\source\Python.h"\
+ "..\source\structmember.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4T) Debug"
+
+DEP_CPP__CTYP=\
+ "..\source\ctypes.h"\
+ "..\source\libffi_msvc\ffi.h"\
+ "..\source\libffi_msvc\ffitarget.h"\
+
+NODEP_CPP__CTYP=\
+ "..\source\Python.h"\
+ "..\source\structmember.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE x86) Release"
+
+DEP_CPP__CTYP=\
+ "..\source\ctypes.h"\
+ "..\source\libffi_msvc\ffi.h"\
+ "..\source\libffi_msvc\ffitarget.h"\
+
+NODEP_CPP__CTYP=\
+ "..\source\Python.h"\
+ "..\source\structmember.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE x86) Debug"
+
+DEP_CPP__CTYP=\
+ "..\source\ctypes.h"\
+ "..\source\libffi_msvc\ffi.h"\
+ "..\source\libffi_msvc\ffitarget.h"\
+
+NODEP_CPP__CTYP=\
+ "..\source\Python.h"\
+ "..\source\structmember.h"\
+
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\source\callbacks.c
+
+!IF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4I) Release"
+
+DEP_CPP_CALLB=\
+ "..\source\ctypes.h"\
+ "..\source\libffi_msvc\ffi.h"\
+ "..\source\libffi_msvc\ffitarget.h"\
+
+NODEP_CPP_CALLB=\
+ "..\source\compile.h"\
+ "..\source\frameobject.h"\
+ "..\source\Python.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4I) Debug"
+
+DEP_CPP_CALLB=\
+ "..\source\ctypes.h"\
+ "..\source\libffi_msvc\ffi.h"\
+ "..\source\libffi_msvc\ffitarget.h"\
+
+NODEP_CPP_CALLB=\
+ "..\source\compile.h"\
+ "..\source\frameobject.h"\
+ "..\source\Python.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4) Release"
+
+DEP_CPP_CALLB=\
+ "..\source\ctypes.h"\
+ "..\source\libffi_arm_wince\ffi.h"\
+ "..\source\libffi_arm_wince\ffitarget.h"\
+ {$(INCLUDE)}"abstract.h"\
+ {$(INCLUDE)}"basetsd.h"\
+ {$(INCLUDE)}"boolobject.h"\
+ {$(INCLUDE)}"bufferobject.h"\
+ {$(INCLUDE)}"cellobject.h"\
+ {$(INCLUDE)}"ceval.h"\
+ {$(INCLUDE)}"classobject.h"\
+ {$(INCLUDE)}"cobject.h"\
+ {$(INCLUDE)}"compile.h"\
+ {$(INCLUDE)}"complexobject.h"\
+ {$(INCLUDE)}"descrobject.h"\
+ {$(INCLUDE)}"dictobject.h"\
+ {$(INCLUDE)}"enumobject.h"\
+ {$(INCLUDE)}"fileobject.h"\
+ {$(INCLUDE)}"floatobject.h"\
+ {$(INCLUDE)}"frameobject.h"\
+ {$(INCLUDE)}"funcobject.h"\
+ {$(INCLUDE)}"import.h"\
+ {$(INCLUDE)}"intobject.h"\
+ {$(INCLUDE)}"intrcheck.h"\
+ {$(INCLUDE)}"iterobject.h"\
+ {$(INCLUDE)}"listobject.h"\
+ {$(INCLUDE)}"longobject.h"\
+ {$(INCLUDE)}"methodobject.h"\
+ {$(INCLUDE)}"modsupport.h"\
+ {$(INCLUDE)}"moduleobject.h"\
+ {$(INCLUDE)}"object.h"\
+ {$(INCLUDE)}"objimpl.h"\
+ {$(INCLUDE)}"patchlevel.h"\
+ {$(INCLUDE)}"pyconfig.h"\
+ {$(INCLUDE)}"pydebug.h"\
+ {$(INCLUDE)}"pyerrors.h"\
+ {$(INCLUDE)}"pyfpe.h"\
+ {$(INCLUDE)}"pymem.h"\
+ {$(INCLUDE)}"pyport.h"\
+ {$(INCLUDE)}"pystate.h"\
+ {$(INCLUDE)}"Python.h"\
+ {$(INCLUDE)}"pythonrun.h"\
+ {$(INCLUDE)}"rangeobject.h"\
+ {$(INCLUDE)}"sliceobject.h"\
+ {$(INCLUDE)}"stringobject.h"\
+ {$(INCLUDE)}"sysmodule.h"\
+ {$(INCLUDE)}"traceback.h"\
+ {$(INCLUDE)}"tupleobject.h"\
+ {$(INCLUDE)}"unicodeobject.h"\
+ {$(INCLUDE)}"weakrefobject.h"\
+ {$(INCLUDE)}"wince-compatibility.h"\
+
+NODEP_CPP_CALLB=\
+ "..\..\..\PYTHON-2.3.5-WINCE\INCLUDE\unixstuff.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4) Debug"
+
+DEP_CPP_CALLB=\
+ "..\source\ctypes.h"\
+
+NODEP_CPP_CALLB=\
+ "..\..\..\WINCE\PYTHON-2.3.4-WINCE\INCLUDE\unixstuff.h"\
+ "..\source\libffi_arm_wince\ffi.h"\
+ "..\source\libffi_arm_wince\ffitarget.h"\
+ ".\angeobject.h"\
+ ".\asetsd.h"\
+ ".\atchlevel.h"\
+ ".\bject.h"\
+ ".\bjimpl.h"\
+ ".\bstract.h"\
+ ".\eakrefobject.h"\
+ ".\ellobject.h"\
+ ".\escrobject.h"\
+ ".\ethodobject.h"\
+ ".\ictobject.h"\
+ ".\ileobject.h"\
+ ".\ince-compatibility.h"\
+ ".\istobject.h"\
+ ".\lassobject.h"\
+ ".\liceobject.h"\
+ ".\loatobject.h"\
+ ".\mport.h"\
+ ".\nicodeobject.h"\
+ ".\ntobject.h"\
+ ".\ntrcheck.h"\
+ ".\numobject.h"\
+ ".\odsupport.h"\
+ ".\oduleobject.h"\
+ ".\ompile.h"\
+ ".\omplexobject.h"\
+ ".\ongobject.h"\
+ ".\oolobject.h"\
+ ".\raceback.h"\
+ ".\rameobject.h"\
+ ".\terobject.h"\
+ ".\tringobject.h"\
+ ".\ufferobject.h"\
+ ".\uncobject.h"\
+ ".\upleobject.h"\
+ ".\val.h"\
+ ".\yconfig.h"\
+ ".\ydebug.h"\
+ ".\yerrors.h"\
+ ".\yfpe.h"\
+ ".\ymem.h"\
+ ".\yport.h"\
+ ".\ysmodule.h"\
+ ".\ystate.h"\
+ ".\ython.h"\
+ ".\ythonrun.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4T) Release"
+
+DEP_CPP_CALLB=\
+ "..\source\ctypes.h"\
+ "..\source\libffi_msvc\ffi.h"\
+ "..\source\libffi_msvc\ffitarget.h"\
+
+NODEP_CPP_CALLB=\
+ "..\source\compile.h"\
+ "..\source\frameobject.h"\
+ "..\source\Python.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4T) Debug"
+
+DEP_CPP_CALLB=\
+ "..\source\ctypes.h"\
+ "..\source\libffi_msvc\ffi.h"\
+ "..\source\libffi_msvc\ffitarget.h"\
+
+NODEP_CPP_CALLB=\
+ "..\source\compile.h"\
+ "..\source\frameobject.h"\
+ "..\source\Python.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE x86) Release"
+
+DEP_CPP_CALLB=\
+ "..\source\ctypes.h"\
+ "..\source\libffi_msvc\ffi.h"\
+ "..\source\libffi_msvc\ffitarget.h"\
+
+NODEP_CPP_CALLB=\
+ "..\source\compile.h"\
+ "..\source\frameobject.h"\
+ "..\source\Python.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE x86) Debug"
+
+DEP_CPP_CALLB=\
+ "..\source\ctypes.h"\
+ "..\source\libffi_msvc\ffi.h"\
+ "..\source\libffi_msvc\ffitarget.h"\
+
+NODEP_CPP_CALLB=\
+ "..\source\compile.h"\
+ "..\source\frameobject.h"\
+ "..\source\Python.h"\
+
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\source\callproc.c
+
+!IF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4I) Release"
+
+DEP_CPP_CALLP=\
+ "..\source\ctypes.h"\
+ "..\source\libffi_msvc\ffi.h"\
+ "..\source\libffi_msvc\ffitarget.h"\
+
+NODEP_CPP_CALLP=\
+ "..\source\Python.h"\
+ "..\source\structmember.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4I) Debug"
+
+DEP_CPP_CALLP=\
+ "..\source\ctypes.h"\
+ "..\source\libffi_msvc\ffi.h"\
+ "..\source\libffi_msvc\ffitarget.h"\
+
+NODEP_CPP_CALLP=\
+ "..\source\Python.h"\
+ "..\source\structmember.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4) Release"
+
+DEP_CPP_CALLP=\
+ "..\source\ctypes.h"\
+ "..\source\libffi_arm_wince\ffi.h"\
+ "..\source\libffi_arm_wince\ffitarget.h"\
+ {$(INCLUDE)}"abstract.h"\
+ {$(INCLUDE)}"basetsd.h"\
+ {$(INCLUDE)}"boolobject.h"\
+ {$(INCLUDE)}"bufferobject.h"\
+ {$(INCLUDE)}"cellobject.h"\
+ {$(INCLUDE)}"ceval.h"\
+ {$(INCLUDE)}"classobject.h"\
+ {$(INCLUDE)}"cobject.h"\
+ {$(INCLUDE)}"complexobject.h"\
+ {$(INCLUDE)}"descrobject.h"\
+ {$(INCLUDE)}"dictobject.h"\
+ {$(INCLUDE)}"enumobject.h"\
+ {$(INCLUDE)}"fileobject.h"\
+ {$(INCLUDE)}"floatobject.h"\
+ {$(INCLUDE)}"funcobject.h"\
+ {$(INCLUDE)}"import.h"\
+ {$(INCLUDE)}"intobject.h"\
+ {$(INCLUDE)}"intrcheck.h"\
+ {$(INCLUDE)}"iterobject.h"\
+ {$(INCLUDE)}"listobject.h"\
+ {$(INCLUDE)}"longobject.h"\
+ {$(INCLUDE)}"methodobject.h"\
+ {$(INCLUDE)}"modsupport.h"\
+ {$(INCLUDE)}"moduleobject.h"\
+ {$(INCLUDE)}"object.h"\
+ {$(INCLUDE)}"objimpl.h"\
+ {$(INCLUDE)}"patchlevel.h"\
+ {$(INCLUDE)}"pyconfig.h"\
+ {$(INCLUDE)}"pydebug.h"\
+ {$(INCLUDE)}"pyerrors.h"\
+ {$(INCLUDE)}"pyfpe.h"\
+ {$(INCLUDE)}"pymem.h"\
+ {$(INCLUDE)}"pyport.h"\
+ {$(INCLUDE)}"pystate.h"\
+ {$(INCLUDE)}"Python.h"\
+ {$(INCLUDE)}"pythonrun.h"\
+ {$(INCLUDE)}"rangeobject.h"\
+ {$(INCLUDE)}"sliceobject.h"\
+ {$(INCLUDE)}"stringobject.h"\
+ {$(INCLUDE)}"structmember.h"\
+ {$(INCLUDE)}"sysmodule.h"\
+ {$(INCLUDE)}"traceback.h"\
+ {$(INCLUDE)}"tupleobject.h"\
+ {$(INCLUDE)}"unicodeobject.h"\
+ {$(INCLUDE)}"weakrefobject.h"\
+ {$(INCLUDE)}"wince-compatibility.h"\
+
+NODEP_CPP_CALLP=\
+ "..\..\..\PYTHON-2.3.5-WINCE\INCLUDE\unixstuff.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4) Debug"
+
+DEP_CPP_CALLP=\
+ "..\source\ctypes.h"\
+
+NODEP_CPP_CALLP=\
+ "..\..\..\WINCE\PYTHON-2.3.4-WINCE\INCLUDE\unixstuff.h"\
+ "..\source\libffi_arm_wince\ffi.h"\
+ "..\source\libffi_arm_wince\ffitarget.h"\
+ ".\angeobject.h"\
+ ".\asetsd.h"\
+ ".\atchlevel.h"\
+ ".\bject.h"\
+ ".\bjimpl.h"\
+ ".\bstract.h"\
+ ".\eakrefobject.h"\
+ ".\ellobject.h"\
+ ".\escrobject.h"\
+ ".\ethodobject.h"\
+ ".\ictobject.h"\
+ ".\ileobject.h"\
+ ".\ince-compatibility.h"\
+ ".\istobject.h"\
+ ".\lassobject.h"\
+ ".\liceobject.h"\
+ ".\loatobject.h"\
+ ".\mport.h"\
+ ".\nicodeobject.h"\
+ ".\ntobject.h"\
+ ".\ntrcheck.h"\
+ ".\numobject.h"\
+ ".\odsupport.h"\
+ ".\oduleobject.h"\
+ ".\omplexobject.h"\
+ ".\ongobject.h"\
+ ".\oolobject.h"\
+ ".\raceback.h"\
+ ".\terobject.h"\
+ ".\tringobject.h"\
+ ".\tructmember.h"\
+ ".\ufferobject.h"\
+ ".\uncobject.h"\
+ ".\upleobject.h"\
+ ".\val.h"\
+ ".\yconfig.h"\
+ ".\ydebug.h"\
+ ".\yerrors.h"\
+ ".\yfpe.h"\
+ ".\ymem.h"\
+ ".\yport.h"\
+ ".\ysmodule.h"\
+ ".\ystate.h"\
+ ".\ython.h"\
+ ".\ythonrun.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4T) Release"
+
+DEP_CPP_CALLP=\
+ "..\source\ctypes.h"\
+ "..\source\libffi_msvc\ffi.h"\
+ "..\source\libffi_msvc\ffitarget.h"\
+
+NODEP_CPP_CALLP=\
+ "..\source\Python.h"\
+ "..\source\structmember.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4T) Debug"
+
+DEP_CPP_CALLP=\
+ "..\source\ctypes.h"\
+ "..\source\libffi_msvc\ffi.h"\
+ "..\source\libffi_msvc\ffitarget.h"\
+
+NODEP_CPP_CALLP=\
+ "..\source\Python.h"\
+ "..\source\structmember.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE x86) Release"
+
+DEP_CPP_CALLP=\
+ "..\source\ctypes.h"\
+ "..\source\libffi_msvc\ffi.h"\
+ "..\source\libffi_msvc\ffitarget.h"\
+
+NODEP_CPP_CALLP=\
+ "..\source\Python.h"\
+ "..\source\structmember.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE x86) Debug"
+
+DEP_CPP_CALLP=\
+ "..\source\ctypes.h"\
+ "..\source\libffi_msvc\ffi.h"\
+ "..\source\libffi_msvc\ffitarget.h"\
+
+NODEP_CPP_CALLP=\
+ "..\source\Python.h"\
+ "..\source\structmember.h"\
+
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\source\cfield.c
+
+!IF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4I) Release"
+
+DEP_CPP_CFIEL=\
+ "..\source\ctypes.h"\
+ "..\source\libffi_msvc\ffi.h"\
+ "..\source\libffi_msvc\ffitarget.h"\
+
+NODEP_CPP_CFIEL=\
+ "..\source\Python.h"\
+ "..\source\structmember.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4I) Debug"
+
+DEP_CPP_CFIEL=\
+ "..\source\ctypes.h"\
+ "..\source\libffi_msvc\ffi.h"\
+ "..\source\libffi_msvc\ffitarget.h"\
+
+NODEP_CPP_CFIEL=\
+ "..\source\Python.h"\
+ "..\source\structmember.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4) Release"
+
+DEP_CPP_CFIEL=\
+ "..\source\ctypes.h"\
+ "..\source\libffi_arm_wince\ffi.h"\
+ "..\source\libffi_arm_wince\ffitarget.h"\
+ {$(INCLUDE)}"abstract.h"\
+ {$(INCLUDE)}"basetsd.h"\
+ {$(INCLUDE)}"boolobject.h"\
+ {$(INCLUDE)}"bufferobject.h"\
+ {$(INCLUDE)}"cellobject.h"\
+ {$(INCLUDE)}"ceval.h"\
+ {$(INCLUDE)}"classobject.h"\
+ {$(INCLUDE)}"cobject.h"\
+ {$(INCLUDE)}"complexobject.h"\
+ {$(INCLUDE)}"descrobject.h"\
+ {$(INCLUDE)}"dictobject.h"\
+ {$(INCLUDE)}"enumobject.h"\
+ {$(INCLUDE)}"fileobject.h"\
+ {$(INCLUDE)}"floatobject.h"\
+ {$(INCLUDE)}"funcobject.h"\
+ {$(INCLUDE)}"import.h"\
+ {$(INCLUDE)}"intobject.h"\
+ {$(INCLUDE)}"intrcheck.h"\
+ {$(INCLUDE)}"iterobject.h"\
+ {$(INCLUDE)}"listobject.h"\
+ {$(INCLUDE)}"longobject.h"\
+ {$(INCLUDE)}"methodobject.h"\
+ {$(INCLUDE)}"modsupport.h"\
+ {$(INCLUDE)}"moduleobject.h"\
+ {$(INCLUDE)}"object.h"\
+ {$(INCLUDE)}"objimpl.h"\
+ {$(INCLUDE)}"patchlevel.h"\
+ {$(INCLUDE)}"pyconfig.h"\
+ {$(INCLUDE)}"pydebug.h"\
+ {$(INCLUDE)}"pyerrors.h"\
+ {$(INCLUDE)}"pyfpe.h"\
+ {$(INCLUDE)}"pymem.h"\
+ {$(INCLUDE)}"pyport.h"\
+ {$(INCLUDE)}"pystate.h"\
+ {$(INCLUDE)}"Python.h"\
+ {$(INCLUDE)}"pythonrun.h"\
+ {$(INCLUDE)}"rangeobject.h"\
+ {$(INCLUDE)}"sliceobject.h"\
+ {$(INCLUDE)}"stringobject.h"\
+ {$(INCLUDE)}"structmember.h"\
+ {$(INCLUDE)}"sysmodule.h"\
+ {$(INCLUDE)}"traceback.h"\
+ {$(INCLUDE)}"tupleobject.h"\
+ {$(INCLUDE)}"unicodeobject.h"\
+ {$(INCLUDE)}"weakrefobject.h"\
+ {$(INCLUDE)}"wince-compatibility.h"\
+
+NODEP_CPP_CFIEL=\
+ "..\..\..\PYTHON-2.3.5-WINCE\INCLUDE\unixstuff.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4) Debug"
+
+DEP_CPP_CFIEL=\
+ "..\source\ctypes.h"\
+
+NODEP_CPP_CFIEL=\
+ "..\..\..\WINCE\PYTHON-2.3.4-WINCE\INCLUDE\unixstuff.h"\
+ "..\source\libffi_arm_wince\ffi.h"\
+ "..\source\libffi_arm_wince\ffitarget.h"\
+ ".\angeobject.h"\
+ ".\asetsd.h"\
+ ".\atchlevel.h"\
+ ".\bject.h"\
+ ".\bjimpl.h"\
+ ".\bstract.h"\
+ ".\eakrefobject.h"\
+ ".\ellobject.h"\
+ ".\escrobject.h"\
+ ".\ethodobject.h"\
+ ".\ictobject.h"\
+ ".\ileobject.h"\
+ ".\ince-compatibility.h"\
+ ".\istobject.h"\
+ ".\lassobject.h"\
+ ".\liceobject.h"\
+ ".\loatobject.h"\
+ ".\mport.h"\
+ ".\nicodeobject.h"\
+ ".\ntobject.h"\
+ ".\ntrcheck.h"\
+ ".\numobject.h"\
+ ".\odsupport.h"\
+ ".\oduleobject.h"\
+ ".\omplexobject.h"\
+ ".\ongobject.h"\
+ ".\oolobject.h"\
+ ".\raceback.h"\
+ ".\terobject.h"\
+ ".\tringobject.h"\
+ ".\tructmember.h"\
+ ".\ufferobject.h"\
+ ".\uncobject.h"\
+ ".\upleobject.h"\
+ ".\val.h"\
+ ".\yconfig.h"\
+ ".\ydebug.h"\
+ ".\yerrors.h"\
+ ".\yfpe.h"\
+ ".\ymem.h"\
+ ".\yport.h"\
+ ".\ysmodule.h"\
+ ".\ystate.h"\
+ ".\ython.h"\
+ ".\ythonrun.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4T) Release"
+
+DEP_CPP_CFIEL=\
+ "..\source\ctypes.h"\
+ "..\source\libffi_msvc\ffi.h"\
+ "..\source\libffi_msvc\ffitarget.h"\
+
+NODEP_CPP_CFIEL=\
+ "..\source\Python.h"\
+ "..\source\structmember.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4T) Debug"
+
+DEP_CPP_CFIEL=\
+ "..\source\ctypes.h"\
+ "..\source\libffi_msvc\ffi.h"\
+ "..\source\libffi_msvc\ffitarget.h"\
+
+NODEP_CPP_CFIEL=\
+ "..\source\Python.h"\
+ "..\source\structmember.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE x86) Release"
+
+DEP_CPP_CFIEL=\
+ "..\source\ctypes.h"\
+ "..\source\libffi_msvc\ffi.h"\
+ "..\source\libffi_msvc\ffitarget.h"\
+
+NODEP_CPP_CFIEL=\
+ "..\source\Python.h"\
+ "..\source\structmember.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE x86) Debug"
+
+DEP_CPP_CFIEL=\
+ "..\source\ctypes.h"\
+ "..\source\libffi_msvc\ffi.h"\
+ "..\source\libffi_msvc\ffitarget.h"\
+
+NODEP_CPP_CFIEL=\
+ "..\source\Python.h"\
+ "..\source\structmember.h"\
+
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\source\malloc_closure.c
+
+!IF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4I) Release"
+
+DEP_CPP_MALLO=\
+ "..\source\ctypes.h"\
+ "..\source\libffi_msvc\ffi.h"\
+ "..\source\libffi_msvc\ffitarget.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4I) Debug"
+
+DEP_CPP_MALLO=\
+ "..\source\ctypes.h"\
+ "..\source\libffi_msvc\ffi.h"\
+ "..\source\libffi_msvc\ffitarget.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4) Release"
+
+DEP_CPP_MALLO=\
+ "..\source\ctypes.h"\
+ "..\source\libffi_arm_wince\ffi.h"\
+ "..\source\libffi_arm_wince\ffitarget.h"\
+ {$(INCLUDE)}"abstract.h"\
+ {$(INCLUDE)}"basetsd.h"\
+ {$(INCLUDE)}"boolobject.h"\
+ {$(INCLUDE)}"bufferobject.h"\
+ {$(INCLUDE)}"cellobject.h"\
+ {$(INCLUDE)}"ceval.h"\
+ {$(INCLUDE)}"classobject.h"\
+ {$(INCLUDE)}"cobject.h"\
+ {$(INCLUDE)}"complexobject.h"\
+ {$(INCLUDE)}"descrobject.h"\
+ {$(INCLUDE)}"dictobject.h"\
+ {$(INCLUDE)}"enumobject.h"\
+ {$(INCLUDE)}"fileobject.h"\
+ {$(INCLUDE)}"floatobject.h"\
+ {$(INCLUDE)}"funcobject.h"\
+ {$(INCLUDE)}"import.h"\
+ {$(INCLUDE)}"intobject.h"\
+ {$(INCLUDE)}"intrcheck.h"\
+ {$(INCLUDE)}"iterobject.h"\
+ {$(INCLUDE)}"listobject.h"\
+ {$(INCLUDE)}"longobject.h"\
+ {$(INCLUDE)}"methodobject.h"\
+ {$(INCLUDE)}"modsupport.h"\
+ {$(INCLUDE)}"moduleobject.h"\
+ {$(INCLUDE)}"object.h"\
+ {$(INCLUDE)}"objimpl.h"\
+ {$(INCLUDE)}"patchlevel.h"\
+ {$(INCLUDE)}"pyconfig.h"\
+ {$(INCLUDE)}"pydebug.h"\
+ {$(INCLUDE)}"pyerrors.h"\
+ {$(INCLUDE)}"pyfpe.h"\
+ {$(INCLUDE)}"pymem.h"\
+ {$(INCLUDE)}"pyport.h"\
+ {$(INCLUDE)}"pystate.h"\
+ {$(INCLUDE)}"Python.h"\
+ {$(INCLUDE)}"pythonrun.h"\
+ {$(INCLUDE)}"rangeobject.h"\
+ {$(INCLUDE)}"sliceobject.h"\
+ {$(INCLUDE)}"stringobject.h"\
+ {$(INCLUDE)}"sysmodule.h"\
+ {$(INCLUDE)}"traceback.h"\
+ {$(INCLUDE)}"tupleobject.h"\
+ {$(INCLUDE)}"unicodeobject.h"\
+ {$(INCLUDE)}"weakrefobject.h"\
+ {$(INCLUDE)}"wince-compatibility.h"\
+
+NODEP_CPP_MALLO=\
+ "..\..\..\PYTHON-2.3.5-WINCE\INCLUDE\unixstuff.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4) Debug"
+
+DEP_CPP_MALLO=\
+ "..\source\ctypes.h"\
+
+NODEP_CPP_MALLO=\
+ "..\..\..\WINCE\PYTHON-2.3.4-WINCE\INCLUDE\unixstuff.h"\
+ "..\source\libffi_arm_wince\ffi.h"\
+ "..\source\libffi_arm_wince\ffitarget.h"\
+ ".\angeobject.h"\
+ ".\asetsd.h"\
+ ".\atchlevel.h"\
+ ".\bject.h"\
+ ".\bjimpl.h"\
+ ".\bstract.h"\
+ ".\eakrefobject.h"\
+ ".\ellobject.h"\
+ ".\escrobject.h"\
+ ".\ethodobject.h"\
+ ".\ictobject.h"\
+ ".\ileobject.h"\
+ ".\ince-compatibility.h"\
+ ".\istobject.h"\
+ ".\lassobject.h"\
+ ".\liceobject.h"\
+ ".\loatobject.h"\
+ ".\mport.h"\
+ ".\nicodeobject.h"\
+ ".\ntobject.h"\
+ ".\ntrcheck.h"\
+ ".\numobject.h"\
+ ".\odsupport.h"\
+ ".\oduleobject.h"\
+ ".\omplexobject.h"\
+ ".\ongobject.h"\
+ ".\oolobject.h"\
+ ".\raceback.h"\
+ ".\terobject.h"\
+ ".\tringobject.h"\
+ ".\ufferobject.h"\
+ ".\uncobject.h"\
+ ".\upleobject.h"\
+ ".\val.h"\
+ ".\yconfig.h"\
+ ".\ydebug.h"\
+ ".\yerrors.h"\
+ ".\yfpe.h"\
+ ".\ymem.h"\
+ ".\yport.h"\
+ ".\ysmodule.h"\
+ ".\ystate.h"\
+ ".\ython.h"\
+ ".\ythonrun.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4T) Release"
+
+DEP_CPP_MALLO=\
+ "..\source\ctypes.h"\
+ "..\source\libffi_msvc\ffi.h"\
+ "..\source\libffi_msvc\ffitarget.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4T) Debug"
+
+DEP_CPP_MALLO=\
+ "..\source\ctypes.h"\
+ "..\source\libffi_msvc\ffi.h"\
+ "..\source\libffi_msvc\ffitarget.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE x86) Release"
+
+DEP_CPP_MALLO=\
+ "..\source\ctypes.h"\
+ "..\source\libffi_msvc\ffi.h"\
+ "..\source\libffi_msvc\ffitarget.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE x86) Debug"
+
+DEP_CPP_MALLO=\
+ "..\source\ctypes.h"\
+ "..\source\libffi_msvc\ffi.h"\
+ "..\source\libffi_msvc\ffitarget.h"\
+
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\source\stgdict.c
+
+!IF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4I) Release"
+
+DEP_CPP_STGDI=\
+ "..\source\ctypes.h"\
+ "..\source\libffi_msvc\ffi.h"\
+ "..\source\libffi_msvc\ffitarget.h"\
+
+NODEP_CPP_STGDI=\
+ "..\source\Python.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4I) Debug"
+
+DEP_CPP_STGDI=\
+ "..\source\ctypes.h"\
+ "..\source\libffi_msvc\ffi.h"\
+ "..\source\libffi_msvc\ffitarget.h"\
+
+NODEP_CPP_STGDI=\
+ "..\source\Python.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4) Release"
+
+DEP_CPP_STGDI=\
+ "..\source\ctypes.h"\
+ "..\source\libffi_arm_wince\ffi.h"\
+ "..\source\libffi_arm_wince\ffitarget.h"\
+ {$(INCLUDE)}"abstract.h"\
+ {$(INCLUDE)}"basetsd.h"\
+ {$(INCLUDE)}"boolobject.h"\
+ {$(INCLUDE)}"bufferobject.h"\
+ {$(INCLUDE)}"cellobject.h"\
+ {$(INCLUDE)}"ceval.h"\
+ {$(INCLUDE)}"classobject.h"\
+ {$(INCLUDE)}"cobject.h"\
+ {$(INCLUDE)}"complexobject.h"\
+ {$(INCLUDE)}"descrobject.h"\
+ {$(INCLUDE)}"dictobject.h"\
+ {$(INCLUDE)}"enumobject.h"\
+ {$(INCLUDE)}"fileobject.h"\
+ {$(INCLUDE)}"floatobject.h"\
+ {$(INCLUDE)}"funcobject.h"\
+ {$(INCLUDE)}"import.h"\
+ {$(INCLUDE)}"intobject.h"\
+ {$(INCLUDE)}"intrcheck.h"\
+ {$(INCLUDE)}"iterobject.h"\
+ {$(INCLUDE)}"listobject.h"\
+ {$(INCLUDE)}"longobject.h"\
+ {$(INCLUDE)}"methodobject.h"\
+ {$(INCLUDE)}"modsupport.h"\
+ {$(INCLUDE)}"moduleobject.h"\
+ {$(INCLUDE)}"object.h"\
+ {$(INCLUDE)}"objimpl.h"\
+ {$(INCLUDE)}"patchlevel.h"\
+ {$(INCLUDE)}"pyconfig.h"\
+ {$(INCLUDE)}"pydebug.h"\
+ {$(INCLUDE)}"pyerrors.h"\
+ {$(INCLUDE)}"pyfpe.h"\
+ {$(INCLUDE)}"pymem.h"\
+ {$(INCLUDE)}"pyport.h"\
+ {$(INCLUDE)}"pystate.h"\
+ {$(INCLUDE)}"Python.h"\
+ {$(INCLUDE)}"pythonrun.h"\
+ {$(INCLUDE)}"rangeobject.h"\
+ {$(INCLUDE)}"sliceobject.h"\
+ {$(INCLUDE)}"stringobject.h"\
+ {$(INCLUDE)}"sysmodule.h"\
+ {$(INCLUDE)}"traceback.h"\
+ {$(INCLUDE)}"tupleobject.h"\
+ {$(INCLUDE)}"unicodeobject.h"\
+ {$(INCLUDE)}"weakrefobject.h"\
+ {$(INCLUDE)}"wince-compatibility.h"\
+
+NODEP_CPP_STGDI=\
+ "..\..\..\PYTHON-2.3.5-WINCE\INCLUDE\unixstuff.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4) Debug"
+
+DEP_CPP_STGDI=\
+ "..\source\ctypes.h"\
+
+NODEP_CPP_STGDI=\
+ "..\..\..\WINCE\PYTHON-2.3.4-WINCE\INCLUDE\unixstuff.h"\
+ "..\source\libffi_arm_wince\ffi.h"\
+ "..\source\libffi_arm_wince\ffitarget.h"\
+ ".\angeobject.h"\
+ ".\asetsd.h"\
+ ".\atchlevel.h"\
+ ".\bject.h"\
+ ".\bjimpl.h"\
+ ".\bstract.h"\
+ ".\eakrefobject.h"\
+ ".\ellobject.h"\
+ ".\escrobject.h"\
+ ".\ethodobject.h"\
+ ".\ictobject.h"\
+ ".\ileobject.h"\
+ ".\ince-compatibility.h"\
+ ".\istobject.h"\
+ ".\lassobject.h"\
+ ".\liceobject.h"\
+ ".\loatobject.h"\
+ ".\mport.h"\
+ ".\nicodeobject.h"\
+ ".\ntobject.h"\
+ ".\ntrcheck.h"\
+ ".\numobject.h"\
+ ".\odsupport.h"\
+ ".\oduleobject.h"\
+ ".\omplexobject.h"\
+ ".\ongobject.h"\
+ ".\oolobject.h"\
+ ".\raceback.h"\
+ ".\terobject.h"\
+ ".\tringobject.h"\
+ ".\ufferobject.h"\
+ ".\uncobject.h"\
+ ".\upleobject.h"\
+ ".\val.h"\
+ ".\yconfig.h"\
+ ".\ydebug.h"\
+ ".\yerrors.h"\
+ ".\yfpe.h"\
+ ".\ymem.h"\
+ ".\yport.h"\
+ ".\ysmodule.h"\
+ ".\ystate.h"\
+ ".\ython.h"\
+ ".\ythonrun.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4T) Release"
+
+DEP_CPP_STGDI=\
+ "..\source\ctypes.h"\
+ "..\source\libffi_msvc\ffi.h"\
+ "..\source\libffi_msvc\ffitarget.h"\
+
+NODEP_CPP_STGDI=\
+ "..\source\Python.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4T) Debug"
+
+DEP_CPP_STGDI=\
+ "..\source\ctypes.h"\
+ "..\source\libffi_msvc\ffi.h"\
+ "..\source\libffi_msvc\ffitarget.h"\
+
+NODEP_CPP_STGDI=\
+ "..\source\Python.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE x86) Release"
+
+DEP_CPP_STGDI=\
+ "..\source\ctypes.h"\
+ "..\source\libffi_msvc\ffi.h"\
+ "..\source\libffi_msvc\ffitarget.h"\
+
+NODEP_CPP_STGDI=\
+ "..\source\Python.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE x86) Debug"
+
+DEP_CPP_STGDI=\
+ "..\source\ctypes.h"\
+ "..\source\libffi_msvc\ffi.h"\
+ "..\source\libffi_msvc\ffitarget.h"\
+
+NODEP_CPP_STGDI=\
+ "..\source\Python.h"\
+
+
+!ENDIF
+
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=..\source\ctypes.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# Begin Group "libffi_arm_wince"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\source\libffi_arm_wince\debug.c
+
+!IF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4I) Release"
+
+DEP_CPP_DEBUG=\
+ "..\source\libffi_arm_wince\ffi.h"\
+ "..\source\libffi_arm_wince\ffi_common.h"\
+ "..\source\libffi_arm_wince\fficonfig.h"\
+ "..\source\libffi_arm_wince\ffitarget.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4I) Debug"
+
+DEP_CPP_DEBUG=\
+ "..\source\libffi_arm_wince\ffi.h"\
+ "..\source\libffi_arm_wince\ffi_common.h"\
+ "..\source\libffi_arm_wince\fficonfig.h"\
+ "..\source\libffi_arm_wince\ffitarget.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4) Release"
+
+DEP_CPP_DEBUG=\
+ "..\source\libffi_arm_wince\ffi.h"\
+ "..\source\libffi_arm_wince\ffi_common.h"\
+ "..\source\libffi_arm_wince\fficonfig.h"\
+ "..\source\libffi_arm_wince\ffitarget.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4) Debug"
+
+DEP_CPP_DEBUG=\
+ "..\source\libffi_arm_wince\ffi.h"\
+ "..\source\libffi_arm_wince\ffi_common.h"\
+ "..\source\libffi_arm_wince\fficonfig.h"\
+ "..\source\libffi_arm_wince\ffitarget.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4T) Release"
+
+DEP_CPP_DEBUG=\
+ "..\source\libffi_arm_wince\ffi.h"\
+ "..\source\libffi_arm_wince\ffi_common.h"\
+ "..\source\libffi_arm_wince\fficonfig.h"\
+ "..\source\libffi_arm_wince\ffitarget.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4T) Debug"
+
+DEP_CPP_DEBUG=\
+ "..\source\libffi_arm_wince\ffi.h"\
+ "..\source\libffi_arm_wince\ffi_common.h"\
+ "..\source\libffi_arm_wince\fficonfig.h"\
+ "..\source\libffi_arm_wince\ffitarget.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE x86) Release"
+
+DEP_CPP_DEBUG=\
+ "..\source\libffi_arm_wince\ffi.h"\
+ "..\source\libffi_arm_wince\ffi_common.h"\
+ "..\source\libffi_arm_wince\fficonfig.h"\
+ "..\source\libffi_arm_wince\ffitarget.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE x86) Debug"
+
+DEP_CPP_DEBUG=\
+ "..\source\libffi_arm_wince\ffi.h"\
+ "..\source\libffi_arm_wince\ffi_common.h"\
+ "..\source\libffi_arm_wince\fficonfig.h"\
+ "..\source\libffi_arm_wince\ffitarget.h"\
+
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\source\libffi_arm_wince\ffi.c
+
+!IF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4I) Release"
+
+DEP_CPP_FFI_C=\
+ "..\source\libffi_arm_wince\ffi.h"\
+ "..\source\libffi_arm_wince\ffi_common.h"\
+ "..\source\libffi_arm_wince\fficonfig.h"\
+ "..\source\libffi_arm_wince\ffitarget.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4I) Debug"
+
+DEP_CPP_FFI_C=\
+ "..\source\libffi_arm_wince\ffi.h"\
+ "..\source\libffi_arm_wince\ffi_common.h"\
+ "..\source\libffi_arm_wince\fficonfig.h"\
+ "..\source\libffi_arm_wince\ffitarget.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4) Release"
+
+DEP_CPP_FFI_C=\
+ "..\source\libffi_arm_wince\ffi.h"\
+ "..\source\libffi_arm_wince\ffi_common.h"\
+ "..\source\libffi_arm_wince\fficonfig.h"\
+ "..\source\libffi_arm_wince\ffitarget.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4) Debug"
+
+DEP_CPP_FFI_C=\
+ "..\source\libffi_arm_wince\ffi.h"\
+ "..\source\libffi_arm_wince\ffi_common.h"\
+ "..\source\libffi_arm_wince\fficonfig.h"\
+ "..\source\libffi_arm_wince\ffitarget.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4T) Release"
+
+DEP_CPP_FFI_C=\
+ "..\source\libffi_arm_wince\ffi.h"\
+ "..\source\libffi_arm_wince\ffi_common.h"\
+ "..\source\libffi_arm_wince\fficonfig.h"\
+ "..\source\libffi_arm_wince\ffitarget.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4T) Debug"
+
+DEP_CPP_FFI_C=\
+ "..\source\libffi_arm_wince\ffi.h"\
+ "..\source\libffi_arm_wince\ffi_common.h"\
+ "..\source\libffi_arm_wince\fficonfig.h"\
+ "..\source\libffi_arm_wince\ffitarget.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE x86) Release"
+
+DEP_CPP_FFI_C=\
+ "..\source\libffi_arm_wince\ffi.h"\
+ "..\source\libffi_arm_wince\ffi_common.h"\
+ "..\source\libffi_arm_wince\fficonfig.h"\
+ "..\source\libffi_arm_wince\ffitarget.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE x86) Debug"
+
+DEP_CPP_FFI_C=\
+ "..\source\libffi_arm_wince\ffi.h"\
+ "..\source\libffi_arm_wince\ffi_common.h"\
+ "..\source\libffi_arm_wince\fficonfig.h"\
+ "..\source\libffi_arm_wince\ffitarget.h"\
+
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\source\libffi_arm_wince\ffi.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\source\libffi_arm_wince\ffi_common.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\source\libffi_arm_wince\fficonfig.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\source\libffi_arm_wince\ffitarget.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\source\libffi_arm_wince\prep_cif.c
+
+!IF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4I) Release"
+
+DEP_CPP_PREP_=\
+ "..\source\libffi_arm_wince\ffi.h"\
+ "..\source\libffi_arm_wince\ffi_common.h"\
+ "..\source\libffi_arm_wince\fficonfig.h"\
+ "..\source\libffi_arm_wince\ffitarget.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4I) Debug"
+
+DEP_CPP_PREP_=\
+ "..\source\libffi_arm_wince\ffi.h"\
+ "..\source\libffi_arm_wince\ffi_common.h"\
+ "..\source\libffi_arm_wince\fficonfig.h"\
+ "..\source\libffi_arm_wince\ffitarget.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4) Release"
+
+DEP_CPP_PREP_=\
+ "..\source\libffi_arm_wince\ffi.h"\
+ "..\source\libffi_arm_wince\ffi_common.h"\
+ "..\source\libffi_arm_wince\fficonfig.h"\
+ "..\source\libffi_arm_wince\ffitarget.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4) Debug"
+
+DEP_CPP_PREP_=\
+ "..\source\libffi_arm_wince\ffi.h"\
+ "..\source\libffi_arm_wince\ffi_common.h"\
+ "..\source\libffi_arm_wince\fficonfig.h"\
+ "..\source\libffi_arm_wince\ffitarget.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4T) Release"
+
+DEP_CPP_PREP_=\
+ "..\source\libffi_arm_wince\ffi.h"\
+ "..\source\libffi_arm_wince\ffi_common.h"\
+ "..\source\libffi_arm_wince\fficonfig.h"\
+ "..\source\libffi_arm_wince\ffitarget.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4T) Debug"
+
+DEP_CPP_PREP_=\
+ "..\source\libffi_arm_wince\ffi.h"\
+ "..\source\libffi_arm_wince\ffi_common.h"\
+ "..\source\libffi_arm_wince\fficonfig.h"\
+ "..\source\libffi_arm_wince\ffitarget.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE x86) Release"
+
+DEP_CPP_PREP_=\
+ "..\source\libffi_arm_wince\ffi.h"\
+ "..\source\libffi_arm_wince\ffi_common.h"\
+ "..\source\libffi_arm_wince\fficonfig.h"\
+ "..\source\libffi_arm_wince\ffitarget.h"\
+
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE x86) Debug"
+
+DEP_CPP_PREP_=\
+ "..\source\libffi_arm_wince\ffi.h"\
+ "..\source\libffi_arm_wince\ffi_common.h"\
+ "..\source\libffi_arm_wince\fficonfig.h"\
+ "..\source\libffi_arm_wince\ffitarget.h"\
+
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\source\libffi_arm_wince\sysv.asm
+
+!IF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4I) Release"
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4I) Debug"
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4) Release"
+
+# Begin Custom Build
+IntDir=.\ARMV4Rel
+InputPath=..\source\libffi_arm_wince\sysv.asm
+InputName=sysv
+
+"$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ armasm -arch 4 $(InputPath) $(IntDir)\$(InputName).obj
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4) Debug"
+
+# Begin Custom Build
+IntDir=.\ARMV4Dbg
+InputPath=..\source\libffi_arm_wince\sysv.asm
+InputName=sysv
+
+"$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ armasm -g -arch 4 $(InputPath) $(IntDir)\$(InputName).obj
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4T) Release"
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE ARMV4T) Debug"
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE x86) Release"
+
+!ELSEIF "$(CFG)" == "_ctypes - Win32 (WCE x86) Debug"
+
+!ENDIF
+
+# End Source File
+# End Group
+# End Target
+# End Project
Added: packages/ctypes/branches/upstream/current/wince/_ctypes.vcw
URL: http://svn.debian.org/wsvn/python-modules/packages/ctypes/branches/upstream/current/wince/_ctypes.vcw?rev=940&op=file
==============================================================================
--- packages/ctypes/branches/upstream/current/wince/_ctypes.vcw (added)
+++ packages/ctypes/branches/upstream/current/wince/_ctypes.vcw Mon Jun 19 12:31:53 2006
@@ -1,0 +1,41 @@
+Microsoft eMbedded Visual Tools Workspace File, Format Version 4.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "_ctypes"=.\_ctypes.vcp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "_ctypes_test"=.\_ctypes_test\_ctypes_test.vcp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
More information about the Python-modules-commits
mailing list