-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: http://svn.dsource.org/projects/pyd/trunk@11 1df65b71-e71…
…6-0410-9316-ac55df2b1602
- Loading branch information
KirkMcDonald
authored and
KirkMcDonald
committed
Jun 24, 2006
1 parent
b7f95e9
commit 77580e2
Showing
9 changed files
with
820 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
C:\dmd\dmd\bin\dmd.exe -o- -Ddpyd\wiki_doc pyd\def.d pyd\exception.d pyd\ftype.d pyd\lazy_load.d pyd\make_object.d pyd\object.d pyd\pyd.d pyd\wiki_doc\wiki_doc\wikidoc.ddoc | ||
|
||
pause |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<h1>pyd.def</h1> | ||
<!-- Generated by Ddoc from pyd\def.d --> | ||
<br><br> | ||
<dl><dt><big>template <u>def</u>(char[] name,alias fn)</big></dt> | ||
<dd>Wraps a D function, making it callable from Python. | ||
<br><br> | ||
For example: | ||
<pre class="d_code">import pyd.pyd; | ||
char[] foo(int i) { | ||
if (i > 10) { | ||
return "It's greater than 10!"; | ||
} else { | ||
return "It's less than 10!"; | ||
} | ||
} | ||
extern (C) | ||
export void inittestdll() { | ||
def!("foo", foo); | ||
module_init("testdll"); | ||
}</pre> | ||
<br><br> | ||
|
||
And in Python: | ||
<br><br> | ||
|
||
<pre class="d_code">>>> import testdll | ||
>>> print testdll.foo(20) | ||
It's greater than 10!</pre> | ||
|
||
<br><br> | ||
|
||
<dl></dl> | ||
</dd> | ||
<dt><big>void <u>module_init</u>(char[] <i>name</i>); | ||
</big></dt> | ||
<dd>Module initialization function. Should be called after the last call to def. | ||
|
||
<br><br> | ||
|
||
</dd> | ||
</dl> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<h1>pyd.exception</h1> | ||
<!-- Generated by Ddoc from pyd\exception.d --> | ||
<br><br> | ||
<dl><dt><big>void <u>handle_exception</u>(); | ||
</big></dt> | ||
<dd>This function first checks if a Python exception is set, and then (if one | ||
is) pulls it out, stuffs it in a PythonException, and throws that exception. | ||
<br><br> | ||
If this exception is never caught, it will be handled by the function | ||
wrapping template and passed right back into Python as though nothing | ||
happened. | ||
|
||
<br><br> | ||
|
||
</dd> | ||
<dt><big>class <u>PythonException</u>: object.Exception; | ||
</big></dt> | ||
<dd>This simple exception class holds a Python exception. | ||
|
||
<br><br> | ||
|
||
<dl></dl> | ||
</dd> | ||
</dl> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<h1>pyd.ftype</h1> | ||
<!-- Generated by Ddoc from pyd\ftype.d --> | ||
This module contains templates for inferring the number of arguments, | ||
the return type, and argument types of an arbitrary function pointer. | ||
<br><br> | ||
Portions of this module were automatically generated by Python modules. | ||
|
||
<br><br> | ||
<b>Authors:</b><br> | ||
Daniel Keep, Tomasz Stachowiak | ||
<br><br> | ||
<b>Date:</b><br> | ||
Fri Jun 23 20:44:59 2006 | ||
|
||
|
||
<br><br> | ||
|
||
<dl><dt><big>template <u>NumberOfArgs</u>(Tf)</big></dt> | ||
<dd>Derives the number of arguments the passed function type accepts. It only | ||
works on functions with 10 or fewer arguments. | ||
|
||
<br><br> | ||
|
||
<dl></dl> | ||
</dd> | ||
<dt><big>template <u>ReturnType</u>(T)</big></dt> | ||
<dd>Derives the return type of the passed function type. | ||
|
||
<br><br> | ||
|
||
<dl></dl> | ||
</dd> | ||
<dt><big>template <u>ArgType</u>(Tf,uint n)</big></dt> | ||
<dd>Derives the type of an individual argument of function Tf. | ||
<br><br> | ||
<b>Params:</b><br> | ||
<table><tr><td>Tf</td> | ||
<td>A function pointer type</td></tr> | ||
<tr><td>n</td> | ||
<td>The 1-indexed function argument to get the type of, e.g.: | ||
<pre class="d_code">int func(int, char, real); | ||
static assert( is(char == ArgType(&func, 2)) );</pre></td></tr> | ||
</table><br> | ||
|
||
<dl></dl> | ||
</dd> | ||
</dl> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<h1>pyd.lazy_load</h1> | ||
<!-- Generated by Ddoc from pyd\lazy_load.d --> | ||
<br><br> | ||
<dl><dt><big>template <u>lazy_load</u>(alias D,alias P)</big></dt> | ||
<dd>This nifty template will lazily-load singleton objects, only actually | ||
allocating them the first time they are used. This can be signifigant in a | ||
small application, where few or even none of the many singletons in this | ||
API are needed. | ||
<br><br> | ||
This is used internally, and is probably not very useful to the end user. | ||
|
||
<br><br> | ||
|
||
<dl></dl> | ||
</dd> | ||
</dl> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<h1>pyd.make_object</h1> | ||
<!-- Generated by Ddoc from pyd\make_object.d --> | ||
This module contains some useful type conversion functions. There are two | ||
interesting operations involved here: | ||
<br><br> | ||
PyObject* -> D type | ||
<br><br> | ||
|
||
D type -> PyObject* | ||
<br><br> | ||
|
||
The former is handled by d_type, the latter by _py. The py function is | ||
provided as a convenience to directly convert a D type into an instance of | ||
DPyObject. | ||
|
||
<br><br> | ||
|
||
<dl><dt><big>template <u>_py</u>(T)</big></dt> | ||
<dd><br><br> | ||
<dl><dt><big>PyObject* <u>_py</u>(T <i>t</i>); | ||
</big></dt> | ||
<dd>Returns a new (owned) reference to a Python object based on the passed | ||
argument. If the passed argument is a PyObject*, this "steals" the | ||
reference. (In other words, it returns the PyObject* without changing its | ||
reference count.) If the passed argument is a DPyObject, this returns a new | ||
reference to whatever the DPyObject holds a reference to. | ||
<br><br> | ||
If the passed argument can'<i>t</i> be converted to a PyObject, a Python | ||
RuntimeError will be raised and this function will return <b>null</b>. | ||
|
||
<br><br> | ||
|
||
</dd> | ||
</dl> | ||
</dd> | ||
<dt><big>template <u>py</u>(T)</big></dt> | ||
<dd><br><br> | ||
<dl><dt><big>DPyObject <u>py</u>(T <i>t</i>); | ||
</big></dt> | ||
<dd>Constructs an object based on the type of the argument passed in. | ||
<br><br> | ||
For example, calling <u>py</u>(10) would return a DPyObject holding the value 10. | ||
<br><br> | ||
|
||
Calling this with a DPyObject will return back a reference to the very same | ||
DPyObject. | ||
<br><br> | ||
|
||
Calling this with a PyObject* will "steal" the reference. | ||
|
||
<br><br> | ||
|
||
</dd> | ||
</dl> | ||
</dd> | ||
<dt><big>class <u>DPyConversionException</u>: object.Exception; | ||
</big></dt> | ||
<dd>An exception class used by d_type. | ||
|
||
<br><br> | ||
|
||
<dl></dl> | ||
</dd> | ||
<dt><big>template <u>d_type</u>(T)</big></dt> | ||
<dd><br><br> | ||
<dl><dt><big>T <u>d_type</u>(PyObject* <i>o</i>); | ||
</big></dt> | ||
<dd>This converts a PyObject* to a D type. The template argument is the type to | ||
convert to. The function argument is the PyObject* to convert. For instance: | ||
<br><br> | ||
<pre class="d_code">PyObject* i = PyInt_FromLong(20); | ||
int n = d_type!(int)(i); | ||
assert(n == 20);</pre> | ||
<br><br> | ||
|
||
This throws a DPyConversionException if the PyObject can't be converted to | ||
the given D type. | ||
|
||
<br><br> | ||
|
||
</dd> | ||
</dl> | ||
</dd> | ||
</dl> | ||
|
Oops, something went wrong.