xref: /php-src/ext/ffi/tests/033.phpt (revision 4acf0084)
1--TEST--
2FFI 033: FFI::new(), FFI::free(), FFI::type(), FFI::typeof(), FFI::arrayType()
3--EXTENSIONS--
4ffi
5--INI--
6ffi.enable=1
7--FILE--
8<?php
9$ffi = FFI::cdef();
10
11$p1 = $ffi->new("uint8_t[2]");
12$p2 = $ffi->new("uint16_t[2]", true, true);
13var_dump($p1, $p2);
14
15$t1 = FFI::typeof($p1);
16var_dump($t1);
17
18$p4 = $ffi->new($t1);
19var_dump($p4);
20
21$t2 = $ffi->type("uint16_t[2]");
22var_dump($t2);
23$p4 = $ffi->new($t2);
24var_dump($p4);
25
26$t2 = $ffi->type("uint32_t");
27var_dump($t2);
28$t3 = FFI::arrayType($t2, [2, 2]);
29var_dump($t3);
30?>
31--EXPECTF--
32object(FFI\CData:uint8_t[2])#%d (2) {
33  [0]=>
34  int(0)
35  [1]=>
36  int(0)
37}
38object(FFI\CData:uint16_t[2])#%d (2) {
39  [0]=>
40  int(0)
41  [1]=>
42  int(0)
43}
44object(FFI\CType:uint8_t[2])#%d (0) {
45}
46object(FFI\CData:uint8_t[2])#%d (2) {
47  [0]=>
48  int(0)
49  [1]=>
50  int(0)
51}
52object(FFI\CType:uint16_t[2])#%d (0) {
53}
54object(FFI\CData:uint16_t[2])#%d (2) {
55  [0]=>
56  int(0)
57  [1]=>
58  int(0)
59}
60object(FFI\CType:uint32_t)#%d (0) {
61}
62object(FFI\CType:uint32_t[2][2])#%d (0) {
63}
64