Yes, it is possible, and there are two approaches for working with C-code.
C code wrapping in CBLOCK
You can embed c-code in tags, for example: %{ // c-code }% .
This function is undocumented, but exists in tests.
https://github.com/phalcon/zephir/blob/master/test/cblock.zep https://github.com/phalcon/zephir/blob/c47ebdb71b18f7d8b182f4da4a9c77f734ee9a71/test/cblock.zep#L16ps . com / phalcon / zephir / blob / c47ebdb71b18f7d8b182f4da4a9c77f734ee9a71 / ext / test / cblock.c
%{
It looks a little ugly, but it works,) A little more elegant, but also more work, customizable optimizers:
By writing your own optimizer
The optimizer acts as an interceptor for function calls. The optimizer replaces a function call in the PHP user space with direct C-calls, which are faster and have lower performance overheads.
You can write an optimizer with clean interfaces, letting Zephir know the type of parameter passed forward to the C function and the return data type.
Manually: https://docs.zephir-lang.com/en/latest/optimizers.html
Example (calling the fibonacci c-func function): https://github.com/phalcon/zephir/pull/21#issuecomment-26178522
source share