From 3481f8385b01a06110106cc03160f84072168cd9 Mon Sep 17 00:00:00 2001 From: KirkMcDonald Date: Tue, 19 Dec 2006 06:33:06 +0000 Subject: [PATCH] testdll improvements git-svn-id: http://svn.dsource.org/projects/pyd/trunk@67 1df65b71-e716-0410-9316-ac55df2b1602 --- examples/testdll/test.py | 9 +++++++++ examples/testdll/testdll.d | 29 ----------------------------- 2 files changed, 9 insertions(+), 29 deletions(-) diff --git a/examples/testdll/test.py b/examples/testdll/test.py index c5fcedb..c6e0107 100644 --- a/examples/testdll/test.py +++ b/examples/testdll/test.py @@ -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'" diff --git a/examples/testdll/testdll.d b/examples/testdll/testdll.d index 3c483ce..dcc2ba2 100644 --- a/examples/testdll/testdll.d +++ b/examples/testdll/testdll.d @@ -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"); } @@ -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!"); }; } @@ -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 @@ -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);