summaryrefslogtreecommitdiffstats
path: root/Mac/Demo/calldll/testcalldll.py
blob: ef176d83fc731a37450f105414b4627057f74738 (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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import calldll
import macfs
import sys
import MacOS
import Res

fss, ok = macfs.PromptGetFile("Show me calldll.ppc.slb")

lib = calldll.getdiskfragment(fss, 'calldll.ppc.slb')

cdll_b_bbbbbbbb = calldll.newcall(lib.cdll_b_bbbbbbbb, 'Byte', 'InByte', 'InByte', 
				'InByte', 'InByte','InByte', 'InByte','InByte', 'InByte')
cdll_h_hhhhhhhh = calldll.newcall(lib.cdll_h_hhhhhhhh, 'Short', 'InShort', 'InShort', 
				'InShort', 'InShort','InShort', 'InShort','InShort', 'InShort')
cdll_l_llllllll = calldll.newcall(lib.cdll_l_llllllll, 'Long', 'InLong', 'InLong', 
				'InLong', 'InLong','InLong', 'InLong','InLong', 'InLong')
				
cdll_N_ssssssss = calldll.newcall(lib.cdll_N_ssssssss, 'None', 'InString', 'InString',
				'InString', 'InString', 'InString', 'InString', 'InString', 'InString')
				
cdll_o_l = calldll.newcall(lib.cdll_o_l, 'OSErr', 'InLong')

cdll_N_pp = calldll.newcall(lib.cdll_N_pp, 'None', 'InPstring', 'OutPstring')

cdll_N_bb = calldll.newcall(lib.cdll_N_bb, 'None', 'InByte', 'OutByte')
cdll_N_hh = calldll.newcall(lib.cdll_N_hh, 'None', 'InShort', 'OutShort')
cdll_N_ll = calldll.newcall(lib.cdll_N_ll, 'None', 'InLong', 'OutLong')
cdll_N_sH = calldll.newcall(lib.cdll_N_sH, 'None', 'InString', 'InHandle')

print 'Test cdll_b_bbbbbbbb'
rv = cdll_b_bbbbbbbb(1, 2, 3, 4, 5, 6, 7, 8)
if rv == 36:
	print 'ok.'
else:
	print 'Failed, returned', rv
	
print 'Test cdll_b_bbbbbbbb negative'
rv = cdll_b_bbbbbbbb(-1, -2, -3, -4, -5, -6, -7, -8)
if rv == -36:
	print 'ok.'
else:
	print 'Failed, returned', rv

print 'Test cdll_h_hhhhhhhh'
rv = cdll_h_hhhhhhhh(1, 2, 3, 4, 5, 6, 7, 8)
if rv == 36:
	print 'ok.'
else:
	print 'Failed, returned', rv
	
print 'Test cdll_h_hhhhhhhh negative'
rv = cdll_h_hhhhhhhh(-1, -2, -3, -4, -5, -6, -7, -8)
if rv == -36:
	print 'ok.'
else:
	print 'Failed, returned', rv

print 'Test cdll_l_llllllll'
rv = cdll_l_llllllll(1, 2, 3, 4, 5, 6, 7, 8)
if rv == 36:
	print 'ok.'
else:
	print 'Failed, returned', rv
	
print 'Test cdll_l_llllllll negative'
rv = cdll_l_llllllll(-1, -2, -3, -4, -5, -6, -7, -8)
if rv == -36:
	print 'ok.'
else:
	print 'Failed, returned', rv
	
print 'Test cdll_N_ssssssss'
print 'Should print one two three four five six seven eight'
rv = cdll_N_ssssssss('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight')
if rv == None:
	print 'ok.'
else:
	print 'Failed, returned', rv
	
print 'Test cdll_o_l(0)'
rv = cdll_o_l(0)
if rv == None:
	print 'ok.'
else:
	print 'Error, returned', rv
	
print 'Test cdll_o_l(-100)'
try:
	rv = cdll_o_l(-100)
	print 'Error, did not raise exception, returned', rv
except MacOS.Error, arg:
	if arg[0] == -100:
		print 'ok.'
	else:
		print 'Error, returned incorrect exception arg:', arg[0]
	
print 'Test cdll_N_pp'
rv = cdll_N_pp('pascal string')
if rv == 'Was: pascal string':
	print 'ok.'
else:
	print 'Failed, returned', `rv`
	
print 'Test cdll_N_bb'
rv = cdll_N_bb(-100)
if rv == -100:
	print 'ok.'
else:
	print 'Failed, returned', rv
	
print 'Test cdll_N_hh'
rv = cdll_N_hh(-100)
if rv == -100:
	print 'ok.'
else:
	print 'Failed, returned', rv
	
print 'Test cdll_N_ll'
rv = cdll_N_ll(-100)
if rv == -100:
	print 'ok.'
else:
	print 'Failed, returned', rv

print 'Test cdll_N_sH'
h = Res.Resource('xyz')
rv = cdll_N_sH('new data', h)
if rv == None and h.data == 'new data':
	print 'ok.'
else:
	print 'Failed, rv is', rv, 'and handle data is', `rv.data`
sys.exit(1)