root/trunk/infrastructure/pyd/wiki_doc/def.html

Revision 33, 1.8 kB (checked in by KirkMcDonald, 6 years ago)

html_doc update

Line 
1 <html><head>
2     <META http-equiv="content-type" content="text/html; charset=utf-8">
3     <title>pyd.def</title>
4     </head><body>
5     <h1>pyd.def</h1>
6     <!-- Generated by Ddoc from pyd\def.d -->
7 <br><br>
8 <dl><dt><big>template def(alias fn,char[] name,fn_t = typeof(&fn),uint MIN_ARGS = MIN_ARGS!(fn))</big></dt>
9 <dd>Wraps a D function, making it callable from Python.
10 <br><br>
11 <b>Params:</b><br>
12 <table><tr><td>name</td>
13 <td>The name of the function as it will appear in Python.</td></tr>
14 <tr><td>fn</td>
15 <td>The function to wrap.</td></tr>
16 <tr><td>MIN_ARGS</td>
17 <td>The minimum number of arguments this function can accept.
18                  For use with functions with default arguments. Defaults to
19                  the maximum number of arguments this function supports.</td></tr>
20 <tr><td>fn_t</td>
21 <td>The function type of the function to wrap. This must be
22              specified if more than one function shares the same name,
23              otherwise the first one defined lexically will be used.</td></tr>
24 </table><br>
25 <b>Examples:</b><br>
26 <pre class="d_code">import pyd.pyd;
27 char[] foo(int i) {
28     if (i &gt; 10) {
29         return "It's greater than 10!";
30     } else {
31         return "It's less than 10!";
32     }
33 }
34 extern (C)
35 export void inittestdll() {
36     def!("foo", foo);
37     module_init("testdll");
38 }</pre>
39  And in Python:
40 <pre class="d_code">&gt;&gt;&gt; import testdll
41 &gt;&gt;&gt; print testdll.foo(20)
42 It's greater than 10!</pre>
43  
44 <br><br>
45
46 <dl></dl>
47 </dd>
48 <dt><big>PyObject * <u>module_init</u>(char[] <i>name</i>);
49 </big></dt>
50 <dd>Module initialization function. Should be called after the last call to def.
51  
52 <br><br>
53
54 </dd>
55 </dl>
56
57     <hr><small>Page generated by <a href="http://www.digitalmars.com/d/ddoc.html">Ddoc</a>. </small>
58     </body></html>
Note: See TracBrowser for help on using the browser.