12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- --TEST--
- FFI 027: Incomplete and variable length arrays
- --EXTENSIONS--
- ffi
- --INI--
- ffi.enable=1
- --FILE--
- <?php
- try {
- $p = FFI::new("int[*]");
- echo "ok\n";
- } catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
- }
- try {
- FFI::cdef("static int (*foo)[*];");
- echo "ok\n";
- } catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
- }
- try {
- FFI::cdef("typedef int foo[*];");
- echo "ok\n";
- } catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
- }
- try {
- FFI::cdef("static void foo(int[*][*]);");
- echo "ok\n";
- } catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
- }
- try {
- var_dump(FFI::sizeof(FFI::new("int[0]")));
- } catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
- }
- try {
- var_dump(FFI::sizeof(FFI::new("int[]")));
- } catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
- }
- try {
- var_dump(FFI::sizeof(FFI::cast("int[]", FFI::new("int[2]"))));
- } catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
- }
- try {
- FFI::cdef("struct _x {int a; int b[];};");
- echo "ok\n";
- } catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
- }
- try {
- $f = FFI::cdef("typedef int(*foo)[];");
- echo "ok\n";
- } catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
- }
- try {
- $f = FFI::cdef("typedef int foo[][2];");
- echo "ok\n";
- } catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
- }
- try {
- $f = FFI::cdef("typedef int foo[];");
- echo "ok\n";
- } catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
- }
- try {
- $f = FFI::cdef("static int foo(int[]);");
- echo "ok\n";
- } catch (Throwable $e) {
- echo get_class($e) . ": " . $e->getMessage()."\n";
- }
- ?>
- --EXPECT--
- FFI\ParserException: "[*]" is not allowed in other than function prototype scope at line 1
- FFI\ParserException: "[*]" is not allowed in other than function prototype scope at line 1
- FFI\ParserException: "[*]" is not allowed in other than function prototype scope at line 1
- ok
- FFI\Exception: Cannot instantiate FFI\CData of zero size
- FFI\ParserException: "[]" is not allowed at line 1
- FFI\ParserException: "[]" is not allowed at line 1
- ok
- ok
- ok
- ok
- ok
|