Skip to content

Commit

Permalink
html_doc: basics, exceptions documented; new layout
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.dsource.org/projects/pyd/trunk@35 1df65b71-e716-0410-9316-ac55df2b1602
  • Loading branch information
KirkMcDonald authored and KirkMcDonald committed Aug 14, 2006
1 parent 415cf00 commit 7fb1a9b
Show file tree
Hide file tree
Showing 17 changed files with 200 additions and 458 deletions.
53 changes: 53 additions & 0 deletions html_doc/basics.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<link href="pyd.css" rel="stylesheet" type="text/css">
<title>Starting out with Pyd</title>
</head>

<body>
<div id="nav">
<p><big>Contents</big></p>
<a class="nav" href="index.html">Main</a><br />
<a class="navcur" href="basics.html">The basics</a><br />
<a class="nav" href="celerid.html">CeleriD</a><br />
<a class="nav" href="conversion.html">Type conversion</a><br />
<a class="nav" href="func_wrapping.html">Function wrapping</a><br />
<a class="nav" href="class_wrapping.html">Class wrapping</a><br />
<a class="nav" href="except_wrapping.html">Exception wrapping</a><br />
<a class="nav" href="dpyobject.html">DPyObject</a>
</div>

<div id="content">

<h1>The basics</h1>

<p>The most minimal working Pyd module looks something like this:</p>

<pre class="code"><span class="keyword">import</span> pyd.pyd;

<span class="keyword">extern</span> (C)
<span class="keyword">export void</span> inittestmodule() {
module_init(<span class="string">"testmodule"</span>);
}</pre>

<p>The first line imports Pyd:</p>

<pre class="code"><span class="keyword">import</span> pyd.pyd;</pre>

<p>The <code>pyd</code> module in the <code>pyd</code> package publicly imports all of the other components of Pyd.</p>

<p>The "init" function is a requirement of the Python/C API. It is a global function with the footprint <code>extern(C) export void function()</code>. Its name <em>must</em> be <code>init</code> plus the name of your module. This function must then contain a call to <code>module_init</code>, with the same module name as an argument. (Users of Boost.Python will be familiar with the <code>BOOST_PYTHON_MODULE</code> macro used in that library. Unfortunately for this purpose, D has no preprocessor, and cannot define the name of a function like the C preprocessor can. Therefore, users of Pyd must define their init functions manually.)</p>

<p>The <code>module_init</code> function has the following form:</p>

<p><code>PyObject* module_init(char[] <span class="arg">name</span>);</code></p>

<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>

<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>
</div>

</body>
</html>
16 changes: 15 additions & 1 deletion html_doc/celerid.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,19 @@
</head>

<body>
<div class="nav"><a class="nav" href="index.html">Main</a> | <a class="navcur" href="celerid.html">CeleriD</a> | <a class="nav" href="conversion.html">Type conversion</a> | <a class="nav" href="func_wrapping.html">Function wrapping</a> | <a class="nav" href="class_wrapping.html">Class wrapping</a> | <a class="nav" href="except_wrapping.html">Exception wrapping</a> | <a class="nav" href="dpyobject.html">DPyObject</a></div>
<div id="nav">
<p><big>Contents</big></p>
<a class="nav" href="index.html">Main</a><br />
<a class="nav" href="basics.html">The basics</a><br />
<a class="navcur" href="celerid.html">CeleriD</a><br />
<a class="nav" href="conversion.html">Type conversion</a><br />
<a class="nav" href="func_wrapping.html">Function wrapping</a><br />
<a class="nav" href="class_wrapping.html">Class wrapping</a><br />
<a class="nav" href="except_wrapping.html">Exception wrapping</a><br />
<a class="nav" href="dpyobject.html">DPyObject</a>
</div>

<div id="content">

<h1>CeleriD</h1>

Expand All @@ -28,5 +40,7 @@ <h1>CeleriD</h1>
<p>Compiling the module is a simple matter of running this:</p>

<pre class="code">&gt;python setup.py build</pre>
</div>

</body>
</html>
141 changes: 0 additions & 141 deletions html_doc/class_wrap.html

This file was deleted.

20 changes: 19 additions & 1 deletion html_doc/class_wrapping.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,19 @@
</head>

<body>
<div class="nav"><a class="nav" href="index.html">Main</a> | <a class="nav" href="celerid.html">CeleriD</a> | <a class="nav" href="conversion.html">Type conversion</a> | <a class="nav" href="func_wrapping.html">Function wrapping</a> | <a class="navcur" href="class_wrapping.html">Class wrapping</a> | <a class="nav" href="except_wrapping.html">Exception wrapping</a> | <a class="nav" href="dpyobject.html">DPyObject</a></div>
<div id="nav">
<p><big>Contents</big></p>
<a class="nav" href="index.html">Main</a><br />
<a class="nav" href="basics.html">The basics</a><br />
<a class="nav" href="celerid.html">CeleriD</a><br />
<a class="nav" href="conversion.html">Type conversion</a><br />
<a class="nav" href="func_wrapping.html">Function wrapping</a><br />
<a class="navcur" href="class_wrapping.html">Class wrapping</a><br />
<a class="nav" href="except_wrapping.html">Exception wrapping</a><br />
<a class="nav" href="dpyobject.html">DPyObject</a>
</div>

<div id="content">

<h1>Class wrapping</h1>

Expand Down Expand Up @@ -50,6 +62,10 @@ <h1>Class wrapping</h1>

<p>If you have a class <code>Foo</code>, you can check whether it is wrapped by simply checking whether <code>is_wrapped!(Foo)</code> is true. It is important to note that this is <em>not</em> a <code>const bool</code>, it is a <em>runtime</em> check.</p>

<h3>Automatic operator overloading</h3>

<p><i>Docs coming soon...</i></p>

<h3>Examples</h3>

<p>Suppose we have the following simple class:</p>
Expand Down Expand Up @@ -104,6 +120,8 @@ <h3>Examples</h3>
Hey, i+3 is 6
&gt;&gt;&gt; </pre>

</div>

</body>
</html>

16 changes: 15 additions & 1 deletion html_doc/conversion.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,19 @@
</head>

<body>
<div class="nav"><a class="nav" href="index.html">Main</a> | <a class="nav" href="celerid.html">CeleriD</a> | <a class="navcur" href="conversion.html">Type conversion</a> | <a class="nav" href="func_wrapping.html">Function wrapping</a> | <a class="nav" href="class_wrapping.html">Class wrapping</a> | <a class="nav" href="except_wrapping.html">Exception wrapping</a> | <a class="nav" href="dpyobject.html">DPyObject</a></div>
<div id="nav">
<p><big>Contents</big></p>
<a class="nav" href="index.html">Main</a><br />
<a class="nav" href="basics.html">The basics</a><br />
<a class="nav" href="celerid.html">CeleriD</a><br />
<a class="navcur" href="conversion.html">Type conversion</a><br />
<a class="nav" href="func_wrapping.html">Function wrapping</a><br />
<a class="nav" href="class_wrapping.html">Class wrapping</a><br />
<a class="nav" href="except_wrapping.html">Exception wrapping</a><br />
<a class="nav" href="dpyobject.html">DPyObject</a>
</div>

<div id="content">

<h1>Type conversion</h1>

Expand Down Expand Up @@ -58,5 +70,7 @@ <h1>Type conversion</h1>

This function will throw a <code>DPyConversionException</code> if the conversion is not possible.</dd>
</dl>
</div>

</body>
</html>
11 changes: 0 additions & 11 deletions html_doc/ctor_wrap.html

This file was deleted.

58 changes: 0 additions & 58 deletions html_doc/def.html

This file was deleted.

23 changes: 0 additions & 23 deletions html_doc/dg_convert.html

This file was deleted.

Loading

0 comments on commit 7fb1a9b

Please sign in to comment.