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

Revision 25, 4.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.def</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.def");</script>
13     <table class="content">
14         <tr><td id="docbody"><h1>pyd.def</h1><!-- Generated by Ddoc from pyd\def.d -->
15 <br><br>
16
17 <script>explorer.outline.incSymbolLevel();</script>
18 <dl>
19 <script>explorer.outline.writeEnabled = true;</script>
20 <dt><span class="decl">template
21 <span class="currsymbol">def</span>
22 <script>explorer.outline.addDecl('def');</script>
23
24 (char[] name,alias fn,uint MIN_ARGS = NumberOfArgs!(typeof(&amp;fn)),fn_t = typeof(&amp;fn))</span></dt>
25 <script>explorer.outline.writeEnabled = false;</script>
26
27
28 <dd>Wraps a D function, making it callable from Python.
29 <br><br>
30 <b>Params:</b><br>
31 <table><tr>
32 <td nowrap valign="top" style="padding-right: 8px">name</td>
33
34                
35 <td>The name of the function as it will appear in Python.</td></tr>
36 <tr>
37 <td nowrap valign="top" style="padding-right: 8px">fn</td>
38
39                
40 <td>The function to wrap.</td></tr>
41 <tr>
42 <td nowrap valign="top" style="padding-right: 8px">MIN_ARGS</td>
43
44                
45 <td>The minimum number of arguments this function can accept.
46                  For use with functions with default arguments. Defaults to
47                  the maximum number of arguments this function supports.</td></tr>
48 <tr>
49 <td nowrap valign="top" style="padding-right: 8px">fn_t</td>
50
51                
52 <td>The function type of the function to wrap. This must be
53              specified if more than one function shares the same name,
54              otherwise the first one defined lexically will be used.</td></tr>
55 </table><br>
56 <b>Examples:</b><br>
57 <pre class="d_code">import pyd.pyd;
58 char[] foo(int i) {
59     if (i &gt; 10) {
60         return "It's greater than 10!";
61     } else {
62         return "It's less than 10!";
63     }
64 }
65 extern (C)
66 export void inittestdll() {
67     def!("foo", foo);
68     module_init("testdll");
69 }</pre>
70  And in Python:
71 <pre class="d_code">&gt;&gt;&gt; import testdll
72 &gt;&gt;&gt; print testdll.foo(20)
73 It's greater than 10!</pre>
74  
75 <br><br>
76
77
78 <script>explorer.outline.incSymbolLevel();</script>
79 <dl></dl>
80 <script>explorer.outline.decSymbolLevel();</script>
81
82
83 </dd>
84
85 <script>explorer.outline.writeEnabled = true;</script>
86 <dt><span class="decl">PyObject *
87 <span class="currsymbol">module_init</span>
88 <script>explorer.outline.addDecl('module_init');</script>
89
90 (char[] <span class="funcparam">name</span>);
91 </span></dt>
92 <script>explorer.outline.writeEnabled = false;</script>
93
94
95 <dd>Module initialization function. Should be called after the last call to def.
96  
97 <br><br>
98
99 </dd>
100 </dl>
101 <script>explorer.outline.decSymbolLevel();</script>
102
103
104 </td></tr>
105         <tr><td id="docfooter">
106             Page was generated with
107             <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px">
108             on Sat Jul  1 22:14:02 2006
109
110         </td></tr>
111     </table>
112 </div>
113 <script>
114     explorer.packageExplorer.addModule("pyd.class_wrap");
115     explorer.packageExplorer.addModule("pyd.ctor_wrap");
116     explorer.packageExplorer.addModule("pyd.def");
117     explorer.packageExplorer.addModule("pyd.dg_convert");
118     explorer.packageExplorer.addModule("pyd.exception");
119     explorer.packageExplorer.addModule("pyd.ftype");
120     explorer.packageExplorer.addModule("pyd.make_object");
121     explorer.packageExplorer.addModule("pyd.object");
122     explorer.packageExplorer.addModule("pyd.pyd");</script>
123 </body></html>
Note: See TracBrowser for help on using the browser.