|
Revision 114, 1.4 kB
(checked in by KirkMcDonald, 2 years ago)
|
Added advanced type conversion. Updated site CSS.
|
| Line | |
|---|
| 1 |
import os.path, sys |
|---|
| 2 |
import distutils.util |
|---|
| 3 |
|
|---|
| 4 |
# Append the directory in which the binaries were placed to Python's sys.path, |
|---|
| 5 |
# then import the D DLL. |
|---|
| 6 |
libDir = os.path.join('build', 'lib.%s-%s' % ( |
|---|
| 7 |
distutils.util.get_platform(), |
|---|
| 8 |
'.'.join(str(v) for v in sys.version_info[:2]) |
|---|
| 9 |
)) |
|---|
| 10 |
sys.path.append(os.path.abspath(libDir)) |
|---|
| 11 |
import testdll |
|---|
| 12 |
|
|---|
| 13 |
testdll.foo() |
|---|
| 14 |
|
|---|
| 15 |
print |
|---|
| 16 |
|
|---|
| 17 |
print testdll.bar(12) |
|---|
| 18 |
|
|---|
| 19 |
print |
|---|
| 20 |
|
|---|
| 21 |
print "testdll.baz():" |
|---|
| 22 |
testdll.baz() |
|---|
| 23 |
print "testdll.baz(20):" |
|---|
| 24 |
testdll.baz(20) |
|---|
| 25 |
print "testdll.baz(30, 'cat'):" |
|---|
| 26 |
testdll.baz(30, 'cat') |
|---|
| 27 |
|
|---|
| 28 |
print |
|---|
| 29 |
|
|---|
| 30 |
print "Testing callback support" |
|---|
| 31 |
def foo(): |
|---|
| 32 |
print "Callback works!" |
|---|
| 33 |
testdll.dg_test(foo) |
|---|
| 34 |
print "Testing delegate wrapping" |
|---|
| 35 |
dg = testdll.func_test() |
|---|
| 36 |
dg() |
|---|
| 37 |
|
|---|
| 38 |
print |
|---|
| 39 |
|
|---|
| 40 |
print "Testing class wrapping" |
|---|
| 41 |
a = testdll.Foo(10) |
|---|
| 42 |
print "Class instantiated!" |
|---|
| 43 |
print "Testing method wrapping:" |
|---|
| 44 |
a.foo() |
|---|
| 45 |
print "Testing property wrapping:" |
|---|
| 46 |
print a.i |
|---|
| 47 |
a.i = 50 |
|---|
| 48 |
print a.i |
|---|
| 49 |
|
|---|
| 50 |
print "Testing opApply wrapping:" |
|---|
| 51 |
try: |
|---|
| 52 |
for i in a: |
|---|
| 53 |
print i |
|---|
| 54 |
except TypeError, e: |
|---|
| 55 |
print "opApply not supported on this platform" |
|---|
| 56 |
|
|---|
| 57 |
print |
|---|
| 58 |
|
|---|
| 59 |
print "Testing exception wrapping" |
|---|
| 60 |
try: |
|---|
| 61 |
testdll.throws() |
|---|
| 62 |
except RuntimeError, e: |
|---|
| 63 |
print "Success: Exception caught!" |
|---|
| 64 |
print e |
|---|
| 65 |
|
|---|
| 66 |
print |
|---|
| 67 |
|
|---|
| 68 |
S = testdll.S |
|---|
| 69 |
s = S() |
|---|
| 70 |
print "s.s = 'hello'" |
|---|
| 71 |
s.s = 'hello' |
|---|
| 72 |
print "s.s" |
|---|
| 73 |
print s.s |
|---|
| 74 |
print "s.write_s()" |
|---|
| 75 |
s.write_s() |
|---|
| 76 |
|
|---|
| 77 |
print |
|---|
| 78 |
|
|---|
| 79 |
print "Testing custom conversion function" |
|---|
| 80 |
print testdll.conv1() |
|---|
| 81 |
testdll.conv2(20) |
|---|
| 82 |
|
|---|
| 83 |
print |
|---|
| 84 |
|
|---|
| 85 |
print '--------' |
|---|
| 86 |
print 'SUCCESS' |
|---|
| 87 |
print '--------' |
|---|