Currently it's not possible for a function to accept args by reference. This PR adds early support for doing so, by transforming any function args that are `&mut T` into args that are passed by reference. E.g.:
```
\#[php_function]
fn my_function( arg: &mut Zval ) {
arg.reference_mut().map( |zval| zval.set_bool(true) );
}
```
* add `before` flag to `#[php_startup]`
this calls the user-provided startup function _before_ the classes and
constants registered by the macro system are registered with PHP. by
default the behaviour is to run this function after, which means you
cannot define an interface and use it on a struct.
* cargo fmt
* Allow passing `--yes` parameter to bypass prompts
Makes this tool usable in automated builds such as Docker containers.
Addresses https://github.com/davidcole1340/ext-php-rs/issues/133
* Update readme and guides
* rustfmt
Co-authored-by: David Cole <david.cole1340@gmail.com>
* Support marking classes as interfaces
This allows passing flags as part of `#[php_class(flags=Interface]` etc, which allows one to mark a class as being an interface.
When a class is an interface, it also shouldn't get a constructor created for it.
* rustfmt
This should fix the errors from the build at
<https://github.com/davidcole1340/ext-php-rs/actions/runs/3145521955/jobs/5112909446>:
Compiling clap v4.0.0
error: Unknown `#[clap(long)]` attribute (`#[arg(long)] exists)
--> crates/cli/src/lib.rs:92:12
|
92 | #[clap(long)]
| ^^^^
error: Unknown `#[clap(long)]` attribute (`#[arg(long)] exists)
--> crates/cli/src/lib.rs:115:12
|
115 | #[clap(long)]
| ^^^^
error: Unknown `#[clap(short)]` attribute (`#[arg(short)] exists)
--> crates/cli/src/lib.rs:134:12
|
134 | #[clap(short, long)]
| ^^^^^
error: could not compile `cargo-php` due to 3 previous errors
warning: build failed, waiting for other jobs to finish...
Error: Process completed with exit code 101.
These errors were probably caused by the release of `clap` 4.0.0
a few hours ago.
* Preliminary Windows support
* Start work on cross-platform build script
* Fix compilation on macOS
* Updated README, tidied up build script
* Check linker version before starting compilation
It doesn't seem like it's possible to change the linker from within the
build script, however, we can retrieve the linker in use and give the
user a suggestion if the linker will not work.
* Switch to using Github repository for bindgen
* Split Windows and Unix implementations into two files
* Fix building on Windows
* Remove `reqwest` and `zip` as dependencies on Unix
* Fix guide tests on Windows
* Started work on Windows CI
* runs -> run
* Use preinstalled LLVM on Windows
* Debugging for Windows CI
* Switch to upstream `rust-bindgen` master branch
* Switch to `rust-lld` for Windows linking
* Don't compile `cargo-php` on Windows
* Switch to using skeptic for tests
* cargo-php: Disable stub generation, fix ext install/remove
The plan is to replace the stub generation by generating them with PHP
code. This is cross-platform and means we don't need to worry about ABI.
We also don't need to embed information into the library.
* cargo-php: Fix on unix OS
* Fix clippy lint
* Updated README
* Re-add CI for Unix + PHP 8.0
* Fix building on thread-safe PHP
* Tidy up build scripts
* Use dynamic lookup on Linux, test with TS Windows
* Define `ZTS` when compiling PHP ZTS
* Combine Windows and Unix CI, fix linking for Win32TS
* Fix exclusions in build CI
* rust-toolchain -> rust
* Set LLVM version
* Only build docs.rs on Ubuntu PHP 8.1
* Fix build on Linux thread-safe
* Update guide example
* Attempt to fix CI on macOS by not installing LLVM
* Download LLVM even on macOS
* Only set LIBCLANG_PATH on non-macOS
* Fix yaml
* Try to set SDK path for macOS
* Multi-line run
* Clippy lint
* Only check docs on PHP 8.1
* When running with docs stub, use PHP 8.1
* Only build docs on Ubuntu
* Remove `macos-ci` branch from actions
* Trigger actions
* Change describe types to C ABI, check ext-php-rs version
Rust doesn't have a stable ABI so the describe function and types are
now C ABI compatible, however, the internal types `Cow`, `Vec`, `Option`
aren't.
Check `ext-php-rs` versions to check compatibility between the CLI and
the extension.
* CLI requires 0.7.1
* Bump versions
* Replace standard library types with ABI-stable replacements
* Change option type
* started work on stub generator
* Worked on stub CLI tool
* Unused import
* Account for namespaces in function and class names
* Add support for docblocks on structs
* Push Rust comments to stubs
* Add indentation to stub generation
* Add CLI application to install and generate stubs
This time CLI application is defined on user side, called with `cargo
run -- ..args..`
* Export anyhow result
* Add constants to stub file
* Removed stub symbols
No longer required as we are now building while also linking to PHP.
Keeping the stubs causes the stubs to override the real symbols in the
extension.
* Fix stubs for real this time
Removed stub symbols as they were being included in the extension
dylib, fix by loading the PHP executable as a dylib, loading the
required symbols globally.
* Maybe actually fix stubs this time
* Forgot to remove PHP binary loading
* let's give this another go... cargo subcommand
Now called via `cargo php <install,stubs>`.
* Added `remove` command
* Tidied up cargo-php, commented, set up CI
* Fix return types with non-ident types
* define namespace ordering
* Fix tests, replace `Self` when in outer context
* Moved allowed bindings into separate file
* Update guide with CLI instructions