Changeset 49

Show
Ignore:
Timestamp:
12/01/06 17:15:39 (5 years ago)
Author:
KirkMcDonald
Message:

'DPy' prefix finally changed to 'Pyd'

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/dcompiler.py

    r48 r49  
    3030    'def.d', 
    3131    'dg_convert.d', 
    32     'dpyobject.d', 
    3332    'exception.d', 
    3433    'func_wrap.d', 
     
    3736    'op_wrap.d', 
    3837    'pyd.d', 
     38    'pydobject.d', 
    3939] 
    4040 
  • trunk/html_doc/basics.html

    r45 r49  
    1818<a class="nav" href="class_wrapping.html">Class wrapping</a><br /> 
    1919<a class="nav" href="except_wrapping.html">Exception wrapping</a><br /> 
    20 <a class="nav" href="dpyobject.html">DPyObject</a><br /> 
     20<a class="nav" href="pydobject.html">PydObject</a><br /> 
    2121<a class="nav" href="credits.html">Credits</a> 
    2222</div> 
     
    4949<p><code>PyObject* module_init(char[] <span class="arg">name</span>);</code></p> 
    5050 
    51 <p>It does little more than call <a href="http://docs.python.org/api/allocating-objects.html">Py_InitModule</a> and return the new module object. This object is also available via the <code>DPy_Module_p</code> property once you've called <code>module_init</code>.</p> 
     51<p>It does little more than call <a href="http://docs.python.org/api/allocating-objects.html">Py_InitModule</a> and return the new module object. This object is also available via the <code>Pyd_Module_p</code> property once you've called <code>module_init</code>.</p> 
    5252 
    5353<p>Due to the way in which Pyd implements function and class wrapping, any calls to <code>def</code> must occur <em>before</em> the call to <code>module_init</code>, and any calls to <code>finalize_class</code> must occur <em>after</em> the call. I know this seems like a rather arbitrary rule, but it is important. Calls to <code>def</code> in the wrong place will simply be ignored, and calls to <code>finalize_class</code> in the wrong place will throw an assert. (And this assert will cause the Python interpreter to crash. So be warned.)</p> 
  • trunk/html_doc/celerid.html

    r48 r49  
    1818<a class="nav" href="class_wrapping.html">Class wrapping</a><br /> 
    1919<a class="nav" href="except_wrapping.html">Exception wrapping</a><br /> 
    20 <a class="nav" href="dpyobject.html">DPyObject</a><br /> 
     20<a class="nav" href="pydobject.html">PydObject</a><br /> 
    2121<a class="nav" href="credits.html">Credits</a> 
    2222</div> 
  • trunk/html_doc/class_wrapping.html

    r45 r49  
    1818<a class="navcur" href="class_wrapping.html">Class wrapping</a><br /> 
    1919<a class="nav" href="except_wrapping.html">Exception wrapping</a><br /> 
    20 <a class="nav" href="dpyobject.html">DPyObject</a><br /> 
     20<a class="nav" href="pydobject.html">PydObject</a><br /> 
    2121<a class="nav" href="credits.html">Credits</a> 
    2222</div> 
  • trunk/html_doc/conversion.html

    r45 r49  
    1818<a class="nav" href="class_wrapping.html">Class wrapping</a><br /> 
    1919<a class="nav" href="except_wrapping.html">Exception wrapping</a><br /> 
    20 <a class="nav" href="dpyobject.html">DPyObject</a><br /> 
     20<a class="nav" href="pydobject.html">PydObject</a><br /> 
    2121<a class="nav" href="credits.html">Credits</a> 
    2222</div> 
     
    4545<tr><td>delegate or function pointer</td>       <td>A callable object</td></tr> 
    4646<tr><td><a href="class_wrapping.html">A wrapped class</a></td> <td>The wrapped type</td></tr> 
    47 <tr><td><a href="dpyobject.html">DPyObject</a></td> <td>The wrapped object's type</td></tr> 
     47<tr><td><a href="pydobject.html">PydObject</a></td> <td>The wrapped object's type</td></tr> 
    4848<tr><td>PyObject*</td>                          <td>The object's type</td></tr> 
    4949</table> 
     
    5151This function will set a Python <code>RuntimeError</code> and return <code>null</code> if the conversion is not possible.</dd> 
    5252 
    53 <dt><code>DPyObject py(<span class="t_arg">T</span>) (<span class="t_arg">T</span> <span class="arg">t</span>);</code></dt> 
    54 <dd>Converts D item <span class="arg">t</span> of type <span class="t_arg">T</span> to a PyObject with the <code>_py</code> function (above), and returns a <a href="dpyobject.html">DPyObject</a> wrapping that PyObject. This will <a href="except_wrapping.html">throw a wrapped Python <code>RuntimeError</code></a> if the conversion is not possible.</dd> 
     53<dt><code>PydObject py(<span class="t_arg">T</span>) (<span class="t_arg">T</span> <span class="arg">t</span>);</code></dt> 
     54<dd>Converts D item <span class="arg">t</span> of type <span class="t_arg">T</span> to a PyObject with the <code>_py</code> function (above), and returns a <a href="pydobject.html">PydObject</a> wrapping that PyObject. This will <a href="except_wrapping.html">throw a wrapped Python <code>RuntimeError</code></a> if the conversion is not possible.</dd> 
    5555 
    5656<dt><code><span class="t_arg">T</span> d_type(<span class="t_arg">T</span>) (PyObject* <span class="arg">o</span>);</dt> 
     
    6060<tr><th>Python type</th>    <th>D type</th>                             </tr> 
    6161<tr><td>Any type</td>       <td>PyObject*</td>                          </tr> 
    62 <tr><td>Any type</td>       <td><a href="dpyobject.html">DPyObject</a></td></tr> 
     62<tr><td>Any type</td>       <td><a href="pydobject.html">PydObject</a></td></tr> 
    6363<tr><td><a href="class_wrapping.html">Wrapped class</a></td> <td>Wrapped class</td></tr> 
    6464<tr><td>Any callable</td>   <td>delegate</td>                           </tr> 
     
    7171</table> 
    7272 
    73 This function will throw a <code>DPyConversionException</code> if the conversion is not possible.</dd> 
     73This function will throw a <code>PydConversionException</code> if the conversion is not possible.</dd> 
    7474</dl> 
    7575</div> 
  • trunk/html_doc/credits.html

    r45 r49  
    1818<a class="nav" href="class_wrapping.html">Class wrapping</a><br /> 
    1919<a class="nav" href="except_wrapping.html">Exception wrapping</a><br /> 
    20 <a class="nav" href="dpyobject.html">DPyObject</a><br /> 
     20<a class="nav" href="pydobject.html">PydObject</a><br /> 
    2121<a class="navcur" href="credits.html">Credits</a> 
    2222</div> 
  • trunk/html_doc/except_wrapping.html

    r46 r49  
    1818<a class="nav" href="class_wrapping.html">Class wrapping</a><br /> 
    1919<a class="navcur" href="except_wrapping.html">Exception wrapping</a><br /> 
    20 <a class="nav" href="dpyobject.html">DPyObject</a><br /> 
     20<a class="nav" href="pydobject.html">PydObject</a><br /> 
    2121<a class="nav" href="credits.html">Credits</a> 
    2222</div> 
     
    3030<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> 
    3131 
    32 <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> 
     32<p>The <a href="pydobject.html">PydObject</a> class wraps a portion of the Python/C API. Whenever a Python exception is raised by a method of PydObject, 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> 
    3333 
    3434<p>Pyd provides the following exception-related functions:</p> 
  • trunk/html_doc/func_wrapping.html

    r45 r49  
    1818<a class="nav" href="class_wrapping.html">Class wrapping</a><br /> 
    1919<a class="nav" href="except_wrapping.html">Exception wrapping</a><br /> 
    20 <a class="nav" href="dpyobject.html">DPyObject</a><br /> 
     20<a class="nav" href="pydobject.html">PydObject</a><br /> 
    2121<a class="nav" href="credits.html">Credits</a> 
    2222</div> 
  • trunk/html_doc/index.html

    r45 r49  
    1818<a class="nav" href="class_wrapping.html">Class wrapping</a><br /> 
    1919<a class="nav" href="except_wrapping.html">Exception wrapping</a><br /> 
    20 <a class="nav" href="dpyobject.html">DPyObject</a><br /> 
     20<a class="nav" href="pydobject.html">PydObject</a><br /> 
    2121<a class="nav" href="credits.html">Credits</a> 
    2222</div> 
  • trunk/html_doc/install.html

    r45 r49  
    1818<a class="nav" href="class_wrapping.html">Class wrapping</a><br /> 
    1919<a class="nav" href="except_wrapping.html">Exception wrapping</a><br /> 
    20 <a class="nav" href="dpyobject.html">DPyObject</a><br /> 
     20<a class="nav" href="pydobject.html">PydObject</a><br /> 
    2121<a class="nav" href="credits.html">Credits</a> 
    2222</div> 
  • trunk/html_doc/pydobject.html

    r45 r49  
    44    <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> 
    55    <link href="pyd.css" rel="stylesheet" type="text/css"> 
    6     <title>pyd.dpyobject</title> 
     6    <title>pyd.pydobject</title> 
    77</head> 
    88 
     
    1818<a class="nav" href="class_wrapping.html">Class wrapping</a><br /> 
    1919<a class="nav" href="except_wrapping.html">Exception wrapping</a><br /> 
    20 <a class="navcur" href="dpyobject.html">DPyObject</a><br /> 
     20<a class="navcur" href="pydobject.html">PydObject</a><br /> 
    2121<a class="nav" href="credits.html">Credits</a> 
    2222</div> 
     
    2424<div id="content"> 
    2525 
    26 <h1>pyd.dpyobject</h1> 
    27 <!-- Generated by Ddoc from pyd\dpyobject.d --> 
    28 <p>The DPyObject class wraps a PyObject*, using the D garbage collector to handle the reference count so that you don't have to. It also overloads quite a lot of operators, and tries to make using Python objects in D code as much like using them in Python as possible. However, it is incomplete (the function and method call methods in particular need work, and there are a number of helper functions that need to be written), and remains a work in progress.</p> 
    29  
    30 <dl><dt><big>class <u>DPyObject</u>; 
     26<h1>pyd.pydobject</h1> 
     27<!-- Generated by Ddoc from pyd\pydobject.d --> 
     28<p>The PydObject class wraps a PyObject*, using the D garbage collector to handle the reference count so that you don't have to. It also overloads quite a lot of operators, and tries to make using Python objects in D code as much like using them in Python as possible. However, it is incomplete (the function and method call methods in particular need work, and there are a number of helper functions that need to be written), and remains a work in progress.</p> 
     29 
     30<dl><dt><big>class <u>PydObject</u>; 
    3131</big></dt> 
    3232<dd>Wrapper class for a Python/C API PyObject. 
     
    5252<tr><td>PyObject * <i>o</i></td>  <td>The PyObject to wrap.</td></tr> 
    5353<tr><td>bool <i>borrowed</i></td> <td>Whether <i>o</i> is a borrowed reference. Instances 
    54                  of DPyObject always own their references. 
     54                 of PydObject always own their references. 
    5555                 Therefore, Py_INCREF will be called if <i>borrowed</i> is 
    5656                 true.</td></tr> 
     
    5858 
    5959<dt><big>this();</big></dt> 
    60 <dd>The default constructor constructs an instance of the Py_None DPyObject.<br /><br /></dd> 
     60<dd>The default constructor constructs an instance of the Py_None PydObject.<br /><br /></dd> 
    6161 
    6262<dt><big>PyObject * <u>ptr</u>();</big></dt> 
     
    6666<dd>Same as hasattr(this, <i>attr_name</i>) in Python.<br><br></dd> 
    6767 
    68 <dt><big>bool <u>hasattr</u>(DPyObject <i>attr_name</i>); 
     68<dt><big>bool <u>hasattr</u>(PydObject <i>attr_name</i>); 
    6969</big></dt> 
    7070<dd>Same as hasattr(this, <i>attr_name</i>) in Python. 
     
    7272 
    7373</dd> 
    74 <dt><big>DPyObject <u>getattr</u>(char[] <i>attr_name</i>); 
     74<dt><big>PydObject <u>getattr</u>(char[] <i>attr_name</i>); 
    7575</big></dt> 
    7676<dd>Same as getattr(this, <i>attr_name</i>) in Python. 
     
    7878 
    7979</dd> 
    80 <dt><big>DPyObject <u>getattr</u>(DPyObject <i>attr_name</i>); 
     80<dt><big>PydObject <u>getattr</u>(PydObject <i>attr_name</i>); 
    8181</big></dt> 
    8282<dd>Same as getattr(this, <i>attr_name</i>) in Python. 
     
    8484 
    8585</dd> 
    86 <dt><big>void <u>setattr</u>(char[] <i>attr_name</i>, DPyObject <i>v</i>); 
     86<dt><big>void <u>setattr</u>(char[] <i>attr_name</i>, PydObject <i>v</i>); 
    8787</big></dt> 
    8888<dd>Same as setattr(this, <i>attr_name</i>, <i>v</i>) in Python. 
     
    9191 
    9292</dd> 
    93 <dt><big>void <u>setattr</u>(DPyObject <i>attr_name</i>, DPyObject <i>v</i>); 
     93<dt><big>void <u>setattr</u>(PydObject <i>attr_name</i>, PydObject <i>v</i>); 
    9494</big></dt> 
    9595<dd>Same as setattr(this, <i>attr_name</i>, <i>v</i>) in Python. 
     
    105105 
    106106</dd> 
    107 <dt><big>void <u>delattr</u>(DPyObject <i>attr_name</i>); 
     107<dt><big>void <u>delattr</u>(PydObject <i>attr_name</i>); 
    108108</big></dt> 
    109109<dd>Same as del this.<i>attr_name</i> in Python. 
     
    112112 
    113113</dd> 
    114 <dt><big>int <u>opCmp</u>(DPyObject <i>rhs</i>); 
     114<dt><big>int <u>opCmp</u>(PydObject <i>rhs</i>); 
    115115</big></dt> 
    116116<dd>Exposes Python object comparison to D. Same as cmp(this, <i>rhs</i>) in Python. 
     
    119119 
    120120</dd> 
    121 <dt><big>bool <u>opEquals</u>(DPyObject <i>rhs</i>); 
     121<dt><big>bool <u>opEquals</u>(PydObject <i>rhs</i>); 
    122122</big></dt> 
    123123<dd>Exposes Python object equality check to D. 
     
    126126 
    127127</dd> 
    128 <dt><big>DPyObject <u>repr</u>(); 
     128<dt><big>PydObject <u>repr</u>(); 
    129129</big></dt> 
    130130<dd>Same as repr(this) in Python. 
     
    132132 
    133133</dd> 
    134 <dt><big>DPyObject <u>str</u>(); 
     134<dt><big>PydObject <u>str</u>(); 
    135135</big></dt> 
    136136<dd>Same as str(this) in Python. 
     
    140140<dt><big>char[] <u>toString</u>(); 
    141141</big></dt> 
    142 <dd>Allows use of DPyObject in writef via %s 
    143 <br><br> 
    144  
    145 </dd> 
    146 <dt><big>DPyObject <u>unicode</u>(); 
     142<dd>Allows use of PydObject in writef via %s 
     143<br><br> 
     144 
     145</dd> 
     146<dt><big>PydObject <u>unicode</u>(); 
    147147</big></dt> 
    148148<dd>Same as unicode(this) in Python. 
     
    150150 
    151151</dd> 
    152 <dt><big>bool <u>isInstance</u>(DPyObject <i>cls</i>); 
     152<dt><big>bool <u>isInstance</u>(PydObject <i>cls</i>); 
    153153</big></dt> 
    154154<dd>Same as isinstance(this, <i>cls</i>) in Python. 
     
    156156 
    157157</dd> 
    158 <dt><big>bool <u>isSubclass</u>(DPyObject <i>cls</i>); 
     158<dt><big>bool <u>isSubclass</u>(PydObject <i>cls</i>); 
    159159</big></dt> 
    160160<dd>Same as issubclass(this, <i>cls</i>) in Python. Only works if this is a class. 
     
    168168 
    169169</dd> 
    170 <dt><big>DPyObject <u>opCall</u>(DPyObject <i>args</i> = null); 
    171 </big></dt> 
    172 <dd>Calls the DPyObject. <strong>(Note: The opCall functions will be changing in the future to something more useful.)</strong> 
     170<dt><big>PydObject <u>opCall</u>(PydObject <i>args</i> = null); 
     171</big></dt> 
     172<dd>Calls the PydObject. <strong>(Note: The opCall functions will be changing in the future to something more useful.)</strong> 
    173173<br><br> 
    174174<b>Params:</b><br> 
    175 <table><tr><td>DPyObject <i>args</i></td> 
    176 <td>Should be a DPyTuple of the arguments to pass. Omit to 
     175<table><tr><td>PydObject <i>args</i></td> 
     176<td>Should be a PydTuple of the arguments to pass. Omit to 
    177177             call with no arguments.</td></tr> 
    178178</table><br> 
    179179<b>Returns:</b><br> 
    180 Whatever the function DPyObject returns. 
    181       
    182 <br><br> 
    183  
    184 </dd> 
    185 <dt><big>DPyObject <u>opCall</u>(DPyObject <i>args</i>, DPyObject <i>kw</i>); 
    186 </big></dt> 
    187 <dd>Calls the DPyObject with positional and keyword arguments. 
     180Whatever the function PydObject returns. 
     181      
     182<br><br> 
     183 
     184</dd> 
     185<dt><big>PydObject <u>opCall</u>(PydObject <i>args</i>, PydObject <i>kw</i>); 
     186</big></dt> 
     187<dd>Calls the PydObject with positional and keyword arguments. 
    188188<br><br> 
    189189<b>Params:</b><br> 
    190 <table><tr><td>DPyObject <i>args</i></td> 
    191 <td>Positional arguments. Should be a DPyTuple. Pass an empty 
    192              DPyTuple for no positional arguments.</td></tr> 
    193 <tr><td>DPyObject <i>kw</i></td> 
    194 <td>Keyword arguments. Should be a DPyDict.</td></tr> 
     190<table><tr><td>PydObject <i>args</i></td> 
     191<td>Positional arguments. Should be a PydTuple. Pass an empty 
     192             PydTuple for no positional arguments.</td></tr> 
     193<tr><td>PydObject <i>kw</i></td> 
     194<td>Keyword arguments. Should be a PydDict.</td></tr> 
    195195</table><br> 
    196196<b>Returns:</b><br> 
    197 Whatever the function DPyObject returns. 
    198       
    199 <br><br> 
    200  
    201 </dd> 
    202 <dt><big>DPyObject <u>method</u>(char[] <i>name</i>, DPyObject <i>args</i> = null); 
     197Whatever the function PydObject returns. 
     198      
     199<br><br> 
     200 
     201</dd> 
     202<dt><big>PydObject <u>method</u>(char[] <i>name</i>, PydObject <i>args</i> = null); 
    203203</big></dt> 
    204204<dd><br><br> 
     
    222222 
    223223</dd> 
    224 <dt><big>DPyObject <u>type</u>(); 
    225 </big></dt> 
    226 <dd>Gets the type of this DPyObject. Same as type(this) in Python. 
     224<dt><big>PydObject <u>type</u>(); 
     225</big></dt> 
     226<dd>Gets the type of this PydObject. Same as type(this) in Python. 
    227227<br><br> 
    228228<b>Returns:</b><br> 
    229 The type DPyObject of this DPyObject. 
     229The type PydObject of this PydObject. 
    230230      
    231231<br><br> 
     
    234234<dt><big>int <u>length</u>(); 
    235235</big></dt> 
    236 <dd>The length of this DPyObject. Same as len(this) in Python. 
     236<dd>The length of this PydObject. Same as len(this) in Python. 
    237237      
    238238<br><br> 
     
    245245 
    246246</dd> 
    247 <dt><big>DPyObject <u>dir</u>(); 
     247<dt><big>PydObject <u>dir</u>(); 
    248248</big></dt> 
    249249<dd>Same as dir(this) in Python. 
     
    251251 
    252252</dd> 
    253 <dt><big>DPyObject <u>opIndex</u>(DPyObject <i>key</i>); 
     253<dt><big>PydObject <u>opIndex</u>(PydObject <i>key</i>); 
    254254</big></dt> 
    255255<dd>Equivalent to o[key] in Python. 
     
    257257 
    258258</dd> 
    259 <dt><big>DPyObject <u>opIndex</u>(char[] <i>key</i>); 
     259<dt><big>PydObject <u>opIndex</u>(char[] <i>key</i>); 
    260260</big></dt> 
    261261<dd>Equivalent to o['key'] in Python; usually only makes sense for 
     
    265265 
    266266</dd> 
    267 <dt><big>DPyObject <u>opIndex</u>(int <i>i</i>); 
     267<dt><big>PydObject <u>opIndex</u>(int <i>i</i>); 
    268268</big></dt> 
    269269<dd>Equivalent to o[i] in Python; usually only makes sense for sequences. 
     
    271271 
    272272</dd> 
    273 <dt><big>void <u>opIndexAssign</u>(DPyObject <i>value</i>, DPyObject <i>key</i>); 
     273<dt><big>void <u>opIndexAssign</u>(PydObject <i>value</i>, PydObject <i>key</i>); 
    274274</big></dt> 
    275275<dd>Equivalent to o[key] = value in Python. 
     
    277277 
    278278</dd> 
    279 <dt><big>void <u>opIndexAssign</u>(DPyObject <i>value</i>, char[] <i>key</i>); 
     279<dt><big>void <u>opIndexAssign</u>(PydObject <i>value</i>, char[] <i>key</i>); 
    280280</big></dt> 
    281281<dd>Equivalent to o['key'] = value in Python. Usually only makes sense for 
     
    285285 
    286286</dd> 
    287 <dt><big>void <u>opIndexAssign</u>(DPyObject <i>value</i>, int <i>i</i>); 
     287<dt><big>void <u>opIndexAssign</u>(PydObject <i>value</i>, int <i>i</i>); 
    288288</big></dt> 
    289289<dd>Equivalent to o[i] = value in Python. Usually only makes sense for 
     
    293293 
    294294</dd> 
    295 <dt><big>void <u>delItem</u>(DPyObject <i>key</i>); 
     295<dt><big>void <u>delItem</u>(PydObject <i>key</i>); 
    296296</big></dt> 
    297297<dd>Equivalent to del o[key] in Python. 
     
    315315 
    316316</dd> 
    317 <dt><big>DPyObject <u>opSlice</u>(int <i>i1</i>, int <i>i2</i>); 
     317<dt><big>PydObject <u>opSlice</u>(int <i>i1</i>, int <i>i2</i>); 
    318318</big></dt> 
    319319<dd>Equivalent to o[i1:i2] in Python. 
     
    321321 
    322322</dd> 
    323 <dt><big>DPyObject <u>opSlice</u>(); 
     323<dt><big>PydObject <u>opSlice</u>(); 
    324324</big></dt> 
    325325<dd>Equivalent to o[:] in Python. 
     
    327327 
    328328</dd> 
    329 <dt><big>void <u>opSliceAssign</u>(DPyObject <i>v</i>, int <i>i1</i>, int <i>i2</i>); 
     329<dt><big>void <u>opSliceAssign</u>(PydObject <i>v</i>, int <i>i1</i>, int <i>i2</i>); 
    330330</big></dt> 
    331331<dd>Equivalent to o[i1:i2] = v in Python. 
     
    333333 
    334334</dd> 
    335 <dt><big>void <u>opSliceAssign</u>(DPyObject <i>v</i>); 
     335<dt><big>void <u>opSliceAssign</u>(PydObject <i>v</i>); 
    336336</big></dt> 
    337337<dd>Equivalent to o[:] = v in Python. 
     
    351351 
    352352</dd> 
    353 <dt><big>int <u>opApply</u>(int delegate(inout DPyObject) <i>dg</i>); 
     353<dt><big>int <u>opApply</u>(int delegate(inout PydObject) <i>dg</i>); 
    354354</big></dt> 
    355355<dd>Iterates over the items in a collection, be they the items in a 
    356356 sequence, keys in a dictionary, or some other iteration defined for the 
    357  DPyObject's type. 
    358       
    359 <br><br> 
    360  
    361 </dd> 
    362 <dt><big>int <u>opApply</u>(int delegate(inout DPyObject, inout DPyObject) <i>dg</i>); 
    363 </big></dt> 
    364 <dd>Iterate over (key, value) pairs in a dictionary. If the DPyObject is not 
     357 PydObject's type. 
     358      
     359<br><br> 
     360 
     361</dd> 
     362<dt><big>int <u>opApply</u>(int delegate(inout PydObject, inout PydObject) <i>dg</i>); 
     363</big></dt> 
     364<dd>Iterate over (key, value) pairs in a dictionary. If the PydObject is not 
    365365 a dict, this simply does nothing. (It iterates over no items.) You 
    366366 should not attempt to modify the dictionary while iterating through it, 
     
    371371 
    372372</dd> 
    373 <dt><big>DPyObject <u>opAdd</u>(DPyObject <i>o</i>); 
    374 </big></dt> 
    375 <dd><br><br> 
    376 </dd> 
    377 <dt><big>DPyObject <u>opSub</u>(DPyObject <i>o</i>); 
    378 </big></dt> 
    379 <dd><br><br> 
    380 </dd> 
    381 <dt><big>DPyObject <u>opMul</u>(DPyObject <i>o</i>); 
    382 </big></dt> 
    383 <dd><br><br> 
    384 </dd> 
    385 <dt><big>DPyObject <u>opMul</u>(int <i>count</i>); 
     373<dt><big>PydObject <u>opAdd</u>(PydObject <i>o</i>); 
     374</big></dt> 
     375<dd><br><br> 
     376</dd> 
     377<dt><big>PydObject <u>opSub</u>(PydObject <i>o</i>); 
     378</big></dt> 
     379<dd><br><br> 
     380</dd> 
     381<dt><big>PydObject <u>opMul</u>(PydObject <i>o</i>); 
     382</big></dt> 
     383<dd><br><br> 
     384</dd> 
     385<dt><big>PydObject <u>opMul</u>(int <i>count</i>); 
    386386</big></dt> 
    387387<dd>Sequence repetition 
     
    389389 
    390390</dd> 
    391 <dt><big>DPyObject <u>opDiv</u>(DPyObject <i>o</i>); 
    392 </big></dt> 
    393 <dd><br><br> 
    394 </dd> 
    395 <dt><big>DPyObject <u>floorDiv</u>(DPyObject <i>o</i>); 
    396 </big></dt> 
    397 <dd><br><br> 
    398 </dd> 
    399 <dt><big>DPyObject <u>opMod</u>(DPyObject <i>o</i>); 
    400 </big></dt> 
    401 <dd><br><br> 
    402 </dd> 
    403 <dt><big>DPyObject <u>divmod</u>(DPyObject <i>o</i>); 
    404 </big></dt> 
    405 <dd><br><br> 
    406 </dd> 
    407 <dt><big>DPyObject <u>pow</u>(DPyObject <i>o1</i>, DPyObject <i>o2</i> = null); 
    408 </big></dt> 
    409 <dd><br><br> 
    410 </dd> 
    411 <dt><big>DPyObject <u>opPos</u>(); 
    412 </big></dt> 
    413 <dd><br><br> 
    414 </dd> 
    415 <dt><big>DPyObject <u>opNeg</u>(); 
    416 </big></dt> 
    417 <dd><br><br> 
    418 </dd> 
    419 <dt><big>DPyObject <u>abs</u>(); 
    420 </big></dt> 
    421 <dd><br><br> 
    422 </dd> 
    423 <dt><big>DPyObject <u>opCom</u>(); 
    424 </big></dt> 
    425 <dd><br><br> 
    426 </dd> 
    427 <dt><big>DPyObject <u>opShl</u>(DPyObject <i>o</i>); 
    428 </big></dt> 
    429 <dd><br><br> 
    430 </dd> 
    431 <dt><big>DPyObject <u>opShr</u>(DPyObject <i>o</i>); 
    432 </big></dt> 
    433 <dd><br><br> 
    434 </dd> 
    435 <dt><big>DPyObject <u>opAnd</u>(DPyObject <i>o</i>); 
    436 </big></dt> 
    437 <dd><br><br> 
    438 </dd> 
    439 <dt><big>DPyObject <u>opXor</u>(DPyObject <i>o</i>); 
    440 </big></dt> 
    441 <dd><br><br> 
    442 </dd> 
    443 <dt><big>DPyObject <u>opOr</u>(DPyObject <i>o</i>); 
    444 </big></dt> 
    445 <dd><br><br> 
    446 </dd> 
    447 <dt><big>DPyObject <u>opAddAssign</u>(DPyObject <i>o</i>); 
    448 </big></dt> 
    449 <dd><br><br> 
    450 </dd> 
    451 <dt><big>DPyObject <u>opSubAssign</u>(DPyObject <i>o</i>); 
    452 </big></dt> 
    453 <dd><br><br> 
    454 </dd> 
    455 <dt><big>DPyObject <u>opMulAssign</u>(DPyObject <i>o</i>); 
    456 </big></dt> 
    457 <dd><br><br> 
    458 </dd> 
    459 <dt><big>DPyObject <u>opMulAssign</u>(int <i>count</i>); 
     391<dt><big>PydObject <u>opDiv</u>(PydObject <i>o</i>); 
     392</big></dt> 
     393<dd><br><br> 
     394</dd> 
     395<dt><big>PydObject <u>floorDiv</u>(PydObject <i>o</i>); 
     396</big></dt> 
     397<dd><br><br> 
     398</dd> 
     399<dt><big>PydObject <u>opMod</u>(PydObject <i>o</i>); 
     400</big></dt> 
     401<dd><br><br> 
     402</dd> 
     403<dt><big>PydObject <u>divmod</u>(PydObject <i>o</i>); 
     404</big></dt> 
     405<dd><br><br> 
     406</dd> 
     407<dt><big>PydObject <u>pow</u>(PydObject <i>o1</i>, PydObject <i>o2</i> = null); 
     408</big></dt> 
     409<dd><br><br> 
     410</dd> 
     411<dt><big>PydObject <u>opPos</u>(); 
     412</big></dt> 
     413<dd><br><br> 
     414</dd> 
     415<dt><big>PydObject <u>opNeg</u>(); 
     416</big></dt> 
     417<dd><br><br> 
     418</dd> 
     419<dt><big>PydObject <u>abs</u>(); 
     420</big></dt> 
     421<dd><br><br> 
     422</dd> 
     423<dt><big>PydObject <u>opCom</u>(); 
     424</big></dt> 
     425<dd><br><br> 
     426</dd> 
     427<dt><big>PydObject <u>opShl</u>(PydObject <i>o</i>); 
     428</big></dt> 
     429<dd><br><br> 
     430</dd> 
     431<dt><big>PydObject <u>opShr</u>(PydObject <i>o</i>); 
     432</big></dt> 
     433<dd><br><br> 
     434</dd> 
     435<dt><big>PydObject <u>opAnd</u>(PydObject <i>o</i>); 
     436</big></dt> 
     437<dd><br><br> 
     438</dd> 
     439<dt><big>PydObject <u>opXor</u>(PydObject <i>o</i>); 
     440</big></dt> 
     441<dd><br><br> 
     442</dd> 
     443<dt><big>PydObject <u>opOr</u>(PydObject <i>o</i>); 
     444</big></dt> 
     445<dd><br><br> 
     446</dd> 
     447<dt><big>PydObject <u>opAddAssign</u>(PydObject <i>o</i>); 
     448</big></dt> 
     449<dd><br><br> 
     450</dd> 
     451<dt><big>PydObject <u>opSubAssign</u>(PydObject <i>o</i>); 
     452</big></dt> 
     453<dd><br><br> 
     454</dd> 
     455<dt><big>PydObject <u>opMulAssign</u>(PydObject <i>o</i>); 
     456</big></dt> 
     457<dd><br><br> 
     458</dd> 
     459<dt><big>PydObject <u>opMulAssign</u>(int <i>count</i>); 
    460460</big></dt> 
    461461<dd>In-place sequence repetition 
     
    463463 
    464464</dd> 
    465 <dt><big>DPyObject <u>opDivAssign</u>(DPyObject <i>o</i>); 
    466 </big></dt> 
    467 <dd><br><br> 
    468 </dd> 
    469 <dt><big>DPyObject <u>floorDivAssign</u>(DPyObject <i>o</i>); 
    470 </big></dt> 
    471 <dd><br><br> 
    472 </dd> 
    473 <dt><big>DPyObject <u>opModAssign</u>(DPyObject <i>o</i>); 
    474 </big></dt> 
    475 <dd><br><br> 
    476 </dd> 
    477 <dt><big>DPyObject <u>powAssign</u>(DPyObject <i>o1</i>, DPyObject <i>o2</i> = null); 
    478 </big></dt> 
    479 <dd><br><br> 
    480 </dd> 
    481 <dt><big>DPyObject <u>opShlAssign</u>(DPyObject <i>o</i>); 
    482 </big></dt> 
    483 <dd><br><br> 
    484 </dd> 
    485 <dt><big>DPyObject <u>opShrAssign</u>(DPyObject <i>o</i>); 
    486 </big></dt> 
    487 <dd><br><br> 
    488 </dd> 
    489 <dt><big>DPyObject <u>opAndAssign</u>(DPyObject <i>o</i>); 
    490 </big></dt> 
    491 <dd><br><br> 
    492 </dd> 
    493 <dt><big>DPyObject <u>opXorAssign</u>(DPyObject <i>o</i>); 
    494 </big></dt> 
    495 <dd><br><br> 
    496 </dd> 
    497 <dt><big>DPyObject <u>opOrAssign</u>(DPyObject <i>o</i>); 
    498 </big></dt> 
    499 <dd><br><br> 
    500 </dd> 
    501 <dt><big>DPyObject <u>asInt</u>(); 
    502 </big></dt> 
    503 <dd><br><br> 
    504 </dd> 
    505 <dt><big>DPyObject <u>asLong</u>(); 
    506 </big></dt> 
    507 <dd><br><br> 
    508 </dd> 
    509 <dt><big>DPyObject <u>asFloat</u>(); 
     465<dt><big>PydObject <u>opDivAssign</u>(PydObject <i>o</i>); 
     466</big></dt> 
     467<dd><br><br> 
     468</dd> 
     469<dt><big>PydObject <u>floorDivAssign</u>(PydObject <i>o</i>); 
     470</big></dt> 
     471<dd><br><br> 
     472</dd> 
     473<dt><big>PydObject <u>opModAssign</u>(PydObject <i>o</i>); 
     474</big></dt> 
     475<dd><br><br> 
     476</dd> 
     477<dt><big>PydObject <u>powAssign</u>(PydObject <i>o1</i>, PydObject <i>o2</i> = null); 
     478</big></dt> 
     479<dd><br><br> 
     480</dd> 
     481<dt><big>PydObject <u>opShlAssign</u>(PydObject <i>o</i>); 
     482</big></dt> 
     483<dd><br><br> 
     484</dd> 
     485<dt><big>PydObject <u>opShrAssign</u>(PydObject <i>o</i>); 
     486</big></dt> 
     487<dd><br><br> 
     488</dd> 
     489<dt><big>PydObject <u>opAndAssign</u>(PydObject <i>o</i>); 
     490</big></dt> 
     491<dd><br><br> 
     492</dd> 
     493<dt><big>PydObject <u>opXorAssign</u>(PydObject <i>o</i>); 
     494</big></dt> 
     495<dd><br><br> 
     496</dd> 
     497<dt><big>PydObject <u>opOrAssign</u>(PydObject <i>o</i>); 
     498</big></dt> 
     499<dd><br><br> 
     500</dd> 
     501<dt><big>PydObject <u>asInt</u>(); 
     502</big></dt> 
     503<dd><br><br> 
     504</dd> 
     505<dt><big>PydObject <u>asLong</u>(); 
     506</big></dt> 
     507<dd><br><br> 
     508</dd> 
     509<dt><big>PydObject <u>asFloat</u>(); 
    510510</big></dt> 
    511511<dd><br><br> 
     
    527527<dd><br><br> 
    528528</dd> 
    529 <dt><big>DPyObject <u>opCat</u>(DPyObject <i>o</i>); 
     529<dt><big>PydObject <u>opCat</u>(PydObject <i>o</i>); 
    530530</big></dt> 
    531531<dd>Sequence concatenation 
     
    533533 
    534534</dd> 
    535 <dt><big>DPyObject <u>opCatAssign</u>(DPyObject <i>o</i>); 
     535<dt><big>PydObject <u>opCatAssign</u>(PydObject <i>o</i>); 
    536536</big></dt> 
    537537<dd>In-place sequence concatenation 
     
    539539 
    540540</dd> 
    541 <dt><big>int <u>count</u>(DPyObject <i>v</i>); 
    542 </big></dt> 
    543 <dd><br><br> 
    544 </dd> 
    545 <dt><big>int <u>index</u>(DPyObject <i>v</i>); 
    546 </big></dt> 
    547 <dd><br><br> 
    548 </dd> 
    549 <dt><big>DPyObject <u>asList</u>(); 
    550 </big></dt> 
    551 <dd>Converts any iterable DPyObject to a list 
    552 <br><br> 
    553  
    554 </dd> 
    555 <dt><big>DPyObject <u>asTuple</u>(); 
    556 </big></dt> 
    557 <dd>Converts any iterable DPyObject to a tuple 
    558 <br><br> 
    559  
    560 </dd> 
    561 <dt><big>bool <u>opIn_r</u>(DPyObject <i>v</i>); 
     541<dt><big>int <u>count</u>(PydObject <i>v</i>); 
     542</big></dt> 
     543<dd><br><br> 
     544</dd> 
     545<dt><big>int <u>index</u>(PydObject <i>v</i>); 
     546</big></dt> 
     547<dd><br><br> 
     548</dd> 
     549<dt><big>PydObject <u>asList</u>(); 
     550</big></dt> 
     551<dd>Converts any iterable PydObject to a list 
     552<br><br> 
     553 
     554</dd> 
     555<dt><big>PydObject <u>asTuple</u>(); 
     556</big></dt> 
     557<dd>Converts any iterable PydObject to a tuple 
     558<br><br> 
     559 
     560</dd> 
     561<dt><big>bool <u>opIn_r</u>(PydObject <i>v</i>); 
    562562</big></dt> 
    563563<dd>Same as "<i>v</i> in this" in Python. 
     
    565565 
    566566</dd> 
    567 <dt><big>bool <u>hasKey</u>(DPyObject <i>key</i>); 
     567<dt><big>bool <u>hasKey</u>(PydObject <i>key</i>); 
    568568</big></dt> 
    569569<dd>Same as opIn_r 
     
    583583 
    584584</dd> 
    585 <dt><big>DPyObject <u>keys</u>(); 
    586 </big></dt> 
    587 <dd><br><br> 
    588 </dd> 
    589 <dt><big>DPyObject <u>values</u>(); 
    590 </big></dt> 
    591 <dd><br><br> 
    592 </dd> 
    593 <dt><big>DPyObject <u>items</u>(); 
     585<dt><big>PydObject <u>keys</u>(); 
     586</big></dt> 
     587<dd><br><br> 
     588</dd> 
     589<dt><big>PydObject <u>values</u>(); 
     590</big></dt> 
     591<dd><br><br> 
     592</dd> 
     593<dt><big>PydObject <u>items</u>(); 
    594594</big></dt> 
    595595<dd><br><br> 
  • trunk/infrastructure/pyd/class_wrap.d

    r48 r49  
    4545 
    4646// This is split out in case I ever want to make a subtype of a wrapped class. 
    47 template DPyObject_HEAD(T) { 
     47template PydWrapObject_HEAD(T) { 
    4848    mixin PyObject_HEAD; 
    4949    T d_obj; 
     
    5454    extern(C) 
    5555    struct wrapped_class_object { 
    56         mixin DPyObject_HEAD!(T); 
     56        mixin PydWrapObject_HEAD!(T); 
    5757    } 
    5858} 
     
    333333         */ 
    334334        static void iter(iter_t) () { 
    335             DPySC_Ready(); 
     335            PydStackContext_Ready(); 
    336336            wrapped_class_type!(T).tp_iter = &wrapped_iter!(T, T.opApply, int function(iter_t)).iter; 
    337337        } 
     
    345345            static PyMethodDef empty = { null, null, 0, null }; 
    346346            alias wrapped_method_list!(T) list; 
     347            PydStackContext_Ready(); 
    347348            list[length-1].ml_name = name ~ \0; 
    348349            list[length-1].ml_meth = cast(PyCFunction)&wrapped_iter!(T, fn, int function(iter_t)).iter; 
     
    369370    pragma(msg, "finalize_class: " ~ name); 
    370371     
    371     assert(DPy_Module_p !is null, "Must initialize module before wrapping classes."); 
    372     char[] module_name = toString(PyModule_GetName(DPy_Module_p)); 
     372    assert(Pyd_Module_p !is null, "Must initialize module before wrapping classes."); 
     373    char[] module_name = toString(PyModule_GetName(Pyd_Module_p)); 
    373374    // Fill in missing values 
    374375    type.ob_type      = PyType_Type_p(); 
     
    401402        static if (is(typeof(&T.opApply))) { 
    402403            if (type.tp_iter is null) { 
    403                 DPySC_Ready(); 
     404                PydStackContext_Ready(); 
    404405                type.tp_iter = &wrapped_iter!(T, T.opApply).iter; 
    405406            } 
     
    425426    } 
    426427    Py_INCREF(cast(PyObject*)&type); 
    427     PyModule_AddObject(DPy_Module_p, name, cast(PyObject*)&type); 
     428    PyModule_AddObject(Pyd_Module_p, name, cast(PyObject*)&type); 
    428429    is_wrapped!(T) = true; 
    429430    wrapped_classes[typeid(T)] = true; 
  • trunk/infrastructure/pyd/def.d

    r45 r49  
    3737PyObject* m_module; 
    3838 
    39 PyObject* DPy_Module_p() { 
     39PyObject* Pyd_Module_p() { 
    4040    return m_module; 
    4141} 
  • trunk/infrastructure/pyd/func_wrap.d

    r45 r49  
    3838 
    3939// Builds a Python callable object from a delegate or function pointer. 
    40 PyObject* DPyFunc_FromDG(T) (T dg) { 
     40PyObject* PydFunc_FromDelegate(T) (T dg) { 
    4141    alias wrapped_class_type!(T) type; 
    4242    alias wrapped_class_object!(T) obj; 
     
    4646        type.tp_dealloc   = &wrapped_methods!(T).wrapped_dealloc; 
    4747        type.tp_basicsize = obj.sizeof; 
    48         type.tp_name = "DPyFunc"; 
     48        type.tp_name = "PydFunc"; 
    4949        type.tp_call = &wrapped_func_call!(T).call; 
    5050        PyType_Ready(&type); 
     
    124124template wrapped_func_call(fn_t) { 
    125125    alias ReturnType!(fn_t) RT; 
    126     // The entry for the tp_call slot of the DPyFunc types. 
     126    // The entry for the tp_call slot of the PydFunc types. 
    127127    // (Or: What gets called when you pass a delegate or function pointer to 
    128128    // Python.) 
     
    232232//----------------------------------------------------------------------------- 
    233233// The steps involved when calling this function are as follows: 
    234 // 1) An instance of DPyWrappedFunc is made, and the callable placed within. 
     234// 1) An instance of PydWrappedFunc is made, and the callable placed within. 
    235235// 2) The delegate type Dg is broken into its constituent parts. 
    236 // 3) These parts are used to get the proper overload of DPyWrappedFunc.fn 
    237 // 4) A delegate to DPyWrappedFunc.fn is returned. 
     236// 3) These parts are used to get the proper overload of PydWrappedFunc.fn 
     237// 4) A delegate to PydWrappedFunc.fn is returned. 
    238238// 5) When fn is called, it attempts to cram the arguments into the callable. 
    239239//    If Python objects to this, an exception is raised. Note that this means 
     
    241241//    detected at runtime. 
    242242 
    243 Dg DPyCallable_AsDelegate(Dg) (PyObject* c) { 
     243Dg PydCallable_AsDelegate(Dg) (PyObject* c) { 
    244244    return _pycallable_asdgT!(Dg).func(c); 
    245245} 
     
    250250 
    251251    Dg func(PyObject* c) { 
    252         auto f = new DPyWrappedFunc(c); 
     252        auto f = new PydWrappedFunc(c); 
    253253 
    254254        return &f.fn!(Tr, Info); 
     
    257257 
    258258private 
    259 class DPyWrappedFunc { 
     259class PydWrappedFunc { 
    260260    PyObject* callable; 
    261261 
  • trunk/infrastructure/pyd/iteration.d

    r45 r49  
    4141 
    4242// This exception is for yielding a PyObject* from within a StackContext. 
    43 class DPyYield : Exception { 
     43class PydYield : Exception { 
    4444    PyObject* m_py; 
    4545    this(PyObject* py) { 
     
    5151 
    5252// Creates an iterator object from an object. 
    53 PyObject* DPySC_FromWrapped(T, alias Iter = T.opApply, iter_t = typeof(&Iter)) (T obj) { 
     53PyObject* PydStackContext_FromWrapped(T, alias Iter = T.opApply, iter_t = typeof(&Iter)) (T obj) { 
    5454    // Get the number of args the opApply's delegate argument takes 
    5555    alias ParameterTypeTuple!(iter_t) IInfo; 
     
    6565 
    6666        t(delegate int(inout Info i) { 
    67             StackContext.throwYield(new DPyYield(PyTuple_FromItems(i))); 
     67            StackContext.throwYield(new PydYield(PyTuple_FromItems(i))); 
    6868            return 0; 
    6969        }); 
     
    7979    // Returns an iterator object for this class 
    8080    extern (C) 
    81     PyObject* iter (PyObject* _self) { 
     81    PyObject* iter(PyObject* _self) { 
    8282        return exception_catcher({ 
    8383            wrap_object* self = cast(wrap_object*)_self; 
    8484 
    85             return DPySC_FromWrapped!(T, Iter, iter_t)(self.d_obj); 
     85            return PydStackContext_FromWrapped!(T, Iter, iter_t)(self.d_obj); 
    8686        }); 
    8787    } 
     
    9292PyObject* sc_iternext(PyObject* _self) { 
    9393    return exception_catcher(delegate PyObject*() { 
    94         alias wrapped_class_object!(StackContext) DPySC_object; 
    95         DPySC_object* self = cast(DPySC_object*)_self; 
     94        alias wrapped_class_object!(StackContext) PydSC_object; 
     95        PydSC_object* self = cast(PydSC_object*)_self; 
    9696 
    9797        try { 
     
    104104        // The StackContext class yields values by throwing an exception. 
    105105        // We catch it and pass the converted value into Python. 
    106         catch (DPyYield y) { 
     106        catch (PydYield y) { 
    107107            return y.item(); 
    108108        } 
     
    112112 
    113113/// Readies the iterator class if it hasn't been already. 
    114 void DPySC_Ready() { 
     114void PydStackContext_Ready() { 
    115115    alias wrapped_class_type!(StackContext) type; 
    116     alias wrapped_class_object!(StackContext) DPySC_object; 
     116    alias wrapped_class_object!(StackContext) PydSC_object; 
    117117     
    118118    if (!is_wrapped!(StackContext)) { 
     
    120120        //type.tp_new       = &wrapped_methods!(StackContext).wrapped_new; 
    121121        //type.tp_dealloc   = &wrapped_methods!(StackContext).wrapped_dealloc; 
    122         type.tp_basicsize = DPySC_object.sizeof; 
     122        type.tp_basicsize = PydSC_object.sizeof; 
    123123        type.tp_flags     = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE; 
    124124        //type.tp_doc = ""; 
  • trunk/infrastructure/pyd/make_object.d

    r45 r49  
    3131 * The former is handled by d_type, the latter by _py. The py function is 
    3232 * provided as a convenience to directly convert a D type into an instance of 
    33  * DPyObject. 
     33 * PydObject. 
    3434 */ 
    3535module pyd.make_object; 
     
    3939private import std.string; 
    4040 
    41 private import pyd.dpyobject; 
     41private import pyd.pydobject; 
    4242private import pyd.class_wrap; 
    4343private import pyd.func_wrap; 
     
    6767 * argument. If the passed argument is a PyObject*, this "steals" the 
    6868 * reference. (In other words, it returns the PyObject* without changing its 
    69  * reference count.) If the passed argument is a DPyObject, this returns a new 
    70  * reference to whatever the DPyObject holds a reference to. 
     69 * reference count.) If the passed argument is a PydObject, this returns a new 
     70 * reference to whatever the PydObject holds a reference to. 
    7171 * 
    7272 * If the passed argument can't be converted to a PyObject, a Python 
     
    132132        return dict; 
    133133    } else static if (is(T == delegate) || is(T == function)) { 
    134         return DPyFunc_FromDG!(T)(t); 
    135     } else static if (is(T : DPyObject)) { 
     134        return PydFunc_FromDelegate!(T)(t); 
     135    } else static if (is(T : PydObject)) { 
    136136        PyObject* temp = t.ptr(); 
    137137        Py_INCREF(temp); 
     
    174174 * Constructs an object based on the type of the argument passed in. 
    175175 * 
    176  * For example, calling py(10) would return a DPyObject holding the value 10. 
    177  * 
    178  * Calling this with a DPyObject will return back a reference to the very same 
    179  * DPyObject. 
     176 * For example, calling py(10) would return a PydObject holding the value 10. 
     177 * 
     178 * Calling this with a PydObject will return back a reference to the very same 
     179 * PydObject. 
    180180 * 
    181181 * Calling this with a PyObject* will "steal" the reference. 
    182182 */ 
    183 DPyObject py(T) (T t) { 
    184     static if(is(T : DPyObject)) { 
     183PydObject py(T) (T t) { 
     184    static if(is(T : PydObject)) { 
    185185        return t; 
    186186    } else { 
    187         return new DPyObject(_py(t)); 
     187        return new PydObject(_py(t)); 
    188188    } 
    189189} 
     
    192192 * An exception class used by d_type. 
    193193 */ 
    194 class DPyConversionException : Exception { 
     194class PydConversionException : Exception { 
    195195    this(char[] msg) { super(msg); } 
    196196} 
     
    204204 *assert(n == 20);) 
    205205 * 
    206  * This throws a DPyConversionException if the PyObject can't be converted to 
     206 * This throws a PydConversionException if the PyObject can't be converted to 
    207207 * the given D type. 
    208208 */ 
     
    214214    // 
    215215    // This also means that: 
    216     //  (1) Conversion to DPyObject will construct an object and return that. 
     216    //  (1) Conversion to PydObject will construct an object and return that. 
    217217    //  (2) Any integral type smaller than a C_long (which is usually just 
    218218    //      an int, meaning short and byte) will use the bool conversion. 
     
    220220    static if (is(PyObject* : T)) { 
    221221        return o; 
    222     } else static if (is(DPyObject : T)) { 
    223         return new DPyObject(o, true); 
     222    } else static if (is(PydObject : T)) { 
     223        return new PydObject(o, true); 
    224224    } else static if (is(T == void)) { 
    225225        if (o != Py_None) could_not_convert!(T)(o); 
     
    236236    } else static if (is(T == delegate)) { 
    237237        if (PyCallable_Check(o)) { 
    238             return DPyCallable_AsDelegate!(T)(o); 
     238            return PydCallable_AsDelegate!(T)(o); 
    239239        } else could_not_convert!(T)(o); 
    240240    /+ 
     
    310310    } 
    311311    d_typename = typeid(T).toString(); 
    312     throw new DPyConversionException( 
     312    throw new PydConversionException( 
    313313        "Couldn't convert Python type '" ~ 
    314314        py_typename ~ 
  • trunk/infrastructure/pyd/pyd.d

    r45 r49  
    3030public import pyd.class_wrap; 
    3131//public import pyd.ctor_wrap; 
    32 public import pyd.dpyobject; 
     32public import pyd.pydobject; 
    3333public import pyd.exception; 
    3434public import pyd.func_wrap; 
  • trunk/infrastructure/pyd/pydobject.d

    r45 r49  
    2020SOFTWARE. 
    2121*/ 
    22 module pyd.dpyobject; 
     22module pyd.pydobject; 
    2323 
    2424private import std.c.stdio; 
     
    3939 *     $(LINK2 http://docs.python.org/api/api.html, The Python/C API) 
    4040 */ 
    41 class DPyObject { 
     41class PydObject { 
    4242protected: 
    4343    PyObject* m_ptr; 
     
    4848     *      o = The PyObject to wrap. 
    4949     *      borrowed = Whether o is a _borrowed reference. Instances 
    50      *                 of DPyObject always own their references. 
     50     *                 of PydObject always own their references. 
    5151     *                 Therefore, Py_INCREF will be called if borrowed is 
    5252     *                 $(D_KEYWORD true). 
     
    5454    this(PyObject* o, bool borrowed=false) { 
    5555        if (o is null) handle_exception(); 
    56         // DPyObject always owns its references 
     56        // PydObject always owns its references 
    5757        if (borrowed) Py_INCREF(o); 
    5858        m_ptr = o; 
    5959    } 
    6060 
    61     /// The default constructor constructs an instance of the Py_None DPyObject. 
     61    /// The default constructor constructs an instance of the Py_None PydObject. 
    6262    this() { this(Py_None, true); } 
    6363 
     
    7777     *      fp = The file object to _print to. std.c.stdio.stdout by default. 
    7878     *      raw = If $(D_KEYWORD true), prints the "str" representation of the 
    79      *            DPyObject, and uses the "repr" otherwise. Defaults to 
     79     *            PydObject, and uses the "repr" otherwise. Defaults to 
    8080     *            $(D_KEYWORD false). 
    8181     * Bugs: This does not seem to work, raising an AccessViolation. Meh. 
     
    9595 
    9696    /// Same as _hasattr(this, attr_name) in Python. 
    97     bool hasattr(DPyObject attr_name) { 
     97    bool hasattr(PydObject attr_name) { 
    9898        return PyObject_HasAttr(m_ptr, attr_name.m_ptr) == 1; 
    9999    } 
    100100 
    101101    /// Same as _getattr(this, attr_name) in Python. 
    102     DPyObject getattr(char[] attr_name) { 
    103         return new DPyObject(PyObject_GetAttrString(m_ptr, attr_name ~ \0)); 
     102    PydObject getattr(char[] attr_name) { 
     103        return new PydObject(PyObject_GetAttrString(m_ptr, attr_name ~ \0)); 
    104104    } 
    105105 
    106106    /// Same as _getattr(this, attr_name) in Python. 
    107     DPyObject getattr(DPyObject attr_name) { 
    108         return new DPyObject(PyObject_GetAttr(m_ptr, attr_name.m_ptr)); 
     107    PydObject getattr(PydObject attr_name) { 
     108        return new PydObject(PyObject_GetAttr(m_ptr, attr_name.m_ptr)); 
    109109    } 
    110110 
     
    112112     * Same as _setattr(this, attr_name, v) in Python. 
    113113     */ 
    114     void setattr(char[] attr_name, DPyObject v) { 
     114    void setattr(char[] attr_name, PydObject v) { 
    115115        if (PyObject_SetAttrString(m_ptr, attr_name ~ \0, v.m_ptr) == -1) 
    116116            handle_exception(); 
     
    120120     * Same as _setattr(this, attr_name, v) in Python. 
    121121     */ 
    122     void setattr(DPyObject attr_name, DPyObject v) { 
     122    void setattr(PydObject attr_name, PydObject v) { 
    123123        if (PyObject_SetAttr(m_ptr, attr_name.m_ptr, v.m_ptr) == -1) 
    124124            handle_exception(); 
     
    136136     * Same as del this.attr_name in Python. 
    137137     */ 
    138     void delattr(DPyObject attr_name) { 
     138    void delattr(PydObject attr_name) { 
    139139        if (PyObject_DelAttr(m_ptr, attr_name.m_ptr) == -1) 
    140140            handle_exception(); 
     
    144144     * Exposes Python object comparison to D. Same as cmp(this, rhs) in Python. 
    145145     */ 
    146     int opCmp(DPyObject rhs) { 
     146    int opCmp(PydObject rhs) { 
    147147        // This function happily maps exactly to opCmp 
    148148        int res = PyObject_Compare(m_ptr, rhs.m_ptr); 
     
    155155     * Exposes Python object equality check to D. 
    156156     */ 
    157     bool opEquals(DPyObject rhs) { 
     157    bool opEquals(PydObject rhs) { 
    158158        int res = PyObject_Compare(m_ptr, rhs.m_ptr); 
    159159        handle_exception(); 
     
    162162     
    163163    /// Same as _repr(this) in Python. 
    164     DPyObject repr() { 
    165         return new DPyObject(PyObject_Repr(m_ptr)); 
     164    PydObject repr() { 
     165        return new PydObject(PyObject_Repr(m_ptr)); 
    166166    } 
    167167 
    168168    /// Same as _str(this) in Python. 
    169     DPyObject str() { 
    170         return new DPyObject(PyObject_Str(m_ptr)); 
    171     } 
    172     /// Allows use of DPyObject in writef via %s 
     169    PydObject str() { 
     170        return new PydObject(PyObject_Str(m_ptr)); 
     171    } 
     172    /// Allows use of PydObject in writef via %s 
    173173    char[] toString() { 
    174174        return d_type!(char[])(m_ptr); 
     
    176176     
    177177    /// Same as _unicode(this) in Python. 
    178     DPyObject unicode() { 
    179         return new DPyObject(PyObject_Unicode(m_ptr)); 
     178    PydObject unicode() { 
     179        return new PydObject(PyObject_Unicode(m_ptr)); 
    180180    } 
    181181 
    182182    /// Same as isinstance(this, cls) in Python. 
    183     bool isInstance(DPyObject cls) { 
     183    bool isInstance(PydObject cls) { 
    184184        int res = PyObject_IsInstance(m_ptr, cls.m_ptr); 
    185185        if (res == -1) handle_exception(); 
     
    188188 
    189189    /// Same as issubclass(this, cls) in Python. Only works if this is a class. 
    190     bool isSubclass(DPyObject cls) { 
     190    bool isSubclass(PydObject cls) { 
    191191        int res = PyObject_IsSubclass(m_ptr, cls.m_ptr); 
    192192        if (res == -1) handle_exception(); 
     
    200200     
    201201    /** 
    202      * Calls the DPyObject. 
     202     * Calls the PydObject. 
    203203     * Params: 
    204      *      args = Should be a DPyTuple of the arguments to pass. Omit to 
     204     *      args = Should be a PydTuple of the arguments to pass. Omit to 
    205205     *             call with no arguments. 
    206      * Returns: Whatever the function DPyObject returns. 
    207      */ 
    208     DPyObject opCall(DPyObject args=null) { 
    209         return new DPyObject(PyObject_CallObject(m_ptr, args is null ? null : args.m_ptr)); 
     206     * Returns: Whatever the function PydObject returns. 
     207     */ 
     208    PydObject opCall(PydObject args=null) { 
     209        return new PydObject(PyObject_CallObject(m_ptr, args is null ? null : args.m_ptr)); 
    210210    } 
    211211     
    212212    /** 
    213      * Calls the DPyObject with positional and keyword arguments. 
     213     * Calls the PydObject with positional and keyword arguments. 
    214214     * Params: 
    215      *      args = Positional arguments. Should be a DPyTuple. Pass an empty 
    216      *             DPyTuple for no positional arguments. 
    217      *      kw = Keyword arguments. Should be a DPyDict. 
    218      * Returns: Whatever the function DPyObject returns. 
    219      */ 
    220     DPyObject opCall(DPyObject args, DPyObject kw) { 
    221         return new DPyObject(PyObject_Call(m_ptr, args.m_ptr, kw.m_ptr)); 
     215     *      args = Positional arguments. Should be a PydTuple. Pass an empty 
     216     *             PydTuple for no positional arguments. 
     217     *      kw = Keyword arguments. Should be a PydDict. 
     218     * Returns: Whatever the function PydObject returns. 
     219     */ 
     220    PydObject opCall(PydObject args, PydObject kw) { 
     221        return new PydObject(PyObject_Call(m_ptr, args.m_ptr, kw.m_ptr)); 
    222222    } 
    223223 
     
    225225     * 
    226226     */ 
    227     DPyObject method(char[] name, DPyObject args=null) { 
    228         // Get the method DPyObject 
     227    PydObject method(char[] name, PydObject args=null) { 
     228        // Get the method PydObject 
    229229        PyObject* m = PyObject_GetAttrString(m_ptr, name ~ \0); 
    230230        PyObject* self_tuple, args_tuple, result; 
     
    249249        Py_DECREF(args_tuple); 
    250250        // Return the result. 
    251         return new DPyObject(result); 
    252     } 
    253  
    254     DPyObject method(char[] name, DPyObject args, DPyObject kw) { 
    255         // Get the method DPyObject 
     251        return new PydObject(result); 
     252    } 
     253 
     254    PydObject method(char[] name, PydObject args, PydObject kw) { 
     255        // Get the method PydObject 
    256256        PyObject* m = PyObject_GetAttrString(m_ptr, name ~ \0); 
    257257        PyObject* self_tuple, args_tuple, result; 
     
    270270        Py_DECREF(args_tuple); 
    271271        // Return the result. 
    272         return new DPyObject(result); 
     272        return new PydObject(result); 
    273273    } 
    274274 
     
    293293 
    294294    /** 
    295      * Gets the _type of this DPyObject. Same as _type(this) in Python. 
    296      * Returns: The _type DPyObject of this DPyObject. 
    297      */ 
    298     DPyObject type() { 
    299         return new DPyObject(PyObject_Type(m_ptr)); 
    300     } 
    301  
    302     /** 
    303      * The _length of this DPyObject. Same as _len(this) in Python. 
     295     * Gets the _type of this PydObject. Same as _type(this) in Python. 
     296     * Returns: The _type PydObject of this PydObject. 
     297     */ 
     298    PydObject type() { 
     299        return new PydObject(PyObject_Type(m_ptr)); 
     300    } 
     301 
     302    /** 
     303     * The _length of this PydObject. Same as _len(this) in Python. 
    304304     */ 
    305305    int length() { 
     
    312312 
    313313    /// Same as _dir(this) in Python. 
    314     DPyObject dir() { 
    315         return new DPyObject(PyObject_Dir(m_ptr)); 
     314    PydObject dir() { 
     315        return new PydObject(PyObject_Dir(m_ptr)); 
    316316    } 
    317317 
     
    320320    //---------- 
    321321    /// Equivalent to o[_key] in Python. 
    322     DPyObject opIndex(DPyObject key) { 
    323         return new DPyObject(PyObject_GetItem(m_ptr, key.m_ptr)); 
     322    PydObject opIndex(PydObject key) { 
     323        return new PydObject(PyObject_GetItem(m_ptr, key.m_ptr)); 
    324324    } 
    325325    /** 
     
    327327     * mappings. 
    328328     */ 
    329     DPyObject opIndex(char[] key) { 
    330         return new DPyObject(PyMapping_GetItemString(m_ptr, key ~ \0)); 
     329    PydObject opIndex(char[] key) { 
     330        return new PydObject(PyMapping_GetItemString(m_ptr, key ~ \0)); 
    331331    } 
    332332    /// Equivalent to o[_i] in Python; usually only makes sense for sequences. 
    333     DPyObject opIndex(int i) { 
    334         return new DPyObject(PySequence_GetItem(m_ptr, i)); 
     333    PydObject opIndex(int i) { 
     334        return new PydObject(PySequence_GetItem(m_ptr, i)); 
    335335    } 
    336336 
    337337    /// Equivalent to o[_key] = _value in Python. 
    338     void opIndexAssign(DPyObject value, DPyObject key) { 
     338    void opIndexAssign(PydObject value, PydObject key) { 
    339339        if (PyObject_SetItem(m_ptr, key.m_ptr, value.m_ptr) == -1) 
    340340            handle_exception(); 
     
    344344     * mappings. 
    345345     */ 
    346     void opIndexAssign(DPyObject value, char[] key) { 
     346    void opIndexAssign(PydObject value, char[] key) { 
    347347        if (PyMapping_SetItemString(m_ptr, key ~ \0, value.m_ptr) == -1) 
    348348            handle_exception(); 
     
    352352     * sequences. 
    353353     */ 
    354     void opIndexAssign(DPyObject value, int i) { 
     354    void opIndexAssign(PydObject value, int i) { 
    355355        if (PySequence_SetItem(m_ptr, i, value.m_ptr) == -1) 
    356356            handle_exception(); 
     
    358358 
    359359    /// Equivalent to del o[_key] in Python. 
    360     void delItem(DPyObject key) { 
     360    void delItem(PydObject key) { 
    361361        if (PyObject_DelItem(m_ptr, key.m_ptr) == -1) 
    362362            handle_exception(); 
     
    383383    //--------- 
    384384    /// Equivalent to o[_i1:_i2] in Python. 
    385     DPyObject opSlice(int i1, int i2) { 
    386         return new DPyObject(PySequence_GetSlice(m_ptr, i1, i2)); 
     385    PydObject opSlice(int i1, int i2) { 
     386        return new PydObject(PySequence_GetSlice(m_ptr, i1, i2)); 
    387387    } 
    388388    /// Equivalent to o[:] in Python. 
    389     DPyObject opSlice() { 
     389    PydObject opSlice() { 
    390390        return this.opSlice(0, this.length()); 
    391391    } 
    392392    /// Equivalent to o[_i1:_i2] = _v in Python. 
    393     void opSliceAssign(DPyObject v, int i1, int i2) { 
     393    void opSliceAssign(PydObject v, int i1, int i2) { 
    394394        if (PySequence_SetSlice(m_ptr, i1, i1, v.m_ptr) == -1) 
    395395            handle_exception(); 
    396396    } 
    397397    /// Equivalent to o[:] = _v in Python. 
    398     void opSliceAssign(DPyObject v) { 
     398    void opSliceAssign(PydObject v) { 
    399399        this.opSliceAssign(v, 0, this.length()); 
    400400    } 
     
    416416     * Iterates over the items in a collection, be they the items in a 
    417417     * sequence, keys in a dictionary, or some other iteration defined for the 
    418      * DPyObject's type. 
    419      */ 
    420     int opApply(int delegate(inout DPyObject) dg) { 
     418     * PydObject's type. 
     419     */ 
     420    int opApply(int delegate(inout PydObject) dg) { 
    421421        PyObject* iterator = PyObject_GetIter(m_ptr); 
    422422        PyObject* item; 
    423423        int result = 0; 
    424         DPyObject o; 
     424        PydObject o; 
    425425 
    426426        if (iterator == null) { 
     
    430430        item = PyIter_Next(iterator); 
    431431        while (item) { 
    432             o = new DPyObject(item); 
     432            o = new PydObject(item); 
    433433            result = dg(o); 
    434434            Py_DECREF(item); 
     
    445445 
    446446    /** 
    447      * Iterate over (key, value) pairs in a dictionary. If the DPyObject is not 
     447     * Iterate over (key, value) pairs in a dictionary. If the PydObject is not 
    448448     * a dict, this simply does nothing. (It iterates over no items.) You 
    449449     * should not attempt to modify the dictionary while iterating through it, 
     
    451451     * iterating through it is an especially bad idea. 
    452452     */ 
    453     int opApply(int delegate(inout DPyObject, inout DPyObject) dg) { 
     453    int opApply(int delegate(inout PydObject, inout PydObject) dg) { 
    454454        PyObject* key, value; 
    455455        version(Python_2_5_Or_Later) { 
     
    459459        } 
    460460        int result = 0; 
    461         DPyObject k, v; 
     461        PydObject k, v; 
    462462 
    463463        while (PyDict_Next(m_ptr, &pos, &key, &value)) { 
    464             k = new DPyObject(key, true); 
    465             v = new DPyObject(value, true); 
     464            k = new PydObject(key, true); 
     465            v = new PydObject(value, true); 
    466466            result = dg(k, v); 
    467467            if (result) break; 
     
    475475    //------------ 
    476476    /// 
    477     DPyObject opAdd(DPyObject o) { 
    478         return new DPyObject(PyNumber_Add(m_ptr, o.m_ptr)); 
    479     } 
    480     /// 
    481     DPyObject opSub(DPyObject o) { 
    482         return new DPyObject(PyNumber_Subtract(m_ptr, o.m_ptr)); 
    483     } 
    484     /// 
    485     DPyObject opMul(DPyObject o) { 
    486         return new DPyObject(PyNumber_Multiply(m_ptr, o.m_ptr)); 
     477    PydObject opAdd(PydObject o) { 
     478        return new PydObject(PyNumber_Add(m_ptr, o.m_ptr)); 
     479    } 
     480    /// 
     481    PydObject opSub(PydObject o) { 
     482        return new PydObject(PyNumber_Subtract(m_ptr, o.m_ptr)); 
     483    } 
     484    /// 
     485    PydObject opMul(PydObject o) { 
     486        return new PydObject(PyNumber_Multiply(m_ptr, o.m_ptr)); 
    487487    } 
    488488    /// Sequence repetition 
    489     DPyObject opMul(int count) { 
    490         return new DPyObject(PySequence_Repeat(m_ptr, count)); 
    491     } 
    492     /// 
    493     DPyObject opDiv(DPyObject o) { 
    494         return new DPyObject(PyNumber_Divide(m_ptr, o.m_ptr)); 
    495     } 
    496     /// 
    497     DPyObject floorDiv(DPyObject o) { 
    498         return new DPyObject(PyNumber_FloorDivide(m_ptr, o.m_ptr)); 
    499     } 
    500     /// 
    501     DPyObject opMod(DPyObject o) { 
    502         return new DPyObject(PyNumber_Remainder(m_ptr, o.m_ptr)); 
    503     } 
    504     /// 
    505     DPyObject divmod(DPyObject o) { 
    506         return new DPyObject(PyNumber_Divmod(m_ptr, o.m_ptr)); 
    507     } 
    508     /// 
    509     DPyObject pow(DPyObject o1, DPyObject o2=null) { 
    510         return new DPyObject(PyNumber_Power(m_ptr, o1.m_ptr, (o2 is null) ? Py_None : o2.m_ptr)); 
    511     } 
    512     /// 
    513     DPyObject opPos() { 
    514         return new DPyObject(PyNumber_Positive(m_ptr)); 
    515     } 
    516     /// 
    517     DPyObject opNeg() { 
    518         return new DPyObject(PyNumber_Negative(m_ptr)); 
    519     } 
    520     /// 
    521     DPyObject abs() { 
    522         return new DPyObject(PyNumber_Absolute(m_ptr)); 
    523     } 
    524     /// 
    525     DPyObject opCom() { 
    526         return new DPyObject(PyNumber_Invert(m_ptr)); 
    527     } 
    528     /// 
    529     DPyObject opShl(DPyObject o) { 
    530         return new DPyObject(PyNumber_Lshift(m_ptr, o.m_ptr)); 
    531     } 
    532     /// 
    533     DPyObject opShr(DPyObject o) { 
    534         return new DPyObject(PyNumber_Rshift(m_ptr, o.m_ptr)); 
    535     } 
    536     /// 
    537     DPyObject opAnd(DPyObject o) { 
    538         return new DPyObject(PyNumber_And(m_ptr, o.m_ptr)); 
    539     } 
    540     /// 
    541     DPyObject opXor(DPyObject o) { 
    542         return new DPyObject(PyNumber_Xor(m_ptr, o.m_ptr)); 
    543     } 
    544     /// 
    545     DPyObject opOr(DPyObject o) { 
    546         return new DPyObject(PyNumber_Or(m_ptr, o.m_ptr)); 
     489    PydObject opMul(int count) { 
     490        return new PydObject(PySequence_Repeat(m_ptr, count)); 
     491    } 
     492    /// 
     493    PydObject opDiv(PydObject o) { 
     494        return new PydObject(PyNumber_Divide(m_ptr, o.m_ptr)); 
     495    } 
     496    /// 
     497    PydObject floorDiv(PydObject o) { 
     498        return new PydObject(PyNumber_FloorDivide(m_ptr, o.m_ptr)); 
     499    } 
     500    /// 
     501    PydObject opMod(PydObject o) { 
     502        return new PydObject(PyNumber_Remainder(m_ptr, o.m_ptr)); 
     503    } 
     504    /// 
     505    PydObject divmod(PydObject o) { 
     506        return new PydObject(PyNumber_Divmod(m_ptr, o.m_ptr)); 
     507    } 
     508    /// 
     509    PydObject pow(PydObject o1, PydObject o2=null) { 
     510        return new PydObject(PyNumber_Power(m_ptr, o1.m_ptr, (o2 is null) ? Py_None : o2.m_ptr)); 
     511    } 
     512    /// 
     513    PydObject opPos() { 
     514        return new PydObject(PyNumber_Positive(m_ptr)); 
     515    } 
     516    /// 
     517    PydObject opNeg() { 
     518        return new PydObject(PyNumber_Negative(m_ptr)); 
     519    } 
     520    /// 
     521    PydObject abs() { 
     522        return new PydObject(PyNumber_Absolute(m_ptr)); 
     523    } 
     524    /// 
     525    PydObject opCom() { 
     526        return new PydObject(PyNumber_Invert(m_ptr)); 
     527    } 
     528    /// 
     529    PydObject opShl(PydObject o) { 
     530        return new PydObject(PyNumber_Lshift(m_ptr, o.m_ptr)); 
     531    } 
     532    /// 
     533    PydObject opShr(PydObject o) { 
     534        return new PydObject(PyNumber_Rshift(m_ptr, o.m_ptr)); 
     535    } 
     536    /// 
     537    PydObject opAnd(PydObject o) { 
     538        return new PydObject(PyNumber_And(m_ptr, o.m_ptr)); 
     539    } 
     540    /// 
     541    PydObject opXor(PydObject o) { 
     542        return new PydObject(PyNumber_Xor(m_ptr, o.m_ptr)); 
     543    } 
     544    /// 
     545    PydObject opOr(PydObject o) { 
     546        return new PydObject(PyNumber_Or(m_ptr, o.m_ptr)); 
    547547    } 
    548548 
     
    554554 
    555555    // A useful wrapper for most of the in-place operators 
    556     private DPyObject 
    557     inplace(op_t op, DPyObject rhs) { 
     556    private PydObject 
     557    inplace(op_t op, PydObject rhs) { 
    558558        if (PyType_HasFeature(m_ptr.ob_type, Py_TPFLAGS_HAVE_INPLACEOPS)) { 
    559559            op(m_ptr, rhs.m_ptr); 
     
    568568    } 
    569569    /// 
    570     DPyObject opAddAssign(DPyObject o) { 
     570    PydObject opAddAssign(PydObject o) { 
    571571        return inplace(&PyNumber_InPlaceAdd, o); 
    572572    } 
    573573    /// 
    574     DPyObject opSubAssign(DPyObject o) { 
     574    PydObject opSubAssign(PydObject o) { 
    575575        return inplace(&PyNumber_InPlaceSubtract, o); 
    576576    } 
    577577    /// 
    578     DPyObject opMulAssign(DPyObject o) { 
     578    PydObject opMulAssign(PydObject o) { 
    579579        return inplace(&PyNumber_InPlaceMultiply, o); 
    580580    } 
    581581    /// In-place sequence repetition 
    582     DPyObject opMulAssign(int count) { 
     582    PydObject opMulAssign(int count) { 
    583583        if (PyType_HasFeature(m_ptr.ob_type, Py_TPFLAGS_HAVE_INPLACEOPS)) { 
    584584            PySequence_InPlaceRepeat(m_ptr, count); 
     
    593593    } 
    594594    /// 
    595     DPyObject opDivAssign(DPyObject o) { 
     595    PydObject opDivAssign(PydObject o) { 
    596596        return inplace(&PyNumber_InPlaceDivide, o); 
    597597    } 
    598598    /// 
    599     DPyObject floorDivAssign(DPyObject o) { 
     599    PydObject floorDivAssign(PydObject o) { 
    600600        return inplace(&PyNumber_InPlaceFloorDivide, o); 
    601601    } 
    602602    /// 
    603     DPyObject opModAssign(DPyObject o) { 
     603    PydObject opModAssign(PydObject o) { 
    604604        return inplace(&PyNumber_InPlaceRemainder, o); 
    605605    } 
    606606    /// 
    607     DPyObject powAssign(DPyObject o1, DPyObject o2=null) { 
     607    PydObject powAssign(PydObject o1, PydObject o2=null) { 
    608608        if (PyType_HasFeature(m_ptr.ob_type, Py_TPFLAGS_HAVE_INPLACEOPS)) { 
    609609            PyNumber_InPlacePower(m_ptr, o1.m_ptr, (o2 is null) ? Py_None : o2.m_ptr); 
     
    618618    } 
    619619    /// 
    620     DPyObject opShlAssign(DPyObject o) { 
     620    PydObject opShlAssign(PydObject o) { 
    621621        return inplace(&PyNumber_InPlaceLshift, o); 
    622622    } 
    623623    /// 
    624     DPyObject opShrAssign(DPyObject o) { 
     624    PydObject opShrAssign(PydObject o) { 
    625625        return inplace(&PyNumber_InPlaceRshift, o); 
    626626    } 
    627627    /// 
    628     DPyObject opAndAssign(DPyObject o) { 
     628    PydObject opAndAssign(PydObject o) { 
    629629        return inplace(&PyNumber_InPlaceAnd, o); 
    630630    } 
    631631    /// 
    632     DPyObject opXorAssign(DPyObject o) { 
     632    PydObject opXorAssign(PydObject o) { 
    633633        return inplace(&PyNumber_InPlaceXor, o); 
    634634    } 
    635635    /// 
    636     DPyObject opOrAssign(DPyObject o) { 
     636    PydObject opOrAssign(PydObject o) { 
    637637        return inplace(&PyNumber_InPlaceOr, o); 
    638638    } 
     
    642642    //----------------- 
    643643    /// 
    644     DPyObject asInt() { 
    645         return new DPyObject(PyNumber_Int(m_ptr)); 
    646     } 
    647     /// 
    648     DPyObject asLong() { 
    649         return new DPyObject(PyNumber_Long(m_ptr)); 
    650     } 
    651     /// 
    652     DPyObject asFloat() { 
    653         return new DPyObject(PyNumber_Float(m_ptr)); 
     644    PydObject asInt() { 
     645        return new PydObject(PyNumber_Int(m_ptr)); 
     646    } 
     647    /// 
     648    PydObject asLong() { 
     649        return new PydObject(PyNumber_Long(m_ptr)); 
     650    } 
     651    /// 
     652    PydObject asFloat() { 
     653        return new PydObject(PyNumber_Float(m_ptr)); 
    654654    } 
    655655    /// 
     
    675675 
    676676    /// Sequence concatenation 
    677     DPyObject opCat(DPyObject o) { 
    678         return new DPyObject(PySequence_Concat(m_ptr, o.m_ptr)); 
     677    PydObject opCat(PydObject o) { 
     678        return new PydObject(PySequence_Concat(m_ptr, o.m_ptr)); 
    679679    } 
    680680    /// In-place sequence concatenation 
    681     DPyObject opCatAssign(DPyObject o) { 
     681    PydObject opCatAssign(PydObject o) { 
    682682        return inplace(&PySequence_InPlaceConcat, o); 
    683683    } 
    684684    /// 
    685     int count(DPyObject v) { 
     685    int count(PydObject v) { 
    686686        int result = PySequence_Count(m_ptr, v.m_ptr); 
    687687        if (result == -1) handle_exception(); 
     
    689689    } 
    690690    /// 
    691     int index(DPyObject v) { 
     691    int index(PydObject v) { 
    692692        int result = PySequence_Index(m_ptr, v.m_ptr); 
    693693        if (result == -1) handle_exception(); 
    694694        return result; 
    695695    } 
    696     /// Converts any iterable DPyObject to a list 
    697     DPyObject asList() { 
    698         return new DPyObject(PySequence_List(m_ptr)); 
    699     } 
    700     /// Converts any iterable DPyObject to a tuple 
    701     DPyObject asTuple() { 
    702         return new DPyObject(PySequence_Tuple(m_ptr)); 
     696    /// Converts any iterable PydObject to a list 
     697    PydObject asList() { 
     698        return new PydObject(PySequence_List(m_ptr)); 
     699    } 
     700    /// Converts any iterable PydObject to a tuple 
     701    PydObject asTuple() { 
     702        return new PydObject(PySequence_Tuple(m_ptr)); 
    703703    } 
    704704    /+ 
     
    711711            return temp; 
    712712        } else { 
    713             PyErr_SetString(PyExc_RuntimeError, "Cannot convert non-PyUnicode DPyObject to wchar[]."); 
     713            PyErr_SetString(PyExc_RuntimeError, "Cannot convert non-PyUnicode PydObject to wchar[]."); 
    714714            handle_exception(); 
    715715        } 
    716716    } 
    717717    // Added by list: 
    718     void insert(int i, DPyObject item) { assert(false); } 
    719     void append(DPyObject item) { assert(false); } 
     718    void insert(int i, PydObject item) { assert(false); } 
     719    void append(PydObject item) { assert(false); } 
    720720    void sort() { assert(false); } 
    721721    void reverse() { assert(false); } 
     
    726726    //----------------- 
    727727    /// Same as "v in this" in Python. 
    728     bool opIn_r(DPyObject v) { 
     728    bool opIn_r(PydObject v) { 
    729729        int result = PySequence_Contains(m_ptr, v.m_ptr); 
    730730        if (result == -1) handle_exception(); 
     
    732732    } 
    733733    /// Same as opIn_r 
    734     bool hasKey(DPyObject key) { return this.opIn_r(key); } 
     734    bool hasKey(PydObject key) { return this.opIn_r(key); } 
    735735    /// Same as "'v' in this" in Python. 
    736736    bool opIn_r(char[] key) { 
     
    744744    } 
    745745    /// 
    746     DPyObject keys() { 
    747         return new DPyObject(PyMapping_Keys(m_ptr)); 
    748     } 
    749     /// 
    750     DPyObject values() { 
    751         return new DPyObject(PyMapping_Values(m_ptr)); 
    752     } 
    753     /// 
    754     DPyObject items() { 
    755         return new DPyObject(PyMapping_Items(m_ptr)); 
     746    PydObject keys() { 
     747        return new PydObject(PyMapping_Keys(m_ptr)); 
     748    } 
     749    /// 
     750    PydObject values() { 
     751        return new PydObject(PyMapping_Values(m_ptr)); 
     752    } 
     753    /// 
     754    PydObject items() { 
     755        return new PydObject(PyMapping_Items(m_ptr)); 
    756756    } 
    757757    /+ 
    758758    // Added by dict 
    759759    void clear() { assert(false); } 
    760     DPyObject copy() { assert(false); } 
    761     void update(DPyObject o, bool over_ride=true) { assert(false); } 
     760    PydObject copy() { assert(false); } 
     761    void update(PydObject o, bool over_ride=true) { assert(false); } 
    762762    +/ 
    763763}