Changeset 49
- Timestamp:
- 12/01/06 17:15:39 (2 years ago)
- Files:
-
- trunk/dcompiler.py (modified) (2 diffs)
- trunk/html_doc/basics.html (modified) (2 diffs)
- trunk/html_doc/celerid.html (modified) (1 diff)
- trunk/html_doc/class_wrapping.html (modified) (1 diff)
- trunk/html_doc/conversion.html (modified) (5 diffs)
- trunk/html_doc/credits.html (modified) (1 diff)
- trunk/html_doc/except_wrapping.html (modified) (2 diffs)
- trunk/html_doc/func_wrapping.html (modified) (1 diff)
- trunk/html_doc/index.html (modified) (1 diff)
- trunk/html_doc/install.html (modified) (1 diff)
- trunk/html_doc/pydobject.html (moved) (moved from trunk/html_doc/dpyobject.html) (42 diffs)
- trunk/infrastructure/pyd/class_wrap.d (modified) (7 diffs)
- trunk/infrastructure/pyd/def.d (modified) (1 diff)
- trunk/infrastructure/pyd/func_wrap.d (modified) (7 diffs)
- trunk/infrastructure/pyd/iteration.d (modified) (8 diffs)
- trunk/infrastructure/pyd/make_object.d (modified) (11 diffs)
- trunk/infrastructure/pyd/pyd.d (modified) (1 diff)
- trunk/infrastructure/pyd/pydobject.d (moved) (moved from trunk/infrastructure/pyd/dpyobject.d) (43 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/dcompiler.py
r48 r49 30 30 'def.d', 31 31 'dg_convert.d', 32 'dpyobject.d',33 32 'exception.d', 34 33 'func_wrap.d', … … 37 36 'op_wrap.d', 38 37 'pyd.d', 38 'pydobject.d', 39 39 ] 40 40 trunk/html_doc/basics.html
r45 r49 18 18 <a class="nav" href="class_wrapping.html">Class wrapping</a><br /> 19 19 <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 /> 21 21 <a class="nav" href="credits.html">Credits</a> 22 22 </div> … … 49 49 <p><code>PyObject* module_init(char[] <span class="arg">name</span>);</code></p> 50 50 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> 52 52 53 53 <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 18 18 <a class="nav" href="class_wrapping.html">Class wrapping</a><br /> 19 19 <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 /> 21 21 <a class="nav" href="credits.html">Credits</a> 22 22 </div> trunk/html_doc/class_wrapping.html
r45 r49 18 18 <a class="navcur" href="class_wrapping.html">Class wrapping</a><br /> 19 19 <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 /> 21 21 <a class="nav" href="credits.html">Credits</a> 22 22 </div> trunk/html_doc/conversion.html
r45 r49 18 18 <a class="nav" href="class_wrapping.html">Class wrapping</a><br /> 19 19 <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 /> 21 21 <a class="nav" href="credits.html">Credits</a> 22 22 </div> … … 45 45 <tr><td>delegate or function pointer</td> <td>A callable object</td></tr> 46 46 <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> 48 48 <tr><td>PyObject*</td> <td>The object's type</td></tr> 49 49 </table> … … 51 51 This function will set a Python <code>RuntimeError</code> and return <code>null</code> if the conversion is not possible.</dd> 52 52 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> 55 55 56 56 <dt><code><span class="t_arg">T</span> d_type(<span class="t_arg">T</span>) (PyObject* <span class="arg">o</span>);</dt> … … 60 60 <tr><th>Python type</th> <th>D type</th> </tr> 61 61 <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> 63 63 <tr><td><a href="class_wrapping.html">Wrapped class</a></td> <td>Wrapped class</td></tr> 64 64 <tr><td>Any callable</td> <td>delegate</td> </tr> … … 71 71 </table> 72 72 73 This function will throw a <code> DPyConversionException</code> if the conversion is not possible.</dd>73 This function will throw a <code>PydConversionException</code> if the conversion is not possible.</dd> 74 74 </dl> 75 75 </div> trunk/html_doc/credits.html
r45 r49 18 18 <a class="nav" href="class_wrapping.html">Class wrapping</a><br /> 19 19 <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 /> 21 21 <a class="navcur" href="credits.html">Credits</a> 22 22 </div> trunk/html_doc/except_wrapping.html
r46 r49 18 18 <a class="nav" href="class_wrapping.html">Class wrapping</a><br /> 19 19 <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 /> 21 21 <a class="nav" href="credits.html">Credits</a> 22 22 </div> … … 30 30 <p>When wrapping functions and classes, the latter is usually of more interest. All wrapped functions, methods, constructors, properties, &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> 31 31 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> 33 33 34 34 <p>Pyd provides the following exception-related functions:</p> trunk/html_doc/func_wrapping.html
r45 r49 18 18 <a class="nav" href="class_wrapping.html">Class wrapping</a><br /> 19 19 <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 /> 21 21 <a class="nav" href="credits.html">Credits</a> 22 22 </div> trunk/html_doc/index.html
r45 r49 18 18 <a class="nav" href="class_wrapping.html">Class wrapping</a><br /> 19 19 <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 /> 21 21 <a class="nav" href="credits.html">Credits</a> 22 22 </div> trunk/html_doc/install.html
r45 r49 18 18 <a class="nav" href="class_wrapping.html">Class wrapping</a><br /> 19 19 <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 /> 21 21 <a class="nav" href="credits.html">Credits</a> 22 22 </div> trunk/html_doc/pydobject.html
r45 r49 4 4 <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> 5 5 <link href="pyd.css" rel="stylesheet" type="text/css"> 6 <title>pyd. dpyobject</title>6 <title>pyd.pydobject</title> 7 7 </head> 8 8 … … 18 18 <a class="nav" href="class_wrapping.html">Class wrapping</a><br /> 19 19 <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 /> 21 21 <a class="nav" href="credits.html">Credits</a> 22 22 </div> … … 24 24 <div id="content"> 25 25 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>; 31 31 </big></dt> 32 32 <dd>Wrapper class for a Python/C API PyObject. … … 52 52 <tr><td>PyObject * <i>o</i></td> <td>The PyObject to wrap.</td></tr> 53 53 <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. 55 55 Therefore, Py_INCREF will be called if <i>borrowed</i> is 56 56 true.</td></tr> … … 58 58 59 59 <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> 61 61 62 62 <dt><big>PyObject * <u>ptr</u>();</big></dt> … … 66 66 <dd>Same as hasattr(this, <i>attr_name</i>) in Python.<br><br></dd> 67 67 68 <dt><big>bool <u>hasattr</u>( DPyObject <i>attr_name</i>);68 <dt><big>bool <u>hasattr</u>(PydObject <i>attr_name</i>); 69 69 </big></dt> 70 70 <dd>Same as hasattr(this, <i>attr_name</i>) in Python. … … 72 72 73 73 </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>); 75 75 </big></dt> 76 76 <dd>Same as getattr(this, <i>attr_name</i>) in Python. … … 78 78 79 79 </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>); 81 81 </big></dt> 82 82 <dd>Same as getattr(this, <i>attr_name</i>) in Python. … … 84 84 85 85 </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>); 87 87 </big></dt> 88 88 <dd>Same as setattr(this, <i>attr_name</i>, <i>v</i>) in Python. … … 91 91 92 92 </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>); 94 94 </big></dt> 95 95 <dd>Same as setattr(this, <i>attr_name</i>, <i>v</i>) in Python. … … 105 105 106 106 </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>); 108 108 </big></dt> 109 109 <dd>Same as del this.<i>attr_name</i> in Python. … … 112 112 113 113 </dd> 114 <dt><big>int <u>opCmp</u>( DPyObject <i>rhs</i>);114 <dt><big>int <u>opCmp</u>(PydObject <i>rhs</i>); 115 115 </big></dt> 116 116 <dd>Exposes Python object comparison to D. Same as cmp(this, <i>rhs</i>) in Python. … … 119 119 120 120 </dd> 121 <dt><big>bool <u>opEquals</u>( DPyObject <i>rhs</i>);121 <dt><big>bool <u>opEquals</u>(PydObject <i>rhs</i>); 122 122 </big></dt> 123 123 <dd>Exposes Python object equality check to D. … … 126 126 127 127 </dd> 128 <dt><big> DPyObject <u>repr</u>();128 <dt><big>PydObject <u>repr</u>(); 129 129 </big></dt> 130 130 <dd>Same as repr(this) in Python. … … 132 132 133 133 </dd> 134 <dt><big> DPyObject <u>str</u>();134 <dt><big>PydObject <u>str</u>(); 135 135 </big></dt> 136 136 <dd>Same as str(this) in Python. … … 140 140 <dt><big>char[] <u>toString</u>(); 141 141 </big></dt> 142 <dd>Allows use of DPyObject in writef via %s143 <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>(); 147 147 </big></dt> 148 148 <dd>Same as unicode(this) in Python. … … 150 150 151 151 </dd> 152 <dt><big>bool <u>isInstance</u>( DPyObject <i>cls</i>);152 <dt><big>bool <u>isInstance</u>(PydObject <i>cls</i>); 153 153 </big></dt> 154 154 <dd>Same as isinstance(this, <i>cls</i>) in Python. … … 156 156 157 157 </dd> 158 <dt><big>bool <u>isSubclass</u>( DPyObject <i>cls</i>);158 <dt><big>bool <u>isSubclass</u>(PydObject <i>cls</i>); 159 159 </big></dt> 160 160 <dd>Same as issubclass(this, <i>cls</i>) in Python. Only works if this is a class. … … 168 168 169 169 </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> 173 173 <br><br> 174 174 <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 to175 <table><tr><td>PydObject <i>args</i></td> 176 <td>Should be a PydTuple of the arguments to pass. Omit to 177 177 call with no arguments.</td></tr> 178 178 </table><br> 179 179 <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.180 Whatever 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. 188 188 <br><br> 189 189 <b>Params:</b><br> 190 <table><tr><td> DPyObject <i>args</i></td>191 <td>Positional arguments. Should be a DPyTuple. Pass an empty192 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> 195 195 </table><br> 196 196 <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);197 Whatever 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); 203 203 </big></dt> 204 204 <dd><br><br> … … 222 222 223 223 </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. 227 227 <br><br> 228 228 <b>Returns:</b><br> 229 The type DPyObject of this DPyObject.229 The type PydObject of this PydObject. 230 230 231 231 <br><br> … … 234 234 <dt><big>int <u>length</u>(); 235 235 </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. 237 237 238 238 <br><br> … … 245 245 246 246 </dd> 247 <dt><big> DPyObject <u>dir</u>();247 <dt><big>PydObject <u>dir</u>(); 248 248 </big></dt> 249 249 <dd>Same as dir(this) in Python. … … 251 251 252 252 </dd> 253 <dt><big> DPyObject <u>opIndex</u>(DPyObject <i>key</i>);253 <dt><big>PydObject <u>opIndex</u>(PydObject <i>key</i>); 254 254 </big></dt> 255 255 <dd>Equivalent to o[key] in Python. … … 257 257 258 258 </dd> 259 <dt><big> DPyObject <u>opIndex</u>(char[] <i>key</i>);259 <dt><big>PydObject <u>opIndex</u>(char[] <i>key</i>); 260 260 </big></dt> 261 261 <dd>Equivalent to o['key'] in Python; usually only makes sense for … … 265 265 266 266 </dd> 267 <dt><big> DPyObject <u>opIndex</u>(int <i>i</i>);267 <dt><big>PydObject <u>opIndex</u>(int <i>i</i>); 268 268 </big></dt> 269 269 <dd>Equivalent to o[i] in Python; usually only makes sense for sequences. … … 271 271 272 272 </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>); 274 274 </big></dt> 275 275 <dd>Equivalent to o[key] = value in Python. … … 277 277 278 278 </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>); 280 280 </big></dt> 281 281 <dd>Equivalent to o['key'] = value in Python. Usually only makes sense for … … 285 285 286 286 </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>); 288 288 </big></dt> 289 289 <dd>Equivalent to o[i] = value in Python. Usually only makes sense for … … 293 293 294 294 </dd> 295 <dt><big>void <u>delItem</u>( DPyObject <i>key</i>);295 <dt><big>void <u>delItem</u>(PydObject <i>key</i>); 296 296 </big></dt> 297 297 <dd>Equivalent to del o[key] in Python. … … 315 315 316 316 </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>); 318 318 </big></dt> 319 319 <dd>Equivalent to o[i1:i2] in Python. … … 321 321 322 322 </dd> 323 <dt><big> DPyObject <u>opSlice</u>();323 <dt><big>PydObject <u>opSlice</u>(); 324 324 </big></dt> 325 325 <dd>Equivalent to o[:] in Python. … … 327 327 328 328 </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>); 330 330 </big></dt> 331 331 <dd>Equivalent to o[i1:i2] = v in Python. … … 333 333 334 334 </dd> 335 <dt><big>void <u>opSliceAssign</u>( DPyObject <i>v</i>);335 <dt><big>void <u>opSliceAssign</u>(PydObject <i>v</i>); 336 336 </big></dt> 337 337 <dd>Equivalent to o[:] = v in Python. … … 351 351 352 352 </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>); 354 354 </big></dt> 355 355 <dd>Iterates over the items in a collection, be they the items in a 356 356 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 not357 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 365 365 a dict, this simply does nothing. (It iterates over no items.) You 366 366 should not attempt to modify the dictionary while iterating through it, … … 371 371 372 372 </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>); 386 386 </big></dt> 387 387 <dd>Sequence repetition … … 389 389 390 390 </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>); 460 460 </big></dt> 461 461 <dd>In-place sequence repetition … … 463 463 464 464 </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>(); 510 510 </big></dt> 511 511 <dd><br><br> … … 527 527 <dd><br><br> 528 528 </dd> 529 <dt><big> DPyObject <u>opCat</u>(DPyObject <i>o</i>);529 <dt><big>PydObject <u>opCat</u>(PydObject <i>o</i>); 530 530 </big></dt> 531 531 <dd>Sequence concatenation … … 533 533 534 534 </dd> 535 <dt><big> DPyObject <u>opCatAssign</u>(DPyObject <i>o</i>);535 <dt><big>PydObject <u>opCatAssign</u>(PydObject <i>o</i>); 536 536 </big></dt> 537 537 <dd>In-place sequence concatenation … … 539 539 540 540 </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 list552 <br><br> 553 554 </dd> 555 <dt><big> DPyObject <u>asTuple</u>();556 </big></dt> 557 <dd>Converts any iterable DPyObject to a tuple558 <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>); 562 562 </big></dt> 563 563 <dd>Same as "<i>v</i> in this" in Python. … … 565 565 566 566 </dd> 567 <dt><big>bool <u>hasKey</u>( DPyObject <i>key</i>);567 <dt><big>bool <u>hasKey</u>(PydObject <i>key</i>); 568 568 </big></dt> 569 569 <dd>Same as opIn_r … … 583 583 584 584 </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>(); 594 594 </big></dt> 595 595 <dd><br><br> trunk/infrastructure/pyd/class_wrap.d
r48 r49 45 45 46 46 // This is split out in case I ever want to make a subtype of a wrapped class. 47 template DPyObject_HEAD(T) {47 template PydWrapObject_HEAD(T) { 48 48 mixin PyObject_HEAD; 49 49 T d_obj; … … 54 54 extern(C) 55 55 struct wrapped_class_object { 56 mixin DPyObject_HEAD!(T);56 mixin PydWrapObject_HEAD!(T); 57 57 } 58 58 } … … 333 333 */ 334 334 static void iter(iter_t) () { 335 DPySC_Ready();335 PydStackContext_Ready(); 336 336 wrapped_class_type!(T).tp_iter = &wrapped_iter!(T, T.opApply, int function(iter_t)).iter; 337 337 } … … 345 345 static PyMethodDef empty = { null, null, 0, null }; 346 346 alias wrapped_method_list!(T) list; 347 PydStackContext_Ready(); 347 348 list[length-1].ml_name = name ~ \0; 348 349 list[length-1].ml_meth = cast(PyCFunction)&wrapped_iter!(T, fn, int function(iter_t)).iter; … … 369 370 pragma(msg, "finalize_class: " ~ name); 370 371 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)); 373 374 // Fill in missing values 374 375 type.ob_type = PyType_Type_p(); … … 401 402 static if (is(typeof(&T.opApply))) { 402 403 if (type.tp_iter is null) { 403 DPySC_Ready();404 PydStackContext_Ready(); 404 405 type.tp_iter = &wrapped_iter!(T, T.opApply).iter; 405 406 } … … 425 426
