PageRenderTime 7ms CodeModel.GetById 1ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/ruby/pointer/runme.rb

#
Ruby | 45 lines | 22 code | 14 blank | 9 comment | 0 complexity | b4c18408acc412b334b3c2b1f5962936 MD5 | raw file
 1# file: runme.rb
 2
 3require 'example'
 4
 5# First create some objects using the pointer library.
 6print "Testing the pointer library\n"
 7a = Example::new_intp()
 8b = Example::new_intp()
 9c = Example::new_intp()
10
11Example::intp_assign(a,37)
12Example::intp_assign(b,42)
13
14print "     a = #{a}\n"
15print "     b = #{b}\n"
16print "     c = #{c}\n"
17
18# Call the add() function with some pointers
19Example::add(a, b, c)
20
21# Now get the result
22r = Example::intp_value(c)
23print "     37 + 42 = #{r}\n"
24
25# Clean up the pointers
26Example::delete_intp(a)
27Example::delete_intp(b)
28Example::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
34print "Trying the typemap library\n"
35r = Example::sub(37, 42)
36print "     37 - 42 = #{r}\n"
37
38# Now try the version with multiple return values
39
40print "Testing multiple return values\n"
41q, r = Example::divide(42, 37)
42print "     42/37 = #{q} remainder #{r}\n"
43
44
45