1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 08:12:21 +01:00
Files
archived-php-src/ext/ffi/tests/ptr_declaration_list.phpt
David Zhong 52c91f0fb7 Fix FFI Parsing of Pointer Declaration Lists (#17794)
* Fix ffi parsing of pointer declaration lists

* Fix ffi pointer declaration lists grammar
2025-02-17 10:27:11 +03:00

34 lines
603 B
PHP

--TEST--
Declaration Lists with Pointers
--EXTENSIONS--
ffi
--SKIPIF--
--FILE--
<?php
$ffi = FFI::cdef(<<<EOF
struct MyStruct {
uint8_t** a, *b, c;
};
EOF);
$test_struct = $ffi->new('struct MyStruct');
$one = $ffi->new("uint8_t");
$oneptr = $ffi->new("uint8_t*");
$oneptrptr = $ffi->new("uint8_t**");
$one->cdata = 1;
$oneptr = FFI::addr($one);
$oneptrptr = FFI::addr($oneptr);
$test_struct->a = $oneptrptr;
$test_struct->b = $oneptr;
$test_struct->c = $one;
var_dump($test_struct->a[0][0]);
var_dump($test_struct->b[0]);
var_dump($test_struct->c);
?>
--EXPECT--
int(1)
int(1)
int(1)