-
Notifications
You must be signed in to change notification settings - Fork 65
/
LibFFICIF.class.st
137 lines (109 loc) · 2.42 KB
/
LibFFICIF.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
Class {
#name : #LibFFICIF,
#superclass : #VMStructType,
#instVars : [
'address',
'libFFI',
'abi',
'nargs',
'arg_types',
'rtype',
'bytes',
'flags'
],
#category : #'VMMaker-FFI'
}
{ #category : #translation }
LibFFICIF class >> filteredInstVarNames [
"Eliminate the obvious simulation-only inst vars"
^ super filteredInstVarNames copyWithoutAll: #(address libFFI)
]
{ #category : #translation }
LibFFICIF class >> instVarNamesAndTypesForTranslationDo: aBinaryBlock [
self filteredInstVarNames do:
[:ivn|
aBinaryBlock
value: ivn
value: (ivn caseOf: {
['abi'] -> [#'ffi_abi'].
['nargs'] -> [#'unsigned int'].
['arg_types'] -> [#'ffi_type **'].
['rtype'] -> [#'ffi_type *'].
['bytes'] -> [#'unsigned int'].
['flags'] -> [#'unsigned int'].
} otherwise: [ self halt ])]
]
{ #category : #translation }
LibFFICIF class >> printTypedefOn: aStream [
"This is already defined in ffi.h"
]
{ #category : #translation }
LibFFICIF class >> structTypeName [
^ 'ffi_cif'
]
{ #category : #accessing }
LibFFICIF >> address [
<doNotGenerate>
^ address
]
{ #category : #accessing }
LibFFICIF >> address: anInteger [
<doNotGenerate>
address := anInteger
]
{ #category : #accessing }
LibFFICIF >> argTypeAt: anIndex [
^ self arg_types at: anIndex
]
{ #category : #accessing }
LibFFICIF >> arg_types [
^ arg_types
]
{ #category : #simulation }
LibFFICIF >> argumentTypes: aCollectionOfTypes [
<doNotGenerate>
nargs := aCollectionOfTypes size.
arg_types := CArrayAccessor on: aCollectionOfTypes
]
{ #category : #accessing }
LibFFICIF >> interpreter [
<doNotGenerate>
^ libFFI interpreter
]
{ #category : #accessing }
LibFFICIF >> libFFI: aLibFFI [
<doNotGenerate>
libFFI := aLibFFI
]
{ #category : #accessing }
LibFFICIF >> nargs [
^ nargs
]
{ #category : #accessing }
LibFFICIF >> numberArguments [
^ self nargs
]
{ #category : #testing }
LibFFICIF >> parametersToSmalltalk: parameters [
<doNotGenerate>
^ arg_types getObject collectWithIndex: [ :type :index |
type marshallToSmalltalk: (parameters at: index - 1) ].
]
{ #category : #accessing }
LibFFICIF >> returnType [
<inline: #always>
^ self rtype
]
{ #category : #accessing }
LibFFICIF >> returnType: aType [
<inline: #always>
self rtype: aType
]
{ #category : #accessing }
LibFFICIF >> rtype [
^ rtype
]
{ #category : #accessing }
LibFFICIF >> rtype: aLibFFIType [
rtype := aLibFFIType
]