ctypes-commit Mailing List for ctypes (Page 30)
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...> - 2006-01-27 20:40:30
|
Update of /cvsroot/ctypes/ctypes/docs/manual In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25075 Modified Files: Tag: branch_1_0 manual.txt Log Message: Correct indent. Index: manual.txt =================================================================== RCS file: /cvsroot/ctypes/ctypes/docs/manual/Attic/manual.txt,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** manual.txt 27 Jan 2006 20:34:24 -0000 1.1.2.2 --- manual.txt 27 Jan 2006 20:40:21 -0000 1.1.2.3 *************** *** 67,77 **** ``dlopen()`` function, ignored on Windows. ! On windows, this method does exactly the same as the ``load`` ! method. ! On other platforms, this function might call other programs like ! the compiler to find the library. When using ctypes to write a ! shared library wrapping, consider using ``load_version`` or ! ``load`` instead. Libaries can also be loaded by accessing them as attributes of the --- 67,77 ---- ``dlopen()`` function, ignored on Windows. ! On windows, this method does exactly the same as the ``load`` ! method. ! On other platforms, this function might call other programs like ! the compiler to find the library. When using ctypes to write a ! shared library wrapping, consider using ``load_version`` or ! ``load`` instead. Libaries can also be loaded by accessing them as attributes of the |
From: Thomas H. <th...@us...> - 2006-01-27 20:34:33
|
Update of /cvsroot/ctypes/ctypes/docs/manual In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22963 Modified Files: Tag: branch_1_0 manual.txt manual.html Log Message: Added contents. Index: manual.txt =================================================================== RCS file: /cvsroot/ctypes/ctypes/docs/manual/Attic/manual.txt,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** manual.txt 27 Jan 2006 20:28:54 -0000 1.1.2.1 --- manual.txt 27 Jan 2006 20:34:24 -0000 1.1.2.2 *************** *** 5,8 **** --- 5,10 ---- (work in progress) + .. contents:: + Loading shared libraries ++++++++++++++++++++++++ Index: manual.html =================================================================== RCS file: /cvsroot/ctypes/ctypes/docs/manual/Attic/manual.html,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** manual.html 27 Jan 2006 20:28:54 -0000 1.1.2.1 --- manual.html 27 Jan 2006 20:34:24 -0000 1.1.2.2 *************** *** 294,299 **** <h1 class="title">ctypes manual</h1> <p>(work in progress)</p> <div class="section"> ! <h1><a id="loading-shared-libraries" name="loading-shared-libraries">Loading shared libraries</a></h1> <p>Shared libraries are accessed when compiling/linking a program, and when the program is run. The purpose of the <tt class="docutils literal"><span class="pre">find</span></tt> method is to --- 294,307 ---- <h1 class="title">ctypes manual</h1> <p>(work in progress)</p> + <div class="contents topic"> + <p class="topic-title first"><a id="contents" name="contents">Contents</a></p> + <ul class="simple"> + <li><a class="reference" href="#loading-shared-libraries" id="id1" name="id1">Loading shared libraries</a></li> + <li><a class="reference" href="#class-libraryloader" id="id2" name="id2">class LibraryLoader</a></li> + <li><a class="reference" href="#predefined-library-loaders" id="id3" name="id3">Predefined library loaders</a></li> + </ul> + </div> <div class="section"> ! <h1><a class="toc-backref" href="#id1" id="loading-shared-libraries" name="loading-shared-libraries">Loading shared libraries</a></h1> <p>Shared libraries are accessed when compiling/linking a program, and when the program is run. The purpose of the <tt class="docutils literal"><span class="pre">find</span></tt> method is to *************** *** 308,312 **** </div> <div class="section"> ! <h1><a id="class-libraryloader" name="class-libraryloader">class LibraryLoader</a></h1> <p>Instances of this <tt class="docutils literal"><span class="pre">LibraryLoader</span></tt> are used to load shared libraries. They have the following methods:</p> --- 316,320 ---- </div> <div class="section"> ! <h1><a class="toc-backref" href="#id2" id="class-libraryloader" name="class-libraryloader">class LibraryLoader</a></h1> <p>Instances of this <tt class="docutils literal"><span class="pre">LibraryLoader</span></tt> are used to load shared libraries. They have the following methods:</p> *************** *** 361,365 **** </div> <div class="section"> ! <h1><a id="predefined-library-loaders" name="predefined-library-loaders">Predefined library loaders</a></h1> <p>ctypes provides some LibraryLoader instances, the differences are the calling conventions the functions will use, the default return type of --- 369,373 ---- </div> <div class="section"> ! <h1><a class="toc-backref" href="#id3" id="predefined-library-loaders" name="predefined-library-loaders">Predefined library loaders</a></h1> <p>ctypes provides some LibraryLoader instances, the differences are the calling conventions the functions will use, the default return type of |
From: Thomas H. <th...@us...> - 2006-01-27 20:29:09
|
Update of /cvsroot/ctypes/ctypes/docs/manual In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21043 Added Files: Tag: branch_1_0 manual.txt manual.html make.bat Log Message: Document LibraryLoader objects. --- NEW FILE: manual.txt --- ============= ctypes manual ============= (work in progress) Loading shared libraries ++++++++++++++++++++++++ Shared libraries are accessed when compiling/linking a program, and when the program is run. The purpose of the ``find`` method is to locate a library in a way similar to what the compiler does (on platforms with several versions of a shared library the most recent should be loaded), while ``load`` acts like when a program is run, and uses the runtime loader directly. ``load_version`` works like ``load`` but tries to be platform independent (for cases where this makes sense). Loading via attribute access is a shorthand notation especially usefull for interactive use, it is equivalent to calling ``load_version`` with no version specified. class LibraryLoader +++++++++++++++++++ Instances of this ``LibraryLoader`` are used to load shared libraries. They have the following methods: ``load(libname, mode=None)`` Load and return the library with the given libname. On most systems ``libname`` is the filename of the shared library; when it's not a pathname it will be searched in a system dependend list of locations (on many systems additional search paths can be specified by an environemtn variable). Sometimes the file extension (like ``.dll`` pon Windows) can be omitted. ``mode`` allows to override the default flags passed to the ``dlopen()`` function. ``RTLD_LOCAL`` and ``RTLD_GLOBAL`` are typical values. On Windows, ``mode`` is ignored. ``load_version(name, version=None, mode=None)`` Build a system dependend filename from ``name`` and optionally ``version``, then load and return it. ``name`` is the library name without any prefix like ``lib`` and suffix like ``.so`` or ``.dylib``. This method should be used if a library is available on different platforms, using the particular naming convention of each platform. ``mode`` allows to override the default flags passed to the ``dlopen()`` function, ignored on Windows. Example: calling ``loader.load_version('z', '1.1.3')`` would possibly load ``/usr/lib/libz.1.1.3.dylib`` on Mac OS X, and ``/lib/libz.so.1.1.3`` on a Linux system. ``find(name, mode=None)`` Try to find a library, load and return it. ``name`` is the library name without any prefix like ``lib``, suffix like ``.so``, ``.dylib`` or version number (this is the form used for the posix linker option ``-l``). ``mode`` allows to override the default flags passed to the ``dlopen()`` function, ignored on Windows. On windows, this method does exactly the same as the ``load`` method. On other platforms, this function might call other programs like the compiler to find the library. When using ctypes to write a shared library wrapping, consider using ``load_version`` or ``load`` instead. Libaries can also be loaded by accessing them as attributes of the loader instance, internally this calls ``load_version`` without specifying ``version`` or ``mode``. Obviously this only works for libraries with names that are valid Python identifiers, and when the name does not start with a ``_`` character. Predefined library loaders ++++++++++++++++++++++++++ ctypes provides some LibraryLoader instances, the differences are the calling conventions the functions will use, the default return type of the functions, and other stuff. All these loaders use the ``RTLD_LOCAL`` mode flag. Functions can be accessed as named attributes of loaded libraries. On Windows, structured exception handling is used around the function call to protect Python from crashing in case you pass invalid parameters to the function. ``cdll`` Functions provided by libraries loaded using the ``cdll`` loader will be called with the standard C calling convention, and have a default return type of ``int``. ctypes does release the Python global interpreter lock (GIL) just before calling the actual function, and reaquire it before returing, so a chance is given to other threads to run. ``windll`` Windows only. Functions provided by libraries loaded by ``windll`` will be called using the Windows ``__stdcall`` calling convention. ctypes can to detect the case that the wrong number of parameters have been passed to the function call by examining the stack pointer before and after the function call. If the wrong parameter count was used, an exception is raised (although the function really *has* been called). The return value of the function is lost in this case. Again, the GIL is released during the call. ``oledll`` Windows only. ``oledll`` behaves in the same way as ``windll``, except that the called function is expected to return a ``HRESULT`` value. These are long values containing error or success codes. In case the function return an error ``HRESULT`` value, a `WindowsError`` is raised. GIL released during the function call. ``pydll`` This loader allows to call functions in libraries using the *Python* calling convention, for example Python C API functions. The GIL is *not* released during the function call, and the state of the Python error flag is examined after the function returns. If the error flag is set, an exception is raised. ctypes provides a prefabricated instance of ``pydll`` exposing the Python C api as the ``pythonapi`` symbol, you should however make sure to set the correct ``restype`` for the functions you use. --- NEW FILE: manual.html --- <?xml version="1.0" encoding="utf-8" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="generator" content="Docutils 0.5: http://docutils.sourceforge.net/" /> <title>ctypes manual</title> <style type="text/css"> /* :Author: David Goodger :Contact: go...@us... :Date: $Date: 2006/01/27 20:28:54 $ :Revision: $Revision: 1.1.2.1 $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to customize this style sheet. */ /* used to remove borders from tables and images */ .borderless, table.borderless td, table.borderless th { border: 0 } table.borderless td, table.borderless th { /* Override padding for "table.docutils td" with "! important". The right padding separates the table cells. */ padding: 0 0.5em 0 0 ! important } .first { /* Override more specific margin styles with "! important". */ margin-top: 0 ! important } .last, .with-subtitle { margin-bottom: 0 ! important } .hidden { display: none } a.toc-backref { text-decoration: none ; color: black } blockquote.epigraph { margin: 2em 5em ; } dl.docutils dd { margin-bottom: 0.5em } /* Uncomment (and remove this text!) to get bold-faced definition list terms dl.docutils dt { font-weight: bold } */ div.abstract { margin: 2em 5em } div.abstract p.topic-title { font-weight: bold ; text-align: center } div.admonition, div.attention, div.caution, div.danger, div.error, div.hint, div.important, div.note, div.tip, div.warning { margin: 2em ; border: medium outset ; padding: 1em } div.admonition p.admonition-title, div.hint p.admonition-title, div.important p.admonition-title, div.note p.admonition-title, div.tip p.admonition-title { font-weight: bold ; font-family: sans-serif } div.attention p.admonition-title, div.caution p.admonition-title, div.danger p.admonition-title, div.error p.admonition-title, div.warning p.admonition-title { color: red ; font-weight: bold ; font-family: sans-serif } /* Uncomment (and remove this text!) to get reduced vertical space in compound paragraphs. div.compound .compound-first, div.compound .compound-middle { margin-bottom: 0.5em } div.compound .compound-last, div.compound .compound-middle { margin-top: 0.5em } */ div.dedication { margin: 2em 5em ; text-align: center ; font-style: italic } div.dedication p.topic-title { font-weight: bold ; font-style: normal } div.figure { margin-left: 2em ; margin-right: 2em } div.footer, div.header { clear: both; font-size: smaller } div.line-block { display: block ; margin-top: 1em ; margin-bottom: 1em } div.line-block div.line-block { margin-top: 0 ; margin-bottom: 0 ; margin-left: 1.5em } div.sidebar { margin-left: 1em ; border: medium outset ; padding: 1em ; background-color: #ffffee ; width: 40% ; float: right ; clear: right } div.sidebar p.rubric { font-family: sans-serif ; font-size: medium } div.system-messages { margin: 5em } div.system-messages h1 { color: red } div.system-message { border: medium outset ; padding: 1em } div.system-message p.system-message-title { color: red ; font-weight: bold } div.topic { margin: 2em } h1.section-subtitle, h2.section-subtitle, h3.section-subtitle, h4.section-subtitle, h5.section-subtitle, h6.section-subtitle { margin-top: 0.4em } h1.title { text-align: center } h2.subtitle { text-align: center } hr.docutils { width: 75% } img.align-left { clear: left } img.align-right { clear: right } ol.simple, ul.simple { margin-bottom: 1em } ol.arabic { list-style: decimal } ol.loweralpha { list-style: lower-alpha } ol.upperalpha { list-style: upper-alpha } ol.lowerroman { list-style: lower-roman } ol.upperroman { list-style: upper-roman } p.attribution { text-align: right ; margin-left: 50% } p.caption { font-style: italic } p.credits { font-style: italic ; font-size: smaller } p.label { white-space: nowrap } p.rubric { font-weight: bold ; font-size: larger ; color: maroon ; text-align: center } p.sidebar-title { font-family: sans-serif ; font-weight: bold ; font-size: larger } p.sidebar-subtitle { font-family: sans-serif ; font-weight: bold } p.topic-title { font-weight: bold } pre.address { margin-bottom: 0 ; margin-top: 0 ; font-family: serif ; font-size: 100% } pre.literal-block, pre.doctest-block { margin-left: 2em ; margin-right: 2em ; background-color: #eeeeee } span.classifier { font-family: sans-serif ; font-style: oblique } span.classifier-delimiter { font-family: sans-serif ; font-weight: bold } span.interpreted { font-family: sans-serif } span.option { white-space: nowrap } span.pre { white-space: pre } span.problematic { color: red } span.section-subtitle { /* font-size relative to parent (h1..h6 element) */ font-size: 80% } table.citation { border-left: solid 1px gray; margin-left: 1px } table.docinfo { margin: 2em 4em } table.docutils { margin-top: 0.5em ; margin-bottom: 0.5em } table.footnote { border-left: solid 1px black; margin-left: 1px } table.docutils td, table.docutils th, table.docinfo td, table.docinfo th { padding-left: 0.5em ; padding-right: 0.5em ; vertical-align: top } table.docutils th.field-name, table.docinfo th.docinfo-name { font-weight: bold ; text-align: left ; white-space: nowrap ; padding-left: 0 } h1 tt.docutils, h2 tt.docutils, h3 tt.docutils, h4 tt.docutils, h5 tt.docutils, h6 tt.docutils { font-size: 100% } tt.docutils { background-color: #eeeeee } ul.auto-toc { list-style-type: none } </style> </head> <body> <div class="document" id="ctypes-manual"> <h1 class="title">ctypes manual</h1> <p>(work in progress)</p> <div class="section"> <h1><a id="loading-shared-libraries" name="loading-shared-libraries">Loading shared libraries</a></h1> <p>Shared libraries are accessed when compiling/linking a program, and when the program is run. The purpose of the <tt class="docutils literal"><span class="pre">find</span></tt> method is to locate a library in a way similar to what the compiler does (on platforms with several versions of a shared library the most recent should be loaded), while <tt class="docutils literal"><span class="pre">load</span></tt> acts like when a program is run, and uses the runtime loader directly. <tt class="docutils literal"><span class="pre">load_version</span></tt> works like <tt class="docutils literal"><span class="pre">load</span></tt> but tries to be platform independent (for cases where this makes sense). Loading via attribute access is a shorthand notation especially usefull for interactive use, it is equivalent to calling <tt class="docutils literal"><span class="pre">load_version</span></tt> with no version specified.</p> </div> <div class="section"> <h1><a id="class-libraryloader" name="class-libraryloader">class LibraryLoader</a></h1> <p>Instances of this <tt class="docutils literal"><span class="pre">LibraryLoader</span></tt> are used to load shared libraries. They have the following methods:</p> <p><tt class="docutils literal"><span class="pre">load(libname,</span> <span class="pre">mode=None)</span></tt></p> <blockquote> <p>Load and return the library with the given libname. On most systems <tt class="docutils literal"><span class="pre">libname</span></tt> is the filename of the shared library; when it's not a pathname it will be searched in a system dependend list of locations (on many systems additional search paths can be specified by an environemtn variable). Sometimes the file extension (like <tt class="docutils literal"><span class="pre">.dll</span></tt> pon Windows) can be omitted.</p> <p><tt class="docutils literal"><span class="pre">mode</span></tt> allows to override the default flags passed to the <tt class="docutils literal"><span class="pre">dlopen()</span></tt> function. <tt class="docutils literal"><span class="pre">RTLD_LOCAL</span></tt> and <tt class="docutils literal"><span class="pre">RTLD_GLOBAL</span></tt> are typical values. On Windows, <tt class="docutils literal"><span class="pre">mode</span></tt> is ignored.</p> </blockquote> <p><tt class="docutils literal"><span class="pre">load_version(name,</span> <span class="pre">version=None,</span> <span class="pre">mode=None)</span></tt></p> <blockquote> <p>Build a system dependend filename from <tt class="docutils literal"><span class="pre">name</span></tt> and optionally <tt class="docutils literal"><span class="pre">version</span></tt>, then load and return it. <tt class="docutils literal"><span class="pre">name</span></tt> is the library name without any prefix like <tt class="docutils literal"><span class="pre">lib</span></tt> and suffix like <tt class="docutils literal"><span class="pre">.so</span></tt> or <tt class="docutils literal"><span class="pre">.dylib</span></tt>. This method should be used if a library is available on different platforms, using the particular naming convention of each platform.</p> <p><tt class="docutils literal"><span class="pre">mode</span></tt> allows to override the default flags passed to the <tt class="docutils literal"><span class="pre">dlopen()</span></tt> function, ignored on Windows.</p> <p>Example: calling <tt class="docutils literal"><span class="pre">loader.load_version('z',</span> <span class="pre">'1.1.3')</span></tt> would possibly load <tt class="docutils literal"><span class="pre">/usr/lib/libz.1.1.3.dylib</span></tt> on Mac OS X, and <tt class="docutils literal"><span class="pre">/lib/libz.so.1.1.3</span></tt> on a Linux system.</p> </blockquote> <p><tt class="docutils literal"><span class="pre">find(name,</span> <span class="pre">mode=None)</span></tt></p> <blockquote> <p>Try to find a library, load and return it. <tt class="docutils literal"><span class="pre">name</span></tt> is the library name without any prefix like <tt class="docutils literal"><span class="pre">lib</span></tt>, suffix like <tt class="docutils literal"><span class="pre">.so</span></tt>, <tt class="docutils literal"><span class="pre">.dylib</span></tt> or version number (this is the form used for the posix linker option <tt class="docutils literal"><span class="pre">-l</span></tt>).</p> <p><tt class="docutils literal"><span class="pre">mode</span></tt> allows to override the default flags passed to the <tt class="docutils literal"><span class="pre">dlopen()</span></tt> function, ignored on Windows.</p> <blockquote> <p>On windows, this method does exactly the same as the <tt class="docutils literal"><span class="pre">load</span></tt> method.</p> <p>On other platforms, this function might call other programs like the compiler to find the library. When using ctypes to write a shared library wrapping, consider using <tt class="docutils literal"><span class="pre">load_version</span></tt> or <tt class="docutils literal"><span class="pre">load</span></tt> instead.</p> </blockquote> </blockquote> <p>Libaries can also be loaded by accessing them as attributes of the loader instance, internally this calls <tt class="docutils literal"><span class="pre">load_version</span></tt> without specifying <tt class="docutils literal"><span class="pre">version</span></tt> or <tt class="docutils literal"><span class="pre">mode</span></tt>. Obviously this only works for libraries with names that are valid Python identifiers, and when the name does not start with a <tt class="docutils literal"><span class="pre">_</span></tt> character.</p> </div> <div class="section"> <h1><a id="predefined-library-loaders" name="predefined-library-loaders">Predefined library loaders</a></h1> <p>ctypes provides some LibraryLoader instances, the differences are the calling conventions the functions will use, the default return type of the functions, and other stuff. All these loaders use the <tt class="docutils literal"><span class="pre">RTLD_LOCAL</span></tt> mode flag.</p> <p>Functions can be accessed as named attributes of loaded libraries.</p> <p>On Windows, structured exception handling is used around the function call to protect Python from crashing in case you pass invalid parameters to the function.</p> <p><tt class="docutils literal"><span class="pre">cdll</span></tt></p> <blockquote> Functions provided by libraries loaded using the <tt class="docutils literal"><span class="pre">cdll</span></tt> loader will be called with the standard C calling convention, and have a default return type of <tt class="docutils literal"><span class="pre">int</span></tt>. ctypes does release the Python global interpreter lock (GIL) just before calling the actual function, and reaquire it before returing, so a chance is given to other threads to run.</blockquote> <p><tt class="docutils literal"><span class="pre">windll</span></tt></p> <blockquote> Windows only. Functions provided by libraries loaded by <tt class="docutils literal"><span class="pre">windll</span></tt> will be called using the Windows <tt class="docutils literal"><span class="pre">__stdcall</span></tt> calling convention. ctypes can to detect the case that the wrong number of parameters have been passed to the function call by examining the stack pointer before and after the function call. If the wrong parameter count was used, an exception is raised (although the function really <em>has</em> been called). The return value of the function is lost in this case. Again, the GIL is released during the call.</blockquote> <p><tt class="docutils literal"><span class="pre">oledll</span></tt></p> <blockquote> Windows only. <tt class="docutils literal"><span class="pre">oledll</span></tt> behaves in the same way as <tt class="docutils literal"><span class="pre">windll</span></tt>, except that the called function is expected to return a <tt class="docutils literal"><span class="pre">HRESULT</span></tt> value. These are long values containing error or success codes. In case the function return an error <tt class="docutils literal"><span class="pre">HRESULT</span></tt> value, a <cite>WindowsError`</cite> is raised. GIL released during the function call.</blockquote> <p><tt class="docutils literal"><span class="pre">pydll</span></tt></p> <blockquote> <p>This loader allows to call functions in libraries using the <em>Python</em> calling convention, for example Python C API functions. The GIL is <em>not</em> released during the function call, and the state of the Python error flag is examined after the function returns. If the error flag is set, an exception is raised.</p> <p>ctypes provides a prefabricated instance of <tt class="docutils literal"><span class="pre">pydll</span></tt> exposing the Python C api as the <tt class="docutils literal"><span class="pre">pythonapi</span></tt> symbol, you should however make sure to set the correct <tt class="docutils literal"><span class="pre">restype</span></tt> for the functions you use.</p> </blockquote> </div> </div> </body> </html> --- NEW FILE: make.bat --- c:\python24\scripts\rst2html.py manual.txt manual.html |
From: Thomas H. <th...@us...> - 2006-01-27 19:06:28
|
Update of /cvsroot/ctypes/ctypes/docs/manual In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23847/manual Log Message: Directory /cvsroot/ctypes/ctypes/docs/manual added to the repository --> Using per-directory sticky tag `branch_1_0' |
From: Thomas H. <th...@us...> - 2006-01-27 18:43:24
|
Update of /cvsroot/ctypes/ctypes/ctypes/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15621 Modified Files: Tag: branch_1_0 test_funcptr.py Log Message: Simplify. Index: test_funcptr.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/Attic/test_funcptr.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_funcptr.py 27 Jan 2006 18:34:09 -0000 1.1.2.2 --- test_funcptr.py 27 Jan 2006 18:43:16 -0000 1.1.2.3 *************** *** 9,20 **** ! def get_libc(): ! import os, sys ! if os.name == "nt": ! return cdll.msvcrt ! elif os.name == "posix": ! return cdll.find("c") ! return None ! libc = get_libc() class CFuncPtrTestCase(unittest.TestCase): --- 9,17 ---- ! import os, sys ! if os.name == "nt": ! libc = cdll.msvcrt ! else: ! libc = cdll.find("c") class CFuncPtrTestCase(unittest.TestCase): *************** *** 95,133 **** self.failUnlessEqual(f(10, 11, 12, 13), 46) ! if libc is not None: ! def test_dllfunctions(self): ! def NoNullHandle(value): ! if not value: ! raise WinError() ! return value ! strchr = libc.strchr ! strchr.restype = c_char_p ! strchr.argtypes = (c_char_p, c_char) ! self.failUnlessEqual(strchr("abcdefghi", "b"), "bcdefghi") ! self.failUnlessEqual(strchr("abcdefghi", "x"), None) ! strtok = libc.strtok ! strtok.restype = c_char_p ! # Neither of this does work ! ## strtok.argtypes = (c_char_p, c_char_p) ! ## strtok.argtypes = (c_string, c_char_p) ! def c_string(init): ! size = len(init) + 1 ! return (c_char*size)(*init) ! s = "a\nb\nc" ! b = c_string(s) ! ## b = (c_char * (len(s)+1))() ! ## b.value = s ! ## b = c_string(s) ! self.failUnlessEqual(strtok(b, "\n"), "a") ! self.failUnlessEqual(strtok(None, "\n"), "b") ! self.failUnlessEqual(strtok(None, "\n"), "c") ! self.failUnlessEqual(strtok(None, "\n"), None) if __name__ == '__main__': --- 92,129 ---- self.failUnlessEqual(f(10, 11, 12, 13), 46) ! def test_dllfunctions(self): ! def NoNullHandle(value): ! if not value: ! raise WinError() ! return value ! strchr = libc.strchr ! strchr.restype = c_char_p ! strchr.argtypes = (c_char_p, c_char) ! self.failUnlessEqual(strchr("abcdefghi", "b"), "bcdefghi") ! self.failUnlessEqual(strchr("abcdefghi", "x"), None) ! strtok = libc.strtok ! strtok.restype = c_char_p ! # Neither of this does work ! ## strtok.argtypes = (c_char_p, c_char_p) ! ## strtok.argtypes = (c_string, c_char_p) ! def c_string(init): ! size = len(init) + 1 ! return (c_char*size)(*init) ! s = "a\nb\nc" ! b = c_string(s) ! ## b = (c_char * (len(s)+1))() ! ## b.value = s ! ## b = c_string(s) ! self.failUnlessEqual(strtok(b, "\n"), "a") ! self.failUnlessEqual(strtok(None, "\n"), "b") ! self.failUnlessEqual(strtok(None, "\n"), "c") ! self.failUnlessEqual(strtok(None, "\n"), None) if __name__ == '__main__': |
From: Thomas H. <th...@us...> - 2006-01-27 18:40:21
|
Update of /cvsroot/ctypes/ctypes/ctypes/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14614 Modified Files: Tag: branch_1_0 test_codegen.py Log Message: Don't use windows path separators. Index: test_codegen.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/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 3 Nov 2005 19:49:19 -0000 1.1.2.1 --- test_codegen.py 27 Jan 2006 18:40:12 -0000 1.1.2.2 *************** *** 19,23 **** test_dir = os.path.dirname(__file__) ! source_dir = os.path.join(test_dir, r"..\..", "source") from ctypes.wrap import h2xml, xml2py --- 19,23 ---- test_dir = os.path.dirname(__file__) ! source_dir = os.path.join(test_dir, "..", "..", "source") from ctypes.wrap import h2xml, xml2py |
From: Thomas H. <th...@us...> - 2006-01-27 18:34:21
|
Update of /cvsroot/ctypes/ctypes/ctypes/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12585 Modified Files: Tag: branch_1_0 test_funcptr.py Log Message: Use cdll.find to find libc. Index: test_funcptr.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/Attic/test_funcptr.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_funcptr.py 3 Nov 2005 19:49:19 -0000 1.1.2.1 --- test_funcptr.py 27 Jan 2006 18:34:09 -0000 1.1.2.2 *************** *** 14,28 **** return cdll.msvcrt elif os.name == "posix": ! if sys.platform == "darwin": ! return cdll.LoadLibrary("/usr/lib/libc.dylib") ! elif sys.platform == "cygwin": ! return cdll.LoadLibrary("/bin/cygwin1.dll") ! elif sys.platform == "sunos5": ! return cdll.LoadLibrary("/lib/libc.so") ! else: ! try: ! return cdll.LoadLibrary("/lib/libc.so.6") ! except OSError: ! pass return None libc = get_libc() --- 14,18 ---- return cdll.msvcrt elif os.name == "posix": ! return cdll.find("c") return None libc = get_libc() |
From: Thomas H. <th...@us...> - 2006-01-27 18:24:26
|
Update of /cvsroot/ctypes/ctypes/ctypes/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8983 Modified Files: Tag: branch_1_0 test_slicing.py Log Message: *** empty log message *** Index: test_slicing.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/Attic/test_slicing.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_slicing.py 27 Jan 2006 18:18:54 -0000 1.1.2.2 --- test_slicing.py 27 Jan 2006 18:24:18 -0000 1.1.2.3 *************** *** 38,42 **** s = "abcdefghijklmnopqrstuvwxyz\0" ! dll = CDLL(find_test_dll()) dll.my_strdup.restype = POINTER(c_char) res = dll.my_strdup(s) --- 38,42 ---- s = "abcdefghijklmnopqrstuvwxyz\0" ! dll = cdll.load(_ctypes_test.__file__) dll.my_strdup.restype = POINTER(c_char) res = dll.my_strdup(s) |
From: Thomas H. <th...@us...> - 2006-01-27 18:19:10
|
Update of /cvsroot/ctypes/ctypes/ctypes/wrap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7034 Modified Files: Tag: branch_1_0 xml2py.py Log Message: Use the recommended way to load libraries: cdll.load(libname) instead of CDLL(libname). Index: xml2py.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/wrap/xml2py.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 *** xml2py.py 24 Aug 2005 08:10:47 -0000 1.1.2.1 --- xml2py.py 27 Jan 2006 18:19:01 -0000 1.1.2.2 *************** *** 136,141 **** known_symbols = {} ! from ctypes import CDLL ! dlls = [CDLL(name) for name in options.dlls] for name in options.modules: --- 136,141 ---- known_symbols = {} ! from ctypes import cdll ! dlls = [cdll.load(name) for name in options.dlls] for name in options.modules: |
Update of /cvsroot/ctypes/ctypes/ctypes/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6972 Modified Files: Tag: branch_1_0 test_win32.py test_values.py test_unicode.py test_slicing.py test_returnfuncptrs.py test_refcounts.py test_prototypes.py test_posix.py test_pointers.py test_paramflags.py test_leaks.py test_functions.py test_checkretval.py test_cfuncs.py test_callbacks.py test_bitfields.py Log Message: Use the recommended way to load libraries: cdll.load(libname) instead of CDLL(libname). Index: test_win32.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/Attic/test_win32.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_win32.py 3 Nov 2005 19:49:19 -0000 1.1.2.1 --- test_win32.py 27 Jan 2006 18:18:54 -0000 1.1.2.2 *************** *** 4,10 **** import unittest, sys ! def find_test_dll(): ! import _ctypes_test ! return _ctypes_test.__file__ if sys.platform == "win32": --- 4,8 ---- import unittest, sys ! import _ctypes_test if sys.platform == "win32": *************** *** 57,61 **** ("bottom", c_long)] ! dll = CDLL(find_test_dll()) pt = POINT(10, 10) --- 55,59 ---- ("bottom", c_long)] ! dll = cdll.load(_ctypes_test.__file__) pt = POINT(10, 10) Index: test_functions.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/Attic/test_functions.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_functions.py 2 Jan 2006 19:12:01 -0000 1.1.2.3 --- test_functions.py 27 Jan 2006 18:18:54 -0000 1.1.2.4 *************** *** 16,22 **** import _ctypes_test ! dll = CDLL(_ctypes_test.__file__) if sys.platform == "win32": ! windll = WinDLL(_ctypes_test.__file__) class FunctionTestCase(unittest.TestCase): --- 16,22 ---- import _ctypes_test ! dll = cdll.load(_ctypes_test.__file__) if sys.platform == "win32": ! windll = windll.load(_ctypes_test.__file__) class FunctionTestCase(unittest.TestCase): Index: test_values.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/Attic/test_values.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_values.py 3 Nov 2005 19:49:19 -0000 1.1.2.1 --- test_values.py 27 Jan 2006 18:18:54 -0000 1.1.2.2 *************** *** 5,16 **** import unittest from ctypes import * ! def find_test_dll(): ! import _ctypes_test ! return _ctypes_test.__file__ class ValuesTestCase(unittest.TestCase): def test_an_integer(self): ! ctdll = CDLL(find_test_dll()) an_integer = c_int.in_dll(ctdll, "an_integer") x = an_integer.value --- 5,15 ---- import unittest from ctypes import * ! ! import _ctypes_test class ValuesTestCase(unittest.TestCase): def test_an_integer(self): ! ctdll = cdll.load(_ctypes_test.__file__) an_integer = c_int.in_dll(ctdll, "an_integer") x = an_integer.value *************** *** 20,33 **** def test_undefined(self): ! ctdll = CDLL(find_test_dll()) self.assertRaises(ValueError, c_int.in_dll, ctdll, "Undefined_Symbol") - import sys - name = "python%s%s" % sys.version_info[:2] - try: - pydll = getattr(cdll, name) - except: - pass - else: class Win_ValuesTestCase(unittest.TestCase): """This test only works when python itself is a dll/shared library""" --- 19,25 ---- def test_undefined(self): ! ctdll = cdll.load(_ctypes_test.__file__) self.assertRaises(ValueError, c_int.in_dll, ctdll, "Undefined_Symbol") class Win_ValuesTestCase(unittest.TestCase): """This test only works when python itself is a dll/shared library""" Index: test_bitfields.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/Attic/test_bitfields.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_bitfields.py 23 Jan 2006 12:19:20 -0000 1.1.2.2 --- test_bitfields.py 27 Jan 2006 18:18:54 -0000 1.1.2.3 *************** *** 25,29 **** ("S", c_short, 7)] ! func = CDLL(_ctypes_test.__file__).unpack_bitfields func.argtypes = POINTER(BITS), c_char --- 25,29 ---- ("S", c_short, 7)] ! func = cdll.load(_ctypes_test.__file__).unpack_bitfields func.argtypes = POINTER(BITS), c_char Index: test_prototypes.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/Attic/test_prototypes.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_prototypes.py 3 Nov 2005 19:49:19 -0000 1.1.2.1 --- test_prototypes.py 27 Jan 2006 18:18:54 -0000 1.1.2.2 *************** *** 23,27 **** import _ctypes_test ! testdll = CDLL(_ctypes_test.__file__) def c_wbuffer(init): --- 23,27 ---- import _ctypes_test ! testdll = cdll.load(_ctypes_test.__file__) def c_wbuffer(init): Index: test_checkretval.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/Attic/test_checkretval.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_checkretval.py 23 Jan 2006 12:16:44 -0000 1.1.2.3 --- test_checkretval.py 27 Jan 2006 18:18:54 -0000 1.1.2.4 *************** *** 15,19 **** import _ctypes_test ! dll = CDLL(_ctypes_test.__file__) self.failUnlessEqual(42, dll._testfunc_p_p(42)) --- 15,19 ---- import _ctypes_test ! dll = cdll.load(_ctypes_test.__file__) self.failUnlessEqual(42, dll._testfunc_p_p(42)) Index: test_callbacks.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/Attic/test_callbacks.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_callbacks.py 3 Nov 2005 19:49:19 -0000 1.1.2.1 --- test_callbacks.py 27 Jan 2006 18:18:54 -0000 1.1.2.2 *************** *** 115,119 **** def test_integrate(self): # Derived from some then non-working code, posted by David Foster ! dll = CDLL(_ctypes_test.__file__) # The function prototype called by 'integrate': double func(double); --- 115,119 ---- def test_integrate(self): # Derived from some then non-working code, posted by David Foster ! dll = cdll.load(_ctypes_test.__file__) # The function prototype called by 'integrate': double func(double); Index: test_pointers.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/Attic/test_pointers.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_pointers.py 3 Nov 2005 19:49:19 -0000 1.1.2.1 --- test_pointers.py 27 Jan 2006 18:18:54 -0000 1.1.2.2 *************** *** 2,8 **** from ctypes import * ! def find_test_dll(): ! import _ctypes_test ! return _ctypes_test.__file__ ctype_types = [c_byte, c_ubyte, c_short, c_ushort, c_int, c_uint, --- 2,6 ---- from ctypes import * ! import _ctypes_test ctype_types = [c_byte, c_ubyte, c_short, c_ushort, c_int, c_uint, *************** *** 23,27 **** def test_pass_pointers(self): ! dll = CDLL(find_test_dll()) func = dll._testfunc_p_p func.restype = c_long --- 21,25 ---- def test_pass_pointers(self): ! dll = cdll.load(_ctypes_test.__file__) func = dll._testfunc_p_p func.restype = c_long *************** *** 38,42 **** def test_change_pointers(self): ! dll = CDLL(find_test_dll()) func = dll._testfunc_p_p --- 36,40 ---- def test_change_pointers(self): ! dll = cdll.load(_ctypes_test.__file__) func = dll._testfunc_p_p *************** *** 73,77 **** callback = PROTOTYPE(func) ! dll = CDLL(find_test_dll()) # This function expects a function pointer, # and calls this with an integer pointer as parameter. --- 71,75 ---- callback = PROTOTYPE(func) ! dll = cdll.load(_ctypes_test.__file__) # This function expects a function pointer, # and calls this with an integer pointer as parameter. *************** *** 159,163 **** def test_charpp( self ): """Test that a character pointer-to-pointer is correctly passed""" ! dll = CDLL(find_test_dll()) func = dll._testfunc_c_p_p func.restype = c_char_p --- 157,161 ---- def test_charpp( self ): """Test that a character pointer-to-pointer is correctly passed""" ! dll = cdll.load(_ctypes_test.__file__) func = dll._testfunc_c_p_p func.restype = c_char_p Index: test_refcounts.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/Attic/test_refcounts.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_refcounts.py 3 Nov 2005 19:49:19 -0000 1.1.2.1 --- test_refcounts.py 27 Jan 2006 18:18:54 -0000 1.1.2.2 *************** *** 7,11 **** import _ctypes_test ! dll = ctypes.CDLL(_ctypes_test.__file__) class RefcountTestCase(unittest.TestCase): --- 7,11 ---- import _ctypes_test ! dll = ctypes.cdll.load(_ctypes_test.__file__) class RefcountTestCase(unittest.TestCase): Index: test_returnfuncptrs.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/Attic/test_returnfuncptrs.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_returnfuncptrs.py 3 Nov 2005 19:49:19 -0000 1.1.2.1 --- test_returnfuncptrs.py 27 Jan 2006 18:18:54 -0000 1.1.2.2 *************** *** 2,8 **** from ctypes import * ! def find_test_dll(): ! import _ctypes_test ! return _ctypes_test.__file__ class ReturnFuncPtrTestCase(unittest.TestCase): --- 2,6 ---- from ctypes import * ! import _ctypes_test class ReturnFuncPtrTestCase(unittest.TestCase): *************** *** 11,15 **** # The _ctypes_test shared lib/dll exports quite some functions for testing. # The get_strchr function returns a *pointer* to the C strchr function. ! dll = CDLL(find_test_dll()) get_strchr = dll.get_strchr get_strchr.restype = CFUNCTYPE(c_char_p, c_char_p, c_char) --- 9,13 ---- # The _ctypes_test shared lib/dll exports quite some functions for testing. # The get_strchr function returns a *pointer* to the C strchr function. ! dll = cdll.load(_ctypes_test.__file__) get_strchr = dll.get_strchr get_strchr.restype = CFUNCTYPE(c_char_p, c_char_p, c_char) *************** *** 21,25 **** def test_without_prototype(self): ! dll = CDLL(find_test_dll()) get_strchr = dll.get_strchr # the default 'c_int' would not work on systems where sizeof(int) != sizeof(void *) --- 19,23 ---- def test_without_prototype(self): ! dll = cdll.load(_ctypes_test.__file__) get_strchr = dll.get_strchr # the default 'c_int' would not work on systems where sizeof(int) != sizeof(void *) Index: test_paramflags.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/Attic/test_paramflags.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_paramflags.py 2 Jan 2006 19:12:01 -0000 1.1.2.2 --- test_paramflags.py 27 Jan 2006 18:18:54 -0000 1.1.2.3 *************** *** 39,43 **** def test_invalid_paramflags(self): import _ctypes_test ! dll = CDLL(_ctypes_test.__file__) proto = CFUNCTYPE(c_int, POINTER(c_int)) --- 39,43 ---- def test_invalid_paramflags(self): import _ctypes_test ! dll = cdll.load(_ctypes_test.__file__) proto = CFUNCTYPE(c_int, POINTER(c_int)) *************** *** 82,86 **** def test_with_restype(self): import _ctypes_test ! dll = CDLL(_ctypes_test.__file__) proto = CFUNCTYPE(BOOL, c_long, POINTER(RECT)) --- 82,86 ---- def test_with_restype(self): import _ctypes_test ! dll = cdll.load(_ctypes_test.__file__) proto = CFUNCTYPE(BOOL, c_long, POINTER(RECT)) *************** *** 102,106 **** def test_with_errcheck(self): import _ctypes_test ! dll = CDLL(_ctypes_test.__file__) def checker(retval, func, args): --- 102,106 ---- def test_with_errcheck(self): import _ctypes_test ! dll = cdll.load(_ctypes_test.__file__) def checker(retval, func, args): *************** *** 172,176 **** ## # 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) --- 172,176 ---- ## # So, we have to forbid c_char_p and c_wchar_p as out parameter types. ## import _ctypes_test ! ## dll = cdll.load(_ctypes_test.__file__) ## proto = CFUNCTYPE(None, POINTER(c_wchar))#c_wchar_p) *************** *** 182,186 **** def test_multiple_outargs(self): import _ctypes_test ! dll = CDLL(_ctypes_test.__file__) # the COM idl of this function would be: --- 182,186 ---- def test_multiple_outargs(self): import _ctypes_test ! dll = cdll.load(_ctypes_test.__file__) # the COM idl of this function would be: *************** *** 194,198 **** # test POINTER(interface) [in, out] parameter import _ctypes_test ! dll = CDLL(_ctypes_test.__file__) from comtypes import IUnknown --- 194,198 ---- # test POINTER(interface) [in, out] parameter import _ctypes_test ! dll = cdll.load(_ctypes_test.__file__) from comtypes import IUnknown *************** *** 209,213 **** def test_inout_args(self): import _ctypes_test ! dll = CDLL(_ctypes_test.__file__) # the COM idl of this function would be: --- 209,213 ---- def test_inout_args(self): import _ctypes_test ! dll = cdll.load(_ctypes_test.__file__) # the COM idl of this function would be: *************** *** 319,323 **** """ import _ctypes_test ! dll = CDLL(_ctypes_test.__file__) # void TwoOutArgs([in] int a, [in, out] int *p1, [in] int b, [in, out] int *p2); proto = CFUNCTYPE(None, c_int, POINTER(c_int), c_int, POINTER(c_int)) --- 319,323 ---- """ import _ctypes_test ! dll = cdll.load(_ctypes_test.__file__) # void TwoOutArgs([in] int a, [in, out] int *p1, [in] int b, [in, out] int *p2); proto = CFUNCTYPE(None, c_int, POINTER(c_int), c_int, POINTER(c_int)) Index: test_slicing.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/Attic/test_slicing.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_slicing.py 3 Nov 2005 19:49:19 -0000 1.1.2.1 --- test_slicing.py 27 Jan 2006 18:18:54 -0000 1.1.2.2 *************** *** 2,8 **** from ctypes import * ! def find_test_dll(): ! import _ctypes_test ! return _ctypes_test.__file__ class SlicesTestCase(unittest.TestCase): --- 2,6 ---- from ctypes import * ! import _ctypes_test class SlicesTestCase(unittest.TestCase): *************** *** 68,72 **** s = u"abcdefghijklmnopqrstuvwxyz\0" ! dll = CDLL(find_test_dll()) dll.my_wcsdup.restype = POINTER(c_wchar) dll.my_wcsdup.argtypes = POINTER(c_wchar), --- 66,70 ---- s = u"abcdefghijklmnopqrstuvwxyz\0" ! dll = cdll.load(_ctypes_test.__file__) dll.my_wcsdup.restype = POINTER(c_wchar) dll.my_wcsdup.argtypes = POINTER(c_wchar), Index: test_unicode.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/Attic/test_unicode.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_unicode.py 3 Nov 2005 19:49:19 -0000 1.1.2.1 --- test_unicode.py 27 Jan 2006 18:18:54 -0000 1.1.2.2 *************** *** 9,14 **** else: import _ctypes_test ! libc = ctypes.CDLL(_ctypes_test.__file__) ! wcslen = libc.my_wcslen wcslen.argtypes = [ctypes.c_wchar_p] --- 9,14 ---- else: import _ctypes_test ! dll = ctypes.cdll.load(_ctypes_test.__file__) ! wcslen = dll.my_wcslen wcslen.argtypes = [ctypes.c_wchar_p] *************** *** 67,71 **** import _ctypes_test ! func = ctypes.CDLL(_ctypes_test.__file__)._testfunc_p_p class StringTestCase(UnicodeTestCase): --- 67,71 ---- import _ctypes_test ! func = ctypes.cdll.load(_ctypes_test.__file__)._testfunc_p_p class StringTestCase(UnicodeTestCase): Index: test_cfuncs.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/Attic/test_cfuncs.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_cfuncs.py 4 Jan 2006 19:22:03 -0000 1.1.2.2 --- test_cfuncs.py 27 Jan 2006 18:18:54 -0000 1.1.2.3 *************** *** 8,12 **** class CFunctions(unittest.TestCase): ! _dll = CDLL(_ctypes_test.__file__) def S(self): --- 8,12 ---- class CFunctions(unittest.TestCase): ! _dll = cdll.load(_ctypes_test.__file__) def S(self): Index: test_leaks.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/Attic/test_leaks.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_leaks.py 2 Jan 2006 19:12:01 -0000 1.1.2.2 --- test_leaks.py 27 Jan 2006 18:18:54 -0000 1.1.2.3 *************** *** 87,91 **** ## def test_dll_leak_1(self): ## dll = cdll.LoadLibrary("msvcrt.dll") ! #### dll = CDLL("msvcrt.dll") #### dll = cdll.msvcrt ## dll._inp.restype = c_byte --- 87,91 ---- ## def test_dll_leak_1(self): ## dll = cdll.LoadLibrary("msvcrt.dll") ! #### dll = cdll.load("msvcrt.dll") #### dll = cdll.msvcrt ## dll._inp.restype = c_byte Index: test_posix.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/Attic/test_posix.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_posix.py 3 Nov 2005 19:49:19 -0000 1.1.2.1 --- test_posix.py 27 Jan 2006 18:18:54 -0000 1.1.2.2 *************** *** 9,14 **** class TestRTLD_GLOBAL(unittest.TestCase): def test_GL(self): ! CDLL('libGL.so', mode=RTLD_GLOBAL) ! CDLL('libGLU.so') ##if os.name == "posix" and sys.platform != "darwin": --- 9,14 ---- class TestRTLD_GLOBAL(unittest.TestCase): def test_GL(self): ! cdll.load('libGL.so', mode=RTLD_GLOBAL) ! cdll.load('libGLU.so') ##if os.name == "posix" and sys.platform != "darwin": |
From: Thomas H. <th...@us...> - 2006-01-27 17:59:53
|
Update of /cvsroot/ctypes/ctypes/docs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29112 Removed Files: Tag: branch_1_0 sum_sample.stx Log Message: ctypes.com is history. --- sum_sample.stx DELETED --- |
From: Thomas H. <th...@us...> - 2006-01-27 17:59:08
|
Update of /cvsroot/ctypes/ctypes/docs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28831 Removed Files: Tag: branch_1_0 com.stx Log Message: ctypes.com is history. --- com.stx DELETED --- |
From: Thomas H. <th...@us...> - 2006-01-27 17:57:57
|
Update of /cvsroot/ctypes/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28359 Modified Files: Tag: branch_1_0 __init__.py Log Message: Add deprecated markers. Index: __init__.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/__init__.py,v retrieving revision 1.61.2.26 retrieving revision 1.61.2.27 diff -C2 -d -r1.61.2.26 -r1.61.2.27 *** __init__.py 26 Jan 2006 20:23:16 -0000 1.61.2.26 --- __init__.py 27 Jan 2006 17:57:50 -0000 1.61.2.27 *************** *** 257,260 **** --- 257,261 ---- POINTER(c_char).from_param = c_char_p.from_param #_SimpleCData.c_char_p_from_param + # XXX Deprecated def SetPointerType(pointer, cls): if _pointer_type_cache.get(cls, None) is not None: *************** *** 272,275 **** --- 273,277 ---- return POINTER(type(inst))(inst) + # XXX Deprecated def ARRAY(typ, len): return typ * len |
From: Thomas H. <th...@us...> - 2006-01-27 17:57:34
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28269 Modified Files: Tag: branch_1_0 ChangeLog Log Message: Index: ChangeLog =================================================================== RCS file: /cvsroot/ctypes/ctypes/ChangeLog,v retrieving revision 1.86.2.34 retrieving revision 1.86.2.35 diff -C2 -d -r1.86.2.34 -r1.86.2.35 *** ChangeLog 4 Jan 2006 19:21:37 -0000 1.86.2.34 --- ChangeLog 27 Jan 2006 17:57:23 -0000 1.86.2.35 *************** *** 1,2 **** --- 1,13 ---- + 2006-01-26 Thomas Heller <th...@py...> + + * ctypes._loader implements the new LibraryLoader class. The + class itself is exposed from the ctypes module itself. + + LibraryLoader objects expose load(), find(), and load_version() + methods - see the docstrings. + + The register_library_alias() function is gone, it does belong + somewhere else (if at all). + 2006-01-02 Thomas Heller <th...@py...> |
From: Thomas H. <th...@us...> - 2006-01-26 21:15:34
|
Update of /cvsroot/ctypes/ctypes/ctypes/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18070/ctypes/test Modified Files: Tag: branch_1_0 test_stringptr.py Log Message: Adapt to library loading changes. Index: test_stringptr.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/Attic/test_stringptr.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_stringptr.py 3 Nov 2005 19:49:19 -0000 1.1.2.1 --- test_stringptr.py 26 Jan 2006 21:15:25 -0000 1.1.2.2 *************** *** 8,22 **** elif os.name == "posix": ! if sys.platform == "darwin": ! libc = cdll.LoadLibrary("/usr/lib/libc.dylib") ! elif sys.platform == "cygwin": ! libc = cdll.LoadLibrary("/bin/cygwin1.dll") ! elif sys.platform == "sunos5": ! libc = cdll.LoadLibrary("/lib/libc.so") ! else: ! try: ! libc = cdll.LoadLibrary("/lib/libc.so.6") ! except OSError: ! libc = None class StringPtrTestCase(unittest.TestCase): --- 8,23 ---- elif os.name == "posix": ! libc = cdll.find("c") ! ## if sys.platform == "darwin": ! ## libc = cdll.LoadLibrary("/usr/lib/libc.dylib") ! ## elif sys.platform == "cygwin": ! ## libc = cdll.LoadLibrary("/bin/cygwin1.dll") ! ## elif sys.platform == "sunos5": ! ## libc = cdll.LoadLibrary("/lib/libc.so") ! ## else: ! ## try: ! ## libc = cdll.LoadLibrary("/lib/libc.so.6") ! ## except OSError: ! ## libc = None class StringPtrTestCase(unittest.TestCase): |
From: Thomas H. <th...@us...> - 2006-01-26 21:02:57
|
Update of /cvsroot/ctypes/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14189 Modified Files: Tag: branch_1_0 _loader.py Log Message: Fix a problem on OS X. Index: _loader.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/Attic/_loader.py,v retrieving revision 1.1.2.11 retrieving revision 1.1.2.12 diff -C2 -d -r1.1.2.11 -r1.1.2.12 *** _loader.py 26 Jan 2006 07:59:52 -0000 1.1.2.11 --- _loader.py 26 Jan 2006 21:02:49 -0000 1.1.2.12 *************** *** 132,136 **** def _load(self, libname, mode): ! return self._dlltype(_dyld_find(libname), mode) elif os.name == "posix": --- 132,141 ---- def _load(self, libname, mode): ! # _dyld_find raises ValueError, convert this into OSError ! try: ! pathname = _dyld_find(libname) ! except ValueError: ! raise OSError("Library %s could not be found" % libname) ! return self._dlltype(pathname, mode) elif os.name == "posix": |
From: Thomas H. <th...@us...> - 2006-01-26 20:23:25
|
Update of /cvsroot/ctypes/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv764 Modified Files: Tag: branch_1_0 __init__.py Log Message: Remove import of unused symbol FreeLibrary. Change the order of arguments in the CDLL constructor. Index: __init__.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/__init__.py,v retrieving revision 1.61.2.25 retrieving revision 1.61.2.26 diff -C2 -d -r1.61.2.25 -r1.61.2.26 *** __init__.py 26 Jan 2006 19:49:14 -0000 1.61.2.25 --- __init__.py 26 Jan 2006 20:23:16 -0000 1.61.2.26 *************** *** 99,104 **** if _os.name in ("nt", "ce"): ! from _ctypes import LoadLibrary as _LoadLibrary, \ ! FreeLibrary as _FreeLibrary from _ctypes import FUNCFLAG_HRESULT as _FUNCFLAG_HRESULT, \ FUNCFLAG_STDCALL as _FUNCFLAG_STDCALL --- 99,103 ---- if _os.name in ("nt", "ce"): ! from _ctypes import LoadLibrary as _dlopen from _ctypes import FUNCFLAG_HRESULT as _FUNCFLAG_HRESULT, \ FUNCFLAG_STDCALL as _FUNCFLAG_STDCALL *************** *** 124,129 **** elif _os.name == "posix": ! from _ctypes import dlopen as _LoadLibrary ! _FreeLibrary = None from _ctypes import sizeof, byref, addressof, alignment --- 123,127 ---- elif _os.name == "posix": ! from _ctypes import dlopen as _dlopen from _ctypes import sizeof, byref, addressof, alignment *************** *** 298,306 **** _restype_ = c_int # default, can be overridden in instances ! _handle = 0 ! def __init__(self, name, handle=None, mode=RTLD_LOCAL): self._name = name if handle is None: ! self._handle = _LoadLibrary(self._name, mode) else: self._handle = handle --- 296,303 ---- _restype_ = c_int # default, can be overridden in instances ! def __init__(self, name, mode=RTLD_LOCAL, handle=None): self._name = name if handle is None: ! self._handle = _dlopen(self._name, mode) else: self._handle = handle *************** *** 323,337 **** return func - # This creates problems in gc. See - # https://sourceforge.net/tracker/index.php?func=detail&aid=1042541&group_id=71702&atid=532154 - # but since we cannot free the libraries anyway (the functions - # retrieved don't keep a reference to the _DLL instance), it does no - # harm to disable this code. - # - ## def __del__(self, FreeLibrary=_FreeLibrary): - ## if self._handle != 0 and FreeLibrary: - ## FreeLibrary(self._handle) - ## self._handle = 0 - class PyDLL(CDLL): """This class represents the Python library itself. It allows to --- 320,323 ---- *************** *** 387,391 **** if _os.name in ("nt", "ce"): ! pythonapi = PyDLL("python dll", _sys.dllhandle) elif _sys.platform == "cygwin": pythonapi = PyDLL("libpython%d.%d.dll" % _sys.version_info[:2]) --- 373,377 ---- if _os.name in ("nt", "ce"): ! pythonapi = PyDLL("python dll", None, _sys.dllhandle) elif _sys.platform == "cygwin": pythonapi = PyDLL("libpython%d.%d.dll" % _sys.version_info[:2]) |
From: Thomas H. <th...@us...> - 2006-01-26 19:59:53
|
Update of /cvsroot/ctypes/ctypes/ctypes/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25404 Modified Files: Tag: branch_1_0 test_loading.py Log Message: Adapt to changes in library loading. Index: test_loading.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/Attic/test_loading.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_loading.py 23 Jan 2006 12:25:49 -0000 1.1.2.3 --- test_loading.py 26 Jan 2006 19:59:45 -0000 1.1.2.4 *************** *** 7,11 **** unknowndll = "xxrandomnamexx" ! def test_LoadLibrary(self): if os.name == "nt": name = "msvcrt" --- 7,11 ---- unknowndll = "xxrandomnamexx" ! def test_load(self): if os.name == "nt": name = "msvcrt" *************** *** 16,35 **** else: name = "libc.so.6" ! cdll.LoadLibrary(name) ! self.assertRaises(OSError, cdll.LoadLibrary, self.unknowndll) ! def test_LoadLibraryVersion(self): version = "6" name = "c" - cdll.LoadLibraryVersion(name, version) if sys.platform == "linux2": # linux uses version, libc 9 should not exist ! self.assertRaises(OSError, cdll.LoadLibraryVersion, name, "9") ! self.assertRaises(OSError, cdll.LoadLibraryVersion, self.unknowndll, "") ! def test_find(self): ! name = "c" ! cdll.find(name, False) ! self.assertRaises(OSError, cdll.find, self.unknowndll) if __name__ == "__main__": --- 16,36 ---- else: name = "libc.so.6" ! cdll.load(name) ! self.assertRaises(OSError, cdll.load, self.unknowndll) ! def test_load_version(self): version = "6" name = "c" if sys.platform == "linux2": + cdll.load_version(name, version) # linux uses version, libc 9 should not exist ! self.assertRaises(OSError, cdll.load_version, name, "9") ! self.assertRaises(OSError, cdll.load_version, self.unknowndll, "") ! if os.name == "posix": ! def test_find(self): ! name = "c" ! cdll.find(name) ! self.assertRaises(OSError, cdll.find, self.unknowndll) if __name__ == "__main__": |
From: Thomas H. <th...@us...> - 2006-01-26 19:56:26
|
Update of /cvsroot/ctypes/ctypes/ctypes/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24420 Modified Files: Tag: branch_1_0 test_libc.py Log Message: Adapted to recent changes. Commented out the decorator tests - the decorators will disapear soon anyway. Index: test_libc.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/Attic/test_libc.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_libc.py 2 Jan 2006 19:12:01 -0000 1.1.2.3 --- test_libc.py 26 Jan 2006 19:56:18 -0000 1.1.2.4 *************** *** 1,9 **** ! import sys import unittest from ctypes import * ! libc = cdll.find('c', False) ! libm = cdll.find('m', False) class LibTest(unittest.TestCase): --- 1,14 ---- ! import sys, os import unittest from ctypes import * ! if os.name == "nt": ! # somewhat dangerous, should use the msvcr version that Python ! # itself uses! ! libm = libc = cdll.find('msvcrt') ! else: ! libm = cdll.find("m") ! libc = cdll.find("c") class LibTest(unittest.TestCase): *************** *** 15,27 **** self.failUnlessEqual(libm.sqrt(2.0), math.sqrt(2.0)) ! def test_cdecl_decorator(self): ! ! # @ cdecl(c_double, "libm", [c_double]) ! def sqrt(value): ! return sqrt._api_(value) ! # Oh well, compatibility with Python 2.3 ! sqrt = cdecl(c_double, "m", [c_double]) (sqrt) ! ! self.failUnlessEqual(sqrt(4.0), 2.0) def test_qsort(self): --- 20,30 ---- self.failUnlessEqual(libm.sqrt(2.0), math.sqrt(2.0)) ! ## def test_cdecl_decorator(self): ! ## # @ cdecl(c_double, "libm", [c_double]) ! ## def sqrt(value): ! ## return sqrt._api_(value) ! ## # Oh well, compatibility with Python 2.3 ! ## sqrt = cdecl(c_double, libm, [c_double]) (sqrt) ! ## self.failUnlessEqual(sqrt(4.0), 2.0) def test_qsort(self): *************** *** 37,59 **** self.failUnlessEqual(chars.raw, " ,,aaaadmmmnpppsss\x00") ! def test_qsort_decorator(self): ! from ctypes.decorators import cdecl ! ! CMPFUNC = CFUNCTYPE(c_int, c_void_p, c_void_p) ! #@ cdecl(None, "libc", [c_void_p, c_int, c_int, CMPFUNC]) ! ! def qsort(sequence, cmp_func): ! itemsize = sizeof(sequence) / len(sequence) ! qsort._api_(sequence, len(sequence), itemsize, CMPFUNC(cmp_func)) ! qsort = cdecl(None, "c", [c_void_p, c_int, c_int, CMPFUNC])(qsort) ! ! def sortfunc(a, b): ! a = cast(a, POINTER(c_int)) ! b = cast(b, POINTER(c_int)) ! return cmp(a[0], b[0]) ! ! ints = (c_int * 9)(1, 3, 5, 7, 9, 8, 6, 4, 2) ! qsort(ints, sortfunc) ! self.failUnlessEqual(ints[:], [1, 2, 3, 4, 5, 6, 7, 8, 9]) if __name__ == "__main__": --- 40,58 ---- self.failUnlessEqual(chars.raw, " ,,aaaadmmmnpppsss\x00") ! ## def test_qsort_decorator(self): ! ## from ctypes.decorators import cdecl ! ## CMPFUNC = CFUNCTYPE(c_int, c_void_p, c_void_p) ! ## #@ cdecl(None, "libc", [c_void_p, c_int, c_int, CMPFUNC]) ! ## def qsort(sequence, cmp_func): ! ## itemsize = sizeof(sequence) / len(sequence) ! ## qsort._api_(sequence, len(sequence), itemsize, CMPFUNC(cmp_func)) ! ## qsort = cdecl(None, "c", [c_void_p, c_int, c_int, CMPFUNC])(qsort) ! ## def sortfunc(a, b): ! ## a = cast(a, POINTER(c_int)) ! ## b = cast(b, POINTER(c_int)) ! ## return cmp(a[0], b[0]) ! ## ints = (c_int * 9)(1, 3, 5, 7, 9, 8, 6, 4, 2) ! ## qsort(ints, sortfunc) ! ## self.failUnlessEqual(ints[:], [1, 2, 3, 4, 5, 6, 7, 8, 9]) if __name__ == "__main__": |
From: Thomas H. <th...@us...> - 2006-01-26 19:49:22
|
Update of /cvsroot/ctypes/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22036 Modified Files: Tag: branch_1_0 util.py __init__.py Log Message: ctypes now uses the LibraryLoader from ctypes._loader Index: util.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/util.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 *** util.py 22 Dec 2005 20:34:57 -0000 1.1.2.2 --- util.py 26 Jan 2006 19:49:14 -0000 1.1.2.3 *************** *** 1,45 **** ! import os, re, tempfile ! ! if os.name == "posix": ! ! def findLib_gcc(name): ! expr = '[^\(\)\s]*lib%s\.[^\(\)\s]*' % name ! cmd = 'if type gcc &>/dev/null; then CC=gcc; else CC=cc; fi;' \ ! '$CC -Wl,-t -o /dev/null 2>&1 -l' + name ! try: ! fdout, outfile = tempfile.mkstemp() ! fd = os.popen(cmd) ! trace = fd.read() ! err = fd.close() ! finally: ! try: ! os.unlink(outfile) ! except OSError, e: ! if e.errno != errno.ENOENT: ! raise ! res = re.search(expr, trace) ! if not res: ! return None ! return res.group(0) ! ! def findLib_ld(name): ! expr = '/[^\(\)\s]*lib%s\.[^\(\)\s]*' % name ! res = re.search(expr, os.popen('/sbin/ldconfig -p 2>/dev/null').read()) ! if not res: ! return None ! return res.group(0) ! ! def get_soname(f): ! cmd = "objdump -p -j .dynamic 2>/dev/null " + f ! res = re.search(r'\sSONAME\s+([^\s]+)', os.popen(cmd).read()) ! if not res: ! return f ! return res.group(1) ! ! def findLib(name): ! lib = findLib_ld(name) ! if not lib: ! lib = findLib_gcc(name) ! if not lib: ! return [name] ! return [get_soname(lib)] --- 1 ---- ! # ctypes.util is no longer used. Index: __init__.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/__init__.py,v retrieving revision 1.61.2.24 retrieving revision 1.61.2.25 diff -C2 -d -r1.61.2.24 -r1.61.2.25 *** __init__.py 23 Jan 2006 12:25:34 -0000 1.61.2.24 --- __init__.py 26 Jan 2006 19:49:14 -0000 1.61.2.25 *************** *** 35,38 **** --- 35,40 ---- FUNCFLAG_PYTHONAPI as _FUNCFLAG_PYTHONAPI + from ctypes._loader import LibraryLoader + """ WINOLEAPI -> HRESULT *************** *** 381,485 **** _restype_ = c_int # needed, but unused (see _FUNCFLAG_HRESULT flag) ! def register_library_alias(alias, libname, osname, platform=None): ! global _library_map ! if osname is not None and osname != _os.name: ! return ! if platform is not None and platform != _sys.platform: ! return ! _library_map[alias] = libname ! ! _library_map = {} ! ! register_library_alias("c", "msvcrt", "nt") ! register_library_alias("m", "msvcrt", "nt") ! ! register_library_alias("c", "coredll", "ce") ! register_library_alias("m", "coredll", "ce") ! ! class _DLLS(object): ! def __init__(self, dlltype): ! self._dlltype = dlltype ! ! def __getattr__(self, name): ! if name[0] == '_': ! raise AttributeError, name ! dll = self.LoadLibrary(name) ! setattr(self, name, dll) ! return dll ! ! def __getitem__(self, name): ! return getattr(self, name) ! ! def LoadLibrary(self, name): ! return self._dlltype(name) ! ! def find(self, name, showname=True): ! global _library_map ! if name in _library_map: ! names = _chain( ! self._findLibrary(name), ! self._findLibrary(_library_map[name])) ! else: ! names = self._findLibrary(name) ! for libname in names: ! try: ! dll = self._dlltype(libname) ! except OSError: ! continue ! break ! else: ! raise OSError, "not found: %s" % name ! if showname: ! print "ctypes.find: %s" % libname ! return dll ! ! def LoadLibraryVersion(self, name, version=''): ! global _library_map ! try: ! return self._LoadLibraryVersion(name, version) ! except OSError, e: ! pass ! if name not in _library_map: ! raise ! name = _library_map[name] ! try: ! return self._LoadLibraryVersion(name, version) ! except OSError: ! raise e ! ! if _os.name == "posix" and _sys.platform == "darwin": ! def _findLibrary(self, name): ! return ['lib%s.dylib' % name, ! '%s.dylib' % name, ! '%s.framework/%s' % (name, name)] ! ! def _LoadLibraryVersion(self, name, version=''): ! for libname in self._findLibrary(name): ! try: ! return self._dlltype(libname) ! except OSError: ! continue ! raise OSError, "not found: %s" % name ! ! elif _os.name == "posix": ! def _findLibrary(self, name): ! from util import findLib ! return findLib(name) ! ! def _LoadLibraryVersion(self, name, version=''): ! if version: ! version = '.' + version ! dll = self._dlltype("lib%s.so%s" % (name, version)) ! return dll ! ! else: ! def _findLibrary(self, name): ! return [name] ! ! def _LoadLibraryVersion(self, name, version=''): ! return self._dlltype(name) ! ! cdll = _DLLS(CDLL) ! pydll = _DLLS(PyDLL) if _os.name in ("nt", "ce"): --- 383,388 ---- _restype_ = c_int # needed, but unused (see _FUNCFLAG_HRESULT flag) ! cdll = LibraryLoader(CDLL) ! pydll = LibraryLoader(PyDLL) if _os.name in ("nt", "ce"): *************** *** 492,497 **** if _os.name in ("nt", "ce"): ! windll = _DLLS(WinDLL) ! oledll = _DLLS(OleDLL) if _os.name == "nt": --- 395,400 ---- if _os.name in ("nt", "ce"): ! windll = LibraryLoader(WinDLL) ! oledll = LibraryLoader(OleDLL) if _os.name == "nt": |
From: Thomas H. <th...@us...> - 2006-01-26 19:47:40
|
Update of /cvsroot/ctypes/ctypes/ctypes/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21428 Removed Files: Tag: branch_1_0 test_variant.py test_comobject.py Log Message: ctypes.com doesn't exist any more. --- test_variant.py DELETED --- --- test_comobject.py DELETED --- |
From: Thomas H. <th...@us...> - 2006-01-26 08:00:00
|
Update of /cvsroot/ctypes/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22889 Modified Files: Tag: branch_1_0 _loader.py Log Message: More docs for __getattr__. Simple minded tests for Windows. Index: _loader.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/Attic/_loader.py,v retrieving revision 1.1.2.10 retrieving revision 1.1.2.11 diff -C2 -d -r1.1.2.10 -r1.1.2.11 *** _loader.py 26 Jan 2006 07:54:36 -0000 1.1.2.10 --- _loader.py 26 Jan 2006 07:59:52 -0000 1.1.2.11 *************** *** 189,193 **** def __getattr__(self, name): ! """Load a library via attribute access. The result is cached.""" if name.startswith("_"): raise AttributeError(name) --- 189,194 ---- def __getattr__(self, name): ! """Load a library via attribute access. Calls ! .load_version(). The result is cached.""" if name.startswith("_"): raise AttributeError(name) *************** *** 213,216 **** --- 214,224 ---- def test(): + if os.name == "nt": + print cdll.msvcrt + print cdll.load("msvcrt") + # load_version looks more like an artefact: + print cdll.load_version("msvcr", "t") + print cdll.find("msvcrt") + if os.name == "posix": # find and load_version *************** *** 224,228 **** # load ! if os.name == "posix" and sys.platform == "darwin": print cdll.load("libm.dylib") print cdll.load("libcrypto.dylib") --- 232,236 ---- # load ! if sys.platform == "darwin": print cdll.load("libm.dylib") print cdll.load("libcrypto.dylib") |
From: Thomas H. <th...@us...> - 2006-01-26 07:54:45
|
Update of /cvsroot/ctypes/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21254 Modified Files: Tag: branch_1_0 _loader.py Log Message: __getattr__(name) calls load_version(name), so a platform independent libname can be used, but the possibly sophisticated search the find(name) does it *not* used. Index: _loader.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/Attic/_loader.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 *** _loader.py 26 Jan 2006 07:44:45 -0000 1.1.2.9 --- _loader.py 26 Jan 2006 07:54:36 -0000 1.1.2.10 *************** *** 192,196 **** if name.startswith("_"): raise AttributeError(name) ! dll = self.find(name) setattr(self, name, dll) return dll --- 192,196 ---- if name.startswith("_"): raise AttributeError(name) ! dll = self.load_version(name) setattr(self, name, dll) return dll *************** *** 220,225 **** # getattr - print cdll.crypto print cdll.m # load --- 220,225 ---- # getattr print cdll.m + print cdll.bz2 # load |
From: Thomas H. <th...@us...> - 2006-01-26 07:44:53
|
Update of /cvsroot/ctypes/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18138 Modified Files: Tag: branch_1_0 _loader.py Log Message: Remove unneeded default argument from _plat_load_version. And more. Index: _loader.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/Attic/_loader.py,v retrieving revision 1.1.2.8 retrieving revision 1.1.2.9 diff -C2 -d -r1.1.2.8 -r1.1.2.9 *** _loader.py 26 Jan 2006 07:24:16 -0000 1.1.2.8 --- _loader.py 26 Jan 2006 07:44:45 -0000 1.1.2.9 *************** *** 110,119 **** if mode is None: mode = self._mode ! return self._dlltype(_dyld_find(libname), mode) ! # Helper for load_version - assembles a filename from name and filename if os.name in ("nt", "ce"): # Windows (XXX what about cygwin?) ! def _plat_load_version(self, name, version, mode=None): # not sure if this makes sense if version is not None: --- 110,119 ---- if mode is None: mode = self._mode ! return self._load(libname, mode) ! # Helpers for load and load_version - assembles a filename from name and filename if os.name in ("nt", "ce"): # Windows (XXX what about cygwin?) ! def _plat_load_version(self, name, version, mode): # not sure if this makes sense if version is not None: *************** *** 121,137 **** return self.load(name, mode) elif os.name == "posix" and sys.platform == "darwin": # Mac OS X ! def _plat_load_version(self, name, version, mode=None): if version: return self.load("lib%s.%s.dylib" % (name, version), mode) return self.load("lib%s.dylib" % name, mode) elif os.name == "posix": # Posix ! def _plat_load_version(self, name, version, mode=None): if version: return self.load("lib%s.so.%s" % (name, version), mode) return self.load("lib%s.so" % name, mode) else: # Others, TBD --- 121,147 ---- return self.load(name, mode) + def _load(self, libname, mode): + return self._dlltype(libname, mode) + elif os.name == "posix" and sys.platform == "darwin": # Mac OS X ! def _plat_load_version(self, name, version, mode): if version: return self.load("lib%s.%s.dylib" % (name, version), mode) return self.load("lib%s.dylib" % name, mode) + + def _load(self, libname, mode): + return self._dlltype(_dyld_find(libname), mode) elif os.name == "posix": # Posix ! def _plat_load_version(self, name, version, mode): if version: return self.load("lib%s.so.%s" % (name, version), mode) return self.load("lib%s.so" % name, mode) + + def _load(self, libname, mode): + return self._dlltype(libname, mode) + else: # Others, TBD *************** *** 139,142 **** --- 149,155 ---- return self.load(name, mode) + def _load(self, libname, mode): + return self._dlltype(libname, mode) + def load_version(self, name, version=None, mode=None): """Build a (system dependend) filename from 'name' and *************** *** 218,222 **** else: print cdll.load("libm.so") ! print cdll.load("libcrypto.so") if __name__ == "__main__": --- 231,236 ---- else: print cdll.load("libm.so") ! print cdll.load("libcrypt.so") ! print cdll.find("crypt") if __name__ == "__main__": |
From: Thomas H. <th...@us...> - 2006-01-26 07:24:24
|
Update of /cvsroot/ctypes/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10891 Modified Files: Tag: branch_1_0 _loader.py Log Message: load() calls dyld_find on OS X now. Index: _loader.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/Attic/_loader.py,v retrieving revision 1.1.2.7 retrieving revision 1.1.2.8 diff -C2 -d -r1.1.2.7 -r1.1.2.8 *** _loader.py 26 Jan 2006 07:14:21 -0000 1.1.2.7 --- _loader.py 26 Jan 2006 07:24:16 -0000 1.1.2.8 *************** *** 108,115 **** constructor, it is ignored on Windows. """ - # XXX Should call dyld_find on OS X (?) if mode is None: mode = self._mode ! return self._dlltype(libname, mode) # Helper for load_version - assembles a filename from name and filename --- 108,114 ---- constructor, it is ignored on Windows. """ if mode is None: mode = self._mode ! return self._dlltype(_dyld_find(libname), mode) # Helper for load_version - assembles a filename from name and filename *************** *** 200,223 **** cdll = LibraryLoader(CDLL) ! if __name__ == "__main__": ! # platform independend tests ! print cdll.find("m") ! print cdll.find("c") ! print cdll.load_version("crypto", "0.9.7") ! if os.name == "posix" and sys.platform == "darwin": ! print cdll.load("libm.dylib") ! print cdll.load("libcrypt.dylib") ! else: ! print cdll.load("libm.so") ! print cdll.load("libcrypt.so") ! if os.name == "nt": ! ## load(filename) ! print cdll.load("msvcrt") ! print cdll.find("m") ! print cdll.load_version("msvcr", "71") ! ! ## load_version(name, version) ! ## find(name) --- 199,223 ---- cdll = LibraryLoader(CDLL) ! def test(): ! if os.name == "posix": ! # find and load_version ! print cdll.find("m") ! print cdll.find("c") ! print cdll.load_version("crypto", "0.9.7") ! # getattr ! print cdll.crypto ! print cdll.m ! # load ! if os.name == "posix" and sys.platform == "darwin": ! print cdll.load("libm.dylib") ! print cdll.load("libcrypto.dylib") ! print cdll.load("libSystem.dylib") ! print cdll.load("System.framework/System") ! else: ! print cdll.load("libm.so") ! print cdll.load("libcrypto.so") ! if __name__ == "__main__": ! test() |