Changeset 67

Show
Ignore:
Timestamp:
12/19/06 01:33:06 (2 years ago)
Author:
KirkMcDonald
Message:

testdll improvements

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/examples/testdll/test.py

    r66 r67  
    5050print 
    5151 
     52print "Testing exception wrapping" 
     53try: 
     54    testdll.throws() 
     55except RuntimeError, e: 
     56    print "Success: Exception caught!" 
     57    print e 
     58 
     59print 
     60 
    5261S = testdll.S 
    5362s = S() 
  • trunk/examples/testdll/testdll.d

    r66 r67  
    33import python; 
    44import pyd.pyd; 
    5 //import pyd.ftype; 
    65import std.stdio, std.string; 
    76 
    8 //import meta.Tuple; 
    9 //import meta.Apply; 
    10  
    11 void apply_test(int i, char[] s) { 
    12     writefln("%s %s", i, s); 
    13 } 
    14  
    157void foo() { 
    16     /+ 
    17     alias Tuple!(int, char[]) T; 
    18     T t; 
    19     t.val!(0) = 20; 
    20     t.val!(1) = "Monkey"; 
    21     apply(&apply_test, t); 
    22     +/ 
    238    writefln("20 Monkey"); 
    249} 
     
    7661} 
    7762 
    78 void iter_test(PyObject* c) { 
    79     Bar b = new Bar(1, 2, 3, 4, 5); 
    80     PyObject* o, res; 
    81     foreach(i; b) { 
    82         o = _py(i); 
    83         res = PyObject_CallFunctionObjArgs(c, o, null); 
    84         Py_DECREF(res); 
    85         Py_DECREF(o); 
    86     } 
    87 } 
    88  
    8963void delegate() func_test() { 
    9064    return { writefln("Delegate works!"); }; 
     
    127101} 
    128102 
    129 //extern (C) 
    130 //export void inittestdll() { 
    131103extern(C) void PydMain() { 
    132104    def!(foo); 
     
    140112    def!(baz); 
    141113    def!(spam); 
    142     def!(iter_test); 
    143114    def!(func_test); 
    144115    def!(dg_test);