Upstream version 1.3.40
[profile/ivi/swig.git] / Examples / ruby / pointer / runme.rb
1 # file: runme.rb
2
3 require 'example'
4
5 # First create some objects using the pointer library.
6 print "Testing the pointer library\n"
7 a = Example::new_intp()
8 b = Example::new_intp()
9 c = Example::new_intp()
10
11 Example::intp_assign(a,37)
12 Example::intp_assign(b,42)
13
14 print "     a = #{a}\n"
15 print "     b = #{b}\n"
16 print "     c = #{c}\n"
17
18 # Call the add() function with some pointers
19 Example::add(a, b, c)
20
21 # Now get the result
22 r = Example::intp_value(c)
23 print "     37 + 42 = #{r}\n"
24
25 # Clean up the pointers
26 Example::delete_intp(a)
27 Example::delete_intp(b)
28 Example::delete_intp(c)
29
30 # Now try the typemap library
31 # This should be much easier. Now how it is no longer
32 # necessary to manufacture pointers.
33
34 print "Trying the typemap library\n"
35 r = Example::sub(37, 42)
36 print "     37 - 42 = #{r}\n"
37
38 # Now try the version with multiple return values
39
40 print "Testing multiple return values\n"
41 q, r = Example::divide(42, 37)
42 print "     42/37 = #{q} remainder #{r}\n"
43
44
45