ctypes-commit Mailing List for ctypes (Page 108)
Brought to you by:
theller
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
(8) |
May
(90) |
Jun
(143) |
Jul
(106) |
Aug
(94) |
Sep
(84) |
Oct
(163) |
Nov
(60) |
Dec
(58) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(128) |
Feb
(79) |
Mar
(227) |
Apr
(192) |
May
(179) |
Jun
(41) |
Jul
(53) |
Aug
(103) |
Sep
(28) |
Oct
(38) |
Nov
(81) |
Dec
(17) |
2006 |
Jan
(184) |
Feb
(111) |
Mar
(188) |
Apr
(67) |
May
(58) |
Jun
(123) |
Jul
(73) |
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
From: Thomas H. <th...@us...> - 2004-06-02 08:39:41
|
Update of /cvsroot/ctypes/ctypes/build/lib.win32-2.4 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6522 Modified Files: _ctypes_test.pyd _ctypes.pyd Log Message: Recompiled the binaries. Index: _ctypes_test.pyd =================================================================== RCS file: /cvsroot/ctypes/ctypes/build/lib.win32-2.4/_ctypes_test.pyd,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 Binary files /tmp/cvs9fsjGn and /tmp/cvsq303l5 differ Index: _ctypes.pyd =================================================================== RCS file: /cvsroot/ctypes/ctypes/build/lib.win32-2.4/_ctypes.pyd,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 Binary files /tmp/cvsonPrzz and /tmp/cvs76iknh differ |
From: Thomas H. <th...@us...> - 2004-06-02 08:39:21
|
Update of /cvsroot/ctypes/ctypes/build/lib.win32-2.3 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6469 Modified Files: _ctypes_test.pyd _ctypes.pyd Log Message: Recompiled the binaries. Index: _ctypes_test.pyd =================================================================== RCS file: /cvsroot/ctypes/ctypes/build/lib.win32-2.3/_ctypes_test.pyd,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 Binary files /tmp/cvsJISwHr and /tmp/cvsWoPyBQ differ Index: _ctypes.pyd =================================================================== RCS file: /cvsroot/ctypes/ctypes/build/lib.win32-2.3/_ctypes.pyd,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 Binary files /tmp/cvsp5DMta and /tmp/cvsFlbSWz differ |
From: Thomas H. <th...@us...> - 2004-06-02 08:28:42
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4596 Modified Files: cfield.c Log Message: Use the code in libffi/types.c instead of duplicating it in cfield.c. Index: cfield.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/cfield.c,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** cfield.c 7 May 2004 19:56:24 -0000 1.30 --- cfield.c 2 Jun 2004 08:28:33 -0000 1.31 *************** *** 981,1035 **** } - /* The following stuff replaces libffi's types.c file, the idea is stolen from - Python's structmodule.c */ - - typedef struct { char c; char x; } s_char; - typedef struct { char c; short x; } s_short; - typedef struct { char c; int x; } s_int; - typedef struct { char c; long x; } s_long; - typedef struct { char c; float x; } s_float; - typedef struct { char c; double x; } s_double; - typedef struct { char c; char *x; } s_char_p; - typedef struct { char c; void *x; } s_void_p; - - #define CHAR_ALIGN (sizeof(s_char) - sizeof(char)) - #define SHORT_ALIGN (sizeof(s_short) - sizeof(short)) - #define INT_ALIGN (sizeof(s_int) - sizeof(int)) - #define LONG_ALIGN (sizeof(s_long) - sizeof(long)) - #define FLOAT_ALIGN (sizeof(s_float) - sizeof(float)) - #define DOUBLE_ALIGN (sizeof(s_double) - sizeof(double)) - #define CHAR_P_ALIGN (sizeof(s_char_p) - sizeof(char*)) - #define VOID_P_ALIGN (sizeof(s_void_p) - sizeof(void*)) - - #ifdef HAVE_USABLE_WCHAR_T - typedef struct { char c; wchar_t x; } s_wchar; - typedef struct { char c; wchar_t *x; } s_wchar_p; - - #define WCHAR_ALIGN (sizeof(s_wchar) - sizeof(wchar_t)) - #define WCHAR_P_ALIGN (sizeof(s_wchar_p) - sizeof(wchar_t*)) - #endif - - #ifdef HAVE_LONG_LONG - typedef struct { char c; PY_LONG_LONG x; } s_long_long; - #define LONG_LONG_ALIGN (sizeof(s_long_long) - sizeof(PY_LONG_LONG)) - #endif - - /* XXX We should make sure that the bit numbers of the types are really correct! */ - - ffi_type ffi_type_uint64 = {sizeof(PY_LONG_LONG), LONG_LONG_ALIGN, FFI_TYPE_UINT64, NULL}; - ffi_type ffi_type_sint64 = {sizeof(PY_LONG_LONG), LONG_LONG_ALIGN, FFI_TYPE_SINT64, NULL}; - ffi_type ffi_type_uint32 = {sizeof(int), INT_ALIGN, FFI_TYPE_UINT32, NULL}; - ffi_type ffi_type_sint32 = {sizeof(int), INT_ALIGN, FFI_TYPE_SINT32, NULL}; - ffi_type ffi_type_uint16 = {sizeof(short), SHORT_ALIGN, FFI_TYPE_UINT16, NULL}; - ffi_type ffi_type_sint16 = {sizeof(short), SHORT_ALIGN, FFI_TYPE_SINT16, NULL}; - ffi_type ffi_type_uint8 = {sizeof(char), CHAR_ALIGN, FFI_TYPE_UINT8, NULL}; - ffi_type ffi_type_sint8 = {sizeof(char), CHAR_ALIGN, FFI_TYPE_SINT8, NULL}; - ffi_type ffi_type_float = {sizeof(float), FLOAT_ALIGN, FFI_TYPE_FLOAT, NULL}; - ffi_type ffi_type_double = {sizeof(double), DOUBLE_ALIGN, FFI_TYPE_DOUBLE, NULL}; - ffi_type ffi_type_pointer = {sizeof(void*), VOID_P_ALIGN, FFI_TYPE_POINTER, NULL}; - /* Size and alignment are fake here. They must not be 0. */ - ffi_type ffi_type_void = {1, 1, FFI_TYPE_VOID, NULL}; - - /* ffi_type_longdouble is missing */ - /*---------------- EOF ----------------*/ --- 981,983 ---- |
From: Thomas H. <th...@us...> - 2004-06-02 08:28:37
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4569 Modified Files: setup.py Log Message: Use the code in libffi/types.c instead of duplicating it in cfield.c. Index: setup.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/setup.py,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** setup.py 25 May 2004 17:25:14 -0000 1.47 --- setup.py 2 Jun 2004 08:28:24 -0000 1.48 *************** *** 35,39 **** if os.name == "nt": kw["sources"].extend([ ! ## "source/libffi_msvc/types.c", "source/libffi_msvc/ffi.c", "source/libffi_msvc/prep_cif.c", --- 35,39 ---- if os.name == "nt": kw["sources"].extend([ ! "source/libffi_msvc/types.c", "source/libffi_msvc/ffi.c", "source/libffi_msvc/prep_cif.c", |
From: Thomas H. <th...@us...> - 2004-05-27 18:22:23
|
Update of /cvsroot/ctypes/ctypes/win32/com In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22967 Modified Files: client.py Log Message: Better GetObject function. Index: client.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/win32/com/client.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** client.py 3 May 2004 15:17:19 -0000 1.4 --- client.py 27 May 2004 18:22:14 -0000 1.5 *************** *** 542,552 **** return result def GetObject(displayName): - # see also: c:/python23/lib/site-packages/win32com/client/__init__.py 47 - # win32com is more flexible - from ctypes.com.moniker import MkParseDisplayName - moniker, i, bindCtx = MkParseDisplayName("winmgmts:") pdisp = POINTER(IDispatch)() ! moniker.BindToObject(bindCtx, None, byref(IDispatch._iid_), byref(pdisp)) return _Dispatch(pdisp) --- 542,559 ---- return result + ##def GetObject(displayName): + ## # see also: c:/python23/lib/site-packages/win32com/client/__init__.py 47 + ## # win32com is more flexible + + ## from ctypes.com.moniker import MkParseDisplayName + ## moniker, i, bindCtx = MkParseDisplayName(displayName) + ## pdisp = POINTER(IDispatch)() + ## moniker.BindToObject(bindCtx, None, byref(IDispatch._iid_), byref(pdisp)) + ## return _Dispatch(pdisp) + def GetObject(displayName): pdisp = POINTER(IDispatch)() ! # Do we need a way to specify the BIND_OPTS parameter? ! ole32.CoGetObject(unicode(displayName), None, byref(IDispatch._iid_), byref(pdisp)) return _Dispatch(pdisp) *************** *** 559,565 **** d = GetObject("winmgmts:") ! result = d.ExecQuery("SELECT * FROM Win32_NTLogEvent WHERE LogFile = 'Application'") ! print len(result) ! print result.Count raise SystemExit --- 566,581 ---- d = GetObject("winmgmts:") ! result = d.ExecQuery("SELECT * FROM Win32_LogicalDisk")# WHERE CAPTION = 'System Idle Process'") ! ## print len(result) ! ## print result.Count ! for i in result: ! print i.GetObjectText_() ! ## print len(i.Properties_) ! ! ## print i.Properties_.Item("Handle").Value ! ! ## for p in i.Properties_: ! ## print p.Name, p.Value ! raise SystemExit |
From: Thomas H. <th...@us...> - 2004-05-27 18:19:44
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22401 Modified Files: _ctypes.c Log Message: Remove an unused variable warning on linux by fixing the windows code. Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.143 retrieving revision 1.144 diff -C2 -d -r1.143 -r1.144 *** _ctypes.c 25 May 2004 12:13:54 -0000 1.143 --- _ctypes.c 27 May 2004 18:19:33 -0000 1.144 *************** *** 2183,2197 **** #ifdef MS_WIN32 ! static PPROC FindAddress(void *handle, char *name, int flags) { PPROC address; char *mangled_name; int i; address = (PPROC)GetProcAddress(handle, name); if (address) return address; ! if (flags & FUNCFLAG_CDECL) return address; ! /* for stdcall, try mangled names */ mangled_name = _alloca(strlen(name) + 1 + 1 + 1 + 3); /* \0 _ @ %d */ for (i = 0; i < 32; ++i) { --- 2183,2204 ---- #ifdef MS_WIN32 ! static PPROC FindAddress(void *handle, char *name, PyObject *type) { PPROC address; char *mangled_name; int i; + StgDictObject *dict = PyType_stgdict((PyObject *)type); + address = (PPROC)GetProcAddress(handle, name); if (address) return address; ! /* It should not happen that dict is NULL, but better be safe */ ! if (dict==NULL || dict->flags & FUNCFLAG_CDECL) return address; ! ! /* for stdcall, try mangled names: ! funcname -> _funcname@<n> ! where n is 0, 4, 8, 12, ..., 128 ! */ mangled_name = _alloca(strlen(name) + 1 + 1 + 1 + 3); /* \0 _ @ %d */ for (i = 0; i < 32; ++i) { *************** *** 2215,2219 **** void *handle; PyObject *objects; - StgDictObject *dict = PyType_stgdict((PyObject *)type); if (!PyArg_ParseTuple(args, "sO", &name, &dll)) --- 2222,2225 ---- *************** *** 2233,2237 **** #ifdef MS_WIN32 ! address = FindAddress(handle, name, dict->flags); if (!address) { PyErr_Format(PyExc_AttributeError, --- 2239,2243 ---- #ifdef MS_WIN32 ! address = FindAddress(handle, name, (PyObject *)type); if (!address) { PyErr_Format(PyExc_AttributeError, |
From: Thomas H. <th...@us...> - 2004-05-27 16:42:22
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4057 Modified Files: test_callbacks.py Log Message: Add a failUnlessAlmostEqual method, for Python 2.2. Replace the '0' argument with '-3', maybe this helps debugging. Index: test_callbacks.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_callbacks.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** test_callbacks.py 25 May 2004 12:12:33 -0000 1.16 --- test_callbacks.py 27 May 2004 16:42:11 -0000 1.17 *************** *** 15,19 **** def check_type_1(self, typ, arg): PROTO = self.functype.im_func(typ, c_byte, typ) ! return PROTO(self.callback)(0, arg) ################ --- 15,34 ---- def check_type_1(self, typ, arg): PROTO = self.functype.im_func(typ, c_byte, typ) ! return PROTO(self.callback)(-3, 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` )) ################ *************** *** 23,27 **** self.failUnlessEqual(self.got_args, (42,)) self.failUnlessEqual(self.check_type_1(c_byte, 42), 42) ! self.failUnlessEqual(self.got_args, (0, 42)) def test_ubyte(self): --- 38,42 ---- self.failUnlessEqual(self.got_args, (42,)) self.failUnlessEqual(self.check_type_1(c_byte, 42), 42) ! self.failUnlessEqual(self.got_args, (-3, 42)) def test_ubyte(self): *************** *** 29,33 **** self.failUnlessEqual(self.got_args, (42,)) self.failUnlessEqual(self.check_type_1(c_ubyte, 42), 42) ! self.failUnlessEqual(self.got_args, (0, 42)) def test_short(self): --- 44,48 ---- self.failUnlessEqual(self.got_args, (42,)) self.failUnlessEqual(self.check_type_1(c_ubyte, 42), 42) ! self.failUnlessEqual(self.got_args, (-3, 42)) def test_short(self): *************** *** 35,39 **** self.failUnlessEqual(self.got_args, (42,)) self.failUnlessEqual(self.check_type_1(c_short, 42), 42) ! self.failUnlessEqual(self.got_args, (0, 42)) def test_ushort(self): --- 50,54 ---- self.failUnlessEqual(self.got_args, (42,)) self.failUnlessEqual(self.check_type_1(c_short, 42), 42) ! self.failUnlessEqual(self.got_args, (-3, 42)) def test_ushort(self): *************** *** 41,45 **** self.failUnlessEqual(self.got_args, (42,)) self.failUnlessEqual(self.check_type_1(c_ushort, 42), 42) ! self.failUnlessEqual(self.got_args, (0, 42)) def test_int(self): --- 56,60 ---- self.failUnlessEqual(self.got_args, (42,)) self.failUnlessEqual(self.check_type_1(c_ushort, 42), 42) ! self.failUnlessEqual(self.got_args, (-3, 42)) def test_int(self): *************** *** 47,51 **** self.failUnlessEqual(self.got_args, (42,)) self.failUnlessEqual(self.check_type_1(c_int, 42), 42) ! self.failUnlessEqual(self.got_args, (0, 42)) def test_uint(self): --- 62,66 ---- self.failUnlessEqual(self.got_args, (42,)) self.failUnlessEqual(self.check_type_1(c_int, 42), 42) ! self.failUnlessEqual(self.got_args, (-3, 42)) def test_uint(self): *************** *** 53,57 **** self.failUnlessEqual(self.got_args, (42,)) self.failUnlessEqual(self.check_type_1(c_uint, 42), 42) ! self.failUnlessEqual(self.got_args, (0, 42)) def test_long(self): --- 68,72 ---- self.failUnlessEqual(self.got_args, (42,)) self.failUnlessEqual(self.check_type_1(c_uint, 42), 42) ! self.failUnlessEqual(self.got_args, (-3, 42)) def test_long(self): *************** *** 59,63 **** self.failUnlessEqual(self.got_args, (42,)) self.failUnlessEqual(self.check_type_1(c_long, 42), 42) ! self.failUnlessEqual(self.got_args, (0, 42)) def test_ulong(self): --- 74,78 ---- self.failUnlessEqual(self.got_args, (42,)) self.failUnlessEqual(self.check_type_1(c_long, 42), 42) ! self.failUnlessEqual(self.got_args, (-3, 42)) def test_ulong(self): *************** *** 65,69 **** self.failUnlessEqual(self.got_args, (42,)) self.failUnlessEqual(self.check_type_1(c_ulong, 42), 42) ! self.failUnlessEqual(self.got_args, (0, 42)) def test_longlong(self): --- 80,84 ---- self.failUnlessEqual(self.got_args, (42,)) self.failUnlessEqual(self.check_type_1(c_ulong, 42), 42) ! self.failUnlessEqual(self.got_args, (-3, 42)) def test_longlong(self): *************** *** 71,75 **** self.failUnlessEqual(self.got_args, (42,)) self.failUnlessEqual(self.check_type_1(c_longlong, 42), 42) ! self.failUnlessEqual(self.got_args, (0, 42)) def test_ulonglong(self): --- 86,90 ---- self.failUnlessEqual(self.got_args, (42,)) self.failUnlessEqual(self.check_type_1(c_longlong, 42), 42) ! self.failUnlessEqual(self.got_args, (-3, 42)) def test_ulonglong(self): *************** *** 77,81 **** self.failUnlessEqual(self.got_args, (42,)) self.failUnlessEqual(self.check_type_1(c_ulonglong, 42), 42) ! self.failUnlessEqual(self.got_args, (0, 42)) def test_float(self): --- 92,96 ---- self.failUnlessEqual(self.got_args, (42,)) self.failUnlessEqual(self.check_type_1(c_ulonglong, 42), 42) ! self.failUnlessEqual(self.got_args, (-3, 42)) def test_float(self): *************** *** 93,97 **** self.failUnlessEqual(self.got_args, (3.14,)) self.failUnlessEqual(self.check_type_1(c_double, 3.14), 3.14) ! self.failUnlessEqual(self.got_args, (0, 3.14)) def test_char(self): --- 108,112 ---- self.failUnlessEqual(self.got_args, (3.14,)) self.failUnlessEqual(self.check_type_1(c_double, 3.14), 3.14) ! self.failUnlessEqual(self.got_args, (-3, 3.14)) def test_char(self): *************** *** 99,103 **** self.failUnlessEqual(self.got_args, ("x",)) self.failUnlessEqual(self.check_type_1(c_char, "x"), "x") ! self.failUnlessEqual(self.got_args, (0, "x")) def test_char_p(self): --- 114,118 ---- self.failUnlessEqual(self.got_args, ("x",)) self.failUnlessEqual(self.check_type_1(c_char, "x"), "x") ! self.failUnlessEqual(self.got_args, (-3, "x")) def test_char_p(self): *************** *** 105,109 **** self.failUnlessEqual(self.got_args, ("abc",)) self.failUnlessEqual(self.check_type_1(c_char_p, "abc"), "abc") ! self.failUnlessEqual(self.got_args, (0, "abc")) try: --- 120,124 ---- self.failUnlessEqual(self.got_args, ("abc",)) self.failUnlessEqual(self.check_type_1(c_char_p, "abc"), "abc") ! self.failUnlessEqual(self.got_args, (-3, "abc")) try: |
From: Thomas H. <th...@us...> - 2004-05-27 16:30:55
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1768 Modified Files: test_cfuncs.py Log Message: Add tests for byte and ubyte. Index: test_cfuncs.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_cfuncs.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test_cfuncs.py 25 May 2004 17:45:22 -0000 1.4 --- test_cfuncs.py 27 May 2004 16:30:38 -0000 1.5 *************** *** 8,11 **** --- 8,23 ---- self.dll = CDLL(_ctypes_test.__file__) + def test_byte(self): + self.dll.tf_b.restype = c_byte + self.failUnlessEqual(self.dll.tf_b(-42), -42) + self.dll.tf_bb.restype = c_byte + self.failUnlessEqual(self.dll.tf_bb(0, -42), -42) + + def test_ubyte(self): + self.dll.tf_B.restype = c_ubyte + self.failUnlessEqual(self.dll.tf_B(42), 42) + self.dll.tf_bB.restype = c_ubyte + self.failUnlessEqual(self.dll.tf_bB(0, 42), 42) + def test_short(self): self.dll.tf_h.restype = c_short |
From: Thomas H. <th...@us...> - 2004-05-27 08:13:14
|
Update of /cvsroot/ctypes/ctypes/win32/com/samples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6474 Modified Files: iexplorer.py Log Message: Changes to work with current ctypes. Index: iexplorer.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/win32/com/samples/iexplorer.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** iexplorer.py 15 Jan 2004 18:41:15 -0000 1.11 --- iexplorer.py 27 May 2004 08:13:01 -0000 1.12 *************** *** 47,52 **** def BeforeNavigate2(self, this, pDisp, URL, Flags, TargetFrameName, PostData, Headers, Cancel): ! print "BeforeNavigate2", pDisp, URL.value, Flags.value, \ ! TargetFrameName.value, Headers.value, Cancel.value ## if URL.value == "http://www.python.org/download/": ## Cancel.value = True --- 47,52 ---- def BeforeNavigate2(self, this, pDisp, URL, Flags, TargetFrameName, PostData, Headers, Cancel): ! print "BeforeNavigate2", pDisp, URL, Flags, \ ! TargetFrameName, Headers, Cancel ## if URL.value == "http://www.python.org/download/": ## Cancel.value = True *************** *** 54,58 **** def NavigateComplete2(self, this, pDisp, URL): ! print "NavigateComplete2", URL.value def FileDownload(self, this, spam, cancel): --- 54,58 ---- def NavigateComplete2(self, this, pDisp, URL): ! print "NavigateComplete2", URL def FileDownload(self, this, spam, cancel): |
From: Thomas H. <th...@us...> - 2004-05-25 17:45:34
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17666 Modified Files: test_cfuncs.py Log Message: Fix a name error on Linux. Index: test_cfuncs.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_cfuncs.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_cfuncs.py 25 May 2004 09:35:16 -0000 1.3 --- test_cfuncs.py 25 May 2004 17:45:22 -0000 1.4 *************** *** 3,9 **** import _ctypes_test - ##dll = CDLL(_ctypes_test.__file__) - ##wdll = WinDLL(_ctypes_test.__file__) - class CFunctions(unittest.TestCase): def __init__(self, *args): --- 3,6 ---- *************** *** 79,95 **** self.failUnlessEqual(self.dll.tf_bd(0, 42), 42) ! class stdcall_dll(WinDLL): ! def __getattr__(self, name): ! if name[:2] == '__' and name[-2:] == '__': ! raise AttributeError, name ! func = self._StdcallFuncPtr("s_" + name, self) ! setattr(self, name, func) ! return func ! class stdcallCFunctions(CFunctions): ! def __init__(self, *args): ! unittest.TestCase.__init__(self, *args) ! self.dll = stdcall_dll(_ctypes_test.__file__) if __name__ == '__main__': --- 76,97 ---- self.failUnlessEqual(self.dll.tf_bd(0, 42), 42) ! try: ! WinDLL ! except NameError: ! pass ! else: ! class stdcall_dll(WinDLL): ! def __getattr__(self, name): ! if name[:2] == '__' and name[-2:] == '__': ! raise AttributeError, name ! func = self._StdcallFuncPtr("s_" + name, self) ! setattr(self, name, func) ! return func ! class stdcallCFunctions(CFunctions): ! def __init__(self, *args): ! unittest.TestCase.__init__(self, *args) ! self.dll = stdcall_dll(_ctypes_test.__file__) if __name__ == '__main__': |
From: Thomas H. <th...@us...> - 2004-05-25 17:42:59
|
Update of /cvsroot/ctypes/ctypes/build/lib.win32-2.3 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17234 Modified Files: _ctypes_test.pyd _ctypes.pyd Log Message: Rebuilt. Tests all run. Index: _ctypes_test.pyd =================================================================== RCS file: /cvsroot/ctypes/ctypes/build/lib.win32-2.3/_ctypes_test.pyd,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 Binary files /tmp/cvspeRLrr and /tmp/cvsEwSHcn differ Index: _ctypes.pyd =================================================================== RCS file: /cvsroot/ctypes/ctypes/build/lib.win32-2.3/_ctypes.pyd,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 Binary files /tmp/cvsuDYRE9 and /tmp/cvsA7xyR5 differ |
From: Thomas H. <th...@us...> - 2004-05-25 17:42:37
|
Update of /cvsroot/ctypes/ctypes/build/lib.win32-2.4 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17170 Modified Files: _ctypes_test.pyd _ctypes.pyd Log Message: Rebuilt. Tests all run. Index: _ctypes_test.pyd =================================================================== RCS file: /cvsroot/ctypes/ctypes/build/lib.win32-2.4/_ctypes_test.pyd,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 Binary files /tmp/cvsN13UGG and /tmp/cvsAJ3uwk differ Index: _ctypes.pyd =================================================================== RCS file: /cvsroot/ctypes/ctypes/build/lib.win32-2.4/_ctypes.pyd,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 Binary files /tmp/cvsVHYMpS and /tmp/cvsA4GWnw differ |
From: Thomas H. <th...@us...> - 2004-05-25 17:42:08
|
Update of /cvsroot/ctypes/ctypes/build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17048 Modified Files: .cvsignore Log Message: Ignore more files. Index: .cvsignore =================================================================== RCS file: /cvsroot/ctypes/ctypes/build/.cvsignore,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** .cvsignore 20 Apr 2004 20:13:29 -0000 1.1 --- .cvsignore 25 May 2004 17:41:59 -0000 1.2 *************** *** 1,2 **** --- 1,3 ---- + temp.win32-2.2 temp.win32-2.3 temp.win32-2.4 |
From: Thomas H. <th...@us...> - 2004-05-25 17:25:24
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14241 Modified Files: setup.py Log Message: No need to unmangle the names of the stdcall test functions. Index: setup.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/setup.py,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** setup.py 25 May 2004 09:34:14 -0000 1.46 --- setup.py 25 May 2004 17:25:14 -0000 1.47 *************** *** 34,40 **** if os.name == "nt": - fmt = "bBhHiIlLqQfd" - testfunc_names = ["s_tf_%s" % s for s in fmt] + ["s_tf_b%s" % s for s in fmt] - kw["sources"].extend([ ## "source/libffi_msvc/types.c", --- 34,37 ---- *************** *** 54,58 **** libraries=["oleaut32"], sources=["source/_ctypes_test.c"], - export_symbols=testfunc_names, include_dirs=["source/libffi_msvc"], ) --- 51,54 ---- |
From: Thomas H. <th...@us...> - 2004-05-25 12:14:04
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19585 Modified Files: _ctypes.c Log Message: On Windows, automatically try mangled names of stdcall functions. Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.142 retrieving revision 1.143 diff -C2 -d -r1.142 -r1.143 *** _ctypes.c 18 May 2004 12:17:20 -0000 1.142 --- _ctypes.c 25 May 2004 12:13:54 -0000 1.143 *************** *** 2182,2185 **** --- 2182,2208 ---- */ + #ifdef MS_WIN32 + static PPROC FindAddress(void *handle, char *name, int flags) + { + PPROC address; + char *mangled_name; + int i; + address = (PPROC)GetProcAddress(handle, name); + if (address) + return address; + if (flags & FUNCFLAG_CDECL) + return address; + /* for stdcall, try mangled names */ + 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); + if (address) + return address; + } + return NULL; + } + #endif + static PyObject * CFuncPtr_FromDll(PyTypeObject *type, PyObject *args, PyObject *kwds) *************** *** 2192,2195 **** --- 2215,2219 ---- void *handle; PyObject *objects; + StgDictObject *dict = PyType_stgdict((PyObject *)type); if (!PyArg_ParseTuple(args, "sO", &name, &dll)) *************** *** 2209,2213 **** #ifdef MS_WIN32 ! address = (PPROC)GetProcAddress(handle, name); if (!address) { PyErr_Format(PyExc_AttributeError, --- 2233,2237 ---- #ifdef MS_WIN32 ! address = FindAddress(handle, name, dict->flags); if (!address) { PyErr_Format(PyExc_AttributeError, |
From: Thomas H. <th...@us...> - 2004-05-25 12:12:49
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19315 Modified Files: test_callbacks.py Log Message: Make this test work with Python 2.2. Index: test_callbacks.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_callbacks.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** test_callbacks.py 19 May 2004 07:15:25 -0000 1.15 --- test_callbacks.py 25 May 2004 12:12:33 -0000 1.16 *************** *** 10,18 **** def check_type(self, typ, arg): ! PROTO = type(self).__dict__["functype"](typ, typ) return PROTO(self.callback)(arg) def check_type_1(self, typ, arg): ! PROTO = type(self).__dict__["functype"](typ, c_byte, typ) return PROTO(self.callback)(0, arg) --- 10,18 ---- def check_type(self, typ, arg): ! PROTO = self.functype.im_func(typ, typ) return PROTO(self.callback)(arg) def check_type_1(self, typ, arg): ! PROTO = self.functype.im_func(typ, c_byte, typ) return PROTO(self.callback)(0, arg) |
From: Thomas H. <th...@us...> - 2004-05-25 11:38:43
|
Update of /cvsroot/ctypes/ctypes/source/libffi_msvc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12849 Modified Files: prep_cif.c Log Message: Add a comment explaining what's going on. Index: prep_cif.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/libffi_msvc/prep_cif.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** prep_cif.c 7 May 2004 19:53:04 -0000 1.3 --- prep_cif.c 25 May 2004 11:38:33 -0000 1.4 *************** *** 145,152 **** --- 145,164 ---- #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); } |
From: Thomas H. <th...@us...> - 2004-05-25 09:37:23
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24324 Modified Files: callbacks.c Log Message: Implement stdcall closures. Index: callbacks.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/callbacks.c,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** callbacks.c 18 May 2004 15:14:18 -0000 1.47 --- callbacks.c 25 May 2004 09:37:12 -0000 1.48 *************** *** 511,514 **** --- 511,515 ---- int nArgs, i; PyCArgObject cResult; + ffi_abi cc; nArgs = PySequence_Size(converters); *************** *** 529,533 **** PrepareResult(restype, &cResult); ! result = ffi_prep_cif(&p->cif, FFI_DEFAULT_ABI, nArgs, cResult.pffi_type, &p->atypes[0]); --- 530,539 ---- PrepareResult(restype, &cResult); ! cc = FFI_DEFAULT_ABI; ! #ifdef MS_WIN32 ! if (is_cdecl == 0) ! cc = FFI_STDCALL; ! #endif ! result = ffi_prep_cif(&p->cif, cc, nArgs, cResult.pffi_type, &p->atypes[0]); *************** *** 538,542 **** return NULL; } - result = ffi_prep_closure(&p->cl, &p->cif, closure_fcn, p); if (result != FFI_OK) { --- 544,547 ---- |
From: Thomas H. <th...@us...> - 2004-05-25 09:35:26
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24032 Modified Files: test_cfuncs.py Log Message: Add tests for stdcall functions (on windows). Index: test_cfuncs.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_cfuncs.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_cfuncs.py 17 May 2004 20:56:43 -0000 1.2 --- test_cfuncs.py 25 May 2004 09:35:16 -0000 1.3 *************** *** 3,76 **** import _ctypes_test ! dll = CDLL(_ctypes_test.__file__) class CFunctions(unittest.TestCase): def test_short(self): ! dll.tf_h.restype = c_short ! self.failUnlessEqual(dll.tf_h(-42), -42) ! dll.tf_bh.restype = c_short ! self.failUnlessEqual(dll.tf_bh(0, -42), -42) def test_ushort(self): ! dll.tf_H.restype = c_ushort ! self.failUnlessEqual(dll.tf_H(42), 42) ! dll.tf_bH.restype = c_ushort ! self.failUnlessEqual(dll.tf_bH(0, 42), 42) def test_int(self): ! dll.tf_i.restype = c_int ! self.failUnlessEqual(dll.tf_i(-42), -42) ! dll.tf_bi.restype = c_int ! self.failUnlessEqual(dll.tf_bi(0, -42), -42) def test_uint(self): ! dll.tf_I.restype = c_uint ! self.failUnlessEqual(dll.tf_I(42), 42) ! dll.tf_bI.restype = c_uint ! self.failUnlessEqual(dll.tf_bI(0, 42), 42) def test_long(self): ! dll.tf_l.restype = c_long ! self.failUnlessEqual(dll.tf_l(-42), -42) ! dll.tf_bl.restype = c_long ! self.failUnlessEqual(dll.tf_bl(0, -42), -42) def test_ulong(self): ! dll.tf_L.restype = c_ulong ! self.failUnlessEqual(dll.tf_L(42), 42) ! dll.tf_bL.restype = c_ulong ! self.failUnlessEqual(dll.tf_bL(0, 42), 42) def test_longlong(self): ! dll.tf_q.restype = c_longlong ! dll.tf_q.argtypes = (c_longlong, ) ! self.failUnlessEqual(dll.tf_q(-42L), -42L) ! dll.tf_bq.restype = c_longlong ! dll.tf_bq.argtypes = (c_byte, c_longlong) ! self.failUnlessEqual(dll.tf_bq(0, -42), -42) def test_ulonglong(self): ! dll.tf_Q.restype = c_ulonglong ! dll.tf_Q.argtypes = (c_longlong, ) ! self.failUnlessEqual(dll.tf_Q(42), 42) ! dll.tf_bQ.restype = c_ulonglong ! dll.tf_bQ.argtypes = (c_byte, c_ulonglong) ! self.failUnlessEqual(dll.tf_bQ(0, 42), 42) def test_float(self): ! dll.tf_f.restype = c_float ! dll.tf_f.argtypes = (c_float,) ! self.failUnlessEqual(dll.tf_f(-42.), -42.) ! dll.tf_bf.restype = c_float ! dll.tf_bf.argtypes = (c_byte, c_float) ! self.failUnlessEqual(dll.tf_bf(0, -42.), -42.) def test_double(self): ! dll.tf_d.restype = c_double ! dll.tf_d.argtypes = (c_double,) ! self.failUnlessEqual(dll.tf_d(42), 42) ! dll.tf_bd.restype = c_double ! dll.tf_bd.argtypes = (c_byte, c_double) ! self.failUnlessEqual(dll.tf_bd(0, 42), 42) if __name__ == '__main__': --- 3,95 ---- import _ctypes_test ! ##dll = CDLL(_ctypes_test.__file__) ! ##wdll = WinDLL(_ctypes_test.__file__) class CFunctions(unittest.TestCase): + def __init__(self, *args): + unittest.TestCase.__init__(self, *args) + self.dll = CDLL(_ctypes_test.__file__) + def test_short(self): ! self.dll.tf_h.restype = c_short ! self.failUnlessEqual(self.dll.tf_h(-42), -42) ! self.dll.tf_bh.restype = c_short ! self.failUnlessEqual(self.dll.tf_bh(0, -42), -42) def test_ushort(self): ! self.dll.tf_H.restype = c_ushort ! self.failUnlessEqual(self.dll.tf_H(42), 42) ! self.dll.tf_bH.restype = c_ushort ! self.failUnlessEqual(self.dll.tf_bH(0, 42), 42) def test_int(self): ! self.dll.tf_i.restype = c_int ! self.failUnlessEqual(self.dll.tf_i(-42), -42) ! self.dll.tf_bi.restype = c_int ! self.failUnlessEqual(self.dll.tf_bi(0, -42), -42) def test_uint(self): ! self.dll.tf_I.restype = c_uint ! self.failUnlessEqual(self.dll.tf_I(42), 42) ! self.dll.tf_bI.restype = c_uint ! self.failUnlessEqual(self.dll.tf_bI(0, 42), 42) def test_long(self): ! self.dll.tf_l.restype = c_long ! self.failUnlessEqual(self.dll.tf_l(-42), -42) ! self.dll.tf_bl.restype = c_long ! self.failUnlessEqual(self.dll.tf_bl(0, -42), -42) def test_ulong(self): ! self.dll.tf_L.restype = c_ulong ! self.failUnlessEqual(self.dll.tf_L(42), 42) ! self.dll.tf_bL.restype = c_ulong ! self.failUnlessEqual(self.dll.tf_bL(0, 42), 42) def test_longlong(self): ! self.dll.tf_q.restype = c_longlong ! self.dll.tf_q.argtypes = (c_longlong, ) ! self.failUnlessEqual(self.dll.tf_q(-42L), -42L) ! self.dll.tf_bq.restype = c_longlong ! self.dll.tf_bq.argtypes = (c_byte, c_longlong) ! self.failUnlessEqual(self.dll.tf_bq(0, -42), -42) def test_ulonglong(self): ! self.dll.tf_Q.restype = c_ulonglong ! self.dll.tf_Q.argtypes = (c_longlong, ) ! self.failUnlessEqual(self.dll.tf_Q(42), 42) ! self.dll.tf_bQ.restype = c_ulonglong ! self.dll.tf_bQ.argtypes = (c_byte, c_ulonglong) ! self.failUnlessEqual(self.dll.tf_bQ(0, 42), 42) def test_float(self): ! self.dll.tf_f.restype = c_float ! self.dll.tf_f.argtypes = (c_float,) ! self.failUnlessEqual(self.dll.tf_f(-42.), -42.) ! self.dll.tf_bf.restype = c_float ! self.dll.tf_bf.argtypes = (c_byte, c_float) ! self.failUnlessEqual(self.dll.tf_bf(0, -42.), -42.) def test_double(self): ! self.dll.tf_d.restype = c_double ! self.dll.tf_d.argtypes = (c_double,) ! self.failUnlessEqual(self.dll.tf_d(42), 42) ! self.dll.tf_bd.restype = c_double ! self.dll.tf_bd.argtypes = (c_byte, c_double) ! self.failUnlessEqual(self.dll.tf_bd(0, 42), 42) ! ! class stdcall_dll(WinDLL): ! def __getattr__(self, name): ! if name[:2] == '__' and name[-2:] == '__': ! raise AttributeError, name ! func = self._StdcallFuncPtr("s_" + name, self) ! setattr(self, name, func) ! return func ! ! class stdcallCFunctions(CFunctions): ! ! def __init__(self, *args): ! unittest.TestCase.__init__(self, *args) ! self.dll = stdcall_dll(_ctypes_test.__file__) if __name__ == '__main__': |
From: Thomas H. <th...@us...> - 2004-05-25 09:34:26
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23911 Modified Files: setup.py Log Message: Export the stdcall test functions with undemangled names. Index: setup.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/setup.py,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** setup.py 18 May 2004 12:25:38 -0000 1.45 --- setup.py 25 May 2004 09:34:14 -0000 1.46 *************** *** 34,37 **** --- 34,40 ---- if os.name == "nt": + fmt = "bBhHiIlLqQfd" + testfunc_names = ["s_tf_%s" % s for s in fmt] + ["s_tf_b%s" % s for s in fmt] + kw["sources"].extend([ ## "source/libffi_msvc/types.c", *************** *** 51,54 **** --- 54,58 ---- libraries=["oleaut32"], sources=["source/_ctypes_test.c"], + export_symbols=testfunc_names, include_dirs=["source/libffi_msvc"], ) |
From: Thomas H. <th...@us...> - 2004-05-25 09:33:32
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23781 Modified Files: _ctypes_test.c Log Message: Refomatted the test functions code, added exported stdcall test functions. Index: _ctypes_test.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes_test.c,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** _ctypes_test.c 18 May 2004 12:02:53 -0000 1.17 --- _ctypes_test.c 25 May 2004 09:33:21 -0000 1.18 *************** *** 312,414 **** }; ! EXPORT(char) tf_b(char c) ! { ! return c; ! } ! EXPORT(unsigned char) tf_B(unsigned char c) ! { ! return c; ! } ! EXPORT(short) tf_h(short c) ! { ! return c; ! } ! EXPORT(unsigned short) tf_H(unsigned short c) ! { ! return c; ! } ! EXPORT(int) tf_i(int c) ! { ! return c; ! } ! EXPORT(unsigned int) tf_I(unsigned int c) ! { ! return c; ! } ! EXPORT(long) tf_l(long c) ! { ! return c; ! } ! EXPORT(unsigned long) tf_L(unsigned long c) ! { ! return c; ! } ! EXPORT(PY_LONG_LONG) tf_q(PY_LONG_LONG c) ! { ! return c; ! } ! EXPORT(unsigned PY_LONG_LONG) tf_Q(unsigned PY_LONG_LONG c) ! { ! return c; ! } ! EXPORT(float) tf_f(float c) ! { ! return c; ! } ! EXPORT(double) tf_d(double c) ! { ! return c; ! } /*******/ ! EXPORT(char) tf_bb(char x, char c) ! { ! return c; ! } ! EXPORT(unsigned char) tf_bB(char x, unsigned char c) ! { ! return c; ! } ! EXPORT(short) tf_bh(char x, short c) ! { ! return c; ! } ! EXPORT(unsigned short) tf_bH(char x, unsigned short c) ! { ! return c; ! } ! EXPORT(int) tf_bi(char x, int c) ! { ! return c; ! } ! EXPORT(unsigned int) tf_bI(char x, unsigned int c) ! { ! return c; ! } ! EXPORT(long) tf_bl(char x, long c) ! { ! return c; ! } ! EXPORT(unsigned long) tf_bL(char x, unsigned long c) ! { ! return c; ! } ! EXPORT(PY_LONG_LONG) tf_bq(char x, PY_LONG_LONG c) ! { ! return c; ! } ! EXPORT(unsigned PY_LONG_LONG) tf_bQ(char x, unsigned PY_LONG_LONG c) ! { ! return c; ! } ! EXPORT(float) tf_bf(char x, float c) ! { ! return c; ! } ! EXPORT(double) tf_bd(char x, double c) ! { ! return c; ! } /********/ --- 312,371 ---- }; ! EXPORT(char) tf_b(char c) { return c; } ! EXPORT(unsigned char) tf_B(unsigned char c) { return c; } ! EXPORT(short) tf_h(short c) { return c; } ! EXPORT(unsigned short) tf_H(unsigned short c) { return c; } ! EXPORT(int) tf_i(int c) { return c; } ! EXPORT(unsigned int) tf_I(unsigned int c) { return c; } ! EXPORT(long) tf_l(long c) { return c; } ! EXPORT(unsigned long) tf_L(unsigned long c) { return c; } ! EXPORT(PY_LONG_LONG) tf_q(PY_LONG_LONG c) { return c; } ! EXPORT(unsigned PY_LONG_LONG) tf_Q(unsigned PY_LONG_LONG c) { return c; } ! EXPORT(float) tf_f(float c) { return c; } ! EXPORT(double) tf_d(double c) { return c; } + #ifdef MS_WIN32 + EXPORT(char) __stdcall s_tf_b(char c) { return c; } + EXPORT(unsigned char) __stdcall s_tf_B(unsigned char c) { return c; } + EXPORT(short) __stdcall s_tf_h(short c) { return c; } + EXPORT(unsigned short) __stdcall s_tf_H(unsigned short c) { return c; } + EXPORT(int) __stdcall s_tf_i(int c) { return c; } + EXPORT(unsigned int) __stdcall s_tf_I(unsigned int c) { return c; } + EXPORT(long) __stdcall s_tf_l(long c) { return c; } + EXPORT(unsigned long) __stdcall s_tf_L(unsigned long c) { return c; } + EXPORT(PY_LONG_LONG) __stdcall s_tf_q(PY_LONG_LONG c) { return c; } + EXPORT(unsigned PY_LONG_LONG) __stdcall s_tf_Q(unsigned PY_LONG_LONG c) { return c; } + EXPORT(float) __stdcall s_tf_f(float c) { return c; } + EXPORT(double) __stdcall s_tf_d(double c) { return c; } + #endif /*******/ ! EXPORT(char) tf_bb(char x, char c) { return c; } ! EXPORT(unsigned char) tf_bB(char x, unsigned char c) { return c; } ! EXPORT(short) tf_bh(char x, short c) { return c; } ! EXPORT(unsigned short) tf_bH(char x, unsigned short c) { return c; } ! EXPORT(int) tf_bi(char x, int c) { return c; } ! EXPORT(unsigned int) tf_bI(char x, unsigned int c) { return c; } ! EXPORT(long) tf_bl(char x, long c) { return c; } ! EXPORT(unsigned long) tf_bL(char x, unsigned long c) { return c; } ! EXPORT(PY_LONG_LONG) tf_bq(char x, PY_LONG_LONG c) { return c; } ! EXPORT(unsigned PY_LONG_LONG) tf_bQ(char x, unsigned PY_LONG_LONG c) { return c; } ! EXPORT(float) tf_bf(char x, float c) { return c; } ! EXPORT(double) tf_bd(char x, double c) { return c; } ! ! #ifdef MS_WIN32 ! EXPORT(char) __stdcall s_tf_bb(char x, char c) { return c; } ! EXPORT(unsigned char) __stdcall s_tf_bB(char x, unsigned char c) { return c; } ! EXPORT(short) __stdcall s_tf_bh(char x, short c) { return c; } ! EXPORT(unsigned short) __stdcall s_tf_bH(char x, unsigned short c) { return c; } ! EXPORT(int) __stdcall s_tf_bi(char x, int c) { return c; } ! EXPORT(unsigned int) __stdcall s_tf_bI(char x, unsigned int c) { return c; } ! EXPORT(long) __stdcall s_tf_bl(char x, long c) { return c; } ! EXPORT(unsigned long) __stdcall s_tf_bL(char x, unsigned long c) { return c; } ! EXPORT(PY_LONG_LONG) __stdcall s_tf_bq(char x, PY_LONG_LONG c) { return c; } ! EXPORT(unsigned PY_LONG_LONG) __stdcall s_tf_bQ(char x, unsigned PY_LONG_LONG c) { return c; } ! EXPORT(float) __stdcall s_tf_bf(char x, float c) { return c; } ! EXPORT(double) __stdcall s_tf_bd(char x, double c) { return c; } ! #endif /********/ |
From: Thomas H. <th...@us...> - 2004-05-19 07:15:43
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30724 Modified Files: test_callbacks.py Log Message: Refactor, and add stdcall tests. The stdcall tests currently fail. Index: test_callbacks.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_callbacks.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** test_callbacks.py 17 May 2004 20:57:48 -0000 1.14 --- test_callbacks.py 19 May 2004 07:15:25 -0000 1.15 *************** *** 2,6 **** from ctypes import * ! class CallbacksBase(unittest.TestCase): def callback(self, *args): self.got_args = args --- 2,8 ---- from ctypes import * ! class Callbacks(unittest.TestCase): ! functype = CFUNCTYPE ! def callback(self, *args): self.got_args = args *************** *** 8,26 **** def check_type(self, typ, arg): ! PROTO = CFUNCTYPE(typ, typ) return PROTO(self.callback)(arg) def check_type_1(self, typ, arg): ! PROTO = CFUNCTYPE(typ, c_byte, typ) return PROTO(self.callback)(0, arg) ################ - - class IntegerCallbacks(CallbacksBase): - def test_cint(self): - PROTO = CFUNCTYPE(c_longlong, c_longlong, c_longlong, c_longlong) - PROTO(self.callback)(0x10, 0x20, 0x30) - def test_byte(self): self.failUnlessEqual(self.check_type(c_byte, 42), 42) --- 10,22 ---- def check_type(self, typ, arg): ! PROTO = type(self).__dict__["functype"](typ, typ) return PROTO(self.callback)(arg) def check_type_1(self, typ, arg): ! PROTO = type(self).__dict__["functype"](typ, c_byte, typ) return PROTO(self.callback)(0, arg) ################ def test_byte(self): self.failUnlessEqual(self.check_type(c_byte, 42), 42) *************** *** 99,103 **** self.failUnlessEqual(self.got_args, (0, 3.14)) - class CharCallbacks(CallbacksBase): def test_char(self): self.failUnlessEqual(self.check_type(c_char, "x"), "x") --- 95,98 ---- *************** *** 112,115 **** --- 107,120 ---- self.failUnlessEqual(self.got_args, (0, "abc")) + try: + WINFUNCTYPE + except NameError: + pass + else: + class StdcallCallbacks(Callbacks): + functype = WINFUNCTYPE + + ################################################################ + class SampleCallbacksTestCase(unittest.TestCase): *************** *** 134,137 **** --- 139,144 ---- self.failUnless(diff < 0.01, "%s not less than 0.01" % diff) + ################################################################ + if __name__ == '__main__': unittest.main() |
From: Thomas H. <th...@us...> - 2004-05-19 06:56:25
|
Update of /cvsroot/ctypes/ctypes/source/libffi_msvc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27054 Modified Files: win32.c Log Message: Fix an endless loop. Index: win32.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/libffi_msvc/win32.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** win32.c 18 May 2004 20:03:31 -0000 1.4 --- win32.c 19 May 2004 06:56:15 -0000 1.5 *************** *** 230,234 **** sc_retdouble: cmp ecx, FFI_TYPE_DOUBLE ! jne sc_retdouble // movl 24(%ebp),%ecx mov ecx, [ebp+24] --- 230,234 ---- sc_retdouble: cmp ecx, FFI_TYPE_DOUBLE ! jne sc_retlongdouble // movl 24(%ebp),%ecx mov ecx, [ebp+24] |
From: Thomas H. <th...@us...> - 2004-05-18 20:03:41
|
Update of /cvsroot/ctypes/ctypes/source/libffi_msvc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26950 Modified Files: win32.c Log Message: Critial bug fix. Index: win32.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/libffi_msvc/win32.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** win32.c 7 May 2004 19:54:02 -0000 1.3 --- win32.c 18 May 2004 20:03:31 -0000 1.4 *************** *** 52,60 **** 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 --- 52,60 ---- 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 *************** *** 81,85 **** // If the return value pointer is NULL, assume no return value. ! cmp [ebp + 24], 0 jne sc_retint --- 81,89 ---- // 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 *************** *** 191,195 **** // If the return value pointer is NULL, assume no return value. ! cmp [ebp + 24], 0 jne sc_retint --- 195,203 ---- // 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 |
From: Thomas H. <th...@us...> - 2004-05-18 15:14:31
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18396 Modified Files: callbacks.c Log Message: Fix an obvious bug, and terminate the ffi_type's fields with a NULL entry. Index: callbacks.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/callbacks.c,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** callbacks.c 18 May 2004 13:52:09 -0000 1.46 --- callbacks.c 18 May 2004 15:14:18 -0000 1.47 *************** *** 521,528 **** for (i = 0; i < nArgs; ++i) { PyObject *cnv = PySequence_GetItem(converters, i); ! PrepareResult(restype, &cResult); p->atypes[i] = cResult.pffi_type; Py_DECREF(cnv); } PrepareResult(restype, &cResult); --- 521,529 ---- for (i = 0; i < nArgs; ++i) { PyObject *cnv = PySequence_GetItem(converters, i); ! PrepareResult(cnv, &cResult); p->atypes[i] = cResult.pffi_type; Py_DECREF(cnv); } + p->atypes[i] = NULL; PrepareResult(restype, &cResult); |