1--TEST-- 2Bug #80847 (Nested structs) 3--EXTENSIONS-- 4ffi 5zend_test 6--SKIPIF-- 7<?php 8if (PHP_OS_FAMILY == 'Windows' && ((1 << 31) > 0)) die('xfail libffi doesn\'t properly support passing big structures by value on Windows/64'); 9?> 10--FILE-- 11<?php 12$header = <<<HEADER 13 typedef struct bug80847_01 { 14 uint64_t b; 15 double c; 16 } bug80847_01; 17 18 typedef struct bug80847_02 { 19 bug80847_01 a; 20 } bug80847_02; 21 22 bug80847_02 ffi_bug80847(bug80847_02 s); 23HEADER; 24 25$ffi = FFI::cdef($header); 26$x = $ffi->new('bug80847_02'); 27$x->a->b = 42; 28$x->a->c = 42.5; 29var_dump($x); 30$y = $ffi->ffi_bug80847($x); 31var_dump($x, $y); 32?> 33--EXPECTF-- 34object(FFI\CData:struct bug80847_02)#%d (1) { 35 ["a"]=> 36 object(FFI\CData:struct bug80847_01)#%d (2) { 37 ["b"]=> 38 int(42) 39 ["c"]=> 40 float(42.5) 41 } 42} 43object(FFI\CData:struct bug80847_02)#%d (1) { 44 ["a"]=> 45 object(FFI\CData:struct bug80847_01)#%d (2) { 46 ["b"]=> 47 int(42) 48 ["c"]=> 49 float(42.5) 50 } 51} 52object(FFI\CData:struct bug80847_02)#%d (1) { 53 ["a"]=> 54 object(FFI\CData:struct bug80847_01)#%d (2) { 55 ["b"]=> 56 int(52) 57 ["c"]=> 58 float(32.5) 59 } 60} 61