root/trunk/infrastructure/pyd/doc/make_object.html

Revision 25, 6.0 kB (checked in by KirkMcDonald, 2 years ago)

Fleshed out the docs a little.

Line 
1 <html><head>
2 <meta http-equiv="content-type" content="text/html; charset=utf-8">
3 <meta content="text/javascript" http-equiv="content-script-type">
4 <title>pyd.make_object</title>
5 <link rel="stylesheet" type="text/css" href="candydoc/style.css">
6 <!--[if lt IE 7]><link rel="stylesheet" type="text/css" href="candydoc/ie56hack.css"><![endif]-->
7 <script language="JavaScript" src="candydoc/util.js" type="text/javascript"></script>
8 <script language="JavaScript" src="candydoc/tree.js" type="text/javascript"></script>
9 <script language="JavaScript" src="candydoc/explorer.js" type="text/javascript"></script>
10 </head><body>
11 <div id="tabarea"></div><div id="explorerclient"></div>
12 <div id="content"><script>explorer.initialize("pyd.make_object");</script>
13     <table class="content">
14         <tr><td id="docbody"><h1>pyd.make_object</h1><!-- Generated by Ddoc from pyd\make_object.d -->
15 This module contains some useful type conversion functions. There are two
16  interesting operations involved here:
17 <br><br>
18 PyObject* -&gt; D type
19 <br><br>
20
21  D type -&gt; PyObject*
22 <br><br>
23
24  The former is handled by d_type, the latter by _py. The py function is
25  provided as a convenience to directly convert a D type into an instance of
26  DPyObject.
27  
28 <br><br>
29
30
31 <script>explorer.outline.incSymbolLevel();</script>
32 <dl>
33 <script>explorer.outline.writeEnabled = true;</script>
34 <dt><span class="decl">template
35 <span class="currsymbol">_py</span>
36 <script>explorer.outline.addDecl('_py');</script>
37
38 (T)</span></dt>
39 <script>explorer.outline.writeEnabled = false;</script>
40
41
42 <dd><br><br>
43
44 <script>explorer.outline.incSymbolLevel();</script>
45 <dl>
46 <script>explorer.outline.writeEnabled = true;</script>
47 <dt><span class="decl">PyObject*
48 <span class="currsymbol">_py</span>
49 <script>explorer.outline.addDecl('_py');</script>
50
51 (T <span class="funcparam">t</span>);
52 </span></dt>
53 <script>explorer.outline.writeEnabled = false;</script>
54
55
56 <dd>Returns a new (owned) reference to a Python object based on the passed
57  argument. If the passed argument is a PyObject*, this "steals" the
58  reference. (In other words, it returns the PyObject* without changing its
59  reference count.) If the passed argument is a DPyObject, this returns a new
60  reference to whatever the DPyObject holds a reference to.
61 <br><br>
62 If the passed argument can'<span class="funcparam">t</span> be converted to a PyObject, a Python
63  RuntimeError will be raised and this function will return <b>null</b>.
64  
65 <br><br>
66
67 </dd>
68 </dl>
69 <script>explorer.outline.decSymbolLevel();</script>
70
71
72 </dd>
73
74 <script>explorer.outline.writeEnabled = true;</script>
75 <dt><span class="decl">template
76 <span class="currsymbol">py</span>
77 <script>explorer.outline.addDecl('py');</script>
78
79 (T)</span></dt>
80 <script>explorer.outline.writeEnabled = false;</script>
81
82
83 <dd><br><br>
84
85 <script>explorer.outline.incSymbolLevel();</script>
86 <dl>
87 <script>explorer.outline.writeEnabled = true;</script>
88 <dt><span class="decl">DPyObject
89 <span class="currsymbol">py</span>
90 <script>explorer.outline.addDecl('py');</script>
91
92 (T <span class="funcparam">t</span>);
93 </span></dt>
94 <script>explorer.outline.writeEnabled = false;</script>
95
96
97 <dd>Constructs an object based on the type of the argument passed in.
98 <br><br>
99 For example, calling
100 <span class="currsymbol">py</span>
101 <script>explorer.outline.addDecl('py');</script>
102
103 (10) would return a DPyObject holding the value 10.
104 <br><br>
105
106  Calling this with a DPyObject will return back a reference to the very same
107  DPyObject.
108 <br><br>
109
110  Calling this with a PyObject* will "steal" the reference.
111  
112 <br><br>
113
114 </dd>
115 </dl>
116 <script>explorer.outline.decSymbolLevel();</script>
117
118
119 </dd>
120
121 <script>explorer.outline.writeEnabled = true;</script>
122 <dt><span class="decl">class
123 <span class="currsymbol">DPyConversionException</span>
124 <script>explorer.outline.addDecl('DPyConversionException');</script>
125
126 : object.Exception;
127 </span></dt>
128 <script>explorer.outline.writeEnabled = false;</script>
129
130
131 <dd>An exception class used by d_type.
132  
133 <br><br>
134
135
136 <script>explorer.outline.incSymbolLevel();</script>
137 <dl></dl>
138 <script>explorer.outline.decSymbolLevel();</script>
139
140
141 </dd>
142
143 <script>explorer.outline.writeEnabled = true;</script>
144 <dt><span class="decl">template
145 <span class="currsymbol">d_type</span>
146 <script>explorer.outline.addDecl('d_type');</script>
147
148 (T)</span></dt>
149 <script>explorer.outline.writeEnabled = false;</script>
150
151
152 <dd><br><br>
153
154 <script>explorer.outline.incSymbolLevel();</script>
155 <dl>
156 <script>explorer.outline.writeEnabled = true;</script>
157 <dt><span class="decl">T
158 <span class="currsymbol">d_type</span>
159 <script>explorer.outline.addDecl('d_type');</script>
160
161 (PyObject* <span class="funcparam">o</span>);
162 </span></dt>
163 <script>explorer.outline.writeEnabled = false;</script>
164
165
166 <dd>This converts a PyObject* to a D type. The template argument is the type to
167  convert to. The function argument is the PyObject* to convert. For instance:
168 <br><br>
169 <pre class="d_code">PyObject* i = PyInt_FromLong(20);
170 int n = d_type!(int)(i);
171 assert(n == 20);</pre>
172 <br><br>
173
174  This throws a DPyConversionException if the PyObject can't be converted to
175  the given D type.
176  
177 <br><br>
178
179 </dd>
180 </dl>
181 <script>explorer.outline.decSymbolLevel();</script>
182
183
184 </dd>
185 </dl>
186 <script>explorer.outline.decSymbolLevel();</script>
187
188
189 </td></tr>
190         <tr><td id="docfooter">
191             Page was generated with
192             <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px">
193             on Sat Jul  1 22:14:02 2006
194
195         </td></tr>
196     </table>
197 </div>
198 <script>
199     explorer.packageExplorer.addModule("pyd.class_wrap");
200     explorer.packageExplorer.addModule("pyd.ctor_wrap");
201     explorer.packageExplorer.addModule("pyd.def");
202     explorer.packageExplorer.addModule("pyd.dg_convert");
203     explorer.packageExplorer.addModule("pyd.exception");
204     explorer.packageExplorer.addModule("pyd.ftype");
205     explorer.packageExplorer.addModule("pyd.make_object");
206     explorer.packageExplorer.addModule("pyd.object");
207     explorer.packageExplorer.addModule("pyd.pyd");</script>
208 </body></html>
Note: See TracBrowser for help on using the browser.