ctypes-commit Mailing List for ctypes (Page 39)
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-09-29 12:43:11
|
Update of /cvsroot/ctypes/ctypes/comtypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21615 Modified Files: Tag: branch_1_0 GUID.py Log Message: Rename the GUID.progid() classmethod into GUID.as_progid(). Index: GUID.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/GUID.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 *** GUID.py 17 Aug 2005 16:02:13 -0000 1.6.2.3 --- GUID.py 29 Sep 2005 12:43:03 -0000 1.6.2.4 *************** *** 77,82 **** from_progid = classmethod(from_progid) ! def progid(self): ! "Get progid from guid" progid = c_wchar_p() _ProgIDFromCLSID(byref(self), byref(progid)) --- 77,82 ---- from_progid = classmethod(from_progid) ! def as_progid(self): ! "Convert a GUID into a progid" progid = c_wchar_p() _ProgIDFromCLSID(byref(self), byref(progid)) |
From: Thomas H. <th...@us...> - 2005-09-29 12:38:44
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20727 Modified Files: Tag: branch_1_0 test_paramflags.py Log Message: Test the errcheck protocol, and some tests for later. Index: test_paramflags.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_paramflags.py,v retrieving revision 1.6 retrieving revision 1.6.2.1 diff -C2 -d -r1.6 -r1.6.2.1 *** test_paramflags.py 10 Mar 2005 14:03:21 -0000 1.6 --- test_paramflags.py 29 Sep 2005 12:38:36 -0000 1.6.2.1 *************** *** 90,93 **** --- 90,101 ---- self.assertRaises(TypeError, lambda: func(hwnd=hwnd_desktop, spam=32)) + def checker(*args): + print "checker", args + + proto = CFUNCTYPE(c_int, c_long, POINTER(RECT)) + func = proto("my_GetWindowRect", dll, ((1, "hwnd"), (2,))) + + func.errcheck = checker + func(32) if os.name == "nt": *************** *** 129,132 **** --- 137,172 ---- #func(a=1) + ## def test_BSTR_inout(self): + ## # test BSTR [in, out] parameter + ## import _ctypes_test + ## dll = CDLL(_ctypes_test.__file__) + + ## from _ctypes import _SimpleCData + + ## class BSTR(_SimpleCData): + ## _type_ = "X" + ## def __repr__(self): + ## return "%s(%r)" % (self.__class__.__name__, self.value) + ## def __del__(self, _free=windll.oleaut32.SysFreeString): + ## if not self._b_base_: + ## _free(self) + + ## proto = CFUNCTYPE(None, BSTR) + ## func = proto("GetBSTR", dll, ((3, "p1"),)) + + ## self.failUnlessEqual(func("SPAM"), "XPAM") + + ## def test_c_wchar_p_out(self): + ## # XXX XXX XXX XXX XXX Doesn't this modify a Python string??? YES, it does. + ## # So, we have to forbid c_char_p and c_wchar_p as out parameter types. + ## import _ctypes_test + ## dll = CDLL(_ctypes_test.__file__) + + ## proto = CFUNCTYPE(None, POINTER(c_wchar))#c_wchar_p) + ## func = proto("GetBSTR", dll, ((3, "p1"),)) + ## text = u"foo bar" + ## print func(text) + ## print text + def test_multiple_outargs(self): import _ctypes_test |
From: Thomas H. <th...@us...> - 2005-09-29 12:37:31
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20448 Modified Files: Tag: branch_1_0 setup.py Log Message: Added (disabled) code for setuptools. Index: setup.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/setup.py,v retrieving revision 1.122.2.2 retrieving revision 1.122.2.3 diff -C2 -d -r1.122.2.2 -r1.122.2.3 *** setup.py 15 Apr 2005 13:01:20 -0000 1.122.2.2 --- setup.py 29 Sep 2005 12:37:20 -0000 1.122.2.3 *************** *** 16,19 **** --- 16,22 ---- ################################################################ + ##from ez_setup import use_setuptools + ##use_setuptools() + import os, sys *************** *** 488,491 **** --- 491,496 ---- if __name__ == '__main__': setup(name="ctypes", + ## entry_points = {"console_scripts" : ["xml2py = ctypes.wrap.xml2py:main", + ## "h2xml = ctypes.wrap.h2xml:main"]}, ext_modules = extensions, package_dir = package_dir, |
From: Bradley L S. <bs...@us...> - 2005-09-29 01:25:53
|
Update of /cvsroot/ctypes/ctypes-java/src/test/ctypes/java/test/generic In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20937/src/test/ctypes/java/test/generic Modified Files: TestNumbers.java StructTest.java TestChars.java PointerTest.java Log Message: Index: StructTest.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/test/ctypes/java/test/generic/StructTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** StructTest.java 15 Apr 2005 03:15:44 -0000 1.1 --- StructTest.java 29 Sep 2005 01:25:45 -0000 1.2 *************** *** 67,70 **** --- 67,72 ---- intArray.pin(); + + CAddress addr = intArray.getAddress(); assertEquals(5, addr.asCInt().getValue()); Index: TestChars.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/test/ctypes/java/test/generic/TestChars.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TestChars.java 15 Apr 2005 03:15:44 -0000 1.1 --- TestChars.java 29 Sep 2005 01:25:45 -0000 1.2 *************** *** 66,69 **** --- 66,70 ---- try { CString str = new CString("Hello"); + assertEquals("CBuffer object: unpinned, length=6", str.toString()); CBuffer buf = new CBuffer(str); Index: TestNumbers.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/test/ctypes/java/test/generic/TestNumbers.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TestNumbers.java 15 Apr 2005 03:15:44 -0000 1.1 --- TestNumbers.java 29 Sep 2005 01:25:45 -0000 1.2 *************** *** 31,34 **** --- 31,35 ---- import ctypes.java.CLongLong; import ctypes.java.CShort; + import ctypes.java.CULong; /** *************** *** 42,46 **** } ! public void testIntFromConstructor() { try { CInt i = new CInt(11); --- 43,47 ---- } ! public void testCIntFromConstructor() { try { CInt i = new CInt(11); *************** *** 51,55 **** } ! public void testIntFromPointer() { try { CInt i = new CInt(0xff); --- 52,78 ---- } ! public void testMaxCIntFromConstructor() { ! try { ! CInt i = new CInt(CInt.MAX_VALUE); ! i.pin(); ! assertEquals(i.getValue(), CInt.MAX_VALUE); ! ! } catch (Exception e) { ! fail(); ! } ! } ! ! public void testMinCIntFromConstructor() { ! try { ! CInt i = new CInt(CInt.MIN_VALUE); ! i.pin(); ! assertEquals(i.getValue(), CInt.MIN_VALUE); ! ! } catch (Exception e) { ! fail(); ! } ! } ! ! public void testCIntFromPointer() { try { CInt i = new CInt(0xff); *************** *** 64,67 **** --- 87,134 ---- } + public void testMaxULongAsInt() { + try { + CULong i = new CULong(CULong.MAX_VALUE); + i.pin(); + CInt ii = new CInt(i.getAddress()); + assertEquals(-1, ii.getValue()); + + } catch (Exception e) { + fail(); + } + } + + public void testMinULongAsInt() { + try { + CULong i = new CULong(CULong.MIN_VALUE); + i.pin(); + CInt ii = new CInt(i.getAddress()); + assertEquals(0, ii.getValue()); + + } catch (Exception e) { + fail(); + } + } + + public void testMinULongFromConstructor() { + try { + CULong i = new CULong(CULong.MIN_VALUE); + i.pin(); + assertEquals(i.getValue(), CULong.MIN_VALUE); + } catch (Exception e) { + fail(); + } + } + + public void testMaxULongFromConstructor() { + try { + CULong i = new CULong(CULong.MAX_VALUE); + i.pin(); + assertEquals(CULong.MAX_VALUE, i.getValue()); + } catch (Exception e) { + fail(); + } + } + public void testLongFromConstructor() { try { *************** *** 72,75 **** --- 139,143 ---- } } + public void testLongFromPointer() { *************** *** 110,115 **** public void testShortFromConstructor() { try { ! CLong i = new CLong(11); ! assertEquals(i.getValue(), 11); } catch (Exception e) { fail(); --- 178,183 ---- public void testShortFromConstructor() { try { ! CShort i = new CShort((short)11); ! assertEquals(i.getValue(), (short) 11); } catch (Exception e) { fail(); *************** *** 117,120 **** --- 185,206 ---- } + public void testMinCShortFromConstructor() { + try { + CShort i = new CShort(CShort.MAX_VALUE); + i.pin(); + assertEquals(i.getValue(), (short) CShort.MAX_VALUE); + } catch (Exception e) { + fail(); + } + } + public void testMaxCShortFromConstructor() { + try { + CShort i = new CShort(CShort.MIN_VALUE); + i.pin(); + assertEquals(i.getValue(), CShort.MIN_VALUE); + } catch (Exception e) { + fail(); + } + } public void testShortFromPointer() { try { Index: PointerTest.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/test/ctypes/java/test/generic/PointerTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PointerTest.java 15 Apr 2005 03:15:44 -0000 1.3 --- PointerTest.java 29 Sep 2005 01:25:45 -0000 1.4 *************** *** 23,28 **** --- 23,32 ---- package ctypes.java.test.generic; + import ctypes.java.CAddress; import ctypes.java.CInt; + import ctypes.java.CIntPtr; import ctypes.java.CPointer; + import ctypes.java.CULong; + import ctypes.java.CULongPtr; import junit.framework.Test; import junit.framework.TestCase; *************** *** 57,64 **** --- 61,105 ---- } + public void testIntPtr() { + try { + CInt i = new CInt(11); + assertEquals(11, i.getValue()); + i.pin(); + assertEquals(11, i.getValue()); + assertEquals(11, i.getAddress().asCInt().getValue()); + CIntPtr ptra = new CIntPtr(i); + ptra.pin(); + //assertEquals(ptra.getValue(), ptra.getAddress().getValue() ); + assertEquals(i.getAddress().getValue(), ptra.getValue()); + assertEquals(11, new CAddress(ptra.getValue()).asCInt().getValue()); + assertEquals(ptra.getCInt().getValue(), i.getValue()); + } catch (Exception e) { + fail(); + } + } + + public void testULongPtr() { + try { + CULong i = new CULong(11); + assertEquals(11, i.getValue()); + i.pin(); + assertEquals(11, i.getValue()); + assertEquals(11, i.getAddress().asCInt().getValue()); + CULongPtr ptra = new CULongPtr(i); + ptra.pin(); + //assertEquals(ptra.getValue(), ptra.getAddress().getValue() ); + assertEquals(i.getAddress().getValue(), ptra.getValue()); + assertEquals(11, new CAddress(ptra.getValue()).asCULong().getValue()); + assertEquals(ptra.getCULong().getValue(), i.getValue()); + } catch (Exception e) { + fail(); + } + } public void testPtrPtrA() { try { CInt i = new CInt(11); + i.pin(); CInt j = new CInt(22); + j.pin(); CPointer ptri = new CPointer(i); CPointer ptrj = new CPointer(j); |
From: Bradley L S. <bs...@us...> - 2005-09-29 01:25:53
|
Update of /cvsroot/ctypes/ctypes-java/src/test/ctypes/java/test/win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20937/src/test/ctypes/java/test/win32 Modified Files: CallbackTest.java Log Message: Index: CallbackTest.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/test/ctypes/java/test/win32/CallbackTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CallbackTest.java 29 Aug 2004 01:28:06 -0000 1.4 --- CallbackTest.java 29 Sep 2005 01:25:45 -0000 1.5 *************** *** 53,61 **** } ! public void testIntArray() { try { // create a memory backed array of integers ! CType[] array = { new CInt(5), new CInt(4), new CInt(3), --- 53,62 ---- } ! public void testArray() { try { // create a memory backed array of integers ! CType[] array = { ! new CInt(5), new CInt(4), new CInt(3), *************** *** 68,72 **** --- 69,96 ---- new CInt(0)}; CArray intArray = new CArray(array); + intArray.pin(); + assertNotNull(intArray.getElements()[0]); + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + } + public void testIntArray() { + try { + CType[] array = { + new CInt(5), + new CInt(4), + new CInt(3), + new CInt(1), + new CInt(7), + new CInt(9), + new CInt(33), + new CInt(2), + new CInt(99), + new CInt(0)}; + CArray intArray = new CArray(array); + intArray.pin(); + assertNotNull(intArray.getElements()[0]); /** * Callback function comparing two ints passed to it |
From: Bradley L S. <bs...@us...> - 2005-09-29 01:25:32
|
Update of /cvsroot/ctypes/ctypes-java/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20795/doc Modified Files: index.htm Log Message: Index: index.htm =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/doc/index.htm,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** index.htm 1 Apr 2004 05:36:35 -0000 1.3 --- index.htm 29 Sep 2005 01:25:19 -0000 1.4 *************** *** 1,68 **** ! <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> ! <!-- saved from url=(0047)http://starship.python.net/crew/theller/ctypes/ --> ! <HTML><HEAD><TITLE>The ctypes module</TITLE> ! <META http-equiv=content-type content="text/html; charset=ISO-8859-1"><LINK ! href="index_files/default.css" rel=STYLESHEET> ! <META content="MSHTML 6.00.2800.1141" name=GENERATOR> ! <link href="default.css" rel="stylesheet" type="text/css"> ! </HEAD> ! <BODY> ! <H1>The ctypes4j library</H1> ! <P>overview :: <A ! href="tutorial.htm">tutorial</A> </P> ! <H2>Overview</H2> ! <P><CODE>ctypes4j</CODE> is a Java library that enables calling legacy C functions ! without coding JNI. This enables simple and rapid prototyping when platform ! integration is required. Ctypes4j achieves this by providing classes that enable ! both the creation and manipulation of C data types in Java, and the calling ! of C level functions in dynamic link libraries/shared dlls. It is based on (and ! named after) the <a href="http://starship.python.net/crew/theller/ctypes/tutorial.html">Ctypes ! module for Python</a>, by Thomas Heller et al.</P> ! <P>CTypes4j aims to provide the same usability, and remain as close as possible ! alignent with the Python version. Furthermore, it is intended that this version ! will serve as the foundation for a <a href="http://www.jython.org/">Jython</a> ! binding with exactly the same API as the python one. </P> ! <P>It currently works on Windows & Linux. With a little configure effort, ! other unices should work.</P> ! <H2>News</H2> ! <P><STRONG><CODE>ctypes</CODE> version 0.2 has been released (1 April 2004)</STRONG>.</P> ! <P>Callbacks now work for Win32.We have a Linux port that works for calling functions ! (linux based callbacks untested).<br> ! Synchronized C layer code with ctypes-python 0.6.3<br> ! CStructs now introspect their component types. Alternatively the array based<br> ! constructor still works.<br> ! Reliable memory management between C and Java.<br> ! </P> ! <P> <STRONG><CODE><font color="#000000">ctypes</font></CODE><font color="#000000"> ! version 0.1 has been released</font></STRONG><font color="#000000">. </font></P> ! <P>Initial release. Support for calling C DLL's on windows works reliably for ! most C types, including structs.</P> ! <H2>Related works</H2> ! <P>Steve Holloway maintains the <a href="http://www.relevancellc.com/halloway/JavaWin32.html">Java/COM, ! Java/Win32 Integration resources.</a> In Steves classification system, CTypes4j ! is a proxy product.</P> ! <H2>Documentation</H2> ! <P>A tutorial is included in the source distribution, but also available <A ! href="tutorial.html">online</A>. You should also read the sample files in the ! source distribution.</P> ! <H2>Support</H2> ! <P>Support may be obtained in the <a href="http://sourceforge.net/mail/?group_id=71702">mailing lists</a> common to ctypes java and python.</P> ! <H2>Building</H2> ! <P>For those without the inclination or resources to build the JNI component of ctypes4j, a prebuild DLL and shared library are included in the respective platform distributions.</P> ! <P>For building on WIN32, the visual C++ compiler is currently required. The project and workspace files are those reliable way to build. For building under linux, you will need to first build and install the gcc-libffi-snapshot20030119.tar.gz snapshot of libffi, downloaded from the <a href="http://sourceforge.net/project/showfiles.php?group_id=71702"> ctypes/python SF project</a>. The autoconf build does not yet work for linux, you must manually edit the Makefile for now.</P> ! <H2>Downloads</H2> ! <P>The release can be downloaded in the <A ! href="http://sourceforge.net/project/showfiles.php?group_id=105719">sourceforge ! files section</A>.</P> ! <P>The release archives contain all the sources, the documentation you are reading ! here, unit tests, and example files in a <CODE>src</CODE> subdirectory. Looking ! at the examples is highly recommended in addition to reading the documentation.</P> ! <P>These files are distributed under the <A ! href="./LICENSE.txt">MIT license</A>.</P> ! <P> </P> ! <HR> ! <A ! href="sflogo.png"><IMG height=31 alt="SourceForge.net Logo" ! src="sflogo.png" width=88 border=0> </A><BR> ! <SMALL>Page updated: Thu ! Mon 30 March 2004</SMALL> </BODY></HTML> --- 1,295 ---- ! <html xmlns:v="urn:schemas-microsoft-com:vml" ! xmlns:o="urn:schemas-microsoft-com:office:office" ! xmlns:w="urn:schemas-microsoft-com:office:word" ! xmlns="http://www.w3.org/TR/REC-html40"> ! ! <head> ! <meta http-equiv=Content-Type content="text/html; charset=iso-8859-1"> ! <meta name=ProgId content=Word.Document> ! <meta name=Generator content="Microsoft Word 11"> ! <meta name=Originator content="Microsoft Word 11"> ! <link rel=File-List href="index_files/filelist.xml"> ! <link rel=Edit-Time-Data href="index_files/editdata.mso"> ! <!--[if !mso]> ! <style> ! v\:* {behavior:url(#default#VML);} ! o\:* {behavior:url(#default#VML);} ! w\:* {behavior:url(#default#VML);} ! .shape {behavior:url(#default#VML);} ! </style> ! <![endif]--> ! <title>The ctypes module</title> ! <!--[if gte mso 9]><xml> ! <o:DocumentProperties> ! <o:Author>bradley</o:Author> ! <o:LastAuthor>bradley</o:LastAuthor> ! <o:Revision>2</o:Revision> ! <o:TotalTime>6</o:TotalTime> ! <o:Created>2005-04-15T03:24:00Z</o:Created> ! <o:LastSaved>2005-04-15T03:30:00Z</o:LastSaved> ! <o:Pages>1</o:Pages> ! <o:Words>485</o:Words> ! <o:Characters>2768</o:Characters> ! <o:Company> </o:Company> ! <o:Lines>23</o:Lines> ! <o:Paragraphs>6</o:Paragraphs> ! <o:CharactersWithSpaces>3247</o:CharactersWithSpaces> ! <o:Version>11.6360</o:Version> ! </o:DocumentProperties> ! </xml><![endif]--><!--[if gte mso 9]><xml> ! <w:WordDocument> ! <w:ValidateAgainstSchemas/> ! <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> ! <w:IgnoreMixedContent>false</w:IgnoreMixedContent> ! <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> ! <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> ! </w:WordDocument> ! </xml><![endif]--><!--[if gte mso 9]><xml> ! <w:LatentStyles DefLockedState="false" LatentStyleCount="156"> ! </w:LatentStyles> ! </xml><![endif]--> ! <link rel=Stylesheet type="text/css" media=all href="index_files/default.css"> ! <link rel=Stylesheet type="text/css" media=all href=default.css> ! <style> ! <!-- ! /* Font Definitions */ ! @font-face ! {font-family:Verdana; ! panose-1:2 11 6 4 3 5 4 4 2 4; ! mso-font-charset:0; ! mso-generic-font-family:swiss; ! mso-font-pitch:variable; ! mso-font-signature:536871559 0 0 0 415 0;} ! /* Style Definitions */ ! p.MsoNormal, li.MsoNormal, div.MsoNormal ! {mso-style-parent:""; ! margin:0cm; ! margin-bottom:.0001pt; ! mso-pagination:widow-orphan; ! font-size:12.0pt; ! font-family:"Times New Roman"; ! mso-fareast-font-family:"Times New Roman";} ! h5 ! {mso-margin-top-alt:auto; ! margin-right:0cm; ! mso-margin-bottom-alt:auto; ! margin-left:0cm; ! mso-pagination:widow-orphan; ! mso-outline-level:5; ! font-size:10.0pt; ! font-weight:bold;} ! p ! {font-size:12.0pt; ! font-family:"Times New Roman"; ! mso-fareast-font-family:"Times New Roman";} ! code ! {mso-ansi-font-size:14.5pt; ! mso-bidi-font-size:14.5pt; ! mso-fareast-font-family:"Times New Roman";} ! pre ! {margin-top:0cm; ! margin-right:24.0pt; ! margin-bottom:0cm; ! margin-left:24.0pt; ! margin-bottom:.0001pt; ! font-size:14.5pt; ! mso-fareast-font-family:"Times New Roman";} ! tt ! {mso-ansi-font-size:14.5pt; ! mso-bidi-font-size:14.5pt; ! mso-fareast-font-family:"Times New Roman";} ! @page Section1 ! {size:612.0pt 792.0pt; ! margin:72.0pt 90.0pt 72.0pt 90.0pt; ! mso-header-margin:35.4pt; ! mso-footer-margin:35.4pt; ! mso-paper-source:0;} ! div.Section1 ! {page:Section1;} ! --> ! </style> ! <!--[if gte mso 10]> ! <style> ! /* Style Definitions */ ! table.MsoNormalTable ! {mso-style-name:"Table Normal"; ! mso-tstyle-rowband-size:0; ! mso-tstyle-colband-size:0; ! mso-style-noshow:yes; ! mso-style-parent:""; ! mso-padding-alt:0cm 5.4pt 0cm 5.4pt; ! mso-para-margin:0cm; ! mso-para-margin-bottom:.0001pt; ! mso-pagination:widow-orphan; ! font-size:10.0pt; ! mso-ansi-language:#0400; ! mso-fareast-language:#0400; ! mso-bidi-language:#0400;} ! </style> ! <![endif]--> ! </head> ! ! <body lang=EN-US link=blue vlink=blue style='tab-interval:36.0pt'> ! ! <div class=Section1> ! ! <h1><span style='font-size:13.5pt'>The ctypes4j library<o:p></o:p></span></h1> ! ! <p><span style='font-size:8.5pt;font-family:Verdana'>overview :: <a ! href="tutorial.htm">tutorial</a> <o:p></o:p></span></p> ! ! <h2><span style='font-size:12.0pt'>Overview<o:p></o:p></span></h2> ! ! <p><code><span style='font-size:10.0pt'>ctypes4j</span></code><span ! style='font-size:8.5pt;font-family:Verdana'> is a Java library that enables ! calling legacy C functions without coding JNI. This enables simple and rapid ! prototyping when platform integration is required. Ctypes4j achieves this by ! providing classes that enable both the creation and manipulation of C data ! types in Java, and the calling of C level functions in dynamic link ! libraries/shared dlls. It is based on (and named after) the <a ! href="http://starship.python.net/crew/theller/ctypes/tutorial.html">Ctypes ! module for Python</a>, by Thomas Heller et al.<o:p></o:p></span></p> ! ! <p><span style='font-size:8.5pt;font-family:Verdana'>CTypes4j aims to provide a ! simple to use method for platform integration without requiring a JNI ! programming. <o:p></o:p></span></p> ! ! <p><span style='font-size:8.5pt;font-family:Verdana'>It currently works on ! Windows & Linux. With a little configure effort, other unices should work.<o:p></o:p></span></p> ! ! <h2><span style='font-size:12.0pt'>News<o:p></o:p></span></h2> ! ! <p><b style='mso-bidi-font-weight:normal'><span style='font-size:10.0pt; ! font-family:Verdana;background:white;mso-highlight:white'>Version 0.8, </span></b><b ! style='mso-bidi-font-weight:normal'><span style='font-size:10.0pt;font-family: ! Verdana'>15 April 2005<o:p></o:p></span></b></p> ! ! <p><span style='font-size:8.0pt;font-family:Verdana;background:white; ! mso-highlight:white'><span style='mso-tab-count:1'> </span>More unit tests. ! Addition of pin method to pin a</span><span style='font-size:8.0pt;font-family: ! Verdana'> <span style='background:white;mso-highlight:white'>CType into a C ! level memory representation</span></span><span style='background:white; ! mso-highlight:white'>.</span><o:p></o:p></p> ! ! <p><span style='font-size:8.0pt;font-family:Verdana;background:white; ! mso-highlight:white'>Version 0.7, 29 Aug, 2004</span><span style='font-size: ! 8.0pt;font-family:Verdana'><o:p></o:p></span></p> ! ! <p><span style='font-size:8.0pt;font-family:Verdana;background:white; ! mso-highlight:white'><span style='mso-tab-count:1'> </span>Synchronized FFI ! code with ctypes-python 0.9.1</span><span style='font-size:8.0pt;font-family: ! Verdana'><o:p></o:p></span></p> ! ! <p><span style='font-size:8.0pt;font-family:Verdana;background:white; ! mso-highlight:white'><span style='mso-tab-count:1'> </span>Example Windows ! GUI API Application from JAWIN included</span><span style='font-size:8.0pt; ! font-family:Verdana'><o:p></o:p></span></p> ! ! <p><span style='font-size:8.0pt;font-family:Verdana;background:white; ! mso-highlight:white'>Version 0.2, 22 Mar, 2004</span><span style='font-size: ! 8.0pt;font-family:Verdana'><o:p></o:p></span></p> ! ! <p><span style='font-size:8.0pt;font-family:Verdana;background:white; ! mso-highlight:white'><span style='mso-tab-count:1'> </span>Callbacks working ! for Win32.</span><span style='font-size:8.0pt;font-family:Verdana'><o:p></o:p></span></p> ! ! <p><span style='font-size:8.0pt;font-family:Verdana;background:white; ! mso-highlight:white'><span style='mso-tab-count:1'> </span>Synchronized C ! code with ctypes-python 0.6.3</span><span style='font-size:8.0pt;font-family: ! Verdana'><o:p></o:p></span></p> ! ! <p><span style='font-size:8.0pt;font-family:Verdana;background:white; ! mso-highlight:white'><span style='mso-tab-count:1'> </span>Linux port ! working for calling functions.</span><span style='font-size:8.0pt;font-family: ! Verdana'><o:p></o:p></span></p> ! ! <p><span style='font-size:8.0pt;font-family:Verdana;background:white; ! mso-highlight:white'><span style='mso-tab-count:1'> </span>CStructs now ! introspect their component types. Alternatively the array based</span><span ! style='font-size:8.0pt;font-family:Verdana'> <span style='background:white; ! mso-highlight:white'>constructor still works.</span><o:p></o:p></span></p> ! ! <p><span style='font-size:8.0pt;font-family:Verdana;background:white; ! mso-highlight:white'><span style='mso-tab-count:1'> </span>Reliable memory ! management between C and Java.</span><span style='font-size:8.0pt;font-family: ! Verdana'><o:p></o:p></span></p> ! ! <p><span style='font-size:8.0pt;font-family:Verdana;background:white; ! mso-highlight:white'>Version 0.1.0, 03-08-2003:</span><span style='font-size: ! 8.0pt;font-family:Verdana'><o:p></o:p></span></p> ! ! <p><span style='font-size:8.0pt;font-family:Verdana'><span style='mso-tab-count: ! 1'> </span>I</span><span style='background:white;mso-highlight:white'>nitial ! Release</span></p> ! ! <h2><span style='font-size:12.0pt;mso-bidi-font-size:17.0pt'>Related works<o:p></o:p></span></h2> ! ! <p><span style='font-size:8.5pt;font-family:Verdana'>Steve Holloway maintains ! the <a href="http://www.relevancellc.com/halloway/JavaWin32.html">Java/COM, ! Java/Win32 Integration resources.</a> In Steves classification system, CTypes4j ! is a proxy product.<o:p></o:p></span></p> ! ! <h2><span style='font-size:12.0pt'>Documentation<o:p></o:p></span></h2> ! ! <p><span style='font-size:8.5pt;font-family:Verdana'>A tutorial is included in ! the source distribution, but also available <a href="tutorial.html">online</a>. ! You should also read the sample files in the source distribution.<o:p></o:p></span></p> ! ! <h2><span style='font-size:12.0pt'>Support<o:p></o:p></span></h2> ! ! <p><span style='font-size:8.5pt;font-family:Verdana'>Support may be obtained in ! the <a href="http://sourceforge.net/mail/?group_id=71702">mailing lists</a> ! common to ctypes java and python.<o:p></o:p></span></p> ! ! <h2><span style='font-size:12.0pt'>Building<o:p></o:p></span></h2> ! ! <p><span style='font-size:8.5pt;font-family:Verdana'>For those without the ! inclination or resources to build the JNI component of ctypes4j, a prebuild DLL ! and shared library are included in the respective platform distributions.<o:p></o:p></span></p> ! ! <p><span style='font-size:8.5pt;font-family:Verdana'>For building on WIN32, the ! visual C++ compiler is currently required. The project and workspace files are ! those reliable way to build. For building under linux, you will need to first ! build and install the gcc-libffi-snapshot20030119.tar.gz snapshot of libffi, ! downloaded from the <a ! href="http://sourceforge.net/project/showfiles.php?group_id=71702">ctypes/python ! SF project</a>. The autoconf build does not yet work for linux, you must ! manually edit the Makefile for now.<o:p></o:p></span></p> ! ! <h2><span style='font-size:12.0pt'>Downloads<o:p></o:p></span></h2> ! ! <p><span style='font-size:8.5pt;font-family:Verdana'>The release can be ! downloaded in the <a ! href="http://sourceforge.net/project/showfiles.php?group_id=105719">sourceforge ! files section</a>.<o:p></o:p></span></p> ! ! <p><span style='font-size:8.5pt;font-family:Verdana'>The release archives ! contain all the sources, the documentation you are reading here, unit tests, ! and example files in a </span><code><span style='font-size:10.0pt'>src</span></code><span ! style='font-size:8.5pt;font-family:Verdana'> subdirectory. Looking at the ! examples is highly recommended in addition to reading the documentation.<o:p></o:p></span></p> ! ! <p><span style='font-size:8.5pt;font-family:Verdana'>These files are ! distributed under the <a href="LICENSE.txt">MIT license</a>.<o:p></o:p></span></p> ! ! <p><span style='font-size:8.5pt;font-family:Verdana'> <o:p></o:p></span></p> ! ! <div class=MsoNormal align=center style='text-align:center'><span ! style='font-size:8.5pt;font-family:Verdana'> ! ! <hr size=2 width="100%" align=center> ! ! </span></div> ! ! <p class=MsoNormal><span style='font-size:8.5pt;font-family:Verdana'><a ! href="sflogo.png"><span style='text-decoration:none;text-underline:none'><img ! border=0 width=88 height=31 id="_x0000_i1026" src=sflogo.png ! alt="SourceForge.net Logo"></span></a><br> ! </span><span style='font-size:7.5pt;font-family:Verdana'>Page updated: Thu Mon ! 30 March 2004</span><span style='font-size:8.5pt;font-family:Verdana'> <o:p></o:p></span></p> ! ! </div> ! ! </body> ! ! </html> |
From: Bradley L S. <bs...@us...> - 2005-09-29 01:25:29
|
Update of /cvsroot/ctypes/ctypes-java/src/java/ctypes/java In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20795/src/java/ctypes/java Modified Files: CType.java CInt.java CAddress.java CULongPtr.java CShort.java CStruct.java CArray.java CULong.java CBuffer.java CIntPtr.java CFunction.java Log Message: Index: CShort.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/CShort.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CShort.java 15 Apr 2005 03:15:44 -0000 1.2 --- CShort.java 29 Sep 2005 01:25:19 -0000 1.3 *************** *** 26,29 **** --- 26,31 ---- public class CShort extends CType { short value = -1; + public static short MAX_VALUE = 32761; + public static short MIN_VALUE = -32761; public CShort(short value) { Index: CBuffer.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/CBuffer.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CBuffer.java 15 Apr 2005 03:15:44 -0000 1.5 --- CBuffer.java 29 Sep 2005 01:25:19 -0000 1.6 *************** *** 70,74 **** public String toString() { ! return "CBuffer object " + caddress.toString() + " length " + size; } --- 70,78 ---- public String toString() { ! if (caddress != null) { ! return "CBuffer object: " + caddress.toString() + ", length=" + size; ! } else { ! return "CBuffer object: unpinned, length=" + size; ! } } Index: CFunction.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/CFunction.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CFunction.java 29 Aug 2004 01:25:28 -0000 1.4 --- CFunction.java 29 Sep 2005 01:25:19 -0000 1.5 *************** *** 34,37 **** --- 34,39 ---- Class resType = null; + static boolean debug = true; + protected CFunction(CDLL dll, String symbol, long handle) { this.handle = handle; *************** *** 85,106 **** if (args != null) { for (int i = 0; i < args.length; i++) { ! if (!(args[i] instanceof CType) && (args[i] != null)) { ! throw new IllegalArgumentException("No types other than CTypes can be passed to this function."); ! } ! if (args[i] instanceof CBuffer ) { ! // for buffers we always pass the pointer ! // this is for char* void* and wchar* ! CType t = (CType) args[i]; ! if (!t.isMemoryBacked()) { ! // allocate some memory for this ! // type as it is not down in the ! // C layer yet ! args[i] = new CBuffer(t); } ! } else if (args[i] instanceof CStruct) { ! CStruct struct = (CStruct) args[i]; ! if (!struct.isMemoryBacked()) { ! CStruct t = (CStruct) args[i]; ! args[i] = new CBuffer(struct); } } --- 87,110 ---- if (args != null) { for (int i = 0; i < args.length; i++) { ! if (args[i] != null) { ! if (!(args[i] instanceof CType) && (args[i] != null)) { ! throw new IllegalArgumentException("No types other than CTypes can be passed to this function."); } ! if (args[i] instanceof CBuffer ) { ! // for buffers we always pass the pointer ! // this is for char* void* and wchar* ! CType t = (CType) args[i]; ! if (!t.isMemoryBacked()) { ! // allocate some memory for this ! // type as it is not down in the ! // C layer yet ! args[i] = new CBuffer(t); ! } ! } else if (args[i] instanceof CStruct) { ! CStruct struct = (CStruct) args[i]; ! if (!struct.isMemoryBacked()) { ! CStruct t = (CStruct) args[i]; ! args[i] = new CBuffer(struct); ! } } } *************** *** 110,115 **** --- 114,141 ---- } + if (debug) { + logArgs(args); + } return callInternal(handle, restype, args, flags); } + + + void logArgs(Object[] args) throws CException{ + System.err.println("Calling " + symbol + " with args:"); + boolean needsCRLF = false; + for (int i = 0 ; i < args.length ; i++) { + if (args[i] != null) { + ((CType)args[i]).dump(1); + needsCRLF = true; + } else { + if (needsCRLF) + System.err.println(); + System.err.print("\t"); + System.err.print("null"); + needsCRLF = true; + + } + } + } /** * @return Index: CIntPtr.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/CIntPtr.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CIntPtr.java 15 Apr 2005 03:15:44 -0000 1.2 --- CIntPtr.java 29 Sep 2005 01:25:19 -0000 1.3 *************** *** 48,52 **** public CIntPtr(long handle) { ! super(new CAddress(handle)); } --- 48,58 ---- public CIntPtr(long handle) { ! ! super(new CAddress((int)handle)); ! int i = (int) handle; ! long ll = (long) i; ! System.out.println("init Cintptr " + (int) handle ); ! this.isAtomic = true; ! this.memoryBacked = true; } *************** *** 62,66 **** if (pointee == null) { pointee = new CInt(); ! pointee.setAddress(caddress, CType.SyncDirection.ToJava); } return pointee; --- 68,76 ---- if (pointee == null) { pointee = new CInt(); ! if (isMemoryBacked()) { ! pointee.setAddress(new CAddress(getAddress().asCInt().getValue()), CType.SyncDirection.ToJava); ! } else { ! pointee.setAddress(new CAddress(value), CType.SyncDirection.ToJava); ! } } return pointee; Index: CULong.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/CULong.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CULong.java 15 Apr 2005 03:15:44 -0000 1.2 --- CULong.java 29 Sep 2005 01:25:19 -0000 1.3 *************** *** 26,30 **** public class CULong extends CType { long value = -1; ! public CULong(long value) { //init with size of 4 bytes --- 26,32 ---- public class CULong extends CType { long value = -1; ! public static long MAX_VALUE = 4294967295L; ! public static long MIN_VALUE = 0; ! public CULong(long value) { //init with size of 4 bytes Index: CULongPtr.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/CULongPtr.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CULongPtr.java 15 Apr 2005 03:15:44 -0000 1.2 --- CULongPtr.java 29 Sep 2005 01:25:19 -0000 1.3 *************** *** 31,35 **** */ public class CULongPtr extends CPointer { ! /** * --- 31,35 ---- */ public class CULongPtr extends CPointer { ! CULong pointee = null; /** * *************** *** 55,60 **** public CULong getCULong() throws CException { ! CULong c = new CULong(caddress); ! return c; } } --- 55,67 ---- public CULong getCULong() throws CException { ! if (pointee == null) { ! pointee = new CULong(); ! if (isMemoryBacked()) { ! pointee.setAddress(new CAddress(getAddress().asCInt().getValue()), CType.SyncDirection.ToJava); ! } else { ! pointee.setAddress(new CAddress(value), CType.SyncDirection.ToJava); ! } ! } ! return pointee; } } Index: CType.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/CType.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** CType.java 15 Apr 2005 03:15:44 -0000 1.7 --- CType.java 29 Sep 2005 01:25:19 -0000 1.8 *************** *** 119,122 **** --- 119,123 ---- if (caddress != CAddress.NULL) { memoryBacked = true; + isAtomic = true; } } *************** *** 139,143 **** public void pin() throws CException { CAddress caddress = allocate(sizeOf()); ! setAddress(caddress, CType.SyncDirection.ToC); } --- 140,145 ---- public void pin() throws CException { CAddress caddress = allocate(sizeOf()); ! setAddress(caddress, CType.SyncDirection.ToC); ! hasValue = true; } *************** *** 156,164 **** } buf.append(this.getClass().getName()); ! buf.append(":Hash 0x"); ! buf.append(Integer.toHexString(hashCode())); if (isMemoryBacked()) { buf.append(caddress.toString()); } } --- 158,168 ---- } buf.append(this.getClass().getName()); ! if (isMemoryBacked()) { buf.append(caddress.toString()); } + buf.append(":Hash 0x"); + buf.append(Integer.toHexString(hashCode())); + } *************** *** 174,178 **** System.err.print(caddress.toString()); } - } public String toString() { --- 178,181 ---- Index: CStruct.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/CStruct.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** CStruct.java 15 Apr 2005 03:15:44 -0000 1.6 --- CStruct.java 29 Sep 2005 01:25:19 -0000 1.7 *************** *** 38,42 **** protected CType[] elements = null; int allocated = 0; ! boolean initialized = false; /** --- 38,42 ---- protected CType[] elements = null; int allocated = 0; ! protected boolean isMemberFieldsProcessed = false; /** *************** *** 51,55 **** super(); elements = contents; ! initialized = true; } --- 51,55 ---- super(); elements = contents; ! isMemberFieldsProcessed = true; } *************** *** 72,77 **** public int sizeOf() { ! if (!initialized) { processClass(); } int sz = 0; --- 72,78 ---- public int sizeOf() { ! if (!isMemberFieldsProcessed && ! (this instanceof CArray )) { processClass(); + isMemberFieldsProcessed = true; } int sz = 0; *************** *** 92,96 **** */ public CType[] getElements() { ! if (!initialized) { processClass(); } --- 93,97 ---- */ public CType[] getElements() { ! if (!isMemberFieldsProcessed && ! (this instanceof CArray)) { processClass(); } *************** *** 103,109 **** public void setElements(CType[] types) { elements = types; ! initialized = false; } protected CAddress allocate(int size) throws CException { this.size = size; --- 104,115 ---- public void setElements(CType[] types) { elements = types; ! isMemberFieldsProcessed = false; } + public void pin() throws CException { + isMemberFieldsProcessed = false; + super.pin(); + } + protected CAddress allocate(int size) throws CException { this.size = size; *************** *** 118,122 **** public void dump(StringBuffer buf, int level) throws CException { ! if (!initialized) { processClass(); } --- 124,128 ---- public void dump(StringBuffer buf, int level) throws CException { ! if (!isMemberFieldsProcessed) { processClass(); } *************** *** 132,136 **** public void dump(int level) throws CException { ! if (!initialized) { processClass(); } --- 138,142 ---- public void dump(int level) throws CException { ! if (!isMemberFieldsProcessed) { processClass(); } *************** *** 146,150 **** public int getLength() { ! if (!initialized) { processClass(); } --- 152,156 ---- public int getLength() { ! if (!isMemberFieldsProcessed && ! (this instanceof CArray)) { processClass(); } *************** *** 155,170 **** ArrayList l = new ArrayList(); processClass(this.getClass(), l); ! elements = new CType[l.size()]; ! for (int i=0; i < l.size() ; i++) { ! elements[i] = (CType) l.get(i); } ! initialized = false; } void processClass(Class c, ArrayList fields) { ! Class parent = c.getSuperclass(); ! if (! parent.equals(CStruct.class)) { ! processClass(parent, fields); } Field[] f = c.getDeclaredFields(); for (int i = 0 ; i < f.length ; i++) { --- 161,178 ---- ArrayList l = new ArrayList(); processClass(this.getClass(), l); ! if (l.size() > 0) { ! elements = new CType[l.size()]; ! for (int i=0; i < l.size() ; i++) { ! elements[i] = (CType) l.get(i); ! } } ! isMemberFieldsProcessed = false; } void processClass(Class c, ArrayList fields) { ! if (!c.equals(CStruct.class)) { ! processClass(c.getSuperclass(), fields); } + Field[] f = c.getDeclaredFields(); for (int i = 0 ; i < f.length ; i++) { Index: CArray.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/CArray.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CArray.java 5 Aug 2003 22:54:59 -0000 1.1 --- CArray.java 29 Sep 2005 01:25:19 -0000 1.2 *************** *** 45,48 **** --- 45,49 ---- } + /** * @param size Index: CAddress.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/CAddress.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CAddress.java 15 Apr 2005 03:15:44 -0000 1.1 --- CAddress.java 29 Sep 2005 01:25:19 -0000 1.2 *************** *** 42,45 **** --- 42,51 ---- } + public CULong asCULong() throws CException { + CULong i = new CULong(); + i.setAddress(this, CType.SyncDirection.ToJava); + return i; + } + public CLongLong asCLongLong() throws CException { CLongLong i = new CLongLong(); Index: CInt.java =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/src/java/ctypes/java/CInt.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CInt.java 15 Apr 2005 03:15:44 -0000 1.4 --- CInt.java 29 Sep 2005 01:25:19 -0000 1.5 *************** *** 26,30 **** public class CInt extends CType implements CReturnable { int value = -1; ! public CInt(int value) { //init with size of 4 bytes --- 26,32 ---- public class CInt extends CType implements CReturnable { int value = -1; ! static public int MAX_VALUE = 2147483647; ! static public int MIN_VALUE = -2147483647; ! public CInt(int value) { //init with size of 4 bytes |
From: Bradley L S. <bs...@us...> - 2005-09-29 01:25:27
|
Update of /cvsroot/ctypes/ctypes-java In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20795 Modified Files: README.txt NEWS.txt Log Message: Index: NEWS.txt =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/NEWS.txt,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** NEWS.txt 15 Apr 2005 03:15:46 -0000 1.4 --- NEWS.txt 29 Sep 2005 01:25:19 -0000 1.5 *************** *** 1,5 **** ctypes.java News - ! Version 0.8, Version 0.7, 29 Aug, 2004 --- 1,7 ---- ctypes.java News - ! Version 0.8, 15 April 2005 ! More unit tests. Addition of pin method to pin a ! CType into a C level memory representation. Version 0.7, 29 Aug, 2004 Index: README.txt =================================================================== RCS file: /cvsroot/ctypes/ctypes-java/README.txt,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** README.txt 29 Aug 2004 01:27:25 -0000 1.3 --- README.txt 29 Sep 2005 01:25:19 -0000 1.4 *************** *** 1,8 **** ! ctypes4j is a java/C framework allowing the creation and manipulation of C data types, ! and calling arbitraty C functions in java, without the need for using JNI. Provision for loading and accessing functions from windows DLL's and UNIX shared libraries is included. This java implementation enables the following: ! * Allow calling native c/c++ fuctions underlying your java platform of choice * Further provide a basis for COM interopability with java. * Form the basis of a jython port of ctypes/python. --- 1,9 ---- ! ctypes4j is a java/C framework facilitating the creation and manipulation of C data types, ! and calling arbitraty C/C++ functions in java, without the need for using JNI. Provision for loading and accessing functions from windows DLL's and UNIX shared libraries is included. This java implementation enables the following: ! * Allow calling native libraries and c/c++ fuctions underlying your java platform ! * Support for arbitrary callback methods * Further provide a basis for COM interopability with java. * Form the basis of a jython port of ctypes/python. *************** *** 13,20 **** layer objects passed to the function into concrete cypes/java classes and vise versa. - For the moment, I have targeted only windows, the support of unix in ctypes/python is - intended to be woven in in a later release. Support for 64bit Java is designed in, - however the JNI layer will need some tweaking to get this to work. - The C-layer elements of this package, and also much of the text you are reading now, are largely derived from Thomas Heller's Python ctypes implementation. It in turn is --- 14,17 ---- *************** *** 27,31 **** ! Current version: 0.7.0 Homepage: http://ctypes4j.sourceforge.net/ --- 24,28 ---- ! Current version: 0.8.0 Homepage: http://ctypes4j.sourceforge.net/ |
From: Thomas H. <th...@us...> - 2005-09-06 12:00:41
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3711 Modified Files: Tag: branch_1_0 ChangeLog Log Message: Fixed another bug. Index: ChangeLog =================================================================== RCS file: /cvsroot/ctypes/ctypes/ChangeLog,v retrieving revision 1.86.2.19 retrieving revision 1.86.2.20 diff -C2 -d -r1.86.2.19 -r1.86.2.20 *** ChangeLog 2 Sep 2005 20:01:35 -0000 1.86.2.19 --- ChangeLog 6 Sep 2005 12:00:29 -0000 1.86.2.20 *************** *** 1,2 **** --- 1,8 ---- + 2005-09-06 Thomas Heller <th...@py...> + + * source\_ctypes.c (CData_FromBaseObj): Forgot to set the b_size + member. This had the effect that sizeof(obj) return always zero + for objects retrieved from structure fields, for example. + 2005-09-02 Thomas Heller <th...@py...> |
From: Thomas H. <th...@us...> - 2005-09-06 11:15:11
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28580 Modified Files: Tag: branch_1_0 _ctypes.c Log Message: Oops: forgot to set the b_size field in CData_FromBaseObj(). Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.226.2.29 retrieving revision 1.226.2.30 diff -C2 -d -r1.226.2.29 -r1.226.2.30 *** _ctypes.c 2 Sep 2005 19:56:36 -0000 1.226.2.29 --- _ctypes.c 6 Sep 2005 11:15:02 -0000 1.226.2.30 *************** *** 1881,1884 **** --- 1881,1885 ---- cmem->b_length = dict->length; + cmem->b_size = dict->size; if (base) { /* use base's buffer */ assert(CDataObject_Check(base)); *************** *** 2272,2276 **** --- 2273,2279 ---- _check_outarg_type(PyObject *arg, int index) { + #if 0 StgDictObject *dict; + #endif if (PointerTypeObject_Check(arg)) |
From: Thomas H. <th...@us...> - 2005-09-02 20:02:17
|
Update of /cvsroot/ctypes/ctypes/comtypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9886 Added Files: Tag: branch_1_0 ChangeLog Log Message: Changelog for comtypes. --- NEW FILE: ChangeLog --- 2005-09-02 Thomas Heller <th...@py...> * comtypes/client/__init__.py: Can now receive events from custom, non-dispatch interfaces. |
From: Thomas H. <th...@us...> - 2005-09-02 20:01:43
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9766 Modified Files: Tag: branch_1_0 ChangeLog Log Message: Index: ChangeLog =================================================================== RCS file: /cvsroot/ctypes/ctypes/ChangeLog,v retrieving revision 1.86.2.18 retrieving revision 1.86.2.19 diff -C2 -d -r1.86.2.18 -r1.86.2.19 *** ChangeLog 2 Sep 2005 17:35:04 -0000 1.86.2.18 --- ChangeLog 2 Sep 2005 20:01:35 -0000 1.86.2.19 *************** *** 1,4 **** --- 1,11 ---- 2005-09-02 Thomas Heller <th...@py...> + * source: Implemented Mike Fletcher's errcheck protocol. A new + 'errcheck' field has been added to CFuncPtrObject. If the + function has an 'errcheck' attribute, this is called with + (function_return_value, function, arguments, ...) and the result + of this call is returned. The 'errcheck' function must accept + more than three parameters for future compatibility. + * source/callproc.c: Call checker (which is the _check_retval_ attribute of the restype) also when restype is *not* a simple |
From: Thomas H. <th...@us...> - 2005-09-02 19:56:44
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8956 Modified Files: Tag: branch_1_0 ctypes.h _ctypes.c Log Message: Implement Mike Fletcher's errcheck protocol. Rename a variable to better describe the purpose. Index: ctypes.h =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/ctypes.h,v retrieving revision 1.74.2.4 retrieving revision 1.74.2.5 diff -C2 -d -r1.74.2.4 -r1.74.2.5 *** ctypes.h 30 Aug 2005 07:11:37 -0000 1.74.2.4 --- ctypes.h 2 Sep 2005 19:56:36 -0000 1.74.2.5 *************** *** 82,85 **** --- 82,86 ---- PyObject *restype; PyObject *checker; + PyObject *errcheck; #ifdef MS_WIN32 int index; Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.226.2.28 retrieving revision 1.226.2.29 diff -C2 -d -r1.226.2.28 -r1.226.2.29 *** _ctypes.c 2 Sep 2005 17:26:24 -0000 1.226.2.28 --- _ctypes.c 2 Sep 2005 19:56:36 -0000 1.226.2.29 *************** *** 1538,1541 **** --- 1538,1553 ---- PyErr_Clear(); } + /* XXX later, maybe. + ob = PyDict_GetItemString((PyObject *)stgdict, "_errcheck_"); + if (ob) { + if (!PyCallable_Check(ob)) { + PyErr_SetString(PyExc_TypeError, + "_errcheck_ must be callable"); + return -1; + } + Py_INCREF(ob); + stgdict->errcheck = ob; + } + */ return 0; *************** *** 2102,2105 **** --- 2114,2142 ---- static int + CFuncPtr_set_errcheck(CFuncPtrObject *self, PyObject *ob) + { + if (ob && !PyCallable_Check(ob)) { + PyErr_SetString(PyExc_TypeError, + "the errcheck attribute must be callable"); + return -1; + } + Py_XDECREF(self->errcheck); + Py_XINCREF(ob); + self->errcheck = ob; + return 0; + } + + static PyObject * + CFuncPtr_get_errcheck(CFuncPtrObject *self) + { + if (self->errcheck) { + Py_INCREF(self->errcheck); + return self->errcheck; + } + Py_INCREF(Py_None); + return Py_None; + } + + static int CFuncPtr_set_restype(CFuncPtrObject *self, PyObject *ob) { *************** *** 2188,2191 **** --- 2225,2230 ---- static PyGetSetDef CFuncPtr_getsets[] = { + { "errcheck", (getter)CFuncPtr_get_errcheck, (setter)CFuncPtr_set_errcheck, + "a function to check for errors", NULL }, { "restype", (getter)CFuncPtr_get_restype, (setter)CFuncPtr_set_restype, "specify the result type", NULL }, *************** *** 2612,2616 **** _build_callargs(CFuncPtrObject *self, PyObject *argtypes, PyObject *inargs, PyObject *kwds, ! PyObject **pretval) { PyObject *paramflags = self->paramflags; --- 2651,2655 ---- _build_callargs(CFuncPtrObject *self, PyObject *argtypes, PyObject *inargs, PyObject *kwds, ! PyObject **poutargs) { PyObject *paramflags = self->paramflags; *************** *** 2625,2629 **** int actual_args; ! *pretval = NULL; /* Trivial cases, where we either return inargs itself, or a slice of it. */ if (argtypes == NULL || paramflags == NULL || PyTuple_GET_SIZE(argtypes) == 0) { --- 2664,2668 ---- int actual_args; ! *poutargs = NULL; /* Trivial cases, where we either return inargs itself, or a slice of it. */ if (argtypes == NULL || paramflags == NULL || PyTuple_GET_SIZE(argtypes) == 0) { *************** *** 2764,2774 **** int j; case 0: ! *pretval = NULL; break; case 1: for (i = 0; i < 32; ++i) { if (outmask & (1 << i)) { ! *pretval = PyTuple_GET_ITEM(callargs, i); ! Py_INCREF(*pretval); break; } --- 2803,2813 ---- int j; case 0: ! *poutargs = NULL; break; case 1: for (i = 0; i < 32; ++i) { if (outmask & (1 << i)) { ! *poutargs = PyTuple_GET_ITEM(callargs, i); ! Py_INCREF(*poutargs); break; } *************** *** 2776,2780 **** break; default: ! *pretval = PyTuple_New(len); j = 0; for (i = 0; i < 32; ++i) { --- 2815,2819 ---- break; default: ! *poutargs = PyTuple_New(len); j = 0; for (i = 0; i < 32; ++i) { *************** *** 2783,2787 **** ob = PyTuple_GET_ITEM(callargs, i); Py_INCREF(ob); ! PyTuple_SET_ITEM(*pretval, j, ob); ++j; } --- 2822,2826 ---- ob = PyTuple_GET_ITEM(callargs, i); Py_INCREF(ob); ! PyTuple_SET_ITEM(*poutargs, j, ob); ++j; } *************** *** 2810,2840 **** static PyObject * ! _build_result(PyObject *result, PyObject *retval) { int i, len; ! if (retval == NULL) return result; if (result == NULL) { ! Py_DECREF(retval); return NULL; } Py_DECREF(result); ! if (!PyTuple_CheckExact(retval)) { ! PyObject *v = _get_one(retval); ! Py_DECREF(retval); return v; } ! assert (retval->ob_refcnt == 1); ! /* We know we are sole owner of the retval tuple. So, we can replace the values in it instead of allocating a new one. */ ! len = PyTuple_GET_SIZE(retval); for (i = 0; i < len; ++i) { ! PyObject *ob = _get_one(PyTuple_GET_ITEM(retval, i)); ! PyTuple_SetItem(retval, i, ob); } ! return retval; } --- 2849,2879 ---- static PyObject * ! _build_result(PyObject *result, PyObject *outargs) { int i, len; ! if (outargs == NULL) return result; if (result == NULL) { ! Py_DECREF(outargs); return NULL; } Py_DECREF(result); ! if (!PyTuple_CheckExact(outargs)) { ! PyObject *v = _get_one(outargs); ! Py_DECREF(outargs); return v; } ! assert (outargs->ob_refcnt == 1); ! /* We know we are sole owner of the outargs tuple. So, we can replace the values in it instead of allocating a new one. */ ! len = PyTuple_GET_SIZE(outargs); for (i = 0; i < len; ++i) { ! PyObject *ob = _get_one(PyTuple_GET_ITEM(outargs, i)); ! PyTuple_SetItem(outargs, i, ob); } ! return outargs; } *************** *** 2849,2853 **** PyObject *result; PyObject *callargs; ! PyObject *retval; #ifdef MS_WIN32 IUnknown *piunk = NULL; --- 2888,2893 ---- PyObject *result; PyObject *callargs; ! PyObject *outargs; ! PyObject *errcheck; #ifdef MS_WIN32 IUnknown *piunk = NULL; *************** *** 2860,2863 **** --- 2900,2905 ---- checker = self->checker ? self->checker : dict->checker; argtypes = self->argtypes ? self->argtypes : dict->argtypes; + /* later, we probably want to have an errcheck field in stgdict */ + errcheck = self->errcheck /* ? self->errcheck : dict->errcheck */; *************** *** 2894,2900 **** } #endif ! callargs = _build_callargs(self, argtypes, inargs, kwds, &retval); if (callargs == NULL) { ! Py_XDECREF(retval); return NULL; } --- 2936,2942 ---- } #endif ! callargs = _build_callargs(self, argtypes, inargs, kwds, &outargs); if (callargs == NULL) { ! Py_XDECREF(outargs); return NULL; } *************** *** 2938,2943 **** restype, checker); Py_DECREF(callargs); ! return _build_result(result, retval); } --- 2980,3002 ---- restype, checker); + /* The 'errcheck' protocol */ + if (result != NULL && errcheck) { + PyObject *v = PyObject_CallFunctionObjArgs(errcheck, + result, + self, + callargs, + outargs, + NULL); + Py_DECREF(result); + Py_DECREF(callargs); + return v; + } + Py_DECREF(callargs); ! /* _build_result assumes that we are the sole owner of the outargs ! tuple. Since _build_result is never called when errcheck is used ! (see above), this assumtion is still true. ! */ ! return _build_result(result, outargs); } *************** *** 2948,2951 **** --- 3007,3011 ---- Py_VISIT(self->restype); Py_VISIT(self->checker); + Py_VISIT(self->errcheck); Py_VISIT(self->argtypes); Py_VISIT(self->converters); *************** *** 2961,2964 **** --- 3021,3025 ---- Py_CLEAR(self->restype); Py_CLEAR(self->checker); + Py_CLEAR(self->errcheck); Py_CLEAR(self->argtypes); Py_CLEAR(self->converters); |
From: Thomas H. <th...@us...> - 2005-09-02 17:35:12
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5682 Modified Files: Tag: branch_1_0 ChangeLog Log Message: Call _check_retval_ also when restype is not a 'simple' ctypes type. Index: ChangeLog =================================================================== RCS file: /cvsroot/ctypes/ctypes/ChangeLog,v retrieving revision 1.86.2.17 retrieving revision 1.86.2.18 diff -C2 -d -r1.86.2.17 -r1.86.2.18 *** ChangeLog 30 Aug 2005 07:12:43 -0000 1.86.2.17 --- ChangeLog 2 Sep 2005 17:35:04 -0000 1.86.2.18 *************** *** 1,2 **** --- 1,8 ---- + 2005-09-02 Thomas Heller <th...@py...> + + * source/callproc.c: Call checker (which is the _check_retval_ + attribute of the restype) also when restype is *not* a simple + ctypes type. + 2005-08-30 Thomas Heller <th...@py...> |
From: Thomas H. <th...@us...> - 2005-09-02 17:28:16
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4471 Modified Files: Tag: branch_1_0 callproc.c Log Message: Call _check_retval_ also when restype is not a 'simple' ctypes type. Index: callproc.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/callproc.c,v retrieving revision 1.127.2.12 retrieving revision 1.127.2.13 diff -C2 -d -r1.127.2.12 -r1.127.2.13 *** callproc.c 30 Aug 2005 09:33:31 -0000 1.127.2.12 --- callproc.c 2 Sep 2005 17:28:05 -0000 1.127.2.13 *************** *** 703,706 **** --- 703,707 ---- { StgDictObject *dict; + PyObject *retval, *v; if (restype == NULL) *************** *** 716,736 **** return PyObject_CallFunction(restype, "i", *(int *)result); ! if (dict->getfunc) { ! PyObject *retval, *v; retval = dict->getfunc(result, dict->size); ! if (!checker || !retval) ! return retval; ! v = PyObject_CallFunctionObjArgs(checker, retval, NULL); ! if (v == NULL) ! _AddTraceback("GetResult", __FILE__, __LINE__-2); ! Py_DECREF(retval); ! return v; ! } ! /* When __ctypes_check_retval__ is introduced, ! call this on the result we get here. ! And later, get rid of the checker stuff. ! */ ! return CData_FromBaseObj(restype, NULL, 0, result); } --- 717,733 ---- return PyObject_CallFunction(restype, "i", *(int *)result); ! if (dict->getfunc) retval = dict->getfunc(result, dict->size); ! else ! retval = CData_FromBaseObj(restype, NULL, 0, result); ! if (!checker || !retval) ! return retval; ! ! v = PyObject_CallFunctionObjArgs(checker, retval, NULL); ! if (v == NULL) ! _AddTraceback("GetResult", __FILE__, __LINE__-2); ! Py_DECREF(retval); ! return v; } |
From: Thomas H. <th...@us...> - 2005-09-02 17:26:36
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4181 Modified Files: Tag: branch_1_0 _ctypes.c Log Message: Fix a refcount leak. Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.226.2.27 retrieving revision 1.226.2.28 diff -C2 -d -r1.226.2.27 -r1.226.2.28 *** _ctypes.c 26 Aug 2005 10:00:25 -0000 1.226.2.27 --- _ctypes.c 2 Sep 2005 17:26:24 -0000 1.226.2.28 *************** *** 2116,2119 **** --- 2116,2120 ---- return -1; } + Py_XDECREF(self->checker); Py_XDECREF(self->restype); Py_INCREF(ob); |
From: Thomas H. <th...@us...> - 2005-09-02 16:54:27
|
Update of /cvsroot/ctypes/ctypes/comtypes/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27745 Modified Files: Tag: branch_1_0 __init__.py Log Message: Can now receive events from custom, non-dispatch interfaces. Index: __init__.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/client/Attic/__init__.py,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -C2 -d -r1.1.2.5 -r1.1.2.6 *** __init__.py 25 Aug 2005 07:41:13 -0000 1.1.2.5 --- __init__.py 2 Sep 2005 16:54:03 -0000 1.1.2.6 *************** *** 412,436 **** interface = comtypes.com_interface_registry[str(guid)] ! class EventReceiver(comtypes.COMObject): ! _com_interfaces_ = [interface] ! def IDispatch_Invoke(self, this, memid, riid, lcid, wFlags, pDispParams, ! pVarResult, pExcepInfo, puArgErr): ! dp = pDispParams[0] ! # DISPPARAMS contains the arguments in reverse order ! args = [dp.rgvarg[i].value for i in range(dp.cArgs)] ! self.dispmap[memid](None, *args[::-1]) ! return 0 ! rcv = EventReceiver() ! dispmap = _get_dispmap(interface) ! rcv.dispmap = dispmap ! for memid, name in dispmap.iteritems(): ! # find methods to call, if not found ignore event ! mth = getattr(sink, "%s.%s" % (interface.__name__, name), None) ! if mth is None: ! mth = getattr(sink, name, lambda *args: 0) ! dispmap[memid] = mth cpc = source.QueryInterface(comtypes.connectionpoints.IConnectionPointContainer) --- 412,449 ---- interface = comtypes.com_interface_registry[str(guid)] ! if issubclass(interface, comtypes.automation.IDispatch): ! dispmap = _get_dispmap(interface) ! for memid, name in dispmap.iteritems(): ! # find methods to call, if not found ignore event ! mth = getattr(sink, "%s.%s" % (interface.__name__, name), None) ! if mth is None: ! mth = getattr(sink, name, lambda *args: 0) ! dispmap[memid] = mth ! class EventReceiver(comtypes.COMObject): ! _com_interfaces_ = [interface] ! def IDispatch_Invoke(self, this, memid, riid, lcid, wFlags, pDispParams, ! pVarResult, pExcepInfo, puArgErr): ! dp = pDispParams[0] ! # DISPPARAMS contains the arguments in reverse order ! args = [dp.rgvarg[i].value for i in range(dp.cArgs)] ! self.dispmap[memid](None, *args[::-1]) ! return 0 ! ! rcv = EventReceiver() ! rcv.dispmap = dispmap ! else: ! class EventReceiver(comtypes.COMObject): ! _com_interfaces_ = [interface] ! ! for itf in interface.mro()[:-2]: # skip object and IUnknown ! for info in itf._methods_: ! restype, name, argtypes, paramflags, idlflags, docstring = info ! ! mth = getattr(sink, name, lambda self, this, *args: None) ! setattr(EventReceiver, name, mth) ! rcv = EventReceiver() cpc = source.QueryInterface(comtypes.connectionpoints.IConnectionPointContainer) |
From: Thomas H. <th...@us...> - 2005-09-02 16:52:42
|
Update of /cvsroot/ctypes/ctypes/comtypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27506 Modified Files: Tag: branch_1_0 __init__.py Log Message: Update comments, fix a NameError. Index: __init__.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/__init__.py,v retrieving revision 1.25.2.29 retrieving revision 1.25.2.30 diff -C2 -d -r1.25.2.29 -r1.25.2.30 *** __init__.py 23 Aug 2005 19:40:24 -0000 1.25.2.29 --- __init__.py 2 Sep 2005 16:52:32 -0000 1.25.2.30 *************** *** 1,3 **** ! # requires ctypes 0.9.3 or later import new ##import warnings --- 1,3 ---- ! # requires ctypes 0.9.8 or later import new ##import warnings *************** *** 22,25 **** --- 22,31 ---- ################################################################ + # Readings: + # Larry Osterman: What are these threading models and why do I care? + # http://blogs.msdn.com/larryosterman/archive/2004/04/28/122240.aspx + ################################################################ + + ################################################################ # Where should the __ctypes_from_param__ story go? # And what would be the 'correct' name for that method? *************** *** 803,807 **** def _not_impl(*args): ! return E_NOTIMPL def prepare_comobject(inst): --- 809,813 ---- def _not_impl(*args): ! return -2147467263 # E_NOTIMPL, 0x80004001L def prepare_comobject(inst): |
From: Thomas H. <th...@us...> - 2005-09-02 16:51:43
|
Update of /cvsroot/ctypes/ctypes/unittests/com In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27373 Modified Files: Tag: branch_1_0 test_perf.py Log Message: Record some test results. Index: test_perf.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/com/test_perf.py,v retrieving revision 1.4.2.2 retrieving revision 1.4.2.3 diff -C2 -d -r1.4.2.2 -r1.4.2.3 *** test_perf.py 11 May 2005 19:02:51 -0000 1.4.2.2 --- test_perf.py 2 Sep 2005 16:51:36 -0000 1.4.2.3 *************** *** 90,93 **** --- 90,98 ---- timeit('-s', "from comtypes.automation import VARIANT; variant = VARIANT()", "variant.value = 3.14 # comtypes") + timeit('-s', "from comtypes.automation import VARIANT; variant = VARIANT()", + "variant.value = (3.14, None, u'foo') # comtypes") + timeit('-s', + "from comtypes.automation import VARIANT; variant = VARIANT((3.14, None, 'foo'))", + "variant.value # comtypes") # on my machine which has around 30000 pystones/second: *************** *** 156,157 **** --- 161,184 ---- ## 3.11: variant.value # comtypes ## 8.57: variant.value = 3.14 # comtypes + + ##ctypes version: 0.9.8 (not yet released, 2005/05/12) + ##python version: 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] + ## 0.40: Class() + ## 0.47: POINT() + ## 0.48: RECT() + ## 0.25: point.y + ## 0.49: rect.lr + ## 0.49: fd.lprgelemdescParam + ## 0.96: fd.lprgelemdescParam[0] + ## 0.99: fd.lprgelemdescParam[1] + ## 1.48: fd.lprgelemdescParam[1].tdesc + ## 1.63: fd.lprgelemdescParam[1].tdesc.vt + ## 3.02: fd.lprgelemdescParam[1].tdesc._.lptdesc[0].vt + ## 0.48: c_int() + ## 0.71: c_int(42) + ## 1.75: VARIANT() # ctypes.com + ## 3.17: variant.value # ctypes.com + ## 8.07: variant.value = 3.14 # ctypes.com + ## 1.51: VARIANT() # comtypes + ## 3.12: variant.value # comtypes + ## 8.75: variant.value = 3.14 # comtypes |
From: Thomas H. <th...@us...> - 2005-08-30 09:33:44
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25646 Modified Files: Tag: branch_1_0 callproc.c Log Message: fix for big endian Index: callproc.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/callproc.c,v retrieving revision 1.127.2.11 retrieving revision 1.127.2.12 diff -C2 -d -r1.127.2.11 -r1.127.2.12 *** callproc.c 30 Aug 2005 07:11:37 -0000 1.127.2.11 --- callproc.c 30 Aug 2005 09:33:31 -0000 1.127.2.12 *************** *** 936,945 **** #if IS_BIG_ENDIAN ! /* libffi returns the result in a buffer of sizeof(ffi_arg). This causes problems on big endian machines, since the result buffer ! address cannot simply be casted to the actual result type. ! Instead, we must adjust the pointer: ! */ ! (char *)resbuf += sizeof(ffi_arg) - rtype->size; #endif --- 936,946 ---- #if IS_BIG_ENDIAN ! /* libffi returns the result in a buffer with sizeof(ffi_arg). This causes problems on big endian machines, since the result buffer ! address cannot simply be used as result pointer, instead we must ! adjust the pointer value: ! */ ! if (rtype->size < sizeof(ffi_arg)) ! (char *)resbuf += sizeof(ffi_arg) - rtype->size; #endif |
From: Thomas H. <th...@us...> - 2005-08-30 07:12:50
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26662 Modified Files: Tag: branch_1_0 ChangeLog Log Message: Large simplification of GetResult(). Don't call __new__() and __init__() if a ctype instance is created from a function call return value. Index: ChangeLog =================================================================== RCS file: /cvsroot/ctypes/ctypes/ChangeLog,v retrieving revision 1.86.2.16 retrieving revision 1.86.2.17 diff -C2 -d -r1.86.2.16 -r1.86.2.17 *** ChangeLog 30 Aug 2005 07:08:43 -0000 1.86.2.16 --- ChangeLog 30 Aug 2005 07:12:43 -0000 1.86.2.17 *************** *** 1,4 **** --- 1,7 ---- 2005-08-30 Thomas Heller <th...@py...> + * source/callproc.c: Don't call __new__ and __init__ when a ctypes + instance is created from a function return value. + * ctypes/wrap/cparser.py: Added a function to find gccxml on $PATH. |
From: Thomas H. <th...@us...> - 2005-08-30 07:11:45
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26509 Modified Files: Tag: branch_1_0 ctypes.h callproc.c Log Message: Large simplification of GetResult(). Don't call __new__() and __init__() if a ctype instance is created from a function call return value. Index: ctypes.h =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/ctypes.h,v retrieving revision 1.74.2.3 retrieving revision 1.74.2.4 diff -C2 -d -r1.74.2.3 -r1.74.2.4 *** ctypes.h 17 Aug 2005 15:54:24 -0000 1.74.2.3 --- ctypes.h 30 Aug 2005 07:11:37 -0000 1.74.2.4 *************** *** 371,374 **** --- 371,376 ---- extern void _AddTraceback(char *, char *, int); + extern PyObject *CData_FromBaseObj(PyObject *type, PyObject *base, int index, char *adr); + #ifdef MS_WIN32 extern PyObject *ComError; Index: callproc.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/callproc.c,v retrieving revision 1.127.2.10 retrieving revision 1.127.2.11 diff -C2 -d -r1.127.2.10 -r1.127.2.11 *** callproc.c 24 Aug 2005 19:04:07 -0000 1.127.2.10 --- callproc.c 30 Aug 2005 07:11:37 -0000 1.127.2.11 *************** *** 690,698 **** } - #define RESULT_PASTE_INTO 1 - #define RESULT_CALL_RESTYPE 2 - /* ! * Convert the C value in result into an instance described by restype */ static PyObject *GetResult(PyObject *restype, void *result, PyObject *checker) --- 690,702 ---- } /* ! * Convert the C value in result into a Python object, depending on restype. ! * ! * - If restype is NULL, return a Python integer. ! * - If restype is None, return None. ! * - If restype is a simple ctypes type (c_int, c_void_p), call the type's getfunc, ! * pass the result to checker and return the result. ! * - If restype is another ctypes type, return an instance of that. ! * - Otherwise, call restype and return the result. */ static PyObject *GetResult(PyObject *restype, void *result, PyObject *checker) *************** *** 700,706 **** StgDictObject *dict; ! if (restype == NULL) { ! return getentry("i")->getfunc(result, sizeof(int)); ! } if (restype == Py_None) { --- 704,709 ---- StgDictObject *dict; ! if (restype == NULL) ! return PyInt_FromLong(*(int *)result); if (restype == Py_None) { *************** *** 709,796 **** } - if (PointerTypeObject_Check(restype)) { - CDataObject *pd; - /* There is no Python api to set the pointer value, so we - create an empty (NULL) pointer, and modify it afterwards. - */ - pd = (CDataObject *)PyObject_CallFunctionObjArgs(restype, NULL); - if (!pd) - return NULL; - if (!CDataObject_Check(pd)) { - Py_DECREF(pd); - PyErr_SetString(PyExc_TypeError, - "BUG: restype call did not return a CDataObject"); - return NULL; - } - /* Even better would be to use the buffer interface */ - memcpy(pd->b_ptr, result, pd->b_size); - return (PyObject *)pd; - } - - if (StructTypeObject_Check(restype)) { - CDataObject *pd; - - pd = (CDataObject *)PyObject_CallFunctionObjArgs(restype, NULL); - if (!pd) - return NULL; - if (!CDataObject_Check(pd)) { - Py_DECREF(pd); - PyErr_SetString(PyExc_TypeError, - "BUG: restype call did not return a CDataObject"); - return NULL; - } - /* Even better would be to use the buffer interface */ - memcpy(pd->b_ptr, result, pd->b_size); - return (PyObject *)pd; - } - dict = PyType_stgdict(restype); ! /* THIS code should probably move into CallProc, where GetResult is ! called. But doesn't matter too much. */ ! #if IS_BIG_ENDIAN ! if (dict && dict->size < sizeof(ffi_arg)) { ! /* libffi returns the result in a buffer of ! sizeof(ffi_arg). This causes problems on big ! endian machines, since the result buffer cannot ! simply be casted to the actual result type. ! Instead, we must adjust the pointer: ! */ ! char *ptr = result; ! ptr += sizeof(ffi_arg) - dict->size; ! result = ptr; ! } ! #endif ! if (dict && dict->getfunc) { ! PyObject *retval = dict->getfunc(result, dict->size); ! if (retval == NULL) ! return NULL; ! if (checker == NULL) return retval; ! { ! PyObject *v; ! v = PyObject_CallFunctionObjArgs(checker, retval, NULL); ! if (v == NULL) ! _AddTraceback("GetResult", __FILE__, __LINE__-2); ! Py_DECREF(retval); ! return v; ! } ! } ! /* void* may have different size than int, so special case this. */ ! if (CFuncPtrTypeObject_Check(restype)) { ! PyObject *addr = PyLong_FromVoidPtr(*(void **)result); ! PyObject *o; ! if (addr == NULL) ! return NULL; ! o = PyObject_CallFunction(restype, "O", addr); ! Py_DECREF(addr); ! return o; } ! if (PyCallable_Check(restype)) ! return PyObject_CallFunction(restype, "i", ! *(int *)result); ! PyErr_SetString(PyExc_TypeError, ! "Bug: cannot convert result"); ! return NULL; /* to silence the compiler */ } --- 712,736 ---- } dict = PyType_stgdict(restype); + if (dict == NULL) + return PyObject_CallFunction(restype, "i", *(int *)result); ! if (dict->getfunc) { ! PyObject *retval, *v; ! retval = dict->getfunc(result, dict->size); ! if (!checker || !retval) return retval; ! ! v = PyObject_CallFunctionObjArgs(checker, retval, NULL); ! if (v == NULL) ! _AddTraceback("GetResult", __FILE__, __LINE__-2); ! Py_DECREF(retval); ! return v; } ! /* When __ctypes_check_retval__ is introduced, ! call this on the result we get here. ! And later, get rid of the checker stuff. ! */ ! return CData_FromBaseObj(restype, NULL, 0, result); } *************** *** 908,914 **** #endif int flags, ! PyObject *argtypes, /* misleading name: This is a method, ! not a type (the .from_param class ! nethod) */ PyObject *restype, PyObject *checker) --- 848,854 ---- #endif int flags, ! PyObject *argtypes, /* misleading name: This is a tuple of ! methods, not types: the .from_param ! class methods of the types */ PyObject *restype, PyObject *checker) *************** *** 995,998 **** --- 935,947 ---- goto cleanup; + #if IS_BIG_ENDIAN + /* libffi returns the result in a buffer of sizeof(ffi_arg). This + causes problems on big endian machines, since the result buffer + address cannot simply be casted to the actual result type. + Instead, we must adjust the pointer: + */ + (char *)resbuf += sizeof(ffi_arg) - rtype->size; + #endif + #ifdef MS_WIN32 if (iid && pIunk) { |
From: Thomas H. <th...@us...> - 2005-08-30 07:08:52
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25734 Modified Files: Tag: branch_1_0 ChangeLog Log Message: Index: ChangeLog =================================================================== RCS file: /cvsroot/ctypes/ctypes/ChangeLog,v retrieving revision 1.86.2.15 retrieving revision 1.86.2.16 diff -C2 -d -r1.86.2.15 -r1.86.2.16 *** ChangeLog 24 Aug 2005 08:29:11 -0000 1.86.2.15 --- ChangeLog 30 Aug 2005 07:08:43 -0000 1.86.2.16 *************** *** 1,2 **** --- 1,7 ---- + 2005-08-30 Thomas Heller <th...@py...> + + * ctypes/wrap/cparser.py: Added a function to find gccxml on + $PATH. + 2005-08-24 Thomas Heller <th...@py...> |
From: Thomas H. <th...@us...> - 2005-08-30 06:56:22
|
Update of /cvsroot/ctypes/ctypes/comtypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22487 Modified Files: Tag: branch_1_0 .cvsignore Log Message: Index: .cvsignore =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/unittests/.cvsignore,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -C2 -d -r1.2 -r1.2.2.1 *** .cvsignore 24 Feb 2005 16:22:16 -0000 1.2 --- .cvsignore 30 Aug 2005 06:56:15 -0000 1.2.2.1 *************** *** 1,2 **** --- 1,4 ---- *.pyc *.pyo + build + dist |
From: Thomas H. <th...@us...> - 2005-08-30 06:55:30
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22355 Modified Files: Tag: branch_1_0 test_codegen.py Log Message: Run this test only when gccxml is available. Index: test_codegen.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/Attic/test_codegen.py,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -C2 -d -r1.1.2.3 -r1.1.2.4 *** test_codegen.py 30 Aug 2005 06:33:52 -0000 1.1.2.3 --- test_codegen.py 30 Aug 2005 06:55:21 -0000 1.1.2.4 *************** *** 3,38 **** import ctypes import _ctypes_test ! 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 - 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__ ! 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' --- 3,32 ---- import ctypes import _ctypes_test + from ctypes.wrap.cparser import find_gccxml ! if find_gccxml(): ! 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' |