[ctypes-commit] ctypes/ctypes/test test_loading.py,1.4,1.5 test_cfuncs.py,1.2,1.3
Brought to you by:
theller
From: Thomas H. <th...@us...> - 2006-03-10 17:35:37
|
Update of /cvsroot/ctypes/ctypes/ctypes/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22822 Modified Files: test_loading.py test_cfuncs.py Log Message: On Windows, it is now possible to access functions exported by ordinal by indexing the loaded dll with the ordinal number: my_function = somedll[42] To implement this, the signature of the _CFuncPtr class has changed. _CFuncPtr can now be called with these arguments: _CFuncPtr(integer address) -> foreign function _CFuncPtr(callable) -> create a C callable function from callable _CFuncPtr(integer index, method name) -> foreign function calling a COM method _CFuncPtr((ordinal number, dll object), ...) -> foreign function exported by ordinal _CFuncPtr((function name, dll object), ...) -> foreign function exported by name WINFUNCTYPE and CFUNCTYPE are factory functions for _CFuncPtr subclasses, so the above applies to the types returned from those as well. Index: test_cfuncs.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/test_cfuncs.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_cfuncs.py 3 Mar 2006 20:11:23 -0000 1.2 --- test_cfuncs.py 10 Mar 2006 17:35:30 -0000 1.3 *************** *** 180,184 **** if name[:2] == '__' and name[-2:] == '__': raise AttributeError, name ! func = self._FuncPtr("s_" + name, self) setattr(self, name, func) return func --- 180,184 ---- if name[:2] == '__' and name[-2:] == '__': raise AttributeError, name ! func = self._FuncPtr(("s_" + name, self)) setattr(self, name, func) return func Index: test_loading.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/test_loading.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test_loading.py 10 Mar 2006 15:40:47 -0000 1.4 --- test_loading.py 10 Mar 2006 17:35:30 -0000 1.5 *************** *** 47,51 **** if os.name in ("nt", "ce"): import _ctypes_test ! dll = CDLL(_ctypes_test.__file__) # We load the same function both via ordinal and name func_ord = dll[42] --- 47,51 ---- if os.name in ("nt", "ce"): import _ctypes_test ! dll = WinDLL(_ctypes_test.__file__) # We load the same function both via ordinal and name func_ord = dll[42] *************** *** 58,61 **** --- 58,62 ---- self.failUnlessEqual(hex(f_ord_addr), hex(f_name_addr)) + dll[1234] if __name__ == "__main__": |