This repository has been archived by the owner on Jan 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
TFUFFIMarshallingInCallbacksTest.class.st
153 lines (118 loc) · 4.98 KB
/
TFUFFIMarshallingInCallbacksTest.class.st
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
Class {
#name : #TFUFFIMarshallingInCallbacksTest,
#superclass : #TFUFFITestCase,
#category : #'ThreadedFFI-UFFI-Tests'
}
{ #category : #testing }
TFUFFIMarshallingInCallbacksTest class >> isAbstract [
^ self == TFUFFIMarshallingInCallbacksTest
]
{ #category : #tests }
TFUFFIMarshallingInCallbacksTest >> assertCharType: name [
self assertType: name value: $A
]
{ #category : #tests }
TFUFFIMarshallingInCallbacksTest >> assertSignedIntType: name [
self assertType: name value: -65
]
{ #category : #tests }
TFUFFIMarshallingInCallbacksTest >> assertType: aType value: aValue [
| callbackGotValue |
callbackGotValue := self call: aType value: aValue.
self assert: callbackGotValue equals: aValue.
]
{ #category : #tests }
TFUFFIMarshallingInCallbacksTest >> assertUnsignedIntType: name [
self assertType: name value: 65
]
{ #category : #tests }
TFUFFIMarshallingInCallbacksTest >> call: aName type: aType value: aValue [
| callback received |
callback := self
newCallbackWithSignature: { #void . aType }
block: [ :a | received := a ].
self
perform: ('simple_callback_f_', aName, ':value:') asSymbol
withArguments: { callback . aValue}.
^ received
]
{ #category : #tests }
TFUFFIMarshallingInCallbacksTest >> call: aName value: aValue [
^ self call: aName type: { aName asSymbol } value: aValue
]
{ #category : #'ffi-calls' }
TFUFFIMarshallingInCallbacksTest >> simple_callback_f_char: callback value: aValue [
^ self ffiCall: #(void simple_callback_f_char(void *callback, char aValue))
]
{ #category : #'ffi-calls' }
TFUFFIMarshallingInCallbacksTest >> simple_callback_f_double: callback value: aValue [
^ self ffiCall: #(void simple_callback_f_double(void *callback, double aValue))
]
{ #category : #'ffi-calls' }
TFUFFIMarshallingInCallbacksTest >> simple_callback_f_float: callback value: aValue [
^ self ffiCall: #(void simple_callback_f_float(void *callback, float aValue))
]
{ #category : #'ffi-calls' }
TFUFFIMarshallingInCallbacksTest >> simple_callback_f_int16: callback value: aValue [
^ self ffiCall: #(void simple_callback_f_int16_t(void *callback, int16 aValue))
]
{ #category : #'ffi-calls' }
TFUFFIMarshallingInCallbacksTest >> simple_callback_f_int32: callback value: aValue [
^ self ffiCall: #(void simple_callback_f_int32_t(void *callback, int32 aValue))
]
{ #category : #'ffi-calls' }
TFUFFIMarshallingInCallbacksTest >> simple_callback_f_int64: callback value: aValue [
^ self ffiCall: #(void simple_callback_f_int64_t(void *callback, int64 aValue))
]
{ #category : #'ffi-calls' }
TFUFFIMarshallingInCallbacksTest >> simple_callback_f_int8: callback value: aValue [
^ self ffiCall: #(void simple_callback_f_int8_t(void *callback, int8 aValue))
]
{ #category : #'ffi-calls' }
TFUFFIMarshallingInCallbacksTest >> simple_callback_f_int: callback value: aValue [
^ self ffiCall: #(void simple_callback_f_int(void *callback, int aValue))
]
{ #category : #'ffi-calls' }
TFUFFIMarshallingInCallbacksTest >> simple_callback_f_long: callback value: aValue [
^ self ffiCall: #(void simple_callback_f_long(void *callback, long aValue))
]
{ #category : #'ffi-calls' }
TFUFFIMarshallingInCallbacksTest >> simple_callback_f_pointer: aCallback value: aValue [
^ self ffiCall: #(void simple_callback_f_ulonglong(void *aCallback, void* aValue))
]
{ #category : #'ffi-calls' }
TFUFFIMarshallingInCallbacksTest >> simple_callback_f_short: callback value: aValue [
^ self ffiCall: #(void simple_callback_f_short(void *callback, short aValue))
]
{ #category : #'ffi-calls' }
TFUFFIMarshallingInCallbacksTest >> simple_callback_f_uchar: callback value: aValue [
^ self ffiCall: #(void simple_callback_f_uchar(void *callback, uchar aValue))
]
{ #category : #'ffi-calls' }
TFUFFIMarshallingInCallbacksTest >> simple_callback_f_uint16: callback value: aValue [
^ self ffiCall: #(void simple_callback_f_uint16_t(void *callback, uint16 aValue))
]
{ #category : #'ffi-calls' }
TFUFFIMarshallingInCallbacksTest >> simple_callback_f_uint32: callback value: aValue [
^ self ffiCall: #(void simple_callback_f_uint32_t(void *callback, uint32 aValue))
]
{ #category : #'ffi-calls' }
TFUFFIMarshallingInCallbacksTest >> simple_callback_f_uint64: callback value: aValue [
^ self ffiCall: #(void simple_callback_f_uint64_t(void *callback, uint64 aValue))
]
{ #category : #'ffi-calls' }
TFUFFIMarshallingInCallbacksTest >> simple_callback_f_uint8: callback value: aValue [
^ self ffiCall: #(void simple_callback_f_uint8_t(void *callback, uint8 aValue))
]
{ #category : #'ffi-calls' }
TFUFFIMarshallingInCallbacksTest >> simple_callback_f_uint: callback value: aValue [
^ self ffiCall: #(void simple_callback_f_uint(void *callback, uint aValue))
]
{ #category : #'ffi-calls' }
TFUFFIMarshallingInCallbacksTest >> simple_callback_f_ulong: callback value: aValue [
^ self ffiCall: #(void simple_callback_f_ulong(void *callback, ulong aValue))
]
{ #category : #'ffi-calls' }
TFUFFIMarshallingInCallbacksTest >> simple_callback_f_ushort: callback value: aValue [
^ self ffiCall: #(void simple_callback_f_ushort(void *callback, ushort aValue))
]