kphp icon indicating copy to clipboard operation
kphp copied to clipboard

FFI backlog

Open quasilyte opened this issue 3 years ago • 0 comments

This issue lists features that are nice to have but are not implemented in our FFI yet.

Separate issues can be created for any of these.

Important

  • [ ] Variable-size arrays support. We have fixed-size arrays and pointers, but there is currently no way to create a T[$n].
  • [ ] Pointer dereferencing via $ptr[0] syntax
  • [ ] Array indexing operations (read+write) via $array[$i] syntax (we have it for fixed-size arrays, but not for dynamic arrays)
  • [x] FFI::string function
  • [ ] Preserve const information in TypeData; should it be a ffi_const_flag_e bit or something more complex? Can we store FFIType* there and avoid all the headaches (this will ease the arrays support too)? #357

Less important

  • Add support for calling C function ptr that were returned from C code (e.g. c2php for functions)
  • Add support for PHP function passing and calling it from C code (e.g. php2c for functions and closures)
  • Compile-time checks for FFI::cast(T1, T2) where sizeof(T1) > sizeof(T2). PHP throws exception in that case.

Even less important

  • Detect obviously bad (close to UB) patterns that cause segfault even in PHP. For example, $v = FFI::cdef('struct Foo { int32_t x; };')->new('struct Foo'); var_dump($v); will cause a segfault in PHP8.
  • Add a check for "Attempt to perform assign pointer to owned C data" (see PHP sources)

quasilyte avatar Oct 22 '21 22:10 quasilyte