ctypes-commit Mailing List for ctypes (Page 40)
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-08-30 06:54:28
|
Update of /cvsroot/ctypes/ctypes/ctypes/wrap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22262 Modified Files: Tag: branch_1_0 h2xml.py Log Message: The cparser module already sets the PATH for gccxml. Index: h2xml.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/wrap/h2xml.py,v retrieving revision 1.3.2.1 retrieving revision 1.3.2.2 diff -C2 -d -r1.3.2.1 -r1.3.2.2 *** h2xml.py 24 Aug 2005 08:11:14 -0000 1.3.2.1 --- h2xml.py 30 Aug 2005 06:54:20 -0000 1.3.2.2 *************** *** 4,27 **** from optparse import OptionParser - if sys.platform == "win32": - - def _locate_gccxml(): - import _winreg - for subkey in (r"Software\gccxml", r"Software\Kitware\GCC_XML"): - for root in (_winreg.HKEY_CURRENT_USER, _winreg.HKEY_LOCAL_MACHINE): - try: - hkey = _winreg.OpenKey(root, subkey, 0, _winreg.KEY_READ) - except WindowsError, detail: - if detail.errno != 2: - raise - else: - return _winreg.QueryValueEx(hkey, "loc")[0] + r"\bin" - - loc = _locate_gccxml() - if loc: - os.environ["PATH"] = loc - - ################################################################ - def main(argv=None): if argv is None: --- 4,7 ---- |
From: Thomas H. <th...@us...> - 2005-08-30 06:53:46
|
Update of /cvsroot/ctypes/ctypes/ctypes/wrap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22159 Modified Files: Tag: branch_1_0 cparser.py Log Message: Add a function to locate gccxml on $PATH. Index: cparser.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/wrap/cparser.py,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -C2 -d -r1.3 -r1.3.2.1 *** cparser.py 17 Mar 2005 19:01:26 -0000 1.3 --- cparser.py 30 Aug 2005 06:53:32 -0000 1.3.2.1 *************** *** 29,32 **** --- 29,44 ---- os.environ["PATH"] = loc + def find_gccxml(): + # find gccxml on $PATH + if sys.platform == "win32": + GCCXML = "gccxml.exe" + else: + GCCXML = "gccxml" + for directory in os.environ["PATH"].split(os.pathsep): + what = os.path.join(directory, GCCXML) + if os.path.isfile(what): + return what + return None + class CompilerError(Exception): pass *************** *** 52,57 **** self.excluded_re.update(EXCLUDED_RE) self.excluded_re.update(self.options.excluded_symbols_re) ! ! def create_source_file(self, lines, ext=".cpp"): "Create a temporary file, write lines to it, and return the filename" --- 64,73 ---- self.excluded_re.update(EXCLUDED_RE) self.excluded_re.update(self.options.excluded_symbols_re) ! if subprocess is None: ! if not find_gccxml(): ! import errno ! raise OSError, (errno.ENOENT, "gccxml not found") ! ! def create_source_file(self, lines, ext=".cpp"): "Create a temporary file, write lines to it, and return the filename" |
From: Thomas H. <th...@us...> - 2005-08-30 06:34:00
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18815 Modified Files: Tag: branch_1_0 test_codegen.py Log Message: Try to catch the problem that gccxml is not available. Index: test_codegen.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/Attic/test_codegen.py,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** test_codegen.py 24 Aug 2005 08:59:45 -0000 1.1.2.2 --- test_codegen.py 30 Aug 2005 06:33:52 -0000 1.1.2.3 *************** *** 15,19 **** args = "-q -I%s _ctypes_test.h -o test.xml" % source_dir ! h2xml.main(["testing"] + args.split()) args = "test.xml -o test.py -l%s" % _ctypes_test.__file__ --- 15,28 ---- args = "-q -I%s _ctypes_test.h -o test.xml" % source_dir ! try: ! h2xml.main(["testing"] + args.split()) ! except OSError, detail: ! # gccxml probably not installed. This error is only ! # raised when the subprocess module is used to invoke ! # gccxml. ! import errno ! if detail.errno == errno.ENOENT: ! return ! raise args = "test.xml -o test.py -l%s" % _ctypes_test.__file__ |
From: Thomas H. <th...@us...> - 2005-08-30 06:32:03
|
Update of /cvsroot/ctypes/ctypes/comtypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18517 Modified Files: Tag: branch_1_0 test_createwrappers.py Log Message: Work around a current limitation in ctypes. Index: test_createwrappers.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/unittests/Attic/test_createwrappers.py,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** test_createwrappers.py 24 Aug 2005 12:12:55 -0000 1.1.2.2 --- test_createwrappers.py 30 Aug 2005 06:31:56 -0000 1.1.2.3 *************** *** 24,28 **** global number def test(self): ! comtypes.client.CreateModule(fname) test.__doc__ = "test CreateModule(%r)" % fname --- 24,34 ---- global number def test(self): ! try: ! comtypes.client.CreateModule(fname) ! except TypeError, detail: ! # work around the bug that arrays and simple pointer ! # types are not supported as 'out' parameters ! if not str(detail).startswith("'out' parameter"): ! raise test.__doc__ = "test CreateModule(%r)" % fname *************** *** 30,34 **** number += 1 - # MSADODC.OCX: _Recordset is not defined. for fname in glob.glob(r"c:\windows\system32\*.ocx"): add_test(fname) --- 36,39 ---- |
From: Thomas H. <th...@us...> - 2005-08-30 06:25:47
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17143 Modified Files: Tag: branch_1_0 test_arrays.py Log Message: Prevent error in non-unicode build. Index: test_arrays.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_arrays.py,v retrieving revision 1.8.6.1 retrieving revision 1.8.6.2 diff -C2 -d -r1.8.6.1 -r1.8.6.2 *** test_arrays.py 22 Aug 2005 09:31:44 -0000 1.8.6.1 --- test_arrays.py 30 Aug 2005 06:25:39 -0000 1.8.6.2 *************** *** 99,107 **** self.failUnlessEqual(sz.value, "foo") ! def test_from_addressW(self): ! p = create_unicode_buffer("foo") ! sz = (c_wchar * 3).from_address(addressof(p)) ! self.failUnlessEqual(sz[:], "foo") ! self.failUnlessEqual(sz.value, "foo") if __name__ == '__main__': --- 99,112 ---- self.failUnlessEqual(sz.value, "foo") ! try: ! create_unicode_buffer ! except NameError: ! pass ! else: ! def test_from_addressW(self): ! p = create_unicode_buffer("foo") ! sz = (c_wchar * 3).from_address(addressof(p)) ! self.failUnlessEqual(sz[:], "foo") ! self.failUnlessEqual(sz.value, "foo") if __name__ == '__main__': |
From: Thomas H. <th...@us...> - 2005-08-26 10:00:36
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25899 Modified Files: Tag: branch_1_0 _ctypes.c Log Message: Remove unused local variable. Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.226.2.26 retrieving revision 1.226.2.27 diff -C2 -d -r1.226.2.26 -r1.226.2.27 *** _ctypes.c 26 Aug 2005 09:58:55 -0000 1.226.2.26 --- _ctypes.c 26 Aug 2005 10:00:25 -0000 1.226.2.27 *************** *** 2104,2108 **** CFuncPtr_set_restype(CFuncPtrObject *self, PyObject *ob) { - PyObject *checker; if (ob == NULL) { Py_XDECREF(self->restype); --- 2104,2107 ---- |
From: Thomas H. <th...@us...> - 2005-08-26 09:59:21
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25445 Modified Files: Tag: branch_1_0 _ctypes.c Log Message: The checker member was not reset when 'restype' was set. Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.226.2.25 retrieving revision 1.226.2.26 diff -C2 -d -r1.226.2.25 -r1.226.2.26 *** _ctypes.c 24 Aug 2005 19:03:05 -0000 1.226.2.25 --- _ctypes.c 26 Aug 2005 09:58:55 -0000 1.226.2.26 *************** *** 1849,1853 **** } ! static PyObject * CData_FromBaseObj(PyObject *type, PyObject *base, int index, char *adr) { --- 1849,1853 ---- } ! PyObject * CData_FromBaseObj(PyObject *type, PyObject *base, int index, char *adr) { *************** *** 2120,2129 **** Py_INCREF(ob); self->restype = ob; ! checker = PyObject_GetAttrString(ob, "_check_retval_"); ! if (checker == NULL) { PyErr_Clear(); - return 0; - } - self->checker = checker; return 0; } --- 2120,2126 ---- Py_INCREF(ob); self->restype = ob; ! self->checker = PyObject_GetAttrString(ob, "_check_retval_"); ! if (self->checker == NULL) PyErr_Clear(); return 0; } |
From: Thomas H. <th...@us...> - 2005-08-25 07:41:27
|
Update of /cvsroot/ctypes/ctypes/comtypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2029 Added Files: Tag: branch_1_0 test_msscript.py Log Message: Work around a bug in MS Script Control for JScript. --- NEW FILE: test_msscript.py --- import ut from ctypes import POINTER from comtypes.automation import IDispatch from comtypes.client import CreateObject class Test(ut.TestCase): def test_jscript(self): engine = CreateObject("MSScriptControl.ScriptControl") engine.Language = "JScript" # strange. # # engine.Eval returns a VARIANT containing a dispatch pointer. # # The dispatch pointer exposes this typeinfo (the number of # dispproperties varies, depending on the length of the list we pass # to Eval): # #class JScriptTypeInfo(comtypes.gen._00020430_0000_0000_C000_000000000046_0_2_0.IDispatch): # 'JScript Type Info' # _iid_ = GUID('{C59C6B12-F6C1-11CF-8835-00A0C911E8B2}') # _idlflags_ = [] # _methods_ = [] #JScriptTypeInfo._disp_methods_ = [ # DISPPROPERTY([dispid(9522932)], VARIANT, '0'), # DISPPROPERTY([dispid(9522976)], VARIANT, '1'), #] # # Although the exact interface members vary, the guid stays # the same. Don't think that's allowed by COM standards - is # this a bug in the MSScriptControl? # # What's even more strange is that the returned dispatch # pointer can't be QI'd for this interface! So it seems the # typeinfo is really a temporary thing. res = engine.Eval("[1, 2, 3, 4]") # comtypes.client works around this bug, by not trying to # high-level wrap the dispatch pointer because QI for the real # interface fails. self.failUnlessEqual(type(res), POINTER(IDispatch)) tinfo_1 = engine.Eval("[1, 2, 3]").GetTypeInfo(0) tinfo_2 = engine.Eval("[1, 2, 3, 4]").GetTypeInfo(0) tinfo_3 = engine.Eval("[1, 2, 3, 4, 5]").GetTypeInfo(0) self.failUnlessEqual(tinfo_1.GetTypeAttr().cVars, 3) self.failUnlessEqual(tinfo_2.GetTypeAttr().cVars, 4) self.failUnlessEqual(tinfo_3.GetTypeAttr().cVars, 5) # These tests simply describe the current behaviour ;-) self.failUnlessEqual(tinfo_1.GetTypeAttr().guid, tinfo_1.GetTypeAttr().guid) ## print (res[0], res[1], res[2]) ## print len(res) if __name__ == "__main__": ut.main() |
From: Thomas H. <th...@us...> - 2005-08-25 07:41:24
|
Update of /cvsroot/ctypes/ctypes/comtypes/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2002 Modified Files: Tag: branch_1_0 __init__.py Log Message: Work around a bug in MS Script Control for JScript. Index: __init__.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/client/Attic/__init__.py,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -C2 -d -r1.1.2.4 -r1.1.2.5 *** __init__.py 23 Aug 2005 19:41:03 -0000 1.1.2.4 --- __init__.py 25 Aug 2005 07:41:13 -0000 1.1.2.5 *************** *** 324,327 **** --- 324,332 ---- except comtypes.COMError: return punk + try: + punk.QueryInterface(comtypes.IUnknown, tinfo.GetTypeAttr().guid) + except comtypes.COMError: + return punk + itf_name = tinfo.GetDocumentation(-1)[0] # interface name tlib = tinfo.GetContainingTypeLib()[0] # typelib *************** *** 332,335 **** --- 337,351 ---- interface = getattr(mod, itf_name) # QI for this interface + # XXX + # What to do if this fails? + # In the following example the engine.Eval() call returns + # such an object. + # + # engine = CreateObject("MsScriptControl.ScriptControl") + # engine.Language = "JScript" + # engine.Eval("[1, 2, 3]") + # + # Could the above code, as an optimization, check that QI works, + # *before* generating the wraper module? return punk.QueryInterface(interface) |
From: Thomas H. <th...@us...> - 2005-08-24 19:04:15
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16373 Modified Files: Tag: branch_1_0 callproc.c Log Message: Better argument checking for the cast function. Index: callproc.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/callproc.c,v retrieving revision 1.127.2.9 retrieving revision 1.127.2.10 diff -C2 -d -r1.127.2.9 -r1.127.2.10 *** callproc.c 24 Aug 2005 18:21:34 -0000 1.127.2.9 --- callproc.c 24 Aug 2005 19:04:07 -0000 1.127.2.10 *************** *** 1445,1455 **** Doesn't work correctly with ctypes integers.\n"; - /* static int cast_check_pointertype(PyObject *arg, PyObject **pobj) { if (PointerTypeObject_Check(arg)) { *pobj = arg; return 1; } if (PyType_Check(arg)) { PyErr_Format(PyExc_TypeError, --- 1445,1465 ---- Doesn't work correctly with ctypes integers.\n"; static int cast_check_pointertype(PyObject *arg, PyObject **pobj) { + StgDictObject *dict; + if (PointerTypeObject_Check(arg)) { *pobj = arg; return 1; } + dict = PyType_stgdict(arg); + if (dict) { + if (PyString_Check(dict->proto) + && (strchr("sPzUZXO", PyString_AS_STRING(dict->proto)[0]))) { + /* simple pointer types, c_void_p, c_wchar_p, BSTR, ... */ + *pobj = arg; + return 1; + } + } if (PyType_Check(arg)) { PyErr_Format(PyExc_TypeError, *************** *** 1463,1467 **** return 0; } - */ static PyObject *cast(PyObject *self, PyObject *args) --- 1473,1476 ---- *************** *** 1471,1476 **** CDataObject *result; ! /* if (!PyArg_ParseTuple(args, "OO&:cast", &obj, &cast_check_pointertype, &ctype))*/ ! if (!PyArg_ParseTuple(args, "OO:cast", &obj, &ctype)) return NULL; if (-1 == ConvParam(obj, 1, &a)) --- 1480,1486 ---- CDataObject *result; ! /* We could and should allow array types for the second argument ! also, but we cannot use the simple memcpy below for them. */ ! if (!PyArg_ParseTuple(args, "OO&:cast", &obj, &cast_check_pointertype, &ctype)) return NULL; if (-1 == ConvParam(obj, 1, &a)) |
From: Thomas H. <th...@us...> - 2005-08-24 19:03:13
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16032 Modified Files: Tag: branch_1_0 _ctypes.c Log Message: Refactor the code that checks parameter flags. Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.226.2.24 retrieving revision 1.226.2.25 diff -C2 -d -r1.226.2.24 -r1.226.2.25 *** _ctypes.c 24 Aug 2005 18:27:19 -0000 1.226.2.24 --- _ctypes.c 24 Aug 2005 19:03:05 -0000 1.226.2.25 *************** *** 2232,2235 **** --- 2232,2270 ---- #endif + /* Return 1 if usable, 0 else. */ + static int + _check_outarg_type(PyObject *arg, int index) + { + StgDictObject *dict; + + if (PointerTypeObject_Check(arg)) + return 1; + #if 0 + /* This is also disabled, because _build_callargs does not handle + these correctly. */ + if (ArrayTypeObject_Check(arg)) + return 1; + #endif + #if 0 + /* This is also disabled, because _build_callargs does not handle + these correctly. */ + dict = PyType_stgdict(arg); + if (dict) { + if (PyString_Check(dict->proto) + && (strchr("sPzUZXO", PyString_AS_STRING(dict->proto)[0]))) { + /* simple pointer types, c_void_p, c_wchar_p, BSTR, ... */ + return 1; + } + } + #endif + PyErr_Format(PyExc_TypeError, + "'out' parameter %d must be a pointer type, not %s", + index, + PyType_Check(arg) ? + ((PyTypeObject *)arg)->tp_name : + arg->ob_type->tp_name); + return 0; + } + /* Returns 1 on success, 0 on error */ static int *************** *** 2268,2289 **** } typ = PyTuple_GET_ITEM(argtypes, i); - dict = PyType_stgdict(typ); - /* We could (and should maybe) also allow array types - for 'out' parameters. The _build_callargs() function must - be modified, though. See comments there... - */ - if ((flag & PARAMFLAG_FOUT) && (!PointerTypeObject_Check(typ))) { - PyErr_Format(PyExc_TypeError, - "output parameter %d not a pointer type: %s", - i+1, - ((PyTypeObject *)typ)->tp_name); - return 0; - } switch (flag & (PARAMFLAG_FIN | PARAMFLAG_FOUT | PARAMFLAG_FLCID)) { case 0: case PARAMFLAG_FIN: case PARAMFLAG_FIN | PARAMFLAG_FLCID: case PARAMFLAG_FOUT: case (PARAMFLAG_FIN | PARAMFLAG_FOUT): break; default: --- 2303,2315 ---- } typ = PyTuple_GET_ITEM(argtypes, i); switch (flag & (PARAMFLAG_FIN | PARAMFLAG_FOUT | PARAMFLAG_FLCID)) { case 0: case PARAMFLAG_FIN: case PARAMFLAG_FIN | PARAMFLAG_FLCID: + break; case PARAMFLAG_FOUT: case (PARAMFLAG_FIN | PARAMFLAG_FOUT): + if (!_check_outarg_type(typ, i+1)) + return 0; break; default: |
From: Thomas H. <th...@us...> - 2005-08-24 18:27:28
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6559 Modified Files: Tag: branch_1_0 _ctypes.c Log Message: Better error messages by using the '...:functionname' pattern in PyArg_ParseTuple calls. And remove unused code blocks. Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.226.2.23 retrieving revision 1.226.2.24 diff -C2 -d -r1.226.2.23 -r1.226.2.24 *** _ctypes.c 22 Aug 2005 09:38:53 -0000 1.226.2.23 --- _ctypes.c 24 Aug 2005 18:27:19 -0000 1.226.2.24 *************** *** 223,227 **** void *address; ! if (!PyArg_ParseTuple(args, "Os", &dll, &name)) return NULL; --- 223,227 ---- void *address; ! if (!PyArg_ParseTuple(args, "Os:in_dll", &dll, &name)) return NULL; *************** *** 1032,1037 **** { #if (PYTHON_API_VERSION < 1012) ! if (!PyArg_ParseTuple(value, "OO", &type, &value)) ! return NULL; #endif if (value == Py_None) { --- 1032,1036 ---- { #if (PYTHON_API_VERSION < 1012) ! # error not supported #endif if (value == Py_None) { *************** *** 1085,1090 **** { #if (PYTHON_API_VERSION < 1012) ! if (!PyArg_ParseTuple(value, "OO", &type, &value)) ! return NULL; #endif if (value == Py_None) { --- 1084,1088 ---- { #if (PYTHON_API_VERSION < 1012) ! # error not supported #endif if (value == Py_None) { *************** *** 1139,1144 **** StgDictObject *stgd; #if (PYTHON_API_VERSION < 1012) ! if (!PyArg_ParseTuple(value, "OO", &type, &value)) ! return NULL; #endif --- 1137,1141 ---- StgDictObject *stgd; #if (PYTHON_API_VERSION < 1012) ! # error not supported #endif *************** *** 3795,3799 **** PyObject *value = NULL; ! if (!PyArg_ParseTuple(args, "|O", &value)) return -1; if (value == NULL) --- 3792,3796 ---- PyObject *value = NULL; ! if (!PyArg_ParseTuple(args, "|O:POINTER", &value)) return -1; if (value == NULL) *************** *** 3961,3965 **** int status; ! if (!PyArg_ParseTuple(args, "OOOO", &self, &hresult, &text, &details)) return NULL; --- 3958,3962 ---- int status; ! if (!PyArg_ParseTuple(args, "OOOO:COMError", &self, &hresult, &text, &details)) return NULL; |
From: Thomas H. <th...@us...> - 2005-08-24 18:21:41
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5328 Modified Files: Tag: branch_1_0 callproc.c Log Message: Better error messages by using the '...:functionname' pattern in PyArg_ParseTuple calls. Index: callproc.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/callproc.c,v retrieving revision 1.127.2.8 retrieving revision 1.127.2.9 diff -C2 -d -r1.127.2.8 -r1.127.2.9 *** callproc.c 17 Aug 2005 16:59:08 -0000 1.127.2.8 --- callproc.c 24 Aug 2005 18:21:34 -0000 1.127.2.9 *************** *** 1341,1346 **** PyCArgObject *parg; if (!CDataObject_Check(obj)) { ! PyErr_SetString(PyExc_TypeError, ! "expected CData instance"); return NULL; } --- 1341,1347 ---- PyCArgObject *parg; if (!CDataObject_Check(obj)) { ! PyErr_Format(PyExc_TypeError, ! "byref() argument must be a ctypes instance, not '%s'", ! obj->ob_type->tp_name); return NULL; } *************** *** 1383,1387 **** { PyObject *ob; ! if (!PyArg_ParseTuple(args, "O&", converter, &ob)) return NULL; Py_INCREF(ob); --- 1384,1388 ---- { PyObject *ob; ! if (!PyArg_ParseTuple(args, "O&:PyObj_FromPtr", converter, &ob)) return NULL; Py_INCREF(ob); *************** *** 1419,1423 **** PyObject *result; ! if (!PyArg_ParseTuple(args, "zs", &coding, &mode)) return NULL; result = Py_BuildValue("(zz)", conversion_mode_encoding, conversion_mode_errors); --- 1420,1424 ---- PyObject *result; ! if (!PyArg_ParseTuple(args, "zs:set_conversion_mode", &coding, &mode)) return NULL; result = Py_BuildValue("(zz)", conversion_mode_encoding, conversion_mode_errors); *************** *** 1444,1447 **** --- 1445,1468 ---- Doesn't work correctly with ctypes integers.\n"; + /* + static int cast_check_pointertype(PyObject *arg, PyObject **pobj) + { + if (PointerTypeObject_Check(arg)) { + *pobj = arg; + return 1; + } + if (PyType_Check(arg)) { + PyErr_Format(PyExc_TypeError, + "cast() argument 2 must be a pointer type, not %s", + ((PyTypeObject *)arg)->tp_name); + } else { + PyErr_Format(PyExc_TypeError, + "cast() argument 2 must be a pointer type, not a %s", + arg->ob_type->tp_name); + } + return 0; + } + */ + static PyObject *cast(PyObject *self, PyObject *args) { *************** *** 1450,1454 **** CDataObject *result; ! if (!PyArg_ParseTuple(args, "OO", &obj, &ctype)) return NULL; if (-1 == ConvParam(obj, 1, &a)) --- 1471,1476 ---- CDataObject *result; ! /* if (!PyArg_ParseTuple(args, "OO&:cast", &obj, &cast_check_pointertype, &ctype))*/ ! if (!PyArg_ParseTuple(args, "OO:cast", &obj, &ctype)) return NULL; if (-1 == ConvParam(obj, 1, &a)) *************** *** 1483,1487 **** 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 == ConvParam(dst, 1, &a_dst)) --- 1505,1509 ---- memset(&a_dst, 0, sizeof(struct argument)); memset(&a_src, 0, sizeof(struct argument)); ! if (!PyArg_ParseTuple(args, "OOi:memmove", &dst, &src, &size)) return NULL; if (-1 == ConvParam(dst, 1, &a_dst)) *************** *** 1509,1513 **** int c, count; ! if (!PyArg_ParseTuple(args, "Oii", &dst, &c, &count)) return NULL; memset(&a_dst, 0, sizeof(struct argument)); --- 1531,1535 ---- int c, count; ! if (!PyArg_ParseTuple(args, "Oii:memset", &dst, &c, &count)) return NULL; memset(&a_dst, 0, sizeof(struct argument)); *************** *** 1533,1537 **** int size; ! if (!PyArg_ParseTuple(args, "O|i", &src, &size)) return NULL; memset(&a_arg, 0, sizeof(struct argument)); --- 1555,1559 ---- int size; ! if (!PyArg_ParseTuple(args, "O|i:string_at", &src, &size)) return NULL; memset(&a_arg, 0, sizeof(struct argument)); *************** *** 1560,1564 **** int size; ! if (!PyArg_ParseTuple(args, "O|i", &src, &size)) return NULL; memset(&a_arg, 0, sizeof(struct argument)); --- 1582,1586 ---- int size; ! if (!PyArg_ParseTuple(args, "O|i:wstring_at", &src, &size)) return NULL; memset(&a_arg, 0, sizeof(struct argument)); |
From: Thomas H. <th...@us...> - 2005-08-24 12:38:28
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21663 Added Files: Tag: branch_1_0 setup_comtypes.py Log Message: setup script for comtypes. --- NEW FILE: setup_comtypes.py --- r"""comtypes - pure Python COM package, based on the ctypes FFI library comtypes offers superior support for custom COM interfaces. Currently only COM client code is implemented, server support will follow later. Limitations: - dispinterface support is somewhat weak. ----------------------------------------------------------------""" ##from distutils.core import setup from setuptools import setup ##import comtypes.client classifiers = [ 'Development Status :: 3 - Alpha', ## 'Development Status :: 4 - Beta', ## 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', 'License :: OSI Approved :: MIT License', 'Operating System :: Microsoft :: Windows', 'Programming Language :: Python', 'Topic :: Software Development :: Libraries :: Python Modules', ] setup(name="comtypes", description="pure Python COM package, based on the ctypes FFI library", long_description = __doc__, author="Thomas Heller", author_email="th...@py...", license="MIT License", url="http://starship.python.net/crew/theller/comtypes/", classifiers=classifiers, version="1.0", packages=["comtypes", "comtypes.client", "comtypes.tools", "comtypes.unittests"]) |
From: Thomas H. <th...@us...> - 2005-08-24 12:36:37
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21416 Modified Files: Tag: branch_1_0 ctypes-dev.el Log Message: Index: ctypes-dev.el =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes-dev.el,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -C2 -d -r1.1 -r1.1.2.1 *** ctypes-dev.el 11 Mar 2005 10:19:14 -0000 1.1 --- ctypes-dev.el 24 Aug 2005 12:36:28 -0000 1.1.2.1 *************** *** 9,23 **** (provide 'ctypes-dev) - (setenv "PYTHONPATH" "c:\\sf\\ctypes") - (defgroup ctypes-dev nil "Various ctypes development utilities" :group 'development) ! (defcustom ctypes-dev-directory "c:\\sf\\ctypes" "ctypes root directory" :group 'ctypes-dev :type 'string) (defmacro with-cd (dirname &rest code) `(let ((old-dirname default-directory) --- 9,23 ---- (provide 'ctypes-dev) (defgroup ctypes-dev nil "Various ctypes development utilities" :group 'development) ! (defcustom ctypes-dev-directory "c:\\sf\\ctypes_dist" "ctypes root directory" :group 'ctypes-dev :type 'string) + (setenv "PYTHONPATH" ctypes-dev-directory) + (defmacro with-cd (dirname &rest code) `(let ((old-dirname default-directory) *************** *** 48,67 **** (defun ctypes-dev-test () (interactive) ! (with-cd "c:\\sf\\ctypes\\unittests" (compile "python runtests.py"))) (defun ctypes-dev-test-debug () (interactive) ! (with-cd "c:\\sf\\ctypes\\unittests" (compile "py_d runtests.py"))) (defun comtypes-test () (interactive) ! (with-cd "c:\\sf\\ctypes\\comtypes\\unittests" (compile "python runtests.py"))) (defun comtypes-test-debug () (interactive) ! (with-cd "c:\\sf\\ctypes\\comtypes\\unittests" (compile "py_d runtests.py"))) --- 48,67 ---- (defun ctypes-dev-test () (interactive) ! (with-cd (concat ctypes-dev-directory "\\unittests") (compile "python runtests.py"))) (defun ctypes-dev-test-debug () (interactive) ! (with-cd (concat ctypes-dev-directory "\\unittests") (compile "py_d runtests.py"))) (defun comtypes-test () (interactive) ! (with-cd (concat ctypes-dev-directory "\\comtypes\\unittests") (compile "python runtests.py"))) (defun comtypes-test-debug () (interactive) ! (with-cd (concat ctypes-dev-directory "\\comtypes\\unittests") (compile "py_d runtests.py"))) |
From: Thomas H. <th...@us...> - 2005-08-24 12:35:59
|
Update of /cvsroot/ctypes/ctypes/comtypes/tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21327 Modified Files: Tag: branch_1_0 codegenerator.py Log Message: Fix some problems when generating typelibs. Index: codegenerator.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/tools/codegenerator.py,v retrieving revision 1.6.2.18 retrieving revision 1.6.2.19 diff -C2 -d -r1.6.2.18 -r1.6.2.19 *** codegenerator.py 23 Aug 2005 19:42:20 -0000 1.6.2.18 --- codegenerator.py 24 Aug 2005 12:35:50 -0000 1.6.2.19 *************** *** 141,144 **** --- 141,146 ---- # this defines the _methods_ self.more.add(tp.typ) + elif type(tp.typ) is typedesc.PointerType: + self.generate(tp.typ) else: super(Generator, self).PointerType(tp) *************** *** 183,187 **** def ComInterfaceHead(self, head): ! self.generate(head.itf.base) basename = self.type_name(head.itf.base) --- 185,196 ---- def ComInterfaceHead(self, head): ! if head.itf.name in self.known_symbols: ! return ! base = head.itf.base ! if head.itf.base is None: ! # we don't beed to generate IUnknown ! return ! self.generate(base.get_head()) ! self.more.add(base) basename = self.type_name(head.itf.base) *************** *** 233,236 **** --- 242,249 ---- def ComInterfaceBody(self, body): + # The base class must be fully generated, including the + # _methods_ list. + self.generate(body.itf.base) + # make sure we can generate the body for m in body.itf.members: |
From: Thomas H. <th...@us...> - 2005-08-24 12:13:10
|
Update of /cvsroot/ctypes/ctypes/comtypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15980 Modified Files: Tag: branch_1_0 test_createwrappers.py Log Message: Index: test_createwrappers.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/unittests/Attic/test_createwrappers.py,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** test_createwrappers.py 23 Aug 2005 19:44:15 -0000 1.1.2.1 --- test_createwrappers.py 24 Aug 2005 12:12:55 -0000 1.1.2.2 *************** *** 3,8 **** import comtypes.typeinfo import comtypes.client ! # This test takes quite some time. It tried to build wrappers for all # .dll, .tlb, and .ocx in the system directory which contain typelibs. --- 3,9 ---- import comtypes.typeinfo import comtypes.client + comtypes.client.__verbose__ = False ! # This test takes quite some time. It tries to build wrappers for all # .dll, .tlb, and .ocx in the system directory which contain typelibs. *************** *** 10,14 **** def setUp(self): comtypes.client.gen_dir = None - comtypes.client.__verbose__ = False def tearDown(self): --- 11,14 ---- *************** *** 26,30 **** comtypes.client.CreateModule(fname) ! test.__doc__ = "CreateModule(%r)" % fname setattr(Test, "test_%d" % number, test) number += 1 --- 26,30 ---- comtypes.client.CreateModule(fname) ! test.__doc__ = "test CreateModule(%r)" % fname setattr(Test, "test_%d" % number, test) number += 1 |
From: Thomas H. <th...@us...> - 2005-08-24 11:49:37
|
Update of /cvsroot/ctypes/ctypes/comtypes/tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10346 Modified Files: Tag: branch_1_0 typedesc.py Log Message: Allow SAFEARRAY in Structure fields - need size and align for that. Index: typedesc.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/tools/typedesc.py,v retrieving revision 1.1.2.9 retrieving revision 1.1.2.10 diff -C2 -d -r1.1.2.9 -r1.1.2.10 *** typedesc.py 23 Aug 2005 19:42:20 -0000 1.1.2.9 --- typedesc.py 24 Aug 2005 11:49:29 -0000 1.1.2.10 *************** *** 2,5 **** --- 2,6 ---- # in ctypes.wrap.typedesc + import ctypes from ctypes.wrap.typedesc import * *************** *** 28,31 **** --- 29,33 ---- def __init__(self, typ): self.typ = typ + self.align = self.size = ctypes.sizeof(ctypes.c_void_p) * 8 class ComMethod(object): |
From: Thomas H. <th...@us...> - 2005-08-24 09:00:38
|
Update of /cvsroot/ctypes/ctypes/sandbox/tools/codegen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8506 Modified Files: Tag: branch_1_0 snapshot.txt setup_gccxml.iss Log Message: Rebuild gccxml installer today. Index: snapshot.txt =================================================================== RCS file: /cvsroot/ctypes/ctypes/sandbox/tools/codegen/snapshot.txt,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -C2 -d -r1.1 -r1.1.2.1 *** snapshot.txt 18 Mar 2005 18:02:12 -0000 1.1 --- snapshot.txt 24 Aug 2005 09:00:29 -0000 1.1.2.1 *************** *** 1,5 **** This is *not* an official gccxml release! ! It was built from CVS Mar 18, 2005, with MSVC 6. For official releases, see http://www.gccxml.org/ \ No newline at end of file --- 1,5 ---- This is *not* an official gccxml release! ! It was built from CVS Aug 25, 2005, with MSVC 7.1. For official releases, see http://www.gccxml.org/ \ No newline at end of file Index: setup_gccxml.iss =================================================================== RCS file: /cvsroot/ctypes/ctypes/sandbox/tools/codegen/setup_gccxml.iss,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -C2 -d -r1.4 -r1.4.2.1 *** setup_gccxml.iss 18 Mar 2005 18:02:13 -0000 1.4 --- setup_gccxml.iss 24 Aug 2005 09:00:29 -0000 1.4.2.1 *************** *** 3,8 **** ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ! AppVerName=gccxml-20050318 ! OutputBaseFileName=gccxml-20050318-setup InfoBeforeFile=snapshot.txt ;AppVerName=gccxml-20050318-vctk --- 3,8 ---- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ! AppVerName=gccxml-20050824 ! OutputBaseFileName=gccxml-20050824-setup InfoBeforeFile=snapshot.txt ;AppVerName=gccxml-20050318-vctk *************** *** 24,31 **** ;Source: "snapshot-vctk.txt"; DestDir: "{app}\doc"; Destname: README.txt; Flags: ignoreversion ! Source: "C:\sf\buildgcc6\bin\minsizerel\gccxml.exe"; DestDir: "{app}\bin"; Flags: ignoreversion ! Source: "C:\sf\buildgcc6\bin\minsizerel\gccxml_cc1plus.exe"; DestDir: "{app}\bin"; Flags: ignoreversion ! ;Source: "C:\sf\buildgcc6\bin\minsizerel\vcInstallPatch.exe"; DestName: "patch.exe"; DestDir: "{app}\install"; Flags: ignoreversion ! Source: "C:\sf\buildgcc6\bin\minsizerel\vcInstall.exe"; DestDir: "{app}\install"; Flags: ignoreversion Source: "C:\sf\gccxml\GCC_XML\VcInstall\*.patch"; DestDir: "{app}\install"; Flags: ignoreversion --- 24,31 ---- ;Source: "snapshot-vctk.txt"; DestDir: "{app}\doc"; Destname: README.txt; Flags: ignoreversion ! Source: "C:\sf\buildgcc\bin\release\gccxml.exe"; DestDir: "{app}\bin"; Flags: ignoreversion ! Source: "C:\sf\buildgcc\bin\release\gccxml_cc1plus.exe"; DestDir: "{app}\bin"; Flags: ignoreversion ! ;Source: "C:\sf\buildgcc\bin\release\vcInstallPatch.exe"; DestName: "patch.exe"; DestDir: "{app}\install"; Flags: ignoreversion ! Source: "C:\sf\buildgcc\bin\release\vcInstall.exe"; DestDir: "{app}\install"; Flags: ignoreversion Source: "C:\sf\gccxml\GCC_XML\VcInstall\*.patch"; DestDir: "{app}\install"; Flags: ignoreversion |
From: Thomas H. <th...@us...> - 2005-08-24 08:59:52
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8142 Modified Files: Tag: branch_1_0 test_codegen.py Log Message: Fix the test to work independent of the current directory. Index: test_codegen.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/Attic/test_codegen.py,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** test_codegen.py 24 Aug 2005 07:12:16 -0000 1.1.2.1 --- test_codegen.py 24 Aug 2005 08:59:45 -0000 1.1.2.2 *************** *** 6,16 **** class Test(unittest.TestCase): def test(self): - os.system("%s ../ctypes/wrap/h2xml.py -I../source _ctypes_test.h -o _ctypes_test.xml" % \ - (sys.executable,)) - os.system("%s ../ctypes/wrap/xml2py.py _ctypes_test.xml -o _ctypes_test.py -l%s" % - (sys.executable, _ctypes_test.__file__)) ! lines = [l.rstrip() for l in open("_ctypes_test.py", "r").readlines()] ! self.failUnlessEqual(lines[2:], EXPECTED[2:]) EXPECTED = r"""# generated by 'xml2py' --- 6,29 ---- class Test(unittest.TestCase): def test(self): ! # XXX should use temporary files. ! ! test_dir = os.path.dirname(__file__) ! source_dir = os.path.join(test_dir, "..", "source") ! ! from ctypes.wrap import h2xml, xml2py ! args = "-q -I%s _ctypes_test.h -o test.xml" % source_dir ! ! h2xml.main(["testing"] + args.split()) ! ! args = "test.xml -o test.py -l%s" % _ctypes_test.__file__ ! xml2py.main(["testing"] + args.split()) ! ! lines = [l.rstrip() for l in open("test.py", "r").readlines()] ! ! for i in xrange(len(lines)): ! if lines[i].strip().startswith("#"): ! continue ! self.failUnlessEqual(lines[i], EXPECTED[i]) EXPECTED = r"""# generated by 'xml2py' *************** *** 21,25 **** def _testfunc_i_bhilfd(b, h, i, l, f, d): ! # ../source/_ctypes_test.h 1 return _testfunc_i_bhilfd._api_(b, h, i, l, f, d) _testfunc_i_bhilfd = cdecl(c_int, '_ctypes_test', [c_char, c_short, c_int, c_long, c_float, c_double]) (_testfunc_i_bhilfd) --- 34,38 ---- def _testfunc_i_bhilfd(b, h, i, l, f, d): ! # source/_ctypes_test.h 1 return _testfunc_i_bhilfd._api_(b, h, i, l, f, d) _testfunc_i_bhilfd = cdecl(c_int, '_ctypes_test', [c_char, c_short, c_int, c_long, c_float, c_double]) (_testfunc_i_bhilfd) |
From: Thomas H. <th...@us...> - 2005-08-24 08:58:47
|
Update of /cvsroot/ctypes/ctypes/sandbox/tools/codegen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7924 Added Files: Tag: branch_1_0 config Log Message: A default config file for gccxml for Windows. --- NEW FILE: config --- GCCXML_COMPILER="cl" |
From: Thomas H. <th...@us...> - 2005-08-24 08:29:18
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1428 Modified Files: Tag: branch_1_0 ChangeLog Log Message: *** empty log message *** Index: ChangeLog =================================================================== RCS file: /cvsroot/ctypes/ctypes/ChangeLog,v retrieving revision 1.86.2.14 retrieving revision 1.86.2.15 diff -C2 -d -r1.86.2.14 -r1.86.2.15 *** ChangeLog 22 Aug 2005 09:38:45 -0000 1.86.2.14 --- ChangeLog 24 Aug 2005 08:29:11 -0000 1.86.2.15 *************** *** 1,2 **** --- 1,14 ---- + 2005-08-24 Thomas Heller <th...@py...> + + * ctypes/wrap: Merged some of Andreas Degert's changes from CVS + HEAD: + + The code generator now sorts the generated definitions according + to the location in the source code. + + If function argument names are found in the xml-file (newer gccxml + create these), the code generator uses them in the generated + wrappers. + 2005-08-22 Thomas Heller <th...@py...> |
From: Thomas H. <th...@us...> - 2005-08-24 08:16:44
|
Update of /cvsroot/ctypes/ctypes/ctypes/wrap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31155 Modified Files: Tag: branch_1_0 typedesc.py gccxmlparser.py codegenerator.py Log Message: Merged in changes from the CVS HEAD: Sort the generated definitions according to location in the source code in codegenerator.py. Created class Argument and changed the arguments list from a list oy types to transport parameter names if supplied. Index: typedesc.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/wrap/typedesc.py,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -C2 -d -r1.1 -r1.1.2.1 *** typedesc.py 4 Feb 2005 17:01:24 -0000 1.1 --- typedesc.py 24 Aug 2005 08:16:35 -0000 1.1.2.1 *************** *** 5,12 **** --- 5,36 ---- from sets import Set as set + class Argument(object): + "a Parameter in the argument list of a callable (Function, Method, ...)" + def __init__(self, atype, name): + self.atype = atype + self.name = name + class _HasArgs(object): + + def __init__(self): + self.arguments = [] + def add_argument(self, arg): + assert isinstance(arg, Argument) self.arguments.append(arg) + def iterArgTypes(self): + for a in self.arguments: + yield a.atype + + def iterArgNames(self): + for a in self.arguments: + yield a.name + + def fixup_argtypes(self, typemap): + for a in self.arguments: + a.atype = typemap[a.atype] + + ################ *************** *** 35,42 **** location = None def __init__(self, name, returns, attributes, extern): self.name = name self.returns = returns self.attributes = attributes # dllimport, __stdcall__, __cdecl__ - self.arguments = [] self.extern = extern --- 59,66 ---- location = None def __init__(self, name, returns, attributes, extern): + _HasArgs.__init__(self) self.name = name self.returns = returns self.attributes = attributes # dllimport, __stdcall__, __cdecl__ self.extern = extern *************** *** 44,70 **** location = None def __init__(self, name): self.name = name - self.arguments = [] class OperatorFunction(_HasArgs): location = None def __init__(self, name, returns): self.name = name self.returns = returns - self.arguments = [] class FunctionType(_HasArgs): location = None def __init__(self, returns, attributes): self.returns = returns self.attributes = attributes - self.arguments = [] class Method(_HasArgs): location = None def __init__(self, name, returns): self.name = name self.returns = returns - self.arguments = [] class FundamentalType(object): --- 68,94 ---- location = None def __init__(self, name): + _HasArgs.__init__(self) self.name = name class OperatorFunction(_HasArgs): location = None def __init__(self, name, returns): + _HasArgs.__init__(self) self.name = name self.returns = returns class FunctionType(_HasArgs): location = None def __init__(self, returns, attributes): + _HasArgs.__init__(self) self.returns = returns self.attributes = attributes class Method(_HasArgs): location = None def __init__(self, name, returns): + _HasArgs.__init__(self) self.name = name self.returns = returns class FundamentalType(object): Index: codegenerator.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/wrap/codegenerator.py,v retrieving revision 1.6.2.3 retrieving revision 1.6.2.4 diff -C2 -d -r1.6.2.3 -r1.6.2.4 *** codegenerator.py 5 Aug 2005 17:55:07 -0000 1.6.2.3 --- codegenerator.py 24 Aug 2005 08:16:35 -0000 1.6.2.4 *************** *** 3,6 **** --- 3,15 ---- # $Log$ + # Revision 1.6.2.4 2005/08/24 08:16:35 theller + # Merged in changes from the CVS HEAD: + # + # Sort the generated definitions according to location in the source + # code in codegenerator.py. + # + # Created class Argument and changed the arguments list from a list oy + # types to transport parameter names if supplied. + # # Revision 1.6.2.3 2005/08/05 17:55:07 theller # If guessing the packing of structures in the code generator fails, *************** *** 44,48 **** # ! import typedesc, sys try: --- 53,57 ---- # ! import typedesc, sys, types try: *************** *** 52,55 **** --- 61,72 ---- try: + sorted + except NameError: + def sorted(seq, cmp): + seq = list(seq) + seq.sort(cmp) + return seq + + try: import cStringIO as StringIO except ImportError: *************** *** 252,256 **** return "%s * %s" % (self.type_name(t.typ, generate), int(t.max)+1) elif isinstance(t, typedesc.FunctionType): ! args = [self.type_name(x, generate) for x in [t.returns] + t.arguments] if "__stdcall__" in t.attributes: return "WINFUNCTYPE(%s)" % ", ".join(args) --- 269,273 ---- return "%s * %s" % (self.type_name(t.typ, generate), int(t.max)+1) elif isinstance(t, typedesc.FunctionType): ! args = [self.type_name(x, generate) for x in [t.returns] + list(t.iterArgTypes())] if "__stdcall__" in t.attributes: return "WINFUNCTYPE(%s)" % ", ".join(args) *************** *** 372,376 **** self._functiontypes += 1 self.generate(tp.returns) ! self.generate_all(tp.arguments) _pointertypes = 0 --- 389,393 ---- self._functiontypes += 1 self.generate(tp.returns) ! self.generate_all(tp.iterArgTypes()) _pointertypes = 0 *************** *** 446,450 **** methods.append(m) self.generate(m.returns) ! self.generate_all(m.arguments) elif type(m) is typedesc.Constructor: pass --- 463,467 ---- methods.append(m) self.generate(m.returns) ! self.generate_all(m.iterArgTypes()) elif type(m) is typedesc.Constructor: pass *************** *** 513,517 **** for m in methods: self.type_name(m.returns) ! for a in m.arguments: self.type_name(a) if "COMMETHOD" in self.known_symbols: --- 530,534 ---- for m in methods: self.type_name(m.returns) ! for a in m.iterArgTypes(): self.type_name(a) if "COMMETHOD" in self.known_symbols: *************** *** 535,539 **** self.type_name(m.returns), m.name) ! for a in m.arguments: print >> self.stream, \ " ( [], %s, )," % self.type_name(a) --- 552,556 ---- self.type_name(m.returns), m.name) ! for a in m.iterArgTypes(): print >> self.stream, \ " ( [], %s, )," % self.type_name(a) *************** *** 541,545 **** else: for m in methods: ! args = [self.type_name(a) for a in m.arguments] print >> self.stream, " STDMETHOD(%s, '%s', [%s])," % ( self.type_name(m.returns), --- 558,562 ---- else: for m in methods: ! args = [self.type_name(a) for a in m.iterArgTypes()] print >> self.stream, " STDMETHOD(%s, '%s', [%s])," % ( self.type_name(m.returns), *************** *** 609,614 **** if dllname: self.generate(func.returns) ! self.generate_all(func.arguments) ! args = [self.type_name(a) for a in func.arguments] if "__stdcall__" in func.attributes: cc = "stdcall" --- 626,631 ---- if dllname: self.generate(func.returns) ! self.generate_all(func.iterArgTypes()) ! args = [self.type_name(a) for a in func.iterArgTypes()] if "__stdcall__" in func.attributes: cc = "stdcall" *************** *** 620,624 **** print >> self.stream, "@ %s(%s, '%s', [%s])" % \ (cc, self.type_name(func.returns), libname, ", ".join(args)) ! argnames = ["p%d" % i for i in range(1, 1+len(args))] # function definition print >> self.stream, "def %s(%s):" % (func.name, ", ".join(argnames)) --- 637,641 ---- print >> self.stream, "@ %s(%s, '%s', [%s])" % \ (cc, self.type_name(func.returns), libname, ", ".join(args)) ! argnames = [a or "p%d" % (i+1) for i, a in enumerate(func.iterArgNames())] # function definition print >> self.stream, "def %s(%s):" % (func.name, ", ".join(argnames)) *************** *** 669,672 **** --- 686,697 ---- self.generate(item) + def cmpitems(a, b): + a = getattr(a, "location", None) + b = getattr(b, "location", None) + if a is None: return -1 + if b is None: return 1 + return cmp(a[0],b[0]) or cmp(int(a[1]),int(b[1])) + cmpitems = staticmethod(cmpitems) + def generate_code(self, items): print >> self.imports, "from ctypes import *" *************** *** 676,680 **** loops += 1 self.more = set() ! self.generate_all(items) items |= self.more --- 701,705 ---- loops += 1 self.more = set() ! self.generate_all(sorted(items, self.cmpitems)) items |= self.more Index: gccxmlparser.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/wrap/gccxmlparser.py,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -C2 -d -r1.2 -r1.2.2.1 *** gccxmlparser.py 11 Mar 2005 10:23:44 -0000 1.2 --- gccxmlparser.py 24 Aug 2005 08:16:35 -0000 1.2.2.1 *************** *** 185,189 **** def _fixup_Function(self, func): func.returns = self.all[func.returns] ! func.arguments = [self.all[a] for a in func.arguments] def FunctionType(self, attrs): --- 185,189 ---- def _fixup_Function(self, func): func.returns = self.all[func.returns] ! func.fixup_argtypes(self.all) def FunctionType(self, attrs): *************** *** 195,199 **** def _fixup_FunctionType(self, func): func.returns = self.all[func.returns] ! func.arguments = [self.all[a] for a in func.arguments] def OperatorFunction(self, attrs): --- 195,199 ---- def _fixup_FunctionType(self, func): func.returns = self.all[func.returns] ! func.fixup_argtypes(self.all) def OperatorFunction(self, attrs): *************** *** 220,230 **** def _fixup_Method(self, m): m.returns = self.all[m.returns] ! m.arguments = [self.all[a] for a in m.arguments] def Argument(self, attrs): - typ = attrs["type"] parent = self.context[-1] if parent is not None: ! parent.add_argument(typ) # name? # enumerations --- 220,229 ---- def _fixup_Method(self, m): m.returns = self.all[m.returns] ! m.fixup_argtypes(self.all) def Argument(self, attrs): parent = self.context[-1] if parent is not None: ! parent.add_argument(typedesc.Argument(attrs["type"], attrs.get("name"))) # enumerations |
From: Thomas H. <th...@us...> - 2005-08-24 08:11:22
|
Update of /cvsroot/ctypes/ctypes/ctypes/wrap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30142 Modified Files: Tag: branch_1_0 h2xml.py Log Message: A more usefull main function. Index: h2xml.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/wrap/h2xml.py,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -C2 -d -r1.3 -r1.3.2.1 *** h2xml.py 17 Mar 2005 19:01:25 -0000 1.3 --- h2xml.py 24 Aug 2005 08:11:14 -0000 1.3.2.1 *************** *** 24,28 **** ################################################################ ! def main(): def add_option(option, opt, value, parser): --- 24,30 ---- ################################################################ ! def main(argv=None): ! if argv is None: ! argv = sys.argv def add_option(option, opt, value, parser): *************** *** 111,115 **** default=[]) ! options, files = parser.parse_args() if not files: --- 113,117 ---- default=[]) ! options, files = parser.parse_args(argv[1:]) if not files: *************** *** 132,134 **** if __name__ == "__main__": ! main() --- 134,136 ---- if __name__ == "__main__": ! sys.exit(main()) |
From: Thomas H. <th...@us...> - 2005-08-24 08:10:56
|
Update of /cvsroot/ctypes/ctypes/ctypes/wrap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30053 Modified Files: Tag: branch_1_0 xml2py.py Log Message: A small fix. Index: xml2py.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/wrap/xml2py.py,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -C2 -d -r1.1 -r1.1.2.1 *** xml2py.py 4 Feb 2005 17:01:24 -0000 1.1 --- xml2py.py 24 Aug 2005 08:10:47 -0000 1.1.2.1 *************** *** 36,42 **** ##ntdll ! def main(args=None): ! if args is None: ! args = sys.argv def windows_dlls(option, opt, value, parser): --- 36,42 ---- ##ntdll ! def main(argv=None): ! if argv is None: ! argv = sys.argv def windows_dlls(option, opt, value, parser): *************** *** 118,122 **** default=default_modules) ! options, files = parser.parse_args(args[1:]) if len(files) != 1: --- 118,122 ---- default=default_modules) ! options, files = parser.parse_args(argv[1:]) if len(files) != 1: *************** *** 132,136 **** stream.write("# generated by 'xml2py'\n") ! stream.write("# flags '%s'\n" % " ".join(sys.argv[1:])) known_symbols = {} --- 132,136 ---- stream.write("# generated by 'xml2py'\n") ! stream.write("# flags '%s'\n" % " ".join(argv[1:])) known_symbols = {} |