ctypes-commit Mailing List for ctypes (Page 58)
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: Bradley L S. <bs...@us...> - 2005-04-15 03:15:55
|
Update of /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4975/src/java/ctypes/java/win32 Modified Files: NTStatus.java PROCESSENTRY32W.java Version.java Log Message: All win32 unit tests pass. Index: PROCESSENTRY32W.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/win32/PROCESSENTRY32W.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PROCESSENTRY32W.java 29 Aug 2004 01:25:29 -0000 1.3 --- PROCESSENTRY32W.java 15 Apr 2005 03:15:46 -0000 1.4 *************** *** 31,35 **** * @author Bradley Schatz * ! * Copyright 2003 Managed Data Security */ public class PROCESSENTRY32W extends CStruct { --- 31,35 ---- * @author Bradley Schatz * ! * Copyright 2003 Bradley Schatz */ public class PROCESSENTRY32W extends CStruct { Index: Version.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/win32/Version.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Version.java 5 Aug 2003 22:54:59 -0000 1.1 --- Version.java 15 Apr 2005 03:15:46 -0000 1.2 *************** *** 31,35 **** * @author Bradley Schatz * ! * Copyright 2003 Managed Data Security */ public class Version { --- 31,35 ---- * @author Bradley Schatz * ! * Copyright 2003 Bradley Schatz */ public class Version { Index: NTStatus.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/win32/NTStatus.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NTStatus.java 5 Aug 2003 22:54:59 -0000 1.1 --- NTStatus.java 15 Apr 2005 03:15:46 -0000 1.2 *************** *** 26,30 **** * @author Bradley Schatz * ! * Copyright 2003 Managed Data Security */ public class NTStatus { --- 26,30 ---- * @author Bradley Schatz * ! * Copyright 2003 Bradley Schatz */ public class NTStatus { |
From: Bradley L S. <bs...@us...> - 2005-04-15 03:15:55
|
Update of /cvsroot/ctypes/ctypes-java In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4975 Modified Files: .classpath NEWS.txt Log Message: All win32 unit tests pass. Index: .classpath =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/.classpath,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** .classpath 11 Mar 2004 01:37:52 -0000 1.3 --- .classpath 15 Apr 2005 03:15:46 -0000 1.4 *************** *** 1,10 **** <?xml version="1.0" encoding="UTF-8"?> <classpath> ! <classpathentry kind="src" path="src/java"/> ! <classpathentry kind="src" path="src/test"/> ! <classpathentry kind="src" path="src/examples"/> ! <classpathentry kind="src" path="src/spike"/> ! <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> ! <classpathentry kind="lib" path="C:/eclipse/plugins/org.junit_3.8.1/junit.jar"/> ! <classpathentry kind="output" path="bin"/> </classpath> --- 1,11 ---- <?xml version="1.0" encoding="UTF-8"?> <classpath> ! <classpathentry kind="src" path="src/java"/> ! <classpathentry kind="src" path="src/test"/> ! <classpathentry kind="src" path="src/examples"/> ! <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> ! <classpathentry kind="lib" path="C:/eclipse/plugins/org.junit_3.8.1/junit.jar"/> ! <classpathentry kind="lib" path="lib/commons-codec-1.3.jar"/> ! <classpathentry kind="lib" path="lib/commons-httpclient.jar"/> ! <classpathentry kind="output" path="bin"/> </classpath> Index: NEWS.txt =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/NEWS.txt,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** NEWS.txt 29 Aug 2004 01:27:25 -0000 1.3 --- NEWS.txt 15 Apr 2005 03:15:46 -0000 1.4 *************** *** 1,9 **** ctypes.java News - Version 0.7, 29 Aug, 2004 Synchronized FFI code with ctypes-python 0.9.1 Example Windows GUI API Application from JAWIN included ! Example NTLM authentication code + integration with commons-httpclisnt ! Version 0.2, 22 Mar, 2004 Callbacks working for Win32. --- 1,10 ---- ctypes.java News - + Version 0.8, + Version 0.7, 29 Aug, 2004 Synchronized FFI code with ctypes-python 0.9.1 Example Windows GUI API Application from JAWIN included ! Version 0.2, 22 Mar, 2004 Callbacks working for Win32. *************** *** 15,18 **** Version 0.1.0, 03-08-2003: - Initial Release \ No newline at end of file --- 16,18 ---- |
From: Bradley L S. <bs...@us...> - 2005-04-15 03:15:54
|
Update of /cvsroot/ctypes/ctypes-java/src/test/ctypes/java/test/win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4975/src/test/ctypes/java/test/win32 Modified Files: BuffersTest.java Added Files: PrimitiveTypesMathTest.java Removed Files: PrimitiveTypesTest.java Log Message: All win32 unit tests pass. Index: BuffersTest.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/test/ctypes/java/test/win32/BuffersTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** BuffersTest.java 31 Mar 2004 23:42:23 -0000 1.3 --- BuffersTest.java 15 Apr 2005 03:15:45 -0000 1.4 *************** *** 43,47 **** } ! public void testsprintfBadBuffers() { try { CDLL dll = CDLL.LoadLibrary("msvcrt.dll"); --- 43,47 ---- } ! public void testSprintfBadBuffers() { try { CDLL dll = CDLL.LoadLibrary("msvcrt.dll"); *************** *** 66,70 **** } ! public void testwsprintfGood() { try { CDLL dll = CDLL.LoadLibrary("msvcrt.dll"); --- 66,70 ---- } ! public void testWsprintfGood() { try { CDLL dll = CDLL.LoadLibrary("msvcrt.dll"); *************** *** 86,90 **** } ! public void testsprintfGood() { try { CDLL dll = CDLL.LoadLibrary("msvcrt.dll"); --- 86,90 ---- } ! public void testSprintfGood() { try { CDLL dll = CDLL.LoadLibrary("msvcrt.dll"); --- NEW FILE: PrimitiveTypesMathTest.java --- /* Copyright (c) 2004 Bradley Schatz 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 THE AUTHORS OR COPYRIGHT HOLDERS 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. */ package ctypes.java.test.win32; import junit.framework.TestCase; import ctypes.java.CBuffer; import ctypes.java.CDouble; import ctypes.java.CFloat; import ctypes.java.CFunction; import ctypes.java.CInt; import ctypes.java.CLongLong; import ctypes.java.CType; import ctypes.java.CULong; import ctypes.java.CDLL; /** * @author bradley * * To change the template for this generated type comment go to * Window>Preferences>Java>Code Generation>Code and Comments */ public class PrimitiveTypesMathTest extends TestCase { public PrimitiveTypesMathTest(String arg0) { super(arg0); } public void testDoubleCos() { try { CDLL dll = CDLL.LoadLibrary("msvcrt.dll"); assertTrue(dll.toString().startsWith("CDLL 'msvcrt.dll,'")); CFunction fp = dll.loadFunction("cos"); CDouble a = new CDouble(0); Object[] ary = { a }; CDouble res = (CDouble) fp.call(CDouble.class, ary, CFunction.FUNCFLAG_CDECL); double resv = res.getValue(); assertTrue(resv == (double) 1); } catch (Exception e) { fail(); } } public void testFloatCos() { try { CDLL dll = CDLL.LoadLibrary("msvcrt.dll"); assertTrue(dll.toString().startsWith("CDLL 'msvcrt.dll,'")); CFunction fp = dll.loadFunction("cos"); CFloat a = new CFloat(0); Object[] ary = { a }; CFloat res = (CFloat) fp.call(CFloat.class, ary, CFunction.FUNCFLAG_CDECL); assertTrue(res.getValue() == (float) 1); } catch (Exception e) { fail(); } } public void testIntAbs() { try { CDLL dll = CDLL.LoadLibrary("msvcrt.dll"); assertTrue(dll.toString().startsWith("CDLL 'msvcrt.dll,'")); CFunction fp = dll.loadFunction("abs"); CInt a = new CInt(-1); Object[] ary = { a }; CInt res = (CInt) fp.call(CInt.class, ary, CFunction.FUNCFLAG_CDECL); assertTrue(res.getValue() == (int) 1); } catch (Exception e) { fail(); } } public static void main(String[] args) { junit.textui.TestRunner.run(PrimitiveTypesMathTest.class); } } --- PrimitiveTypesTest.java DELETED --- |
From: Thomas H. <th...@us...> - 2005-04-14 19:11:17
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8641 Modified Files: ChangeLog Log Message: Record changes. Index: ChangeLog =================================================================== RCS file: /cvsroot/ctypes/ctypes/ChangeLog,v retrieving revision 1.88 retrieving revision 1.89 diff -C2 -d -r1.88 -r1.89 *** ChangeLog 7 Apr 2005 10:11:58 -0000 1.88 --- ChangeLog 14 Apr 2005 19:11:06 -0000 1.89 *************** *** 1,2 **** --- 1,8 ---- + 2005-04-14 Thomas Heller <th...@py...> + + * 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-06 Thomas Heller <th...@py...> |
From: Thomas H. <th...@us...> - 2005-04-14 18:55:58
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31935 Modified Files: _ctypes.c Log Message: Fix a crash when a POINTER type has no _type_. No instance of such a type can be created. Reported by Georg Thalhammer, patch provided by Andreas Degert, somewhat modified. Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.299 retrieving revision 1.300 diff -C2 -d -r1.299 -r1.300 *** _ctypes.c 8 Apr 2005 13:33:39 -0000 1.299 --- _ctypes.c 14 Apr 2005 18:55:46 -0000 1.300 *************** *** 1396,1399 **** --- 1396,1400 ---- stgdict->getfunc = fmt->getfunc; stgdict->asparam = Simple_asparam; + //later stgdict->fromparam = fmt->fromparam; /* replace the class dict by the storage dict */ *************** *** 1442,1445 **** --- 1443,1447 ---- Py_INCREF(result); CTYPE_c_void_p = (PyObject *)result; + //later stgdict->fromparam = NULL; break; case 'c': /* c_char */ *************** *** 3588,3591 **** --- 3590,3595 ---- } stgdict = PyObject_stgdict((PyObject *)self); + /* should have been catched in Pointer_new() */ + assert(stgdict->proto); if (!CDataObject_Check(value) || 0 == PyObject_IsInstance(value, stgdict->itemtype)) { *************** *** 3637,3643 **** Pointer_new(PyTypeObject *type, PyObject *args, PyObject *kw) { ! if (!PyType_stgdict((PyObject *)type)) { ! PyErr_SetString(PyExc_RuntimeError, ! "Cannot create instances: has no _type_"); return NULL; } --- 3641,3648 ---- Pointer_new(PyTypeObject *type, PyObject *args, PyObject *kw) { ! StgDictObject *dict = PyType_stgdict(type); ! if (!dict || !dict->itemtype) ! PyErr_SetString(PyExc_TypeError, ! "Cannot create instance: has no _type_"); return NULL; } |
From: Thomas H. <th...@us...> - 2005-04-14 18:48:05
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27053 Modified Files: Tag: branch_1_0 _ctypes.c Log Message: It is not possible to create an instance of a POINTER type which has no _type_. So the check for _type_ in Pointer_set_contents can be removed again. Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.226.2.3 retrieving revision 1.226.2.4 diff -C2 -d -r1.226.2.3 -r1.226.2.4 *** _ctypes.c 14 Apr 2005 18:17:47 -0000 1.226.2.3 --- _ctypes.c 14 Apr 2005 18:47:36 -0000 1.226.2.4 *************** *** 3735,3743 **** } stgdict = PyObject_stgdict((PyObject *)self); ! if (!stgdict->proto) { ! PyErr_SetString(PyExc_TypeError, ! "Pointer can't set content: has no _type_"); ! return -1; ! } if (!CDataObject_Check(value) || 0 == PyObject_IsInstance(value, stgdict->proto)) { --- 3735,3740 ---- } stgdict = PyObject_stgdict((PyObject *)self); ! /* should have been catched in Pointer_new() */ ! assert(stgdict->proto); if (!CDataObject_Check(value) || 0 == PyObject_IsInstance(value, stgdict->proto)) { *************** *** 3809,3815 **** Pointer_new(PyTypeObject *type, PyObject *args, PyObject *kw) { ! if (!PyType_stgdict((PyObject *)type)) { ! PyErr_SetString(PyExc_RuntimeError, ! "Cannot create instances: has no _type_"); return NULL; } --- 3806,3813 ---- Pointer_new(PyTypeObject *type, PyObject *args, PyObject *kw) { ! StgDictObject *dict = PyType_stgdict((PyObject *)type); ! if (!dict || !dict->proto) { ! PyErr_SetString(PyExc_TypeError, ! "Cannot create instance: has no _type_"); return NULL; } |
From: Thomas H. <th...@us...> - 2005-04-14 18:19:17
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10713 Modified Files: Tag: branch_1_0 ChangeLog Log Message: Fix a crash when a POINTER type has no _type_. Patch provided by Andreas Degert. Index: ChangeLog =================================================================== RCS file: /cvsroot/ctypes/ctypes/ChangeLog,v retrieving revision 1.86.2.2 retrieving revision 1.86.2.3 diff -C2 -d -r1.86.2.2 -r1.86.2.3 *** ChangeLog 7 Apr 2005 12:49:35 -0000 1.86.2.2 --- ChangeLog 14 Apr 2005 18:18:56 -0000 1.86.2.3 *************** *** 1,2 **** --- 1,7 ---- + 2005-04-14 Thomas Heller <th...@py...> + + * source/_ctypes.c: Fix a crash when a POINTER type has no _type_. + Patch provided by Andreas Degert. + 2005-04-07 Thomas Heller <th...@py...> |
From: Thomas H. <th...@us...> - 2005-04-14 18:18:05
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10134 Modified Files: Tag: branch_1_0 test_pointers.py Log Message: Fix a crash when a POINTER type has no _type_. Patch provided by Andreas Degert. Index: test_pointers.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_pointers.py,v retrieving revision 1.16 retrieving revision 1.16.6.1 diff -C2 -d -r1.16 -r1.16.6.1 *** test_pointers.py 14 Oct 2004 13:16:13 -0000 1.16 --- test_pointers.py 14 Apr 2005 18:17:56 -0000 1.16.6.1 *************** *** 12,15 **** --- 12,24 ---- class PointersTestCase(unittest.TestCase): + def test_pointer_crash(self): + + class A(POINTER(c_ulong)): + pass + + print POINTER(c_ulong)(c_ulong(22)) + # Pointer can't set contents: has no _type_ + self.failUnlessRaises(TypeError, A, c_ulong(33)) + def test_pass_pointers(self): dll = CDLL(find_test_dll()) |
From: Thomas H. <th...@us...> - 2005-04-14 18:17:56
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10060 Modified Files: Tag: branch_1_0 _ctypes.c Log Message: Fix a crash when a POINTER type has no _type_. Patch provided by Andreas Degert. Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.226.2.2 retrieving revision 1.226.2.3 diff -C2 -d -r1.226.2.2 -r1.226.2.3 *** _ctypes.c 7 Apr 2005 12:50:08 -0000 1.226.2.2 --- _ctypes.c 14 Apr 2005 18:17:47 -0000 1.226.2.3 *************** *** 3735,3738 **** --- 3735,3743 ---- } stgdict = PyObject_stgdict((PyObject *)self); + if (!stgdict->proto) { + PyErr_SetString(PyExc_TypeError, + "Pointer can't set content: has no _type_"); + return -1; + } if (!CDataObject_Check(value) || 0 == PyObject_IsInstance(value, stgdict->proto)) { |
From: Thomas H. <th...@us...> - 2005-04-13 19:57:20
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22063 Added Files: test_repr.py Log Message: Simple types subclasses repr should contain the actual class name, not the base class name. Patch provided by Gregor Thalhammer. --- NEW FILE: test_repr.py --- from ctypes import * import unittest nums = [c_byte, c_short, c_int, c_long, c_longlong, c_ubyte, c_ushort, c_uint, c_ulong, c_ulonglong, c_float, c_double] 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(42", repr(X(42))[:4]) def test_char(self): self.failUnlessEqual("c_char('x')", repr(c_char('x'))) class X(c_char): pass self.failUnlessEqual("X('x')", repr(X('x'))) if __name__ == "__main__": unittest.main() |
From: Thomas H. <th...@us...> - 2005-04-13 19:52:22
|
Update of /cvsroot/ctypes/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18932 Modified Files: __init__.py Log Message: Simple types subclasses repr should contain the actual class name, not the base class name. Patch provided by Gregor Thalhammer. Index: __init__.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/__init__.py,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -d -r1.68 -r1.69 *** __init__.py 12 Apr 2005 19:02:26 -0000 1.68 --- __init__.py 13 Apr 2005 19:51:42 -0000 1.69 *************** *** 140,159 **** _type_ = "h" def __repr__(self): ! return "c_short(%d)" % self.value class c_ushort(_SimpleCData): _type_ = "H" def __repr__(self): ! return "c_ushort(%d)" % self.value class c_long(_SimpleCData): _type_ = "l" def __repr__(self): ! return "c_long(%d)" % self.value class c_ulong(_SimpleCData): _type_ = "L" def __repr__(self): ! return "c_ulong(%d)" % self.value if _calcsize("i") == _calcsize("l"): --- 140,159 ---- _type_ = "h" def __repr__(self): ! return "%s(%d)" % (self.__class__.__name__, self.value) class c_ushort(_SimpleCData): _type_ = "H" def __repr__(self): ! return "%s(%d)" % (self.__class__.__name__, self.value) class c_long(_SimpleCData): _type_ = "l" def __repr__(self): ! return "%s(%d)" % (self.__class__.__name__, self.value) class c_ulong(_SimpleCData): _type_ = "L" def __repr__(self): ! return "%s(%d)" % (self.__class__.__name__, self.value) if _calcsize("i") == _calcsize("l"): *************** *** 165,174 **** _type_ = "i" def __repr__(self): ! return "c_int(%d)" % self.value class c_uint(_SimpleCData): _type_ = "I" def __repr__(self): ! return "c_uint(%d)" % self.value class c_float(_SimpleCData): --- 165,174 ---- _type_ = "i" def __repr__(self): ! return "%s(%d)" % (self.__class__.__name__, self.value) class c_uint(_SimpleCData): _type_ = "I" def __repr__(self): ! return "%s(%d)" % (self.__class__.__name__, self.value) class c_float(_SimpleCData): *************** *** 190,199 **** _type_ = "q" def __repr__(self): ! return "c_longlong(%s)" % self.value class c_ulonglong(_SimpleCData): _type_ = "Q" def __repr__(self): ! return "c_ulonglong(%s)" % self.value ## def from_param(cls, val): ## return ('d', float(val), val) --- 190,199 ---- _type_ = "q" def __repr__(self): ! return "%s(%s)" % (self.__class__.__name__, self.value) class c_ulonglong(_SimpleCData): _type_ = "Q" def __repr__(self): ! return "%s(%s)" % (self.__class__.__name__, self.value) ## def from_param(cls, val): ## return ('d', float(val), val) *************** *** 203,207 **** _type_ = "B" def __repr__(self): ! return "c_ubyte(%s)" % self.value # backward compatibility: ##c_uchar = c_ubyte --- 203,207 ---- _type_ = "B" def __repr__(self): ! return "%s(%s)" % (self.__class__.__name__, self.value) # backward compatibility: ##c_uchar = c_ubyte *************** *** 210,219 **** _type_ = "b" def __repr__(self): ! return "c_byte(%s)" % self.value class c_char(_SimpleCData): _type_ = "c" def __repr__(self): ! return "c_char(%r)" % self.value class c_char_p(_SimpleCData): --- 210,219 ---- _type_ = "b" def __repr__(self): ! return "%s(%s)" % (self.__class__.__name__, self.value) class c_char(_SimpleCData): _type_ = "c" def __repr__(self): ! return "%s(%r)" % (self.__class__.__name__, self.value) class c_char_p(_SimpleCData): *************** *** 263,272 **** _type_ = "u" def __repr__(self): ! return "c_wchar(%r)" % self.value class c_wchar_p(_SimpleCData): _type_ = "Z" def __repr__(self): ! return "%s(%r)" % (self.__class__.__name__, self.value) POINTER(c_wchar).from_param = c_wchar_p.from_param #_SimpleCData.c_wchar_p_from_param --- 263,272 ---- _type_ = "u" def __repr__(self): ! return "%s(%r)" % (self.__class__.__name__, self.value) class c_wchar_p(_SimpleCData): _type_ = "Z" def __repr__(self): ! return "%s(%s)" % (self.__class__.__name__, self.value) POINTER(c_wchar).from_param = c_wchar_p.from_param #_SimpleCData.c_wchar_p_from_param |
From: Thomas H. <th...@us...> - 2005-04-13 19:32:22
|
Update of /cvsroot/ctypes/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7274 Modified Files: Tag: branch_1_0 __init__.py Log Message: Simple types subclasses repr should contain the actual class name, not the base class name. Patch provided by Gregor Thalhammer. Index: __init__.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/__init__.py,v retrieving revision 1.61.2.1 retrieving revision 1.61.2.2 diff -C2 -d -r1.61.2.1 -r1.61.2.2 *** __init__.py 7 Apr 2005 12:49:43 -0000 1.61.2.1 --- __init__.py 13 Apr 2005 19:32:12 -0000 1.61.2.2 *************** *** 133,152 **** _type_ = "h" def __repr__(self): ! return "c_short(%d)" % self.value class c_ushort(_SimpleCData): _type_ = "H" def __repr__(self): ! return "c_ushort(%d)" % self.value class c_long(_SimpleCData): _type_ = "l" def __repr__(self): ! return "c_long(%d)" % self.value class c_ulong(_SimpleCData): _type_ = "L" def __repr__(self): ! return "c_ulong(%d)" % self.value if _calcsize("i") == _calcsize("l"): --- 133,152 ---- _type_ = "h" def __repr__(self): ! return "%s(%d)" % (self.__class__.__name__, self.value) class c_ushort(_SimpleCData): _type_ = "H" def __repr__(self): ! return "%s(%d)" % (self.__class__.__name__, self.value) class c_long(_SimpleCData): _type_ = "l" def __repr__(self): ! return "%s(%d)" % (self.__class__.__name__, self.value) class c_ulong(_SimpleCData): _type_ = "L" def __repr__(self): ! return "%s(%d)" % (self.__class__.__name__, self.value) if _calcsize("i") == _calcsize("l"): *************** *** 158,167 **** _type_ = "i" def __repr__(self): ! return "c_int(%d)" % self.value class c_uint(_SimpleCData): _type_ = "I" def __repr__(self): ! return "c_uint(%d)" % self.value class c_float(_SimpleCData): --- 158,167 ---- _type_ = "i" def __repr__(self): ! return "%s(%d)" % (self.__class__.__name__, self.value) class c_uint(_SimpleCData): _type_ = "I" def __repr__(self): ! return "%s(%d)" % (self.__class__.__name__, self.value) class c_float(_SimpleCData): *************** *** 183,192 **** _type_ = "q" def __repr__(self): ! return "c_longlong(%s)" % self.value class c_ulonglong(_SimpleCData): _type_ = "Q" def __repr__(self): ! return "c_ulonglong(%s)" % self.value ## def from_param(cls, val): ## return ('d', float(val), val) --- 183,192 ---- _type_ = "q" def __repr__(self): ! return "%s(%s)" % (self.__class__.__name__, self.value) class c_ulonglong(_SimpleCData): _type_ = "Q" def __repr__(self): ! return "%s(%s)" % (self.__class__.__name__, self.value) ## def from_param(cls, val): ## return ('d', float(val), val) *************** *** 196,200 **** _type_ = "B" def __repr__(self): ! return "c_ubyte(%s)" % self.value # backward compatibility: ##c_uchar = c_ubyte --- 196,200 ---- _type_ = "B" def __repr__(self): ! return "%s(%s)" % (self.__class__.__name__, self.value) # backward compatibility: ##c_uchar = c_ubyte *************** *** 203,212 **** _type_ = "b" def __repr__(self): ! return "c_byte(%s)" % self.value class c_char(_SimpleCData): _type_ = "c" def __repr__(self): ! return "c_char(%r)" % self.value class c_char_p(_SimpleCData): --- 203,212 ---- _type_ = "b" def __repr__(self): ! return "%s(%s)" % (self.__class__.__name__, self.value) class c_char(_SimpleCData): _type_ = "c" def __repr__(self): ! return "%s(%r)" % (self.__class__.__name__, self.value) class c_char_p(_SimpleCData): *************** *** 275,279 **** _type_ = "u" def __repr__(self): ! return "c_wchar(%r)" % self.value POINTER(c_wchar).from_param = c_wchar_p.from_param #_SimpleCData.c_wchar_p_from_param --- 275,279 ---- _type_ = "u" def __repr__(self): ! return "%s(%r)" % (self.__class__.__name__, self.value) POINTER(c_wchar).from_param = c_wchar_p.from_param #_SimpleCData.c_wchar_p_from_param |
From: Thomas H. <th...@us...> - 2005-04-13 19:31:34
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6941 Added Files: Tag: branch_1_0 test_repr.py Log Message: Simple types subclasses repr should contain the actual class name, not the base class name. Patch provided by Gregor Thalhammer. --- NEW FILE: test_repr.py --- from ctypes import * import unittest nums = [c_byte, c_short, c_int, c_long, c_longlong, c_ubyte, c_ushort, c_uint, c_ulong, c_ulonglong, c_float, c_double] 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(42", repr(X(42))[:4]) def test_char(self): self.failUnlessEqual("c_char('x')", repr(c_char('x'))) class X(c_char): pass self.failUnlessEqual("X('x')", repr(X('x'))) if __name__ == "__main__": unittest.main() |
From: Thomas H. <th...@us...> - 2005-04-12 19:02:53
|
Update of /cvsroot/ctypes/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21832 Modified Files: __init__.py Log Message: Automatic search for .so extension again. Index: __init__.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/__init__.py,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -d -r1.67 -r1.68 *** __init__.py 8 Apr 2005 13:11:22 -0000 1.67 --- __init__.py 12 Apr 2005 19:02:26 -0000 1.68 *************** *** 121,126 **** elif _os.name == "posix": ! from _ctypes import dlopen as _LoadLibrary _FreeLibrary = None from _ctypes import sizeof, byref, addressof, alignment --- 121,133 ---- elif _os.name == "posix": ! from _ctypes import dlopen as _dlopen _FreeLibrary = None + def _LoadLibrary(name): + try: + return _dlopen(name) + except OSError: + if not name.endswith(".so"): + return _dlopen(name + ".so") + raise from _ctypes import sizeof, byref, addressof, alignment |
From: Thomas H. <th...@us...> - 2005-04-12 19:01:44
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21297 Modified Files: test_libc.py Log Message: Index: test_libc.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_libc.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test_libc.py 12 Apr 2005 18:45:51 -0000 1.1 --- test_libc.py 12 Apr 2005 19:01:19 -0000 1.2 *************** *** 6,15 **** if os.name == "nt": return cdll.msvcrt ! else: return cdll.libc libc = get_libc() class LibTest(unittest.TestCase): ! def test_strcpy(self): comparefunc = CFUNCTYPE(c_int, POINTER(c_char), POINTER(c_char)) libc.qsort.argtypes = c_void_p, c_int, c_int, comparefunc --- 6,27 ---- if os.name == "nt": return cdll.msvcrt ! try: ! return CDLL("libc.so.6") ! except OSError: return cdll.libc + libc = get_libc() + libm = cdll.libm class LibTest(unittest.TestCase): ! def test_sqrt(self): ! libm.sqrt.argtypes = c_double, ! libm.sqrt.restype = c_double ! self.failUnlessEqual(libm.sqrt(4.0), 2.0) ! import math ! self.failUnlessEqual(libm.sqrt(2.0), math.sqrt(2.0)) ! ! ! def test_qsort(self): comparefunc = CFUNCTYPE(c_int, POINTER(c_char), POINTER(c_char)) libc.qsort.argtypes = c_void_p, c_int, c_int, comparefunc *************** *** 21,25 **** chars = create_string_buffer("spam, spam, and spam") libc.qsort(chars, len(chars)-1, sizeof(c_char), comparefunc(sort)) ! print repr(chars.raw) if __name__ == "__main__": --- 33,37 ---- chars = create_string_buffer("spam, spam, and spam") libc.qsort(chars, len(chars)-1, sizeof(c_char), comparefunc(sort)) ! self.failUnlessEqual(chars.raw, " ,,aaaadmmmnpppsss\x00") if __name__ == "__main__": |
From: Thomas H. <th...@us...> - 2005-04-12 18:46:01
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12623 Added Files: test_libc.py Log Message: New test. --- NEW FILE: test_libc.py --- from ctypes import * import unittest def get_libc(): import os, sys if os.name == "nt": return cdll.msvcrt else: return cdll.libc libc = get_libc() class LibTest(unittest.TestCase): def test_strcpy(self): comparefunc = CFUNCTYPE(c_int, POINTER(c_char), POINTER(c_char)) libc.qsort.argtypes = c_void_p, c_int, c_int, comparefunc libc.qsort.restype = None def sort(a, b): return cmp(a[0], b[0]) chars = create_string_buffer("spam, spam, and spam") libc.qsort(chars, len(chars)-1, sizeof(c_char), comparefunc(sort)) print repr(chars.raw) if __name__ == "__main__": unittest.main() |
From: Thomas H. <th...@us...> - 2005-04-08 13:33:48
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10935 Modified Files: _ctypes.c Log Message: Convert CFuncPtrObject argtypes into a tuple before storing it. Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.298 retrieving revision 1.299 diff -C2 -d -r1.298 -r1.299 *** _ctypes.c 8 Apr 2005 13:21:30 -0000 1.298 --- _ctypes.c 8 Apr 2005 13:33:39 -0000 1.299 *************** *** 1618,1622 **** if (!converters) goto error; ! Py_INCREF(ob); stgdict->argtypes = ob; stgdict->converters = converters; --- 1618,1624 ---- if (!converters) goto error; ! ob = PySequence_Tuple(ob); ! if (ob == NULL) ! goto error; stgdict->argtypes = ob; stgdict->converters = converters; *************** *** 2135,2146 **** self->argtypes = NULL; } else { converters = converters_from_argtypes(ob); ! if (!converters) return -1; Py_XDECREF(self->converters); self->converters = converters; Py_XDECREF(self->argtypes); ! Py_INCREF(ob); ! self->argtypes = ob; } return 0; --- 2137,2152 ---- self->argtypes = NULL; } else { + PyObject *argtypes = PySequence_Tuple(ob); + if (argtypes == NULL) + return -1; converters = converters_from_argtypes(ob); ! if (!converters) { ! Py_DECREF(argtypes); return -1; + } Py_XDECREF(self->converters); self->converters = converters; Py_XDECREF(self->argtypes); ! self->argtypes = argtypes; } return 0; *************** *** 2789,2793 **** argtypes = self->argtypes ? self->argtypes : dict->argtypes; - pProc = *(void **)self->b_ptr; #ifdef MS_WIN32 --- 2795,2798 ---- |
From: Thomas H. <th...@us...> - 2005-04-08 13:21:40
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4409 Modified Files: ctypes.h callproc.c _ctypes.c Log Message: _CallProc now receives the argtypes tuple as additional argument. Index: ctypes.h =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/ctypes.h,v retrieving revision 1.96 retrieving revision 1.97 diff -C2 -d -r1.96 -r1.97 *** ctypes.h 8 Apr 2005 12:49:22 -0000 1.96 --- ctypes.h 8 Apr 2005 13:21:29 -0000 1.97 *************** *** 289,292 **** --- 289,293 ---- int flags, PyObject *argcnv, + PyObject *argtypes, PyObject *restype, PyObject *checker); Index: callproc.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/callproc.c,v retrieving revision 1.149 retrieving revision 1.150 diff -C2 -d -r1.149 -r1.150 *** callproc.c 8 Apr 2005 13:11:33 -0000 1.149 --- callproc.c 8 Apr 2005 13:21:30 -0000 1.150 *************** *** 715,718 **** --- 715,719 ---- int flags, PyObject *argcnv, /* tuple a converter objects */ + PyObject *argtypes, PyObject *restype, PyObject *checker) *************** *** 990,996 **** NULL, 0, /* flags */ ! NULL, /* self->argtypes */ ! NULL, /* self->restype */ ! NULL); /* checker */ return result; } --- 991,998 ---- NULL, 0, /* flags */ ! NULL, ! NULL, ! NULL, ! NULL); return result; } *************** *** 1017,1024 **** arguments, NULL, ! FUNCFLAG_CDECL, /* flags */ ! NULL, /* self->argtypes */ ! NULL, /* self->restype */ ! NULL); /* checker */ return result; } --- 1019,1027 ---- arguments, NULL, ! FUNCFLAG_CDECL, ! NULL, ! NULL, ! NULL, ! NULL); return result; } Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.297 retrieving revision 1.298 diff -C2 -d -r1.297 -r1.298 *** _ctypes.c 8 Apr 2005 13:11:33 -0000 1.297 --- _ctypes.c 8 Apr 2005 13:21:30 -0000 1.298 *************** *** 2863,2866 **** --- 2863,2867 ---- dict->flags, converters, + argtypes, restype, checker); |
From: Thomas H. <th...@us...> - 2005-04-08 13:11:53
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31299 Modified Files: callproc.c _ctypes.c Log Message: _ctypes now exports the addresses of the memmove and memset functions. Remove the C implementation. Index: callproc.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/callproc.c,v retrieving revision 1.148 retrieving revision 1.149 diff -C2 -d -r1.148 -r1.149 *** callproc.c 8 Apr 2005 12:46:55 -0000 1.148 --- callproc.c 8 Apr 2005 13:11:33 -0000 1.149 *************** *** 879,935 **** } - /* obsolete, should be removed */ - /* Only used by sample code (in samples\Windows\COM.py) */ - static PyObject * - call_commethod(PyObject *self, PyObject *args) - { - IUnknown *pIunk; - int index; - PyObject *arguments; - PPROC *lpVtbl; - PyObject *result; - CDataObject *pcom; - PyObject *argtypes = NULL; - - if (!PyArg_ParseTuple(args, - "OiO!|O!", - &pcom, &index, - &PyTuple_Type, &arguments, - &PyTuple_Type, &argtypes)) - return NULL; - - if (argtypes && (PyTuple_GET_SIZE(arguments) != PyTuple_GET_SIZE(argtypes))) { - PyErr_Format(PyExc_TypeError, - "Method takes %d arguments (%d given)", - PyTuple_GET_SIZE(argtypes), PyTuple_GET_SIZE(arguments)); - return NULL; - } - - if (!CDataObject_Check(pcom) || (pcom->b_size != sizeof(void *))) { - PyErr_Format(PyExc_TypeError, - "COM Pointer expected instead of %s instance", - pcom->ob_type->tp_name); - return NULL; - } - - if ((*(void **)(pcom->b_ptr)) == NULL) { - PyErr_SetString(PyExc_ValueError, - "The COM 'this' pointer is NULL"); - return NULL; - } - - pIunk = (IUnknown *)(*(void **)(pcom->b_ptr)); - lpVtbl = (PPROC *)(pIunk->lpVtbl); - - result = _CallProc(lpVtbl[index], - arguments, - pIunk, - FUNCFLAG_HRESULT, /* flags */ - argtypes, /* self->argtypes */ - NULL, /* self->restype */ - NULL); /* checker */ - return result; - } - static char copy_com_pointer_doc[] = "CopyComPointer(a, b) -> integer\n"; --- 879,882 ---- *************** *** 1260,1320 **** } - /* - Hm, can't we use ctypes itself to implement/access memmove and memset? - The implementations below still lack SEH on windows... - */ - static char memmove_doc[] = - "memmove(dst, src, count) -> adress\n\ - \n\ - Copy count bytes from src to dst, return the dst address as integer.\n"; - - static PyObject * - c_memmove(PyObject *self, PyObject *args) - { - struct argument a_dst, a_src; - int size; - void *c_result; - PyObject *result = NULL; - PyObject *dst, *src; - - memset(&a_dst, 0, sizeof(struct argument)); - memset(&a_src, 0, sizeof(struct argument)); - if (!PyArg_ParseTuple(args, "OOi", &dst, &src, &size)) - return NULL; - if (-1 == PyObject_asparam(dst, &a_dst, 1)) - goto done; - if (-1 == PyObject_asparam(src, &a_src, 2)) - goto done; - c_result = memmove(*(void **)a_dst.pdata, *(void **)a_src.pdata, size); - result = PyLong_FromVoidPtr(c_result); - done: - Py_XDECREF(a_dst.keep); - Py_XDECREF(a_src.keep); - return result; - } - - static char memset_doc[] = - "memset(dst, c, count) -> adress\n\ - \n\ - Set count bytes starting at dst to c, return the dst address as integer.\n"; - static PyObject * - c_memset(PyObject *self, PyObject *args) - { - PyObject *dst, *result; - struct argument a_dst; - void *c_result; - int c, count; - - if (!PyArg_ParseTuple(args, "Oii", &dst, &c, &count)) - return NULL; - memset(&a_dst, 0, sizeof(struct argument)); - if (-1 == PyObject_asparam(dst, &a_dst, 1)) - return NULL; - c_result = memset(*(void **)a_dst.pdata, c, count); - result = PyLong_FromVoidPtr(c_result); - Py_XDECREF(a_dst.keep); - return result; - } - static char string_at_doc[] = "string_at(addr[, size]) -> string\n\ --- 1207,1210 ---- *************** *** 1374,1379 **** PyMethodDef module_methods[] = { {"string_at", string_at, METH_VARARGS, string_at_doc}, - {"memmove", c_memmove, METH_VARARGS, memmove_doc}, - {"memset", c_memset, METH_VARARGS, memset_doc}, {"cast", cast, METH_VARARGS, cast_doc}, #ifdef CTYPES_UNICODE --- 1264,1267 ---- *************** *** 1386,1390 **** {"LoadLibrary", load_library, METH_VARARGS, load_library_doc}, {"FreeLibrary", free_library, METH_VARARGS, free_library_doc}, - {"call_commethod", call_commethod, METH_VARARGS }, {"_check_HRESULT", check_hresult, METH_VARARGS}, #else --- 1274,1277 ---- Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.296 retrieving revision 1.297 diff -C2 -d -r1.296 -r1.297 *** _ctypes.c 8 Apr 2005 11:13:21 -0000 1.296 --- _ctypes.c 8 Apr 2005 13:11:33 -0000 1.297 *************** *** 3876,3879 **** --- 3876,3882 ---- PyModule_AddObject(m, "FUNCFLAG_PYTHONAPI", PyInt_FromLong(FUNCFLAG_PYTHONAPI)); PyModule_AddStringConstant(m, "__version__", "2.0.0.0cvs"); + + PyModule_AddObject(m, "_memmove_adr", PyLong_FromVoidPtr(&memmove)); + PyModule_AddObject(m, "_memset_adr", PyLong_FromVoidPtr(&memset)); PyExc_ArgError = PyErr_NewException("ctypes.ArgumentError", NULL, NULL); |
From: Thomas H. <th...@us...> - 2005-04-08 13:11:32
|
Update of /cvsroot/ctypes/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31243 Modified Files: __init__.py Log Message: _ctypes now exports the addresses of the memmove and memset functions. Remove the C implementation. Index: __init__.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/__init__.py,v retrieving revision 1.66 retrieving revision 1.67 diff -C2 -d -r1.66 -r1.67 *** __init__.py 8 Apr 2005 11:13:11 -0000 1.66 --- __init__.py 8 Apr 2005 13:11:22 -0000 1.67 *************** *** 451,455 **** # functions ! from _ctypes import memmove, memset, string_at, cast from decorators import cdecl --- 451,461 ---- # functions ! from _ctypes import string_at, cast ! ! # _ctypes exports the addresses of the 'memmove' and 'memset' functions. ! from _ctypes import _memmove_adr, _memset_adr ! # we could get fancy here with the argtypes ! memmove = CDLL._CdeclFuncPtr(_memmove_adr) ! memset = CDLL._CdeclFuncPtr(_memset_adr) from decorators import cdecl |
From: Thomas H. <th...@us...> - 2005-04-08 12:49:32
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18145 Modified Files: ctypes.h Log Message: Rename variable. Index: ctypes.h =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/ctypes.h,v retrieving revision 1.95 retrieving revision 1.96 diff -C2 -d -r1.95 -r1.96 *** ctypes.h 8 Apr 2005 07:14:25 -0000 1.95 --- ctypes.h 8 Apr 2005 12:49:22 -0000 1.96 *************** *** 182,185 **** --- 182,186 ---- typedef PyObject *(* SETFUNC)(void *ptr, PyObject* value, unsigned size, PyObject *type); typedef int (* ASPARAM)(CDataObject *self, struct argument *pa); + typedef int (* FROMPARAM)(PyObject *self, PyObject *value, struct argument *pa); /* a table entry describing a predefined ctypes type */ *************** *** 221,224 **** --- 222,226 ---- GETFUNC getfunc; ASPARAM asparam; + // FROMPARAM fromparam; /* Following fields only used by CFuncPtrType_Type instances */ *************** *** 286,290 **** void *pIUnk, int flags, ! PyObject *argtypes, PyObject *restype, PyObject *checker); --- 288,292 ---- void *pIUnk, int flags, ! PyObject *argcnv, PyObject *restype, PyObject *checker); |
From: Thomas H. <th...@us...> - 2005-04-08 12:47:21
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17134 Modified Files: callproc.c Log Message: Rename variables for clarity. Index: callproc.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/callproc.c,v retrieving revision 1.147 retrieving revision 1.148 diff -C2 -d -r1.147 -r1.148 *** callproc.c 8 Apr 2005 12:37:32 -0000 1.147 --- callproc.c 8 Apr 2005 12:46:55 -0000 1.148 *************** *** 714,724 **** void *pIunk, int flags, ! PyObject *argtypes, /* misleading name: This is a method, ! not a type (the .from_param class ! nethod) */ PyObject *restype, PyObject *checker) { ! int i, n, argcount, argtype_count; struct argument *pa; --- 714,722 ---- void *pIunk, int flags, ! PyObject *argcnv, /* tuple a converter objects */ PyObject *restype, PyObject *checker) { ! int i, n, argcount, argcnv_count; struct argument *pa; *************** *** 736,740 **** if (pIunk) ++argcount; ! argtype_count = argtypes ? PyTuple_GET_SIZE(argtypes) : 0; rtype = GetType(restype); --- 734,738 ---- if (pIunk) ++argcount; ! argcnv_count = argcnv ? PyTuple_GET_SIZE(argcnv) : 0; rtype = GetType(restype); *************** *** 760,769 **** arg = PyTuple_GET_ITEM(argtuple, i); /* borrowed ref */ /* For cdecl functions, we allow more actual arguments ! than the length of the argtypes tuple. This is checked in _ctypes::CFuncPtr_Call */ ! if (argtypes && argtype_count > i) { PyObject *v; ! converter = PyTuple_GET_ITEM(argtypes, i); v = PyObject_CallFunctionObjArgs(converter, arg, --- 758,767 ---- arg = PyTuple_GET_ITEM(argtuple, i); /* borrowed ref */ /* For cdecl functions, we allow more actual arguments ! than the length of the argcnv tuple. This is checked in _ctypes::CFuncPtr_Call */ ! if (argcnv && argcnv_count > i) { PyObject *v; ! converter = PyTuple_GET_ITEM(argcnv, i); v = PyObject_CallFunctionObjArgs(converter, arg, |
From: Thomas H. <th...@us...> - 2005-04-08 12:37:44
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11023 Modified Files: callproc.c Log Message: todo comment. Index: callproc.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/callproc.c,v retrieving revision 1.146 retrieving revision 1.147 diff -C2 -d -r1.146 -r1.147 *** callproc.c 8 Apr 2005 07:16:04 -0000 1.146 --- callproc.c 8 Apr 2005 12:37:32 -0000 1.147 *************** *** 1262,1265 **** --- 1262,1269 ---- } + /* + Hm, can't we use ctypes itself to implement/access memmove and memset? + The implementations below still lack SEH on windows... + */ static char memmove_doc[] = "memmove(dst, src, count) -> adress\n\ |
From: Thomas H. <th...@us...> - 2005-04-08 11:13:29
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1047 Modified Files: _ctypes.c Log Message: The instance check for BSTR in CData_clear was killing the performance on non-BSTR simple types. Moved the SysFreeString call into the BSTR class. Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.295 retrieving revision 1.296 diff -C2 -d -r1.295 -r1.296 *** _ctypes.c 8 Apr 2005 07:15:12 -0000 1.295 --- _ctypes.c 8 Apr 2005 11:13:21 -0000 1.296 *************** *** 1823,1837 **** { Py_CLEAR(self->b_objects); - #ifdef MS_WIN32 - if (self->b_base == NULL) { - /* If a BSTR instance owns the memory (b_base is NULL), we - have to call SysFreeString. - */ - if (PyObject_IsInstance((PyObject *)self, CTYPE_BSTR)) { - if (*(BSTR *)self->b_ptr) - SysFreeString(*(BSTR *)self->b_ptr); - } - } - #endif if (self->b_needsfree) PyMem_Free(self->b_ptr); --- 1823,1826 ---- |
From: Thomas H. <th...@us...> - 2005-04-08 11:13:24
|
Update of /cvsroot/ctypes/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv950 Modified Files: __init__.py Log Message: The instance check for BSTR in CData_clear was killing the performance on non-BSTR simple types. Moved the SysFreeString call into the BSTR class. Index: __init__.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/__init__.py,v retrieving revision 1.65 retrieving revision 1.66 diff -C2 -d -r1.65 -r1.66 *** __init__.py 6 Apr 2005 13:16:56 -0000 1.65 --- __init__.py 8 Apr 2005 11:13:11 -0000 1.66 *************** *** 221,231 **** c_voidp = c_void_p # backwards compatibility (to a bug) - if _os.name == "nt": - class BSTR(_SimpleCData): - _type_ = "X" - def __repr__(self): - return "%s(%r)" % (self.__class__.__name__, self.value) - - # This cache maps types to pointers to them. _pointer_type_cache = {} --- 221,224 ---- *************** *** 437,440 **** --- 430,441 ---- oledll = _DLLS(OleDLL) + class BSTR(_SimpleCData): + _type_ = "X" + def __repr__(self): + return "%s(%r)" % (self.__class__.__name__, self.value) + def __del__(self, _free=windll.oleaut32.SysFreeString): + if not self._b_base_: + _free(self) + GetLastError = windll.kernel32.GetLastError |