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
|
# file: runme.py
import example
# Try to set the values of some global variables
example.cvar.ivar = 42
example.cvar.svar = -31000
example.cvar.lvar = 65537
example.cvar.uivar = 123456
example.cvar.usvar = 61000
example.cvar.ulvar = 654321
example.cvar.scvar = -13
example.cvar.ucvar = 251
example.cvar.cvar = "S"
example.cvar.fvar = 3.14159
example.cvar.dvar = 2.1828
example.cvar.strvar = "Hello World"
example.cvar.iptrvar = example.new_int(37)
example.cvar.ptptr = example.new_Point(37, 42)
example.cvar.name = "Bill"
# Now print out the values of the variables
print "Variables (values printed from Python)"
print "ivar =", example.cvar.ivar
print "svar =", example.cvar.svar
print "lvar =", example.cvar.lvar
print "uivar =", example.cvar.uivar
print "usvar =", example.cvar.usvar
print "ulvar =", example.cvar.ulvar
print "scvar =", example.cvar.scvar
print "ucvar =", example.cvar.ucvar
print "fvar =", example.cvar.fvar
print "dvar =", example.cvar.dvar
print "cvar =", example.cvar.cvar
print "strvar =", example.cvar.strvar
print "cstrvar =", example.cvar.cstrvar
print "iptrvar =", example.cvar.iptrvar
print "name =", example.cvar.name
print "ptptr =", example.cvar.ptptr, example.Point_print(example.cvar.ptptr)
print "pt =", example.cvar.pt, example.Point_print(example.cvar.pt)
print "\nVariables (values printed from C)"
example.print_vars()
print "\nNow I'm going to try and modify some read only variables"
print " Tring to set 'path'"
try:
example.cvar.path = "Whoa!"
print "Hey, what's going on?!?! This shouldn't work"
except Exception:
print "Good."
print " Trying to set 'status'"
try:
example.cvar.status = 0
print "Hey, what's going on?!?! This shouldn't work"
except Exception:
print "Good."
print "\nI'm going to try and update a structure variable.\n"
example.cvar.pt = example.cvar.ptptr
print "The new value is"
example.pt_print()
print "You should see the value", example.Point_print(example.cvar.ptptr)
|