blob: 24ded1083355961663f8e000cb490e172c891b6b (
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
|
--TEST--
Bug #80847 (Nested structs)
--SKIPIF--
<?php
if (!extension_loaded('ffi')) die('skip ffi extension not available');
if (!extension_loaded('zend_test')) die('skip zend_test extension not available');
if (PHP_OS_FAMILY == 'Windows' && ((1 << 31) > 0)) die('xfail libffi doesn\'t properly support passing big strctures by value on Windows/64');
?>
--FILE--
<?php
require_once('utils.inc');
$header = <<<HEADER
typedef struct bug80847_01 {
uint64_t b;
double c;
} bug80847_01;
typedef struct bug80847_02 {
bug80847_01 a;
} bug80847_02;
bug80847_02 ffi_bug80847(bug80847_02 s);
HEADER;
if (PHP_OS_FAMILY !== 'Windows') {
$ffi = FFI::cdef($header);
} else {
try {
$ffi = FFI::cdef($header, 'php_zend_test.dll');
} catch (FFI\Exception $ex) {
$ffi = FFI::cdef($header, ffi_get_php_dll_name());
}
}
$x = $ffi->new('bug80847_02');
$x->a->b = 42;
$x->a->c = 42.5;
var_dump($x);
$y = $ffi->ffi_bug80847($x);
var_dump($x, $y);
?>
--EXPECTF--
object(FFI\CData:struct bug80847_02)#%d (1) {
["a"]=>
object(FFI\CData:struct bug80847_01)#%d (2) {
["b"]=>
int(42)
["c"]=>
float(42.5)
}
}
object(FFI\CData:struct bug80847_02)#%d (1) {
["a"]=>
object(FFI\CData:struct bug80847_01)#%d (2) {
["b"]=>
int(42)
["c"]=>
float(42.5)
}
}
object(FFI\CData:struct bug80847_02)#%d (1) {
["a"]=>
object(FFI\CData:struct bug80847_01)#%d (2) {
["b"]=>
int(52)
["c"]=>
float(32.5)
}
}
|