Changeset 35

Show
Ignore:
Timestamp:
08/13/06 20:30:19 (2 years ago)
Author:
KirkMcDonald
Message:

html_doc: basics, exceptions documented; new layout

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/html_doc/celerid.html

    r34 r35  
    88 
    99<body> 
    10 <div class="nav"><a class="nav" href="index.html">Main</a> | <a class="navcur" href="celerid.html">CeleriD</a> | <a class="nav" href="conversion.html">Type conversion</a> | <a class="nav" href="func_wrapping.html">Function wrapping</a> | <a class="nav" href="class_wrapping.html">Class wrapping</a> | <a class="nav" href="except_wrapping.html">Exception wrapping</a> | <a class="nav" href="dpyobject.html">DPyObject</a></div> 
     10<div id="nav"> 
     11<p><big>Contents</big></p> 
     12<a class="nav" href="index.html">Main</a><br /> 
     13<a class="nav" href="basics.html">The basics</a><br /> 
     14<a class="navcur" href="celerid.html">CeleriD</a><br /> 
     15<a class="nav" href="conversion.html">Type conversion</a><br /> 
     16<a class="nav" href="func_wrapping.html">Function wrapping</a><br /> 
     17<a class="nav" href="class_wrapping.html">Class wrapping</a><br /> 
     18<a class="nav" href="except_wrapping.html">Exception wrapping</a><br /> 
     19<a class="nav" href="dpyobject.html">DPyObject</a> 
     20</div> 
     21 
     22<div id="content"> 
    1123 
    1224<h1>CeleriD</h1> 
     
    2941 
    3042<pre class="code">&gt;python setup.py build</pre> 
     43</div> 
     44 
    3145</body> 
    3246</html> 
  • trunk/html_doc/class_wrapping.html

    r34 r35  
    88 
    99<body> 
    10 <div class="nav"><a class="nav" href="index.html">Main</a> | <a class="nav" href="celerid.html">CeleriD</a> | <a class="nav" href="conversion.html">Type conversion</a> | <a class="nav" href="func_wrapping.html">Function wrapping</a> | <a class="navcur" href="class_wrapping.html">Class wrapping</a> | <a class="nav" href="except_wrapping.html">Exception wrapping</a> | <a class="nav" href="dpyobject.html">DPyObject</a></div> 
     10<div id="nav"> 
     11<p><big>Contents</big></p> 
     12<a class="nav" href="index.html">Main</a><br /> 
     13<a class="nav" href="basics.html">The basics</a><br /> 
     14<a class="nav" href="celerid.html">CeleriD</a><br /> 
     15<a class="nav" href="conversion.html">Type conversion</a><br /> 
     16<a class="nav" href="func_wrapping.html">Function wrapping</a><br /> 
     17<a class="navcur" href="class_wrapping.html">Class wrapping</a><br /> 
     18<a class="nav" href="except_wrapping.html">Exception wrapping</a><br /> 
     19<a class="nav" href="dpyobject.html">DPyObject</a> 
     20</div> 
     21 
     22<div id="content"> 
    1123 
    1224<h1>Class wrapping</h1> 
     
    5062 
    5163<p>If you have a class <code>Foo</code>, you can check whether it is wrapped by simply checking whether <code>is_wrapped!(Foo)</code> is true. It is important to note that this is <em>not</em> a <code>const bool</code>, it is a <em>runtime</em> check.</p> 
     64 
     65<h3>Automatic operator overloading</h3> 
     66 
     67<p><i>Docs coming soon...</i></p> 
    5268 
    5369<h3>Examples</h3> 
     
    105121&gt;&gt;&gt; </pre> 
    106122 
     123</div> 
     124 
    107125</body> 
    108126</html> 
  • trunk/html_doc/conversion.html

    r34 r35  
    88 
    99<body> 
    10 <div class="nav"><a class="nav" href="index.html">Main</a> | <a class="nav" href="celerid.html">CeleriD</a> | <a class="navcur" href="conversion.html">Type conversion</a> | <a class="nav" href="func_wrapping.html">Function wrapping</a> | <a class="nav" href="class_wrapping.html">Class wrapping</a> | <a class="nav" href="except_wrapping.html">Exception wrapping</a> | <a class="nav" href="dpyobject.html">DPyObject</a></div> 
     10<div id="nav"> 
     11<p><big>Contents</big></p> 
     12<a class="nav" href="index.html">Main</a><br /> 
     13<a class="nav" href="basics.html">The basics</a><br /> 
     14<a class="nav" href="celerid.html">CeleriD</a><br /> 
     15<a class="navcur" href="conversion.html">Type conversion</a><br /> 
     16<a class="nav" href="func_wrapping.html">Function wrapping</a><br /> 
     17<a class="nav" href="class_wrapping.html">Class wrapping</a><br /> 
     18<a class="nav" href="except_wrapping.html">Exception wrapping</a><br /> 
     19<a class="nav" href="dpyobject.html">DPyObject</a> 
     20</div> 
     21 
     22<div id="content"> 
    1123 
    1224<h1>Type conversion</h1> 
     
    5971This function will throw a <code>DPyConversionException</code> if the conversion is not possible.</dd> 
    6072</dl> 
     73</div> 
     74 
    6175</body> 
    6276</html> 
  • trunk/html_doc/dpyobject.html

    r34 r35  
    88 
    99<body> 
    10 <div class="nav"><a class="nav" href="index.html">Main</a> | <a class="nav" href="celerid.html">CeleriD</a> | <a class="nav" href="conversion.html">Type conversion</a> | <a class="nav" href="func_wrapping.html">Function wrapping</a> | <a class="nav" href="class_wrapping.html">Class wrapping</a> | <a class="nav" href="except_wrapping.html">Exception wrapping</a> | <a class="navcur" href="dpyobject.html">DPyObject</a></div> 
     10<div id="nav"> 
     11<p><big>Contents</big></p> 
     12<a class="nav" href="index.html">Main</a><br /> 
     13<a class="nav" href="basics.html">The basics</a><br /> 
     14<a class="nav" href="celerid.html">CeleriD</a><br /> 
     15<a class="nav" href="conversion.html">Type conversion</a><br /> 
     16<a class="nav" href="func_wrapping.html">Function wrapping</a><br /> 
     17<a class="nav" href="class_wrapping.html">Class wrapping</a><br /> 
     18<a class="nav" href="except_wrapping.html">Exception wrapping</a><br /> 
     19<a class="navcur" href="dpyobject.html">DPyObject</a> 
     20</div> 
     21 
     22<div id="content"> 
    1123 
    1224<h1>pyd.dpyobject</h1> 
     
    587599<hr /> 
    588600<small>Page generated by <a href="http://www.digitalmars.com/d/ddoc.html">Ddoc</a>.</small> 
     601</div> 
     602 
    589603</body> 
    590604</html> 
  • trunk/html_doc/except_wrapping.html

    r34 r35  
    88 
    99<body> 
    10 <div class="nav"><a class="nav" href="index.html">Main</a> | <a class="nav" href="celerid.html">CeleriD</a> | <a class="nav" href="conversion.html">Type conversion</a> | <a class="nav" href="func_wrapping.html">Function wrapping</a> | <a class="nav" href="class_wrapping.html">Class wrapping</a> | <a class="navcur" href="except_wrapping.html">Exception wrapping</a> | <a class="nav" href="dpyobject.html">DPyObject</a></div> 
     10<div id="nav"> 
     11<p><big>Contents</big></p> 
     12<a class="nav" href="index.html">Main</a><br /> 
     13<a class="nav" href="basics.html">The basics</a><br /> 
     14<a class="nav" href="celerid.html">CeleriD</a><br /> 
     15<a class="nav" href="conversion.html">Type conversion</a><br /> 
     16<a class="nav" href="func_wrapping.html">Function wrapping</a><br /> 
     17<a class="nav" href="class_wrapping.html">Class wrapping</a><br /> 
     18<a class="navcur" href="except_wrapping.html">Exception wrapping</a><br /> 
     19<a class="nav" href="dpyobject.html">DPyObject</a> 
     20</div> 
     21 
     22<div id="content"> 
    1123 
    1224<h1>Exception wrapping</h1> 
    1325 
    14 <p><i>Coming soon...</i></p> 
     26<p>The raw Python/C API has a <a href="http://docs.python.org/api/exceptionHandling.html">protocol</a> for allowing C extensions to use Python's exception mechanism. It is a goal of Pyd's that a user will never have to deal with this protocol. Instead, Pyd provides a mechanism for translating Python exceptions into D exceptions, and for translating D exceptions into Python exceptions.</p> 
     27 
     28<p>When wrapping functions and classes, the latter is usually of more interest. All wrapped functions, methods, constructors, properties, &amp;c, will catch any otherwise uncaught D exceptions and translate them into a Python <code>RuntimeError</code>. <i>(In the future, I may define a new Python exception type for this purpose.)</i> This is fairly important, as any uncaught D exceptions would otherwise crash the Python interpreter.</p> 
     29 
     30<p>The <a href="dpyobject.html">DPyObject</a> class wraps a portion of the Python/C API. Whenever a Python exception is raised by a method of DPyObject, it will be thrown as a <code>PythonException</code>. This is a normal D exception that knows how to carry the complete state of a Python exception. <code>PythonException</code> objects have three properties, <code>type</code>, <code>value</code>, and <code>traceback</code>, which each return an owned reference to a <code>PyObject*</code> corresponding to a different part of a Python exception. If the <code>PythonException</code> goes uncaught, the function wrapper will catch it, and translate it back into the original Python exception.</p> 
     31 
     32<p>Pyd provides the following exception-related functions:</p> 
     33 
     34<dl> 
     35<dt><code>void handle_exception();</code></dt> 
     36<dd>This checks if a Python exception has been set and, if it has, throws a <code>PythonException</code> containing the set exception. It will also clear the Python error condition.</dd> 
     37 
     38<dt><code>PyObject* exception_catcher(PyObject* delegate() <span class="arg">dg</span>);</code</dt> 
     39<dt><code>int exception_catcher(int delegate() <span class="arg">dg</span>);</code</dt> 
     40<dd>These two functions call the passed delegate within a <code>try ... catch</code> block, and if any exception occurs, will set an appropriate Python error condidition and return an "invalid" value. (These are <code>null</code> for the <code>PyObject*</code> version, -1 for the <code>int</code> version.) Otherwise, it will simply return whatever the delegate does. It is recommended that any function that interfaces directly with Python place its contents within a function literal in a call to one of these functions. (D can usually infer the return type of a function literal. If it can't, you might want to review D's syntax for <a href="http://www.digitalmars.com/d/expression.html#FunctionLiteral">function literals</a>.) For example: 
     41 
     42<pre class="code"><span class="keyword">extern</span> (C) 
     43PyObject* some_func(PyObject* self) { 
     44    <span class="keyword">return</span> exception_catcher({ 
     45        PyObject* result; 
     46        <span class="comment">// do something useful</span> 
     47        <span class="keyword">return</span> result; 
     48    }); 
     49}</pre> 
     50</dd> 
     51 
     52</div> 
    1553 
    1654</body> 
  • trunk/html_doc/func_wrapping.html

    r34 r35  
    88 
    99<body> 
    10 <div class="nav"><a class="nav" href="index.html">Main</a> | <a class="nav" href="celerid.html">CeleriD</a> | <a class="nav" href="conversion.html">Type conversion</a> | <a class="navcur" href="func_wrapping.html">Function wrapping</a> | <a class="nav" href="class_wrapping.html">Class wrapping</a> | <a class="nav" href="except_wrapping.html">Exception wrapping</a> | <a class="nav" href="dpyobject.html">DPyObject</a></div> 
     10<div id="nav"> 
     11<p><big>Contents</big></p> 
     12<a class="nav" href="index.html">Main</a><br /> 
     13<a class="nav" href="basics.html">The basics</a><br /> 
     14<a class="nav" href="celerid.html">CeleriD</a><br /> 
     15<a class="nav" href="conversion.html">Type conversion</a><br /> 
     16<a class="navcur" href="func_wrapping.html">Function wrapping</a><br /> 
     17<a class="nav" href="class_wrapping.html">Class wrapping</a><br /> 
     18<a class="nav" href="except_wrapping.html">Exception wrapping</a><br /> 
     19<a class="nav" href="dpyobject.html">DPyObject</a> 
     20</div> 
     21 
     22<div id="content"> 
    1123 
    1224<h1>Function wrapping</h1> 
     
    7688s = apple</pre> 
    7789 
     90</div> 
     91 
    7892</body> 
    7993</html> 
  • trunk/html_doc/index.html

    r34 r35  
    88 
    99<body> 
    10 <div class="nav"><a class="navcur" href="index.html">Main</a> | <a class="nav" href="celerid.html">CeleriD</a> | <a class="nav" href="conversion.html">Type conversion</a> | <a class="nav" href="func_wrapping.html">Function wrapping</a> | <a class="nav" href="class_wrapping.html">Class wrapping</a> | <a class="nav" href="except_wrapping.html">Exception wrapping</a> | <a class="nav" href="dpyobject.html">DPyObject</a></div> 
     10<div id="nav"> 
     11<p><big>Contents</big></p> 
     12<a class="navcur" href="index.html">Main</a><br /> 
     13<a class="nav" href="basics.html">The basics</a><br /> 
     14<a class="nav" href="celerid.html">CeleriD</a><br /> 
     15<a class="nav" href="conversion.html">Type conversion</a><br /> 
     16<a class="nav" href="func_wrapping.html">Function wrapping</a><br /> 
     17<a class="nav" href="class_wrapping.html">Class wrapping</a><br /> 
     18<a class="nav" href="except_wrapping.html">Exception wrapping</a><br /> 
     19<a class="nav" href="dpyobject.html">DPyObject</a> 
     20</div> 
     21 
     22<div id="content"> 
    1123 
    1224<h1>Pyd</h1> 
     
    1426 
    1527<p>Pyd also comes with its own extension to Python's <a href="http://docs.python.org/dist/dist.html">distutils</a>, called <a href="celerid.html">CeleriD</a>, making the building of extension modules quite easy.</p> 
     28 
     29<p>Pyd's Trac page can be found <a href="http://dsource.org/projects/pyd/wiki">here</a>.</p> 
    1630 
    1731<p>A simple "hello, world" module might look like this:</p> 
     
    3650&gt;&gt;&gt; testdll.hello_func() 
    3751Hello, world!</pre> 
     52 
     53</div> 
     54 
    3855</body> 
    3956</html> 
  • trunk/html_doc/pyd.css

    r33 r35  
    11body { 
    22    background-color: #d8d8d8; 
     3    margin: 0px 0px 0px 0px; 
    34    font-size: 90%; 
    45    font-family: Geneva, Arial, Helvetica, sans-serif; 
     
    1112    background-color: #305880; 
    1213} 
    13 div.nav { 
    14     width: 100%; 
     14div#content { 
     15    position: absolute; 
     16    left: 160px; 
     17    top: 0px; 
     18    padding: 5px; 
     19
     20div#nav { 
    1521    color: #d8d8d8; 
    1622    background-color: #305880; 
    17     text-align: center; 
    18     margin: 2px; 
     23    margin-right: 15px; 
    1924    padding: 2px; 
    2025    line-height: 140%; 
     26    width: 150px; 
    2127} 
    2228a.nav {