|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
// Start of FFI v.0.1.0 |
|
4
|
|
|
|
|
5
|
|
|
namespace { |
|
6
|
|
|
use FFI\CData; |
|
7
|
|
|
use FFI\CType; |
|
8
|
|
|
use FFI\ParserException; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* FFI class provides access to a simple way to call native functions, |
|
12
|
|
|
* access native variables and create/access data structures defined |
|
13
|
|
|
* in C language. |
|
14
|
|
|
* |
|
15
|
|
|
* @since 7.4 |
|
16
|
|
|
*/ |
|
17
|
|
|
class FFI |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* The method creates a binding on the existing C function. |
|
21
|
|
|
* |
|
22
|
|
|
* All variables and functions defined by first arguments are bound |
|
23
|
|
|
* to corresponding native symbols in DSO library and then may be |
|
24
|
|
|
* accessed as FFI object methods and properties. C types of argument, |
|
25
|
|
|
* return value and variables are automatically converted to/from PHP |
|
26
|
|
|
* types (if possible). Otherwise, they are wrapped in a special CData |
|
27
|
|
|
* proxy object and may be accessed by elements. |
|
28
|
|
|
* |
|
29
|
|
|
* @param string $code The collection of C declarations. |
|
30
|
|
|
* @param string|null $lib DSO library. |
|
31
|
|
|
* @return FFI |
|
32
|
|
|
* @throws ParserException |
|
33
|
|
|
*/ |
|
34
|
|
|
public static function cdef(string $code = '', ?string $lib = null): FFI {} |
|
|
|
|
|
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* <p>Instead of embedding of a long C definition into PHP string, |
|
38
|
|
|
* and creating FFI through FFI::cdef(), it's possible to separate |
|
39
|
|
|
* it into a C header file. Note, that C preprocessor directives |
|
40
|
|
|
* (e.g. #define or #ifdef) are not supported. And only a couple of |
|
41
|
|
|
* special macros may be used especially for FFI.</p> |
|
42
|
|
|
* |
|
43
|
|
|
* <code> |
|
44
|
|
|
* #define FFI_LIB "libc.so.6" |
|
45
|
|
|
* |
|
46
|
|
|
* int printf(const char *format, ...); |
|
47
|
|
|
* </code> |
|
48
|
|
|
* |
|
49
|
|
|
* Here, FFI_LIB specifies, that the given library should be loaded. |
|
50
|
|
|
* |
|
51
|
|
|
* <code> |
|
52
|
|
|
* $ffi = FFI::load(__DIR__ . "/printf.h"); |
|
53
|
|
|
* $ffi->printf("Hello world!\n"); |
|
54
|
|
|
* </code> |
|
55
|
|
|
* |
|
56
|
|
|
* @param string $filename |
|
57
|
|
|
* @return FFI|null |
|
58
|
|
|
*/ |
|
59
|
|
|
public static function load(string $filename): ?FFI {} |
|
|
|
|
|
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* FFI definition parsing and shared library loading may take |
|
63
|
|
|
* significant time. It's not useful to do it on each HTTP request in |
|
64
|
|
|
* WEB environment. However, it's possible to pre-load FFI definitions |
|
65
|
|
|
* and libraries at php startup, and instantiate FFI objects when |
|
66
|
|
|
* necessary. Header files may be extended with FFI_SCOPE define |
|
67
|
|
|
* (default pre-loading scope is "C"). This name is going to be |
|
68
|
|
|
* used as FFI::scope() argument. It's possible to pre-load few |
|
69
|
|
|
* files into a single scope. |
|
70
|
|
|
* |
|
71
|
|
|
* <code> |
|
72
|
|
|
* #define FFI_LIB "libc.so.6" |
|
73
|
|
|
* #define FFI_SCOPE "libc" |
|
74
|
|
|
* |
|
75
|
|
|
* int printf(const char *format, ...); |
|
76
|
|
|
* </code> |
|
77
|
|
|
* |
|
78
|
|
|
* These files are loaded through the same FFI::load() load function, |
|
79
|
|
|
* executed from file loaded by opcache.preload php.ini directive. |
|
80
|
|
|
* |
|
81
|
|
|
* <code> |
|
82
|
|
|
* ffi.preload=/etc/php/ffi/printf.h |
|
83
|
|
|
* </code> |
|
84
|
|
|
* |
|
85
|
|
|
* Finally, FFI::scope() instantiate an FFI object, that implements |
|
86
|
|
|
* all C definition from the given scope. |
|
87
|
|
|
* |
|
88
|
|
|
* <code> |
|
89
|
|
|
* $ffi = FFI::scope("libc"); |
|
90
|
|
|
* $ffi->printf("Hello world!\n"); |
|
91
|
|
|
* </code> |
|
92
|
|
|
* |
|
93
|
|
|
* @param string $name |
|
94
|
|
|
* @return FFI |
|
95
|
|
|
*/ |
|
96
|
|
|
public static function scope(string $name): FFI {} |
|
|
|
|
|
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* Method that creates an arbitrary C structure. |
|
100
|
|
|
* |
|
101
|
|
|
* @param string|CType $type |
|
102
|
|
|
* @param bool $owned |
|
103
|
|
|
* @param bool $persistent |
|
104
|
|
|
* @return CData|null |
|
105
|
|
|
* @throws ParserException |
|
106
|
|
|
*/ |
|
107
|
|
|
public static function new($type, bool $owned = true, bool $persistent = false): ?CData {} |
|
|
|
|
|
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* Manually removes previously created "not-owned" data structure. |
|
111
|
|
|
* |
|
112
|
|
|
* @param CData $ptr |
|
113
|
|
|
* @return void |
|
114
|
|
|
*/ |
|
115
|
|
|
public static function free(CData $ptr): void {} |
|
|
|
|
|
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* Casts given $pointer to another C type, specified by C declaration |
|
119
|
|
|
* string or FFI\CType object. |
|
120
|
|
|
* |
|
121
|
|
|
* This function may be called statically and use only predefined |
|
122
|
|
|
* types, or as a method of previously created FFI object. In last |
|
123
|
|
|
* case the first argument may reuse all type and tag names |
|
124
|
|
|
* defined in FFI::cdef(). |
|
125
|
|
|
* |
|
126
|
|
|
* @param CType|string $type |
|
127
|
|
|
* @param CData|int|float|bool|null $ptr |
|
128
|
|
|
* @return CData|null |
|
129
|
|
|
*/ |
|
130
|
|
|
public static function cast($type, $ptr): ?CData {} |
|
|
|
|
|
|
131
|
|
|
|
|
132
|
|
|
/** |
|
133
|
|
|
* This function creates and returns a FFI\CType object, representng |
|
134
|
|
|
* type of the given C type declaration string. |
|
135
|
|
|
* |
|
136
|
|
|
* FFI::type() may be called statically and use only predefined types, |
|
137
|
|
|
* or as a method of previously created FFI object. In last case the |
|
138
|
|
|
* first argument may reuse all type and tag names defined in |
|
139
|
|
|
* FFI::cdef(). |
|
140
|
|
|
* |
|
141
|
|
|
* @param string $type |
|
142
|
|
|
* @return CType|null |
|
143
|
|
|
*/ |
|
144
|
|
|
public static function type(string $type): ?CType {} |
|
|
|
|
|
|
145
|
|
|
|
|
146
|
|
|
/** |
|
147
|
|
|
* This function returns the FFI\CType object, representing the type of |
|
148
|
|
|
* the given FFI\CData object. |
|
149
|
|
|
* |
|
150
|
|
|
* @param CData $ptr |
|
151
|
|
|
* @return CType |
|
152
|
|
|
*/ |
|
153
|
|
|
public static function typeof(CData $ptr): CType {} |
|
|
|
|
|
|
154
|
|
|
|
|
155
|
|
|
/** |
|
156
|
|
|
* Constructs a new C array type with elements of $type and |
|
157
|
|
|
* dimensions specified by $dimensions. |
|
158
|
|
|
* |
|
159
|
|
|
* @param CType $type |
|
160
|
|
|
* @param int[] $dimensions |
|
161
|
|
|
* @return CType |
|
162
|
|
|
*/ |
|
163
|
|
|
public static function arrayType(CType $type, array $dimensions): CType {} |
|
|
|
|
|
|
164
|
|
|
|
|
165
|
|
|
/** |
|
166
|
|
|
* Returns C pointer to the given C data structure. The pointer is |
|
167
|
|
|
* not "owned" and won't be free. Anyway, this is a potentially |
|
168
|
|
|
* unsafe operation, because the life-time of the returned pointer |
|
169
|
|
|
* may be longer than life-time of the source object, and this may |
|
170
|
|
|
* cause dangling pointer dereference (like in regular C). |
|
171
|
|
|
* |
|
172
|
|
|
* @param CData $ptr |
|
173
|
|
|
* @return CData |
|
174
|
|
|
*/ |
|
175
|
|
|
public static function addr(CData $ptr): CData {} |
|
|
|
|
|
|
176
|
|
|
|
|
177
|
|
|
/** |
|
178
|
|
|
* Returns size of C data type of the given FFI\CData or FFI\CType. |
|
179
|
|
|
* |
|
180
|
|
|
* @param CData|CType $ptr |
|
181
|
|
|
* @return int |
|
182
|
|
|
*/ |
|
183
|
|
|
public static function sizeof($ptr): int {} |
|
|
|
|
|
|
184
|
|
|
|
|
185
|
|
|
/** |
|
186
|
|
|
* Returns size of C data type of the given FFI\CData or FFI\CType. |
|
187
|
|
|
* |
|
188
|
|
|
* @param CData|CType $ptr |
|
189
|
|
|
* @return int |
|
190
|
|
|
*/ |
|
191
|
|
|
public static function alignof($ptr): int {} |
|
|
|
|
|
|
192
|
|
|
|
|
193
|
|
|
/** |
|
194
|
|
|
* Copies $size bytes from memory area $source to memory area $target. |
|
195
|
|
|
* $source may be any native data structure (FFI\CData) or PHP string. |
|
196
|
|
|
* |
|
197
|
|
|
* @param CData $to |
|
198
|
|
|
* @param CData|string $from |
|
199
|
|
|
* @param int $size |
|
200
|
|
|
*/ |
|
201
|
|
|
public static function memcpy(CData $to, $from, int $size): void {} |
|
|
|
|
|
|
202
|
|
|
|
|
203
|
|
|
/** |
|
204
|
|
|
* Compares $size bytes from memory area $ptr1 and $ptr2. |
|
205
|
|
|
* |
|
206
|
|
|
* @param CData|string $ptr1 |
|
207
|
|
|
* @param CData|string $ptr2 |
|
208
|
|
|
* @param int $size |
|
209
|
|
|
* @return int |
|
210
|
|
|
*/ |
|
211
|
|
|
public static function memcmp($ptr1, $ptr2, int $size): int {} |
|
|
|
|
|
|
212
|
|
|
|
|
213
|
|
|
/** |
|
214
|
|
|
* Fills the $size bytes of the memory area pointed to by $target with |
|
215
|
|
|
* the constant byte $byte. |
|
216
|
|
|
* |
|
217
|
|
|
* @param CData $ptr |
|
218
|
|
|
* @param int $value |
|
219
|
|
|
* @param int $size |
|
220
|
|
|
*/ |
|
221
|
|
|
public static function memset(CData $ptr, int $value, int $size): void {} |
|
|
|
|
|
|
222
|
|
|
|
|
223
|
|
|
/** |
|
224
|
|
|
* Creates a PHP string from $size bytes of memory area pointed by |
|
225
|
|
|
* $source. If size is omitted, $source must be zero terminated |
|
226
|
|
|
* array of C chars. |
|
227
|
|
|
* |
|
228
|
|
|
* @param CData $ptr |
|
229
|
|
|
* @param int|null $size |
|
230
|
|
|
* @return string |
|
231
|
|
|
*/ |
|
232
|
|
|
public static function string(CData $ptr, ?int $size = null): string {} |
|
|
|
|
|
|
233
|
|
|
|
|
234
|
|
|
/** |
|
235
|
|
|
* Checks whether the FFI\CData is a null pointer. |
|
236
|
|
|
* |
|
237
|
|
|
* @param CData $ptr |
|
238
|
|
|
* @return bool |
|
239
|
|
|
*/ |
|
240
|
|
|
public static function isNull(CData $ptr): bool {} |
|
|
|
|
|
|
241
|
|
|
} |
|
242
|
|
|
} |
|
243
|
|
|
|
|
244
|
|
|
namespace FFI { |
|
245
|
|
|
/** |
|
246
|
|
|
* General FFI exception. |
|
247
|
|
|
* |
|
248
|
|
|
* @since 7.4 |
|
249
|
|
|
*/ |
|
250
|
|
|
class Exception extends \Error {} |
|
251
|
|
|
|
|
252
|
|
|
/** |
|
253
|
|
|
* An exception that occurs when parsing invalid header files. |
|
254
|
|
|
* |
|
255
|
|
|
* @since 7.4 |
|
256
|
|
|
*/ |
|
257
|
|
|
class ParserException extends Exception {} |
|
258
|
|
|
|
|
259
|
|
|
/** |
|
260
|
|
|
* Proxy object that provides access to compiled structures. |
|
261
|
|
|
* |
|
262
|
|
|
* In the case that CData is a wrapper over a scalar, it contains an |
|
263
|
|
|
* additional "cdata" property. |
|
264
|
|
|
* |
|
265
|
|
|
* In the case that the CData is a wrapper over an arbitrary C structure, |
|
266
|
|
|
* then it allows reading and writing to the fields defined by |
|
267
|
|
|
* this structure. |
|
268
|
|
|
* |
|
269
|
|
|
* @method mixed __get(string $name) |
|
270
|
|
|
* @method mixed __set(string $name, mixed $value) |
|
271
|
|
|
* |
|
272
|
|
|
* In the case that CData is a wrapper over an array, it is an |
|
273
|
|
|
* implementation of the {@see \Traversable}, {@see \Countable}, |
|
274
|
|
|
* and {@see \ArrayAccess} |
|
275
|
|
|
* |
|
276
|
|
|
* @mixin \Traversable |
|
277
|
|
|
* @mixin \Countable |
|
278
|
|
|
* @mixin \ArrayAccess |
|
279
|
|
|
* |
|
280
|
|
|
* In the case when CData is a wrapper over a function pointer, it can |
|
281
|
|
|
* be called. |
|
282
|
|
|
* |
|
283
|
|
|
* @method mixed __invoke(mixed ...$args) |
|
284
|
|
|
* |
|
285
|
|
|
* @template TCData of int|float|bool|null|string|CData |
|
286
|
|
|
* |
|
287
|
|
|
* @since 7.4 |
|
288
|
|
|
*/ |
|
289
|
|
|
class CData |
|
290
|
|
|
{ |
|
291
|
|
|
/** |
|
292
|
|
|
* Note that this method does not physically exist and is only required |
|
293
|
|
|
* for correct type inference. |
|
294
|
|
|
* |
|
295
|
|
|
* @param int $offset |
|
296
|
|
|
* @return bool |
|
297
|
|
|
*/ |
|
298
|
|
|
private function offsetExists(int $offset) {} |
|
299
|
|
|
|
|
300
|
|
|
/** |
|
301
|
|
|
* Note that this method does not physically exist and is only required |
|
302
|
|
|
* for correct type inference. |
|
303
|
|
|
* |
|
304
|
|
|
* @param int $offset |
|
305
|
|
|
* @return CData|int|float|bool|null|string |
|
306
|
|
|
*/ |
|
307
|
|
|
private function offsetGet(int $offset) {} |
|
308
|
|
|
|
|
309
|
|
|
/** |
|
310
|
|
|
* Note that this method does not physically exist and is only required |
|
311
|
|
|
* for correct type inference. |
|
312
|
|
|
* |
|
313
|
|
|
* @param int $offset |
|
314
|
|
|
* @param CData|int|float|bool|null|string $value |
|
315
|
|
|
*/ |
|
316
|
|
|
private function offsetSet(int $offset, $value) {} |
|
317
|
|
|
|
|
318
|
|
|
/** |
|
319
|
|
|
* Note that this method does not physically exist and is only required |
|
320
|
|
|
* for correct type inference. |
|
321
|
|
|
* |
|
322
|
|
|
* @param int $offset |
|
323
|
|
|
*/ |
|
324
|
|
|
private function offsetUnset(int $offset) {} |
|
325
|
|
|
|
|
326
|
|
|
/** |
|
327
|
|
|
* Note that this method does not physically exist and is only required |
|
328
|
|
|
* for correct type inference. |
|
329
|
|
|
* |
|
330
|
|
|
* @return int |
|
331
|
|
|
*/ |
|
332
|
|
|
private function count(): int {} |
|
333
|
|
|
} |
|
334
|
|
|
|
|
335
|
|
|
/** |
|
336
|
|
|
* Class containing C type information. |
|
337
|
|
|
* |
|
338
|
|
|
* @since 7.4 |
|
339
|
|
|
*/ |
|
340
|
|
|
class CType |
|
341
|
|
|
{ |
|
342
|
|
|
/** |
|
343
|
|
|
* @since 8.1 |
|
344
|
|
|
*/ |
|
345
|
|
|
public const TYPE_VOID = 0; |
|
346
|
|
|
|
|
347
|
|
|
/** |
|
348
|
|
|
* @since 8.1 |
|
349
|
|
|
*/ |
|
350
|
|
|
public const TYPE_FLOAT = 1; |
|
351
|
|
|
|
|
352
|
|
|
/** |
|
353
|
|
|
* @since 8.1 |
|
354
|
|
|
*/ |
|
355
|
|
|
public const TYPE_DOUBLE = 2; |
|
356
|
|
|
|
|
357
|
|
|
/** |
|
358
|
|
|
* Please note that this constant may NOT EXIST if there is |
|
359
|
|
|
* no long double support on the current platform. |
|
360
|
|
|
* |
|
361
|
|
|
* @since 8.1 |
|
362
|
|
|
*/ |
|
363
|
|
|
public const TYPE_LONGDOUBLE = 3; |
|
364
|
|
|
|
|
365
|
|
|
/** |
|
366
|
|
|
* @since 8.1 |
|
367
|
|
|
*/ |
|
368
|
|
|
public const TYPE_UINT8 = 4; |
|
369
|
|
|
|
|
370
|
|
|
/** |
|
371
|
|
|
* @since 8.1 |
|
372
|
|
|
*/ |
|
373
|
|
|
public const TYPE_SINT8 = 5; |
|
374
|
|
|
|
|
375
|
|
|
/** |
|
376
|
|
|
* @since 8.1 |
|
377
|
|
|
*/ |
|
378
|
|
|
public const TYPE_UINT16 = 6; |
|
379
|
|
|
|
|
380
|
|
|
/** |
|
381
|
|
|
* @since 8.1 |
|
382
|
|
|
*/ |
|
383
|
|
|
public const TYPE_SINT16 = 7; |
|
384
|
|
|
|
|
385
|
|
|
/** |
|
386
|
|
|
* @since 8.1 |
|
387
|
|
|
*/ |
|
388
|
|
|
public const TYPE_UINT32 = 8; |
|
389
|
|
|
|
|
390
|
|
|
/** |
|
391
|
|
|
* @since 8.1 |
|
392
|
|
|
*/ |
|
393
|
|
|
public const TYPE_SINT32 = 9; |
|
394
|
|
|
|
|
395
|
|
|
/** |
|
396
|
|
|
* @since 8.1 |
|
397
|
|
|
*/ |
|
398
|
|
|
public const TYPE_UINT64 = 10; |
|
399
|
|
|
|
|
400
|
|
|
/** |
|
401
|
|
|
* @since 8.1 |
|
402
|
|
|
*/ |
|
403
|
|
|
public const TYPE_SINT64 = 11; |
|
404
|
|
|
|
|
405
|
|
|
/** |
|
406
|
|
|
* @since 8.1 |
|
407
|
|
|
*/ |
|
408
|
|
|
public const TYPE_ENUM = 12; |
|
409
|
|
|
|
|
410
|
|
|
/** |
|
411
|
|
|
* @since 8.1 |
|
412
|
|
|
*/ |
|
413
|
|
|
public const TYPE_BOOL = 13; |
|
414
|
|
|
|
|
415
|
|
|
/** |
|
416
|
|
|
* @since 8.1 |
|
417
|
|
|
*/ |
|
418
|
|
|
public const TYPE_CHAR = 14; |
|
419
|
|
|
|
|
420
|
|
|
/** |
|
421
|
|
|
* @since 8.1 |
|
422
|
|
|
*/ |
|
423
|
|
|
public const TYPE_POINTER = 15; |
|
424
|
|
|
|
|
425
|
|
|
/** |
|
426
|
|
|
* @since 8.1 |
|
427
|
|
|
*/ |
|
428
|
|
|
public const TYPE_FUNC = 16; |
|
429
|
|
|
|
|
430
|
|
|
/** |
|
431
|
|
|
* @since 8.1 |
|
432
|
|
|
*/ |
|
433
|
|
|
public const TYPE_ARRAY = 17; |
|
434
|
|
|
|
|
435
|
|
|
/** |
|
436
|
|
|
* @since 8.1 |
|
437
|
|
|
*/ |
|
438
|
|
|
public const TYPE_STRUCT = 18; |
|
439
|
|
|
|
|
440
|
|
|
/** |
|
441
|
|
|
* @since 8.1 |
|
442
|
|
|
*/ |
|
443
|
|
|
public const ATTR_CONST = 1; |
|
444
|
|
|
|
|
445
|
|
|
/** |
|
446
|
|
|
* @since 8.1 |
|
447
|
|
|
*/ |
|
448
|
|
|
public const ATTR_INCOMPLETE_TAG = 2; |
|
449
|
|
|
|
|
450
|
|
|
/** |
|
451
|
|
|
* @since 8.1 |
|
452
|
|
|
*/ |
|
453
|
|
|
public const ATTR_VARIADIC = 4; |
|
454
|
|
|
|
|
455
|
|
|
/** |
|
456
|
|
|
* @since 8.1 |
|
457
|
|
|
*/ |
|
458
|
|
|
public const ATTR_INCOMPLETE_ARRAY = 8; |
|
459
|
|
|
|
|
460
|
|
|
/** |
|
461
|
|
|
* @since 8.1 |
|
462
|
|
|
*/ |
|
463
|
|
|
public const ATTR_VLA = 16; |
|
464
|
|
|
|
|
465
|
|
|
/** |
|
466
|
|
|
* @since 8.1 |
|
467
|
|
|
*/ |
|
468
|
|
|
public const ATTR_UNION = 32; |
|
469
|
|
|
|
|
470
|
|
|
/** |
|
471
|
|
|
* @since 8.1 |
|
472
|
|
|
*/ |
|
473
|
|
|
public const ATTR_PACKED = 64; |
|
474
|
|
|
|
|
475
|
|
|
/** |
|
476
|
|
|
* @since 8.1 |
|
477
|
|
|
*/ |
|
478
|
|
|
public const ATTR_MS_STRUCT = 128; |
|
479
|
|
|
|
|
480
|
|
|
/** |
|
481
|
|
|
* @since 8.1 |
|
482
|
|
|
*/ |
|
483
|
|
|
public const ATTR_GCC_STRUCT = 256; |
|
484
|
|
|
|
|
485
|
|
|
/** |
|
486
|
|
|
* @since 8.1 |
|
487
|
|
|
*/ |
|
488
|
|
|
public const ABI_DEFAULT = 0; |
|
489
|
|
|
|
|
490
|
|
|
/** |
|
491
|
|
|
* @since 8.1 |
|
492
|
|
|
*/ |
|
493
|
|
|
public const ABI_CDECL = 1; |
|
494
|
|
|
|
|
495
|
|
|
/** |
|
496
|
|
|
* @since 8.1 |
|
497
|
|
|
*/ |
|
498
|
|
|
public const ABI_FASTCALL = 2; |
|
499
|
|
|
|
|
500
|
|
|
/** |
|
501
|
|
|
* @since 8.1 |
|
502
|
|
|
*/ |
|
503
|
|
|
public const ABI_THISCALL = 3; |
|
504
|
|
|
|
|
505
|
|
|
/** |
|
506
|
|
|
* @since 8.1 |
|
507
|
|
|
*/ |
|
508
|
|
|
public const ABI_STDCALL = 4; |
|
509
|
|
|
|
|
510
|
|
|
/** |
|
511
|
|
|
* @since 8.1 |
|
512
|
|
|
*/ |
|
513
|
|
|
public const ABI_PASCAL = 5; |
|
514
|
|
|
|
|
515
|
|
|
/** |
|
516
|
|
|
* @since 8.1 |
|
517
|
|
|
*/ |
|
518
|
|
|
public const ABI_REGISTER = 6; |
|
519
|
|
|
|
|
520
|
|
|
/** |
|
521
|
|
|
* @since 8.1 |
|
522
|
|
|
*/ |
|
523
|
|
|
public const ABI_MS = 7; |
|
524
|
|
|
|
|
525
|
|
|
/** |
|
526
|
|
|
* @since 8.1 |
|
527
|
|
|
*/ |
|
528
|
|
|
public const ABI_SYSV = 8; |
|
529
|
|
|
|
|
530
|
|
|
/** |
|
531
|
|
|
* @since 8.1 |
|
532
|
|
|
*/ |
|
533
|
|
|
public const ABI_VECTORCALL = 9; |
|
534
|
|
|
|
|
535
|
|
|
/** |
|
536
|
|
|
* Returns the name of the type. |
|
537
|
|
|
* |
|
538
|
|
|
* @since 8.0 |
|
539
|
|
|
* @return string |
|
540
|
|
|
*/ |
|
541
|
|
|
public function getName(): string {} |
|
542
|
|
|
|
|
543
|
|
|
/** |
|
544
|
|
|
* Returns the identifier of the root type. |
|
545
|
|
|
* |
|
546
|
|
|
* Value may be one of: |
|
547
|
|
|
* - {@see CType::TYPE_VOID} |
|
548
|
|
|
* - {@see CType::TYPE_FLOAT} |
|
549
|
|
|
* - {@see CType::TYPE_DOUBLE} |
|
550
|
|
|
* - {@see CType::TYPE_LONGDOUBLE} |
|
551
|
|
|
* - {@see CType::TYPE_UINT8} |
|
552
|
|
|
* - {@see CType::TYPE_SINT8} |
|
553
|
|
|
* - {@see CType::TYPE_UINT16} |
|
554
|
|
|
* - {@see CType::TYPE_SINT16} |
|
555
|
|
|
* - {@see CType::TYPE_UINT32} |
|
556
|
|
|
* - {@see CType::TYPE_SINT32} |
|
557
|
|
|
* - {@see CType::TYPE_UINT64} |
|
558
|
|
|
* - {@see CType::TYPE_SINT64} |
|
559
|
|
|
* - {@see CType::TYPE_ENUM} |
|
560
|
|
|
* - {@see CType::TYPE_BOOL} |
|
561
|
|
|
* - {@see CType::TYPE_CHAR} |
|
562
|
|
|
* - {@see CType::TYPE_POINTER} |
|
563
|
|
|
* - {@see CType::TYPE_FUNC} |
|
564
|
|
|
* - {@see CType::TYPE_ARRAY} |
|
565
|
|
|
* - {@see CType::TYPE_STRUCT} |
|
566
|
|
|
* |
|
567
|
|
|
* @since 8.1 |
|
568
|
|
|
* @return int |
|
569
|
|
|
*/ |
|
570
|
|
|
public function getKind(): int {} |
|
571
|
|
|
|
|
572
|
|
|
/** |
|
573
|
|
|
* Returns the size of the type in bytes. |
|
574
|
|
|
* |
|
575
|
|
|
* @since 8.1 |
|
576
|
|
|
* @return int |
|
577
|
|
|
*/ |
|
578
|
|
|
public function getSize(): int {} |
|
579
|
|
|
|
|
580
|
|
|
/** |
|
581
|
|
|
* Returns the alignment of the type in bytes. |
|
582
|
|
|
* |
|
583
|
|
|
* @since 8.1 |
|
584
|
|
|
* @return int |
|
585
|
|
|
*/ |
|
586
|
|
|
public function getAlignment(): int {} |
|
587
|
|
|
|
|
588
|
|
|
/** |
|
589
|
|
|
* Returns the bit-mask of type attributes. |
|
590
|
|
|
* |
|
591
|
|
|
* @since 8.1 |
|
592
|
|
|
* @return int |
|
593
|
|
|
*/ |
|
594
|
|
|
public function getAttributes(): int {} |
|
595
|
|
|
|
|
596
|
|
|
/** |
|
597
|
|
|
* Returns the identifier of the enum value type. |
|
598
|
|
|
* |
|
599
|
|
|
* Value may be one of: |
|
600
|
|
|
* - {@see CType::TYPE_UINT32} |
|
601
|
|
|
* - {@see CType::TYPE_UINT64} |
|
602
|
|
|
* |
|
603
|
|
|
* @since 8.1 |
|
604
|
|
|
* @return int |
|
605
|
|
|
* @throws Exception In the case that the type is not an enumeration. |
|
606
|
|
|
*/ |
|
607
|
|
|
public function getEnumKind(): int {} |
|
608
|
|
|
|
|
609
|
|
|
/** |
|
610
|
|
|
* Returns the type of array elements. |
|
611
|
|
|
* |
|
612
|
|
|
* @since 8.1 |
|
613
|
|
|
* @return CType |
|
614
|
|
|
* @throws Exception In the case that the type is not an array. |
|
615
|
|
|
*/ |
|
616
|
|
|
public function getArrayElementType(): CType {} |
|
617
|
|
|
|
|
618
|
|
|
/** |
|
619
|
|
|
* Returns the size of an array. |
|
620
|
|
|
* |
|
621
|
|
|
* @since 8.1 |
|
622
|
|
|
* @return int |
|
623
|
|
|
* @throws Exception In the case that the type is not an array. |
|
624
|
|
|
*/ |
|
625
|
|
|
public function getArrayLength(): int {} |
|
626
|
|
|
|
|
627
|
|
|
/** |
|
628
|
|
|
* Returns the original type of the pointer. |
|
629
|
|
|
* |
|
630
|
|
|
* @since 8.1 |
|
631
|
|
|
* @return CType |
|
632
|
|
|
* @throws Exception In the case that the type is not a pointer. |
|
633
|
|
|
*/ |
|
634
|
|
|
public function getPointerType(): CType {} |
|
635
|
|
|
|
|
636
|
|
|
/** |
|
637
|
|
|
* Returns the field string names of a structure or union. |
|
638
|
|
|
* |
|
639
|
|
|
* @since 8.1 |
|
640
|
|
|
* @return array<string> |
|
641
|
|
|
* @throws Exception In the case that the type is not a struct or union. |
|
642
|
|
|
*/ |
|
643
|
|
|
public function getStructFieldNames(): array {} |
|
644
|
|
|
|
|
645
|
|
|
/** |
|
646
|
|
|
* Returns the offset of the structure by the name of this field. In |
|
647
|
|
|
* the case that the type is a union, then for each field of this type |
|
648
|
|
|
* the offset will be equal to 0. |
|
649
|
|
|
* |
|
650
|
|
|
* @since 8.1 |
|
651
|
|
|
* @param string $name |
|
652
|
|
|
* @return int |
|
653
|
|
|
* @throws Exception In the case that the type is not a struct or union. |
|
654
|
|
|
*/ |
|
655
|
|
|
public function getStructFieldOffset(string $name): int {} |
|
656
|
|
|
|
|
657
|
|
|
/** |
|
658
|
|
|
* Returns the field type of a structure or union. |
|
659
|
|
|
* |
|
660
|
|
|
* @since 8.1 |
|
661
|
|
|
* @param string $name |
|
662
|
|
|
* @return CType |
|
663
|
|
|
* @throws Exception In the case that the type is not a struct or union. |
|
664
|
|
|
*/ |
|
665
|
|
|
public function getStructFieldType(string $name): CType {} |
|
666
|
|
|
|
|
667
|
|
|
/** |
|
668
|
|
|
* Returns the application binary interface (ABI) identifier with which |
|
669
|
|
|
* you can call the function. |
|
670
|
|
|
* |
|
671
|
|
|
* Value may be one of: |
|
672
|
|
|
* - {@see CType::ABI_DEFAULT} |
|
673
|
|
|
* - {@see CType::ABI_CDECL} |
|
674
|
|
|
* - {@see CType::ABI_FASTCALL} |
|
675
|
|
|
* - {@see CType::ABI_THISCALL} |
|
676
|
|
|
* - {@see CType::ABI_STDCALL} |
|
677
|
|
|
* - {@see CType::ABI_PASCAL} |
|
678
|
|
|
* - {@see CType::ABI_REGISTER} |
|
679
|
|
|
* - {@see CType::ABI_MS} |
|
680
|
|
|
* - {@see CType::ABI_SYSV} |
|
681
|
|
|
* - {@see CType::ABI_VECTORCALL} |
|
682
|
|
|
* |
|
683
|
|
|
* @since 8.1 |
|
684
|
|
|
* @return int |
|
685
|
|
|
* @throws Exception In the case that the type is not a function. |
|
686
|
|
|
*/ |
|
687
|
|
|
public function getFuncABI(): int {} |
|
688
|
|
|
|
|
689
|
|
|
/** |
|
690
|
|
|
* Returns the return type of the function. |
|
691
|
|
|
* |
|
692
|
|
|
* @since 8.1 |
|
693
|
|
|
* @return CType |
|
694
|
|
|
* @throws Exception In the case that the type is not a function. |
|
695
|
|
|
*/ |
|
696
|
|
|
public function getFuncReturnType(): CType {} |
|
697
|
|
|
|
|
698
|
|
|
/** |
|
699
|
|
|
* Returns the number of arguments to the function. |
|
700
|
|
|
* |
|
701
|
|
|
* @since 8.1 |
|
702
|
|
|
* @return int |
|
703
|
|
|
* @throws Exception In the case that the type is not a function. |
|
704
|
|
|
*/ |
|
705
|
|
|
public function getFuncParameterCount(): int {} |
|
706
|
|
|
|
|
707
|
|
|
/** |
|
708
|
|
|
* Returns the type of the function argument by its numeric index. |
|
709
|
|
|
* |
|
710
|
|
|
* @since 8.1 |
|
711
|
|
|
* @param int $index |
|
712
|
|
|
* @return CType |
|
713
|
|
|
* @throws Exception In the case that the type is not a function. |
|
714
|
|
|
*/ |
|
715
|
|
|
public function getFuncParameterType(int $index): CType {} |
|
716
|
|
|
} |
|
717
|
|
|
} |
|
718
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.