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

/tags/ttn-post-libtool-1-4-3-upgrade/SWIG/Examples/python/pointer/runme.py

#
Python | 44 lines | 22 code | 13 blank | 9 comment | 0 complexity | 3d7925b6b318eb7ce75179820841a1aa MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
 1# file: example.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