blob: b748384cee07aa5ef82b9d8b2adf70f135756a6c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# file: runme.rb
require 'example'
# Try to set the values of some global variables
Example.ivar = 42
Example.svar = -31000
Example.lvar = 65537
Example.uivar = 123456
Example.usvar = 61000
Example.ulvar = 654321
Example.scvar = -13
Example.ucvar = 251
Example.cvar = "S"
Example.fvar = 3.14159
Example.dvar = 2.1828
Example.strvar = "Hello World"
Example.iptrvar= Example.new_int(37)
Example.ptptr = Example.new_Point(37,42)
Example.name = "Bill"
# Now print out the values of the variables
puts "Variables (values printed from Ruby)"
puts "ivar = #{Example.ivar}"
puts "svar = #{Example.svar}"
puts "lvar = #{Example.lvar}"
puts "uivar = #{Example.uivar}"
puts "usvar = #{Example.usvar}"
puts "ulvar = #{Example.ulvar}"
puts "scvar = #{Example.scvar}"
puts "ucvar = #{Example.ucvar}"
puts "fvar = #{Example.fvar}"
puts "dvar = #{Example.dvar}"
puts "cvar = #{Example.cvar}"
puts "strvar = #{Example.strvar}"
puts "cstrvar = #{Example.cstrvar}"
puts "iptrvar = #{Example.iptrvar}"
puts "name = #{Example.name}"
puts "ptptr = #{Example.ptptr} (#{Example.Point_print(Example.ptptr)})"
puts "pt = #{Example.pt} (#{Example.Point_print(Example.pt)})"
puts "\nVariables (values printed from C)"
Example.print_vars()
puts "\nNow I'm going to try and modify some read only variables";
puts " Trying to set 'path'";
begin
Example.path = "Whoa!"
puts "Hey, what's going on?!?! This shouldn't work"
rescue NameError
puts "Good."
end
puts " Trying to set 'status'";
begin
Example.status = 0
puts "Hey, what's going on?!?! This shouldn't work"
rescue NameError
puts "Good."
end
puts "\nI'm going to try and update a structure variable.\n"
Example.pt = Example.ptptr
puts "The new value is"
Example.pt_print()
puts "You should see the value #{Example.Point_print(Example.ptptr)}"
|