Skip to content

Commit

Permalink
testdll improvements
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.dsource.org/projects/pyd/trunk@67 1df65b71-e716-0410-9316-ac55df2b1602
  • Loading branch information
KirkMcDonald authored and KirkMcDonald committed Dec 19, 2006
1 parent a05b5ff commit 3481f83
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 29 deletions.
9 changes: 9 additions & 0 deletions examples/testdll/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ def foo():

print

print "Testing exception wrapping"
try:
testdll.throws()
except RuntimeError, e:
print "Success: Exception caught!"
print e

print

S = testdll.S
s = S()
print "s.s = 'hello'"
Expand Down
29 changes: 0 additions & 29 deletions examples/testdll/testdll.d
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,9 @@ module testdll;

import python;
import pyd.pyd;
//import pyd.ftype;
import std.stdio, std.string;

//import meta.Tuple;
//import meta.Apply;

void apply_test(int i, char[] s) {
writefln("%s %s", i, s);
}

void foo() {
/+
alias Tuple!(int, char[]) T;
T t;
t.val!(0) = 20;
t.val!(1) = "Monkey";
apply(&apply_test, t);
+/
writefln("20 Monkey");
}

Expand Down Expand Up @@ -75,17 +60,6 @@ class Foo {
void i(int j) { m_i = j; }
}

void iter_test(PyObject* c) {
Bar b = new Bar(1, 2, 3, 4, 5);
PyObject* o, res;
foreach(i; b) {
o = _py(i);
res = PyObject_CallFunctionObjArgs(c, o, null);
Py_DECREF(res);
Py_DECREF(o);
}
}

void delegate() func_test() {
return { writefln("Delegate works!"); };
}
Expand Down Expand Up @@ -126,8 +100,6 @@ void throws() {
throw new Exception("Yay! An exception!");
}

//extern (C)
//export void inittestdll() {
extern(C) void PydMain() {
def!(foo);
// Python does not support function overloading. This allows us to wrap
Expand All @@ -139,7 +111,6 @@ extern(C) void PydMain() {
// Default argument support - Now implicit!
def!(baz);
def!(spam);
def!(iter_test);
def!(func_test);
def!(dg_test);
def!(throws);
Expand Down

0 comments on commit 3481f83

Please sign in to comment.