ctypes-commit Mailing List for ctypes (Page 54)
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...> - 2005-05-11 19:21:27
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32252 Modified Files: Tag: branch_1_0 test_functions.py Log Message: Remove a broken test. Index: test_functions.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_functions.py,v retrieving revision 1.46.2.1 retrieving revision 1.46.2.2 diff -C2 -d -r1.46.2.1 -r1.46.2.2 *** test_functions.py 15 Apr 2005 18:19:56 -0000 1.46.2.1 --- test_functions.py 11 May 2005 19:21:19 -0000 1.46.2.2 *************** *** 189,197 **** self.failUnlessEqual(result.contents.value, 99) - # We need to keep the pointer alive, otherwise the contents change: - result = f(pointer(c_int(99))) - self.failIfEqual(result.contents.value, 99) - - # XXX But this not! WHY on earth? arg = byref(v) result = f(arg) --- 189,192 ---- |
From: Thomas H. <th...@us...> - 2005-05-11 19:17:27
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31314 Modified Files: _ctypes.c Log Message: oops - patch was incomplete. Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.304 retrieving revision 1.305 diff -C2 -d -r1.304 -r1.305 *** _ctypes.c 11 May 2005 19:11:35 -0000 1.304 --- _ctypes.c 11 May 2005 19:17:15 -0000 1.305 *************** *** 1978,1984 **** } ! cmem = (CDataObject *)((PyTypeObject *)type)->tp_new(type, empty_tuple, NULL); if (cmem == NULL) return NULL; if (cmem->b_needsfree) --- 1978,1990 ---- } ! cmem = (CDataObject *)_type_new(type, NULL, NULL); if (cmem == NULL) return NULL; + if (!CDataObject_Check(cmem)) { + Py_DECREF(cmem); + PyErr_SetString(PyExc_TypeError, + "BUG: type call did not return a CDataObject"); + return NULL; + } if (cmem->b_needsfree) |
From: Thomas H. <th...@us...> - 2005-05-11 19:15:24
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30808 Added Files: test_init.py Log Message: Don't call __init__, only __new__, when an ctypes object is retrieved from a base object. --- NEW FILE: test_init.py --- from ctypes import * import unittest class X(Structure): _fields_ = [("a", c_int), ("b", c_int)] def __init__(self): self.a = 9 self.b = 12 class Y(Structure): _fields_ = [("x", X)] class InitTest(unittest.TestCase): def test_get(self): # make sure the only accessing a nested structure # doesn't call the structure's __init__ y = Y() self.failUnlessEqual((y.x.a, y.x.b), (0, 0)) # But explicitely creating an X structure calls __init__, of course. x = X() self.failUnlessEqual((x.a, x.b), (9, 12)) y.x = x self.failUnlessEqual((y.x.a, y.x.b), (9, 12)) if __name__ == "__main__": unittest.main() |
From: Thomas H. <th...@us...> - 2005-05-11 19:13:17
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30127 Modified Files: ctypes.h Log Message: Don't call __init__, only __new__, when an ctypes object is retrieved from a base object. Index: ctypes.h =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/ctypes.h,v retrieving revision 1.97 retrieving revision 1.98 diff -C2 -d -r1.97 -r1.98 *** ctypes.h 8 Apr 2005 13:21:29 -0000 1.97 --- ctypes.h 11 May 2005 19:13:03 -0000 1.98 *************** *** 18,21 **** --- 18,22 ---- typedef int (*THUNK)(void); + typedef struct tagCDataObject CDataObject; /* A default buffer in CDataObject, which can be used for small C types. If *************** *** 44,52 **** */ ! typedef struct tagCDataObject { PyObject_HEAD char *b_ptr; /* pointer to memory block */ int b_needsfree; /* need _we_ free the memory? */ ! struct tagCDataObject *b_base; /* pointer to base object or NULL */ int b_size; /* size of memory block in bytes */ int b_length; /* number of references we need */ --- 45,53 ---- */ ! struct tagCDataObject { PyObject_HEAD char *b_ptr; /* pointer to memory block */ int b_needsfree; /* need _we_ free the memory? */ ! CDataObject *b_base; /* pointer to base object or NULL */ int b_size; /* size of memory block in bytes */ int b_length; /* number of references we need */ *************** *** 55,59 **** PyObject *b_objects; /* list of references we need to keep */ union value b_value; ! } CDataObject; typedef struct { --- 56,60 ---- PyObject *b_objects; /* list of references we need to keep */ union value b_value; ! }; typedef struct { |
From: Thomas H. <th...@us...> - 2005-05-11 19:11:44
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29758 Modified Files: _ctypes.c Log Message: Don't call __init__, only __new__, when an ctypes object is retrieved from a base object. Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.303 retrieving revision 1.304 diff -C2 -d -r1.303 -r1.304 *** _ctypes.c 29 Apr 2005 19:43:50 -0000 1.303 --- _ctypes.c 11 May 2005 19:11:35 -0000 1.304 *************** *** 1946,1953 **** --- 1946,1974 ---- } + static PyObject * + _type_new(PyObject *type, PyObject *args, PyObject *kwds) + { + static PyObject* empty_tuple; + if (!empty_tuple) + empty_tuple = PyTuple_New(0); + if (!PyType_Check(type)) { + PyErr_SetString(PyExc_TypeError, "BUG: expected a type object"); + return NULL; + } + return ((PyTypeObject *)type)->tp_new((PyTypeObject *)type, + args ? args : empty_tuple, kwds); + } + PyObject * CData_FromBaseObj(PyObject *type, PyObject *base, int index, char *adr) { CDataObject *cmem; + static PyObject *empty_tuple; + + if (empty_tuple == NULL) { + empty_tuple = PyTuple_New(0); + if (empty_tuple == NULL) + return NULL; + } if (base && !CDataObject_Check(base)) { *************** *** 1957,1961 **** } ! cmem = (CDataObject *)PyObject_CallFunctionObjArgs(type, NULL); if (cmem == NULL) return NULL; --- 1978,1982 ---- } ! cmem = (CDataObject *)((PyTypeObject *)type)->tp_new(type, empty_tuple, NULL); if (cmem == NULL) return NULL; *************** *** 1991,1995 **** CDataObject *pd; ! pd = (CDataObject *)PyObject_CallFunctionObjArgs(type, NULL); if (!pd) return NULL; --- 2012,2016 ---- CDataObject *pd; ! pd = (CDataObject *)_type_new(type, NULL, NULL); if (!pd) return NULL; *************** *** 2050,2054 **** { CDataObject *obj; ! int size, align, length; StgDictObject *dict; --- 2071,2075 ---- { CDataObject *obj; ! int length; StgDictObject *dict; *************** *** 2060,2065 **** } dict->flags |= DICTFLAG_FINAL; - size = dict->size; - align = dict->align; length = dict->length; --- 2081,2084 ---- |
From: Thomas H. <th...@us...> - 2005-05-11 19:03:00
|
Update of /cvsroot/ctypes/ctypes/unittests/com In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27474 Modified Files: Tag: branch_1_0 test_perf.py Log Message: Even faster now, as a side-effect from not calling __init__ when ctypes instances are accessed from a base object. Index: test_perf.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/com/test_perf.py,v retrieving revision 1.4.2.1 retrieving revision 1.4.2.2 diff -C2 -d -r1.4.2.1 -r1.4.2.2 *** test_perf.py 11 May 2005 18:47:00 -0000 1.4.2.1 --- test_perf.py 11 May 2005 19:02:51 -0000 1.4.2.2 *************** *** 137,157 **** ##ctypes version: 0.9.8 (not yet released, 2005/05/11) ##python version: 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] ! ## 0.40: Class() ## 0.48: POINT() ! ## 0.49: RECT() ! ## 0.25: point.y ! ## 0.63: rect.lr ! ## 0.76: fd.lprgelemdescParam ! ## 1.39: fd.lprgelemdescParam[0] ! ## 1.45: fd.lprgelemdescParam[1] ! ## 2.03: fd.lprgelemdescParam[1].tdesc ! ## 2.26: fd.lprgelemdescParam[1].tdesc.vt ! ## 4.26: fd.lprgelemdescParam[1].tdesc._.lptdesc[0].vt ## 0.48: c_int() ## 0.72: c_int(42) ## 1.75: VARIANT() # ctypes.com ! ## 3.33: variant.value # ctypes.com ! ## 8.51: variant.value = 3.14 # ctypes.com ## 1.46: VARIANT() # comtypes ! ## 3.13: variant.value # comtypes ! ## 8.97: variant.value = 3.14 # comtypes --- 137,157 ---- ##ctypes version: 0.9.8 (not yet released, 2005/05/11) ##python version: 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] ! ## 0.41: Class() ## 0.48: POINT() ! ## 0.48: RECT() ! ## 0.26: point.y ! ## 0.56: rect.lr ! ## 0.61: fd.lprgelemdescParam ! ## 1.14: fd.lprgelemdescParam[0] ! ## 1.20: fd.lprgelemdescParam[1] ! ## 1.76: fd.lprgelemdescParam[1].tdesc ! ## 1.93: fd.lprgelemdescParam[1].tdesc.vt ! ## 3.60: fd.lprgelemdescParam[1].tdesc._.lptdesc[0].vt ## 0.48: c_int() ## 0.72: c_int(42) ## 1.75: VARIANT() # ctypes.com ! ## 3.21: variant.value # ctypes.com ! ## 8.23: variant.value = 3.14 # ctypes.com ## 1.46: VARIANT() # comtypes ! ## 3.11: variant.value # comtypes ! ## 8.57: variant.value = 3.14 # comtypes |
From: Thomas H. <th...@us...> - 2005-05-11 18:56:37
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25170 Modified Files: Tag: branch_1_0 _ctypes.c Log Message: Don't call __init__, only __new__, when an ctypes object is retrieved from a base object. Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.226.2.9 retrieving revision 1.226.2.10 diff -C2 -d -r1.226.2.9 -r1.226.2.10 *** _ctypes.c 6 May 2005 18:37:09 -0000 1.226.2.9 --- _ctypes.c 11 May 2005 18:56:28 -0000 1.226.2.10 *************** *** 1814,1821 **** --- 1814,1843 ---- } + + static PyObject * + _type_new(PyObject *type, PyObject *args, PyObject *kwds) + { + static PyObject* empty_tuple; + if (!empty_tuple) + empty_tuple = PyTuple_New(0); + if (!PyType_Check(type)) { + PyErr_SetString(PyExc_TypeError, "BUG: expected a type object"); + return NULL; + } + return ((PyTypeObject *)type)->tp_new((PyTypeObject *)type, + args ? args : empty_tuple, kwds); + } + static PyObject * CData_FromBaseObj(PyObject *type, PyObject *base, int index, char *adr) { CDataObject *cmem; + static PyObject *empty_tuple; + + if (empty_tuple == NULL) { + empty_tuple = PyTuple_New(0); + if (empty_tuple == NULL) + return NULL; + } if (base && !CDataObject_Check(base)) { *************** *** 1825,1831 **** } ! cmem = (CDataObject *)PyObject_CallFunctionObjArgs(type, NULL); if (cmem == NULL) return NULL; if (cmem->b_needsfree) --- 1847,1859 ---- } ! cmem = (CDataObject *)_type_new(type, NULL, NULL); if (cmem == NULL) return NULL; + if (!CDataObject_Check(cmem)) { + Py_DECREF(cmem); + PyErr_SetString(PyExc_TypeError, + "BUG: type call did not return a CDataObject"); + return NULL; + } if (cmem->b_needsfree) *************** *** 1858,1862 **** CDataObject *pd; ! pd = (CDataObject *)PyObject_CallFunctionObjArgs(type, NULL); if (!pd) return NULL; --- 1886,1890 ---- CDataObject *pd; ! pd = (CDataObject *)_type_new(type, NULL, NULL); if (!pd) return NULL; *************** *** 2020,2024 **** { CDataObject *obj; ! int size, align, length; StgDictObject *dict; --- 2048,2052 ---- { CDataObject *obj; ! int length; StgDictObject *dict; *************** *** 2030,2035 **** } dict->flags |= DICTFLAG_FINAL; - size = dict->size; - align = dict->align; length = dict->length; --- 2058,2061 ---- |
From: Thomas H. <th...@us...> - 2005-05-11 18:47:08
|
Update of /cvsroot/ctypes/ctypes/unittests/com In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23103 Modified Files: Tag: branch_1_0 test_perf.py Log Message: Recent test results. Index: test_perf.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/com/test_perf.py,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -C2 -d -r1.4 -r1.4.2.1 *** test_perf.py 9 Mar 2005 20:29:09 -0000 1.4 --- test_perf.py 11 May 2005 18:47:00 -0000 1.4.2.1 *************** *** 29,38 **** pass - def get_fd(): ! # get a FUNCDESC instance ! from ctypes.com.client import Dispatch ! d = Dispatch("InternetExplorer.Application") ! return d.Navigate.fd ################################################################ --- 29,42 ---- pass def get_fd(): ! # get a FUNCDESC instance from a typelib ! from comtypes.typeinfo import LoadTypeLibEx ! from comtypes import GUID ! tlib = LoadTypeLibEx("shdocvw.dll") ! # IWebBrowser interface ! tinfo = tlib.GetTypeInfoOfGuid(GUID("{EAB22AC1-30C1-11CF-A7EB-0000C05BAE0B}")) ! tcomp = tinfo.GetTypeComp() ! kind, fd = tcomp.Bind("Navigate") ! return fd ################################################################ *************** *** 63,67 **** "fd.lprgelemdescParam[1].tdesc.vt") timeit("-s", "from test_perf import get_fd; fd = get_fd()", ! "fd.lprgelemdescParam[1].tdesc.u.lptdesc[0].vt") timeit('-s', "from ctypes import c_int", "c_int()") --- 67,71 ---- "fd.lprgelemdescParam[1].tdesc.vt") timeit("-s", "from test_perf import get_fd; fd = get_fd()", ! "fd.lprgelemdescParam[1].tdesc._.lptdesc[0].vt") timeit('-s', "from ctypes import c_int", "c_int()") *************** *** 87,91 **** "variant.value = 3.14 # comtypes") ! # on my machine: ##ctypes version: 0.9.2 --- 91,95 ---- "variant.value = 3.14 # comtypes") ! # on my machine which has around 30000 pystones/second: ##ctypes version: 0.9.2 *************** *** 130,131 **** --- 134,157 ---- ## 4.99: variant.value # comtypes ## 11.40: variant.value = 3.14 # comtypes + + ##ctypes version: 0.9.8 (not yet released, 2005/05/11) + ##python version: 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] + ## 0.40: Class() + ## 0.48: POINT() + ## 0.49: RECT() + ## 0.25: point.y + ## 0.63: rect.lr + ## 0.76: fd.lprgelemdescParam + ## 1.39: fd.lprgelemdescParam[0] + ## 1.45: fd.lprgelemdescParam[1] + ## 2.03: fd.lprgelemdescParam[1].tdesc + ## 2.26: fd.lprgelemdescParam[1].tdesc.vt + ## 4.26: fd.lprgelemdescParam[1].tdesc._.lptdesc[0].vt + ## 0.48: c_int() + ## 0.72: c_int(42) + ## 1.75: VARIANT() # ctypes.com + ## 3.33: variant.value # ctypes.com + ## 8.51: variant.value = 3.14 # ctypes.com + ## 1.46: VARIANT() # comtypes + ## 3.13: variant.value # comtypes + ## 8.97: variant.value = 3.14 # comtypes |
From: Thomas H. <th...@us...> - 2005-05-11 18:28:46
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18879 Added Files: Tag: branch_1_0 test_init.py Log Message: New test. --- NEW FILE: test_init.py --- from ctypes import * import unittest class X(Structure): _fields_ = [("a", c_int), ("b", c_int)] def __init__(self): self.a = 9 self.b = 12 class Y(Structure): _fields_ = [("x", X)] class InitTest(unittest.TestCase): def test_get(self): # make sure the only accessing a nested structure # doesn't call the structure's __init__ y = Y() self.failUnlessEqual((y.x.a, y.x.b), (0, 0)) # But explicitely creating an X structure calls __init__, of course. x = X() self.failUnlessEqual((x.a, x.b), (9, 12)) y.x = x self.failUnlessEqual((y.x.a, y.x.b), (9, 12)) if __name__ == "__main__": unittest.main() |
From: Thomas H. <th...@us...> - 2005-05-11 15:09:46
|
Update of /cvsroot/ctypes/ctypes/win32/com In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6436 Modified Files: Tag: branch_1_0 __init__.py Log Message: Only call the _factory's LockServer method if a _factory is present. Index: __init__.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/win32/com/__init__.py,v retrieving revision 1.42 retrieving revision 1.42.2.1 diff -C2 -d -r1.42 -r1.42.2.1 *** __init__.py 2 Dec 2004 08:02:39 -0000 1.42 --- __init__.py 11 May 2005 15:09:36 -0000 1.42.2.1 *************** *** 4,8 **** from ctypes.wintypes import DWORD, WORD, BYTE ! DEBUG = __debug__ # enable debugging output (via Windows' OutputDebugString) from ctypes import HRESULT --- 4,8 ---- from ctypes.wintypes import DWORD, WORD, BYTE ! DEBUG = False from ctypes import HRESULT *************** *** 343,352 **** def AddRef(self, this): self._refcnt += 1 ! self._factory.LockServer(None, 1) return self._refcnt def Release(self, this): self._refcnt -= 1 ! self._factory.LockServer(None, 0) # Later ## if self._refcnt == 0: --- 343,354 ---- def AddRef(self, this): self._refcnt += 1 ! if self._factory: ! self._factory.LockServer(None, 1) return self._refcnt def Release(self, this): self._refcnt -= 1 ! if self._factory: ! self._factory.LockServer(None, 0) # Later ## if self._refcnt == 0: |
From: Thomas H. <th...@us...> - 2005-05-11 12:50:35
|
Update of /cvsroot/ctypes/ctypes/comtypes/samples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7758 Modified Files: Tag: branch_1_0 mstask.py Log Message: Add TASK flags. Index: mstask.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/samples/mstask.py,v retrieving revision 1.2.2.2 retrieving revision 1.2.2.3 diff -C2 -d -r1.2.2.2 -r1.2.2.3 *** mstask.py 25 Apr 2005 14:30:39 -0000 1.2.2.2 --- mstask.py 11 May 2005 12:50:26 -0000 1.2.2.3 *************** *** 36,40 **** from comtypes import defaultvalue ! ##WCHAR = c_wchar LPCWSTR = c_wchar_p #POINTER(WCHAR) LPWSTR = c_wchar_p #POINTER(WCHAR) --- 36,45 ---- from comtypes import defaultvalue ! # The code generation emitted ! # WCHAR = c_wchar ! # LPCWSTR = POINTER(WCHAR) ! # LPWSTR = POINTER(WCHAR) ! # but we redefine because LPCWSTR and LPWSTR are always zero-terminated strings here. ! LPCWSTR = c_wchar_p #POINTER(WCHAR) LPWSTR = c_wchar_p #POINTER(WCHAR) *************** *** 45,48 **** --- 50,54 ---- ################################################################ + # SYSTEMTIME should probably move elsewhere - wintypes.py ? class _SYSTEMTIME(Structure): _fields_ = [ *************** *** 57,65 **** ] def __repr__(self): ! return "SystemTime(%s/%s/%s %d:%02d:%02d)" % (self.wYear, self.wMonth, self.wDay, ! self.wHour, self.wMinute, self.wSecond) LPSYSTEMTIME = POINTER(_SYSTEMTIME) SYSTEMTIME = _SYSTEMTIME _TASK_TRIGGER_TYPE = c_int # enum TASK_TIME_TRIGGER_ONCE = 0 --- 63,86 ---- ] def __repr__(self): ! return "SystemTime(%s/%s/%s %d:%02d:%2.3f)" % \ ! (self.wYear, self.wMonth, self.wDay, ! self.wHour, self.wMinute, self.wSecond + self.wMilliseconds / 1000.) LPSYSTEMTIME = POINTER(_SYSTEMTIME) SYSTEMTIME = _SYSTEMTIME + TASK_FLAG_INTERACTIVE = (0x1) + TASK_FLAG_DELETE_WHEN_DONE = (0x2) + TASK_FLAG_DISABLED = (0x4) + TASK_FLAG_START_ONLY_IF_IDLE = (0x10) + TASK_FLAG_KILL_ON_IDLE_END = (0x20) + TASK_FLAG_DONT_START_IF_ON_BATTERIES = (0x40) + TASK_FLAG_KILL_IF_GOING_ON_BATTERIES = (0x80) + TASK_FLAG_RUN_ONLY_IF_DOCKED = (0x100) + TASK_FLAG_HIDDEN = (0x200) + TASK_FLAG_RUN_IF_CONNECTED_TO_INTERNET = (0x400) + TASK_FLAG_RESTART_ON_IDLE_RESUME = (0x800) + TASK_FLAG_SYSTEM_REQUIRED = (0x1000) + TASK_FLAG_RUN_ONLY_IF_LOGGED_ON = (0x2000) + _TASK_TRIGGER_TYPE = c_int # enum TASK_TIME_TRIGGER_ONCE = 0 *************** *** 254,258 **** ( ["in"], LPSYSTEMTIME ), ( ["out", "in"], POINTER(WORD) ), - ## ( ["in"], POINTER(WORD) ), ( ["out"], POINTER(LPSYSTEMTIME) ), ), --- 275,278 ---- *************** *** 399,403 **** print "Nothing" ## print task.EditWorkItem(None, 0) ! print "XXX", task.GetNextRunTime() ## t = SYSTEMTIME() ## t.wYear = 2000 --- 419,424 ---- print "Nothing" ## print task.EditWorkItem(None, 0) ! next = task.GetNextRunTime() ! print task.GetRunTimes(byref(next), None, 3) ## t = SYSTEMTIME() ## t.wYear = 2000 *************** *** 412,418 **** ## t = pointer(t[1]) - for i in range(3): - print task.CreateTrigger() - for i in range(task.GetTriggerCount()): try: --- 433,436 ---- |
From: Thomas H. <th...@us...> - 2005-05-11 12:49:45
|
Update of /cvsroot/ctypes/ctypes/comtypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7512 Modified Files: Tag: branch_1_0 typeinfo.py Log Message: Remove double import- Index: typeinfo.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/typeinfo.py,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -C2 -d -r1.3 -r1.3.2.1 *** typeinfo.py 16 Mar 2005 16:34:05 -0000 1.3 --- typeinfo.py 11 May 2005 12:49:36 -0000 1.3.2.1 *************** *** 17,21 **** from comtypes.automation import IID from comtypes.automation import IUnknown - from comtypes.automation import IUnknown from comtypes.automation import LCID from comtypes.automation import LONG --- 17,20 ---- |
From: Thomas H. <th...@us...> - 2005-05-11 12:48:39
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7247 Modified Files: Tag: branch_1_0 ChangeLog Log Message: Record changes. Index: ChangeLog =================================================================== RCS file: /cvsroot/ctypes/ctypes/ChangeLog,v retrieving revision 1.86.2.5 retrieving revision 1.86.2.6 diff -C2 -d -r1.86.2.5 -r1.86.2.6 *** ChangeLog 29 Apr 2005 19:04:37 -0000 1.86.2.5 --- ChangeLog 11 May 2005 12:48:28 -0000 1.86.2.6 *************** *** 1,2 **** --- 1,12 ---- + 2005-05-06 Thomas Heller <th...@py...> + + * source/_ctypes.c: Clearer code, less code, and greater + performance by reworking CData_FromBaseObj. + + * source/_ctypes.c, source/ctypes.h: CDataObject and + CFuncPtrObject now have a small buffer. If the C type fits into + that it is used, otherwise PyMem_Malloc() is called to create a + bigger one. This speeds up instance creation a lot. + 2005-04-22 Thomas Heller <th...@py...> |
From: Thomas H. <th...@us...> - 2005-05-06 18:37:21
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27914 Modified Files: Tag: branch_1_0 _ctypes.c Log Message: Backport from trunk: Clearer code, less code, greater performance by reworking CData_FromBaseObj. Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.226.2.8 retrieving revision 1.226.2.9 diff -C2 -d -r1.226.2.8 -r1.226.2.9 *** _ctypes.c 6 May 2005 17:59:56 -0000 1.226.2.8 --- _ctypes.c 6 May 2005 18:37:09 -0000 1.226.2.9 *************** *** 1684,1690 **** CData_Type */ - - char basespec_string[] = "base specification"; - static int CData_traverse(CDataObject *self, visitproc visit, void *arg) --- 1684,1687 ---- *************** *** 1800,1844 **** }; ! /* ! * Trick #17: Pass a PyCObject named _basespec_ to the tp_new constructor, ! * then let tp_new remove it from the keyword dict, so that tp_init doesn't ! * get confused by it. ! * ! */ ! ! /* ! * If base is NULL, index is ignored, and baseofs is cast to a pointer ! * and used as the buffer of the new instance. ! * ! * If base is not NULL, it must be a CDataObject. ! * The new instance is a kind of 'slice' of the base object. ! * It shares base's pointer at offset baseofs, and uses index ! * in the base's object list to keep its references. ! * ! * In the latter case, the new instance shares the buffer of base. ! * ! * Box a memory block into a CData instance: ! * CData_AtAddress(PyObject *type, void *buf); ! * ! * Create a CData instance as 'slice' of a base object: ! * CData_FromBaseObj(PyObject *type, PyObject *base, int index, int baseofs); ! * ! */ ! ! /* ! XXX: The trick above is slow... Much faster is it, as it seems, to create ! the new instance as if it were standalone, and then patch it afterwards - ! even if this means we must PyMem_Free the just allocated memory. ! ! Fix later. ! */ static PyObject * CData_FromBaseObj(PyObject *type, PyObject *base, int index, char *adr) { ! struct basespec spec; ! PyObject *cobj; ! PyObject *mem; ! PyObject *args, *kw; ! CDataObject *cd; if (base && !CDataObject_Check(base)) { --- 1797,1821 ---- }; ! static void CData_MallocBuffer(CDataObject *obj, StgDictObject *dict) ! { ! if (dict->size <= sizeof(obj->b_value)) { ! /* No need to call malloc, can use the default buffer */ ! obj->b_ptr = (char *)&obj->b_value; ! obj->b_needsfree = 0; ! } else { ! /* In python 2.4, and ctypes 0.9.6, the malloc call took about ! 33% of the creation time for c_int(). ! */ ! obj->b_ptr = PyMem_Malloc(dict->size); ! obj->b_needsfree = 1; ! memset(obj->b_ptr, 0, dict->size); ! } ! obj->b_size = dict->size; ! } ! static PyObject * CData_FromBaseObj(PyObject *type, PyObject *base, int index, char *adr) { ! CDataObject *cmem; if (base && !CDataObject_Check(base)) { *************** *** 1848,1877 **** } ! spec.base = (CDataObject *)base; ! spec.adr = adr; ! spec.index = index; ! cobj = PyCObject_FromVoidPtrAndDesc(&spec, basespec_string, NULL); ! kw = Py_BuildValue("{s:O}", "_basespec_", cobj); ! args = PyTuple_New(0); ! ! mem = PyObject_Call(type, args, kw); ! Py_DECREF(kw); ! Py_DECREF(args); ! if (mem == NULL) return NULL; - - /* XXX cobj will be invalid once we leave this function! */ - assert(cobj->ob_refcnt == 1); - Py_DECREF(cobj); ! cd = (CDataObject *)mem; ! ! return mem; } ! PyObject * CData_AtAddress(PyObject *type, void *buf) { ! return CData_FromBaseObj(type, NULL, 0, buf); } --- 1825,1876 ---- } ! cmem = (CDataObject *)PyObject_CallFunctionObjArgs(type, NULL); ! if (cmem == NULL) return NULL; ! if (cmem->b_needsfree) ! PyMem_Free(cmem->b_ptr); ! cmem->b_ptr = NULL; ! if (base) { /* use base's buffer */ ! cmem->b_ptr = adr; ! cmem->b_needsfree = 0; ! Py_INCREF(base); ! cmem->b_base = (CDataObject *)base; ! cmem->b_index = index; ! } else { /* copy contents of adr */ ! StgDictObject *dict = PyType_stgdict(type); ! CData_MallocBuffer(cmem, PyType_stgdict(type)); ! memcpy(cmem->b_ptr, adr, dict->size); ! cmem->b_index = index; ! } ! return (PyObject *)cmem; } ! /* ! Box a memory block into a CData instance. ! ! We create an new instance, free the memory it contains, and fill in the ! memory pointer afterwards. ! */ ! static PyObject * CData_AtAddress(PyObject *type, void *buf) { ! CDataObject *pd; ! ! pd = (CDataObject *)PyObject_CallFunctionObjArgs(type, NULL); ! if (!pd) ! return NULL; ! if (!CDataObject_Check(pd)) { ! Py_DECREF(pd); ! PyErr_SetString(PyExc_TypeError, ! "BUG: type call did not return a CDataObject"); ! return NULL; ! } ! if (pd->b_needsfree) { ! pd->b_needsfree = 0; ! PyMem_Free(pd->b_ptr); ! } ! pd->b_ptr = buf; ! return (PyObject *)pd; } *************** *** 2017,2043 **** /******************************************************************/ - static void CData_MallocBuffer(CDataObject *obj, StgDictObject *dict) - { - if (dict->size <= sizeof(obj->b_value)) { - /* No need to call malloc, can use the default buffer */ - obj->b_ptr = (char *)&obj->b_value; - obj->b_needsfree = 0; - } else { - /* In python 2.4, and ctypes 0.9.6, the malloc call took about - 33% of the creation time for c_int(). - */ - obj->b_ptr = PyMem_Malloc(dict->size); - obj->b_needsfree = 1; - memset(obj->b_ptr, 0, dict->size); - } - obj->b_size = dict->size; - } - - static PyObject * GenericCData_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { CDataObject *obj; - PyObject *basespec = NULL; int size, align, length; StgDictObject *dict; --- 2016,2023 ---- *************** *** 2054,2123 **** length = dict->length; - if (kwds) - basespec = PyDict_GetItemString(kwds, "_basespec_"); - obj = (CDataObject *)type->tp_alloc(type, 0); if (!obj) return NULL; - /* Three different cases: - * - no basespec object in kwds: Allocate new memory - * - basespec->base is set: - * This is the base object owning the buffer, - * index and offset must be set - * - basespec->base is NULL: - * index is ignored, offset contains the buffer address to use. - */ ! if (basespec) { ! struct basespec *spec; ! void *descr; ! ! descr = PyCObject_GetDesc(basespec); ! if (!descr) { ! Py_DECREF(obj); ! return NULL; ! } ! if (descr != basespec_string) { ! PyErr_SetString(PyExc_TypeError, "invalid object"); ! Py_DECREF(obj); ! return NULL; ! } ! spec = PyCObject_AsVoidPtr(basespec); ! ! if (spec->base) { ! Py_INCREF(spec->base); ! obj->b_base = spec->base; ! obj->b_index = spec->index; ! ! obj->b_objects = NULL; ! obj->b_length = length; ! ! obj->b_ptr = spec->adr; ! obj->b_size = size; ! obj->b_needsfree = 0; ! } else { ! obj->b_base = NULL; ! obj->b_index = 0; ! obj->b_objects = NULL; ! obj->b_length = length; ! obj->b_ptr = spec->adr; ! obj->b_size = size; ! obj->b_needsfree = 0; ! } ! /* don't pass this to tp_init! */ ! if (-1 == PyDict_DelItemString(kwds, "_basespec_")) { ! Py_DECREF(obj); ! return NULL; ! } ! ! } else { ! obj->b_base = NULL; ! obj->b_index = 0; ! obj->b_objects = NULL; ! obj->b_length = length; ! ! CData_MallocBuffer(obj, dict); ! } return (PyObject *)obj; } --- 2034,2047 ---- length = dict->length; obj = (CDataObject *)type->tp_alloc(type, 0); if (!obj) return NULL; ! obj->b_base = NULL; ! obj->b_index = 0; ! obj->b_objects = NULL; ! obj->b_length = length; ! CData_MallocBuffer(obj, dict); return (PyObject *)obj; } *************** *** 2452,2459 **** THUNK thunk; ! if (kwds && PyDict_GetItemString(kwds, "_basespec_")) { return GenericCData_new(type, args, kwds); - } if (2 <= PyTuple_GET_SIZE(args)) { #ifdef MS_WIN32 --- 2376,2383 ---- THUNK thunk; ! if (PyTuple_GET_SIZE(args) == 0) return GenericCData_new(type, args, kwds); + /* Shouldn't the following better be done in __init__? */ if (2 <= PyTuple_GET_SIZE(args)) { #ifdef MS_WIN32 |
From: Thomas H. <th...@us...> - 2005-05-06 18:00:08
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17183 Modified Files: Tag: branch_1_0 ctypes.h _ctypes.c Log Message: Backport from trunk: CDataObject and CFuncPtrObject now have a small buffer. If the C type fits into that it is used, otherwise PyMem_Malloc() is called to create a bigger one. This speeds up instance creation a lot. Index: ctypes.h =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/ctypes.h,v retrieving revision 1.74 retrieving revision 1.74.2.1 diff -C2 -d -r1.74 -r1.74.2.1 *** ctypes.h 16 Mar 2005 17:50:25 -0000 1.74 --- ctypes.h 6 May 2005 17:59:56 -0000 1.74.2.1 *************** *** 17,22 **** #endif - typedef struct tagCDataObject CDataObject; typedef int (*THUNK)(void); /* --- 17,41 ---- #endif typedef int (*THUNK)(void); + typedef struct tagCDataObject CDataObject; + + /* A default buffer in CDataObject, which can be used for small C types. If + this buffer is too small, PyMem_Malloc will be called to create a larger one, + and this one is not used. + + Making CDataObject a variable size object would be a better solution, but more + difficult in the presence of CFuncPtrObject. Maybe later. + */ + union value { + char c[16]; + short s; + int i; + long l; + float f; + double d; + #ifdef HAVE_LONG_LONG + PY_LONG_LONG ll; + #endif + }; /* *************** *** 36,39 **** --- 55,59 ---- b_object list */ PyObject *b_objects; /* list of references we need to keep */ + union value b_value; }; *************** *** 49,52 **** --- 69,73 ---- b_object list */ PyObject *b_objects; /* list of references we need to keep */ + union value b_value; /* end of tagCDataObject, additional fields follow */ Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.226.2.7 retrieving revision 1.226.2.8 diff -C2 -d -r1.226.2.7 -r1.226.2.8 *** _ctypes.c 29 Apr 2005 20:28:35 -0000 1.226.2.7 --- _ctypes.c 6 May 2005 17:59:56 -0000 1.226.2.8 *************** *** 2017,2020 **** --- 2017,2038 ---- /******************************************************************/ + static void CData_MallocBuffer(CDataObject *obj, StgDictObject *dict) + { + if (dict->size <= sizeof(obj->b_value)) { + /* No need to call malloc, can use the default buffer */ + obj->b_ptr = (char *)&obj->b_value; + obj->b_needsfree = 0; + } else { + /* In python 2.4, and ctypes 0.9.6, the malloc call took about + 33% of the creation time for c_int(). + */ + obj->b_ptr = PyMem_Malloc(dict->size); + obj->b_needsfree = 1; + memset(obj->b_ptr, 0, dict->size); + } + obj->b_size = dict->size; + } + + static PyObject * GenericCData_new(PyTypeObject *type, PyObject *args, PyObject *kwds) *************** *** 2100,2111 **** obj->b_length = length; ! /* 0.7 us in Python 2.3, 20 % of total creation time for c_int() */ ! /* same ABSOLUTE time, but smaller percentage in Python 2.2 */ ! /* We could save this time if the buffer in this case ! would be part of the object already */ ! obj->b_ptr = PyMem_Malloc(size); ! obj->b_size = size; ! obj->b_needsfree = 1; ! memset(obj->b_ptr, 0, size); } return (PyObject *)obj; --- 2118,2122 ---- obj->b_length = length; ! CData_MallocBuffer(obj, dict); } return (PyObject *)obj; |
From: Thomas H. <th...@us...> - 2005-05-06 12:18:07
|
Update of /cvsroot/ctypes/ctypes/win32/com In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25719 Modified Files: Tag: branch_1_0 ChangeLog Log Message: Recent changes. Index: ChangeLog =================================================================== RCS file: /cvsroot/ctypes/ctypes/win32/com/ChangeLog,v retrieving revision 1.8 retrieving revision 1.8.4.1 diff -C2 -d -r1.8 -r1.8.4.1 *** ChangeLog 7 Sep 2004 06:39:52 -0000 1.8 --- ChangeLog 6 May 2005 12:17:55 -0000 1.8.4.1 *************** *** 1,2 **** --- 1,13 ---- + 2005-05-06 Thomas Heller <th...@py...> + + * ctypes/com/automation.py: Added a DualObjWithEvents base class + for implementing COM objects with dual interface supporting events + delivered via connection point. + + * ctypes/com/hresult.py: Added connection point error codes. + + * ctypes/com/connectionpoints.py: Added a ConnectionPoint + implementation. + 2004-09-06 Thomas Heller <th...@py...> |
From: Thomas H. <th...@us...> - 2005-05-06 09:58:53
|
Update of /cvsroot/ctypes/ctypes/win32/com In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27455 Modified Files: Tag: branch_1_0 automation.py Log Message: Add a DualObjWithEvents base class for implementing COM objects with dual interface supporting events delivered via connection point. Index: automation.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/win32/com/automation.py,v retrieving revision 1.21.2.1 retrieving revision 1.21.2.2 diff -C2 -d -r1.21.2.1 -r1.21.2.2 *** automation.py 29 Apr 2005 20:28:57 -0000 1.21.2.1 --- automation.py 6 May 2005 09:58:43 -0000 1.21.2.2 *************** *** 790,793 **** --- 790,794 ---- ################################################################ + # A base class for an object implementing a dual COM interface, class DualObjImpl(COMObject): *************** *** 845,848 **** --- 846,880 ---- ################################################################ + # A base class for an object implementing a dual COM interface, which + # also implements IConnectionPointContainer for a single outgoing + # interface. + from ctypes.com.connectionpoints import IConnectionPoint, ConnectionPoint + class DualObjWithEventsImpl(DualObjImpl): + def __init__(self): + super(DualObjWithEventsImpl, self).__init__() + from ctypes.com.client import GetContainingTypeLib, GetTypeInfoOfGuid + tlib = GetContainingTypeLib(self.typeinfo) + typeinfo = GetTypeInfoOfGuid(tlib, self._outgoing_interface_._iid_) + self._connectionpoint = ConnectionPoint(self._outgoing_interface_, typeinfo) + + # IConnectionPointContainer methods + def IConnectionPointContainer_FindConnectionPoint(self, this, refiid, ppcp): + if not ppcp: + return E_POINTER + if self._outgoing_interface_._iid_ != refiid[0]: + return CONNECT_E_NOCONNECTION + # 'byref' will not work in this case, since the QueryInterface + # method implementation is called on Python directly. There's + # no C layer between which will convert the second parameter + # from byref() to a pointer. + return self._connectionpoint.QueryInterface(None, pointer(IConnectionPoint._iid_), ppcp) + + def IConnectionPointContainer_EnumConnectionPoints(self, this, ppEnum): + # according to MSDN, E_NOTIMPL is specificially disallowed + # because, without typeinfo, there's no way for the caller to + # find out. Since we provide typeinfo, we ignore this. + return E_NOTIMPL + + ################################################################ # The following two are used by the readtlb tool |
From: Thomas H. <th...@us...> - 2005-05-06 09:56:24
|
Update of /cvsroot/ctypes/ctypes/win32/com In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26836 Modified Files: Tag: branch_1_0 connectionpoints.py Log Message: Add a ConnectionPoint object implementation. Index: connectionpoints.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/win32/com/connectionpoints.py,v retrieving revision 1.10 retrieving revision 1.10.4.1 diff -C2 -d -r1.10 -r1.10.4.1 *** connectionpoints.py 21 Apr 2004 18:07:34 -0000 1.10 --- connectionpoints.py 6 May 2005 09:56:12 -0000 1.10.4.1 *************** *** 1,4 **** --- 1,5 ---- # connect.py - ConnectionPoint support from ctypes import * + from ctypes.com.hresult import * from ctypes.com import IUnknown, GUID, REFIID, STDMETHOD, HRESULT, COMObject from ctypes.wintypes import DWORD *************** *** 62,65 **** --- 63,139 ---- ################################################################ + class ConnectionPoint(COMObject): + # A simple ConnectionPoint implementation + _com_interfaces_ = [IConnectionPoint] + + def __init__(self, sink_interface, sink_typeinfo): + COMObject.__init__(self) + self._connections = {} + self._cookie = 0 + self._sink_interface = sink_interface + self._typeinfo = sink_typeinfo + + def AddRef(self, this): + return 2 + + def Release(self, this): + return 1 + + ################################ + # IConnectionPoint methods + # XXX per MSDN, all these methods *must* be implemented - E_NOTIMPL is no allowed return value + def IConnectionPoint_Advise(self, this, pUnk, pdwCookie): + # IConnectionPoint::Advise + from ctypes.com.client import QueryInterface + if not pUnk or not pdwCookie: + return E_POINTER + try: + p = QueryInterface(pUnk, self._sink_interface) + except WindowsError: + return CONNECT_E_CANNOTCONNECT + pdwCookie[0] = self._cookie = self._cookie + 1 + self._connections[self._cookie] = p + p.AddRef() + return S_OK + + def IConnectionPoint_Unadvise(self, this, dwCookie): + try: + del self._connections[dwCookie] + except KeyError: + return CONNECT_E_NOCONNECTION + return S_OK + + ## def IConnectionPoint_GetConnectionPointContainer(self, this, ppCPC): + ## pass + ## def IConnectionPoint_GetConnectionInterface(self, this, pIID): + ## pass + + ################ + + def Fire_Event(self, name, *args, **kw): + # call this method to notify the active advise connections + from ctypes.com.automation import DISPPARAMS, VARIANT, DISPATCH_METHOD + # we could cache the memids... + memid = c_int() + self._typeinfo.GetIDsOfNames(byref(c_wchar_p(name)), 1, byref(memid)) + for p in self._connections.values(): + params = DISPPARAMS() + params.cArgs = len(args) + rgvarg = params.rgvarg = (VARIANT * len(args))() + for i, a in enumerate(args): + rgvarg[i].value = a + p.Invoke(memid.value, + byref(GUID()), + 0, # lcid + DISPATCH_METHOD, # wFlags + byref(params), + None, # pVarResult + None, # pExcepInfo + None) # puArgError + return S_OK + + + + ################################################################ # A Base class for events delivered to a dispinterface # |
From: Thomas H. <th...@us...> - 2005-05-06 09:53:45
|
Update of /cvsroot/ctypes/ctypes/win32/com In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25737 Modified Files: Tag: branch_1_0 hresult.py Log Message: Add connection point error codes. Index: hresult.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/win32/com/hresult.py,v retrieving revision 1.5 retrieving revision 1.5.4.1 diff -C2 -d -r1.5 -r1.5.4.1 *** hresult.py 28 Jul 2004 13:28:47 -0000 1.5 --- hresult.py 6 May 2005 09:53:34 -0000 1.5.4.1 *************** *** 20,21 **** --- 20,27 ---- CO_E_CLASSSTRING = 0x800401F3L + + # connection point error codes + CONNECT_E_CANNOTCONNECT = -2147220990 + CONNECT_E_ADVISELIMIT = -2147220991 + CONNECT_E_NOCONNECTION = -2147220992 + |
From: Thomas H. <th...@us...> - 2005-05-04 19:31:55
|
Update of /cvsroot/ctypes/ctypes/ctypes/wrap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24892 Modified Files: Tag: branch_1_0 cparser_config.py Log Message: Ignore a symbol defined by olectl.h (on Windows). Index: cparser_config.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/wrap/cparser_config.py,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -C2 -d -r1.4 -r1.4.2.1 *** cparser_config.py 18 Mar 2005 11:28:36 -0000 1.4 --- cparser_config.py 4 May 2005 19:31:42 -0000 1.4.2.1 *************** *** 57,60 **** --- 57,61 ---- WINOLEAUTAPI WINOLEAPI + WINOLECTLAPI APIENTRY EXTERN_C |
From: Thomas H. <th...@us...> - 2005-04-29 20:29:06
|
Update of /cvsroot/ctypes/ctypes/win32/com In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16324 Modified Files: Tag: branch_1_0 automation.py Log Message: Move the BSTR specific code into the BSTR classes. Index: automation.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/win32/com/automation.py,v retrieving revision 1.21 retrieving revision 1.21.2.1 diff -C2 -d -r1.21 -r1.21.2.1 *** automation.py 17 Feb 2005 15:05:25 -0000 1.21 --- automation.py 29 Apr 2005 20:28:57 -0000 1.21.2.1 *************** *** 95,98 **** --- 95,101 ---- 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) assert(sizeof(BSTR) == 4) |
From: Thomas H. <th...@us...> - 2005-04-29 20:28:52
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16132 Modified Files: Tag: branch_1_0 _ctypes.c Log Message: Move the BSTR specific code into the BSTR classes. Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.226.2.6 retrieving revision 1.226.2.7 diff -C2 -d -r1.226.2.6 -r1.226.2.7 *** _ctypes.c 29 Apr 2005 19:05:24 -0000 1.226.2.6 --- _ctypes.c 29 Apr 2005 20:28:35 -0000 1.226.2.7 *************** *** 1699,1724 **** { Py_CLEAR(self->b_objects); ! if (self->b_needsfree) { ! #ifdef MS_WIN32 ! static SETFUNC BSTR_set; ! StgDictObject *dict = PyObject_stgdict((PyObject *)self); ! ! if (!BSTR_set) ! BSTR_set = getentry("X")->setfunc; ! ! /* XXX A hacck, but hopefully a working one. If the memory ! has been allocated by us (b_needsfree is true), we also ! have to call SysFreeString ! */ ! ! /* XXX more explanations needed !!! XXX XXX XXX */ ! ! if (dict && dict->setfunc == BSTR_set) { ! if (*(BSTR *)self->b_ptr) ! SysFreeString(*(BSTR *)self->b_ptr); ! } ! #endif PyMem_Free(self->b_ptr); - } self->b_ptr = NULL; Py_CLEAR(self->b_base); --- 1699,1704 ---- { Py_CLEAR(self->b_objects); ! if (self->b_needsfree) PyMem_Free(self->b_ptr); self->b_ptr = NULL; Py_CLEAR(self->b_base); |
From: Thomas H. <th...@us...> - 2005-04-29 20:28:24
|
Update of /cvsroot/ctypes/ctypes/comtypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15964 Modified Files: Tag: branch_1_0 __init__.py Log Message: Move the BSTR specific code into the BSTR classes. Index: __init__.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/__init__.py,v retrieving revision 1.25 retrieving revision 1.25.2.1 diff -C2 -d -r1.25 -r1.25.2.1 *** __init__.py 17 Mar 2005 10:34:33 -0000 1.25 --- __init__.py 29 Apr 2005 20:28:12 -0000 1.25.2.1 *************** *** 277,280 **** --- 277,283 ---- 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) ################################################################ |
From: Thomas H. <th...@us...> - 2005-04-29 19:43:59
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24565 Modified Files: _ctypes.c Log Message: Nicer code with same performance. Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.302 retrieving revision 1.303 diff -C2 -d -r1.302 -r1.303 *** _ctypes.c 15 Apr 2005 11:52:02 -0000 1.302 --- _ctypes.c 29 Apr 2005 19:43:50 -0000 1.303 *************** *** 3416,3429 **** Simple_init(CDataObject *self, PyObject *args, PyObject *kw) { ! switch (PyTuple_Size(args)) { ! case 0: ! return 0; ! case 1: ! return Simple_set_value(self, PyTuple_GET_ITEM(args, 0)); ! default: ! PyErr_SetString(PyExc_TypeError, ! "function takes at most 1 argument"); return -1; ! } } --- 3416,3425 ---- Simple_init(CDataObject *self, PyObject *args, PyObject *kw) { ! PyObject *value = NULL; ! if (!PyArg_UnpackTuple(args, "__init__", 0, 1, &value)) return -1; ! if (value) ! return Simple_set_value(self, value); ! return 0; } |
From: Thomas H. <th...@us...> - 2005-04-29 19:05:34
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2227 Modified Files: Tag: branch_1_0 _ctypes.c Log Message: PyArg_UnpackTuple is faster than PyArg_ParseTuple- Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.226.2.5 retrieving revision 1.226.2.6 diff -C2 -d -r1.226.2.5 -r1.226.2.6 *** _ctypes.c 29 Apr 2005 11:57:46 -0000 1.226.2.5 --- _ctypes.c 29 Apr 2005 19:05:24 -0000 1.226.2.6 *************** *** 3549,3557 **** { PyObject *value = NULL; ! ! /* XXX Optimize. PyArg_ParseTuple is slow... */ ! if (!PyArg_ParseTuple(args, "|O", &value)) return -1; - if (value) return Simple_set_value(self, value); --- 3549,3554 ---- { PyObject *value = NULL; ! if (!PyArg_UnpackTuple(args, "__init__", 0, 1, &value)) return -1; if (value) return Simple_set_value(self, value); |