PageRenderTime 6ms CodeModel.GetById 1ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/python/pointer/runme.py

#
Python | 44 lines | 22 code | 13 blank | 9 comment | 0 complexity | c7842eef0bab14564773ce175621f23c MD5 | raw file
 1# file: runme.py
 2
 3import example;
 4
 5# First create some objects using the pointer library.
 6print "Testing the pointer library";
 7a = example.new_intp();
 8b = example.new_intp();
 9c = example.new_intp();
10example.intp_assign(a,37);
11example.intp_assign(b,42);
12
13print "     a =",a
14print "     b =",b
15print "     c =",c
16
17# Call the add() function with some pointers
18example.add(a,b,c)
19
20# Now get the result
21r = example.intp_value(c)
22print "     37 + 42 =",r
23
24# Clean up the pointers
25example.delete_intp(a)
26example.delete_intp(b)
27example.delete_intp(c)
28
29# Now try the typemap library
30# This should be much easier. Now how it is no longer
31# necessary to manufacture pointers.
32
33print "Trying the typemap library";
34r = example.sub(37,42)
35print "     37 - 42 =",r
36
37# Now try the version with multiple return values
38
39print "Testing multiple return values";
40q,r = example.divide(42,37)
41print "     42/37 = %d remainder %d" % (q,r)
42
43
44