Commit Graph

39 Commits

Author SHA1 Message Date
David Cole
d9e40ea4d2
Ensure CLI-Extension compatibility (#108)
* 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
2021-11-21 17:27:12 +13:00
David Cole
fa05703c08 Release v0.7.0 2021-11-20 14:33:41 +13:00
David Cole
6df362b714
Added CLI crate for stubs, installation and removal (#107)
* 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
2021-11-20 14:19:02 +13:00
David Cole
b92202c89b Release v0.6.0 2021-10-10 23:21:39 +13:00
David Cole
466c1658e3
Refactor module paths (#101)
* Refactor module layout

* Fixed documentation tests

* Removed skel, moved macro crate

* Ignore folders for crate publish

* Fix builder for zts

* Add `rustfmt.toml`, wrap all comments #96

* Fixed up documentation links, tidied up

* Add `Zend` prefix to callable and hashtable

* Updated guide types

* Updated changelog
2021-10-10 17:51:55 +13:00
David Cole
f8b57274fb Version 0.5.3 2021-10-07 04:25:10 +13:00
David Cole
88e0d7b668 Version 0.5.2 2021-10-07 04:13:00 +13:00
David
3403cba7bf
Add ZBox<T> to replace owned variants (#94)
* Added `ZBox` and `ZBoxable`

* Implement `ZBoxable` for `ZendStr`

Build for all f eatures on CI

* Replace `OwnedZendObject` with `ZBox<ZendObject>`

* Replace `ClassObject` with `ZBox<ZendClassObject>`

Fixed deserialization bug

Panic when uninitialized - better than UB

* Replace `OwnedHashTable` with `ZBox<HashTable>`

* Remove `MaybeUninit` from `ZendClassObject`
2021-10-05 16:59:41 +13:00
David Cole
a64d8896a2 Release v0.5.1 2021-09-29 01:09:20 +13:00
David
1e41b50100
Prepared for v0.5.0 release (#79)
- Bumped versions
- Updated changelog
- Updated docs.rs bindings
- Updated documentation about rename methods
2021-09-28 01:31:55 +13:00
David
aea8717456
Refactor Zend strings (#77)
* Call zval destructor when changing zval type and dropping

* Remove `ZendHashTable` wrapper

Replaced by returning references to the actual hashtable, and having a
new type `OwnedHashTable` when creating a new hashtable.

* Refactor `ZendString` into a borrowed and owned variant

`&ZendStr` is now equivalent to `&str`, while `ZendString` is equivalent
to `String`.

* Tidy up `ZendString`, add `Debug` implementation
2021-09-28 00:33:16 +13:00
David Cole
5bf24588c9 v0.4.0: bump version 2021-09-05 18:46:38 +12:00
David
52fae5c6d4
Use configuration tags instead of features for flags (#59)
e.g. PHP debug or ZTS mode are no longer features, but just simply
configuration flags.
2021-09-05 14:49:50 +12:00
David
4a4370c817
Add ability to send Rust closures to PHP (#58)
* Start work on returning new objects

Change `IntoZval` to consume `self`

* Add conversion from vector reference to PHP hashtable through clones

* `set_binary` now only takes `Vec`

Used to take `AsRef<[T]>` to allow users to pass arrays, however, this
causes the data to be cloned even if the user passes a `Vec`.

* Rename `as_zval` to `into_zval` to match Rust conventions

* Started work on closures

* Finish implementation of closures

* Document closures, add to prelude, feature gate

* Fixed closure example
2021-09-05 13:45:59 +12:00
David
73526d62b5
Drop object contents rather than deallocating whole object (#57)
The object memory is automatically deallocated, however, anything that
has been allocated on the heap (strings, vectors etc.) must be
deallocated while we are freeing the object.
2021-09-05 00:53:29 +12:00
David Cole
6abe209525 v0.3.0 bump version 2021-08-26 20:47:46 +12:00
David
1193cc0537
Replace struct derive macro with attribute macro (#54)
* Replace `ZendObjectOverride` derive macro with `#[php_class]`

* Updated guide with `#[php_class]` macro

* Panic rather than return error when implementing interface

It's gonna panic either way so might as well make it easier for the
builder

* Remove `libc` dependency
2021-08-26 01:04:33 +12:00
David Cole
b1787ebd0a v0.2.0 bump version 2021-08-23 16:49:04 +12:00
David
84aaa07d3e
Add abstraction macros (#49)
* Remove uses of `unwrap`, improve library safety

* Started work on `#[php_function]` attribute

* Added `PhantomData` to `ZendHashTable`

Proper lifetimes for `HashTable` type

* `#[php_function]` now accepts `Vec<T>`

Refactored `ZendHashTable` iterators - there is now `Iter` and
`IntoIter` depending on whether it will consume the HashTable or not.

* Add support for nullable types

* Allow `optional` parameter on attribute

* Support primitive and `Option` return types

* Tidied and refactored attribute

* Added documentation for `#[php_function]`

Implemented `IntoZval` for `Option<T>` when `IntoZval` is also
implemented for `T`. `None` resolves to `null`.

* Added `#[php_method]` attribute

* Added `Callable` type, implemented `Drop` on `Zval`

While implementing `Drop`, the `Copy` derivation was removed, however,
this should not have been there in the first place (`Zval` is not valid
for `Copy` if it contains a string).

* Added some macro functions to example

* Add support for boolean arguments

* Added wrapper around binary data

Future support for binary arguments with `#[php_function]` macros.
Unpacking binary data is no longer unsafe. It was never really unsafe in
the beginning, as we were always reading valid memory, just the contents
of the data could not be trusted.

* Added `#[php_module]` attribute, added support for binary arguments

* Added defaults for functions

* Add defaults for methods

* Add startup function macro and prelude

* Refactored method adding

Now done through impl attribute

* Don't rename functions - generate another internal fn

Also hide all generated functions from docs

* Generate startup function when not already defined

* Add support for class and global constants

* Updated `skel` project

* Updated macro documentation, added executor globals

* Remove `Copy` bound for HashMap to Zval

* Updated documentation

* Add `FromZval` trait, updated docs

* Fixed clippy lints

* Fixed ZTS executor globals

* Fix clippy lint
2021-08-18 13:15:25 +12:00
David Cole
496e3501e1 Bumped ext-php-rs-derive version 2021-08-11 12:41:31 +12:00
David Cole
ad51a66193 v0.1.0: bumped version 2021-08-11 12:39:20 +12:00
David
c98bf495ea
v0.0.7: bumped version (#43) 2021-05-21 17:16:36 +12:00
David
0db6888c46
Added support for PHP ZTS (#37)
* Added support for PHP ZTS

* Added GitHub action for ZTS

Runs seperate from the other tests, as the setup-php action does not
support ZTS, therefore we run the tests in a Docker container.

* Source Rust env file before building

* No `source` command on docker

* Another attempt at fixing Rust in Docker
2021-05-19 20:45:39 +12:00
David Cole
ee2c394102 v0.0.6: bumped version and changelog 2021-05-11 21:49:09 +12:00
Will Browning
e0743b1589
Remove default-features=false from bindgen (#36) 2021-05-07 10:35:46 +12:00
David Cole
e5a092d5f7 v0.0.5: bumped version and changelog 2021-04-24 13:39:06 +12:00
David
439f2ae981
Relicense under MIT or Apache 2.0 (#27)
* Relicense under MIT or Apache 2.0

* Updated license in README to match Rust guidelines
2021-04-22 20:01:30 +12:00
David Cole
f1a63c3600 Release 0.0.4 2021-04-17 21:59:59 +12:00
Will Browning
cea3cb2dc4
Updated Bindgen to 0.58.1 (#20)
* Update bindgen

* Fix failing test

* Add env llvm and libclang variables

* Fixed doc comment for table macros

* Removed newline

Co-authored-by: David Cole <david.cole1340@gmail.com>
2021-04-17 00:05:17 +12:00
David Cole
91632cd0f3 Published ext-php-rs-derive 2021-04-05 01:47:28 +12:00
David Cole
8763b2314c v0.0.3: bumped version 2021-04-05 01:44:20 +12:00
David
860ffb3587
Created derive macro for ZendObjectHandler (#19)
* Initialize handlers on first touch

In the process of turning the two macros into one derive proc macro

* Changed the object handler macros into derive
2021-04-05 01:43:08 +12:00
David Cole
ec87e0453a Accidentally yanked 0.0.1 2021-04-02 18:21:35 +13:00
David Cole
047cdf3928 Updated Cargo.toml 2021-04-02 18:15:30 +13:00
David Cole
c6aa081a02 Rename crate to ext-php-rs 2021-04-02 18:12:30 +13:00
David
e4deb1f93f
Implemented classes (#17)
* Add PHP thread safety to build matrix

* Revert "Add PHP thread safety to build matrix"

This reverts commit 7de868e6b6e329b87c412af8daf61cba1a3e29c5.

* Fixed arguments not being reconized by PHP

* Added function to create interned Zend string

* Changed statup/shutdown function types to Rust types

Prevents users having to import from bindings

* Added flags for classes

* WIP: class builder

* Added properties to classes

* Added class constants

* Added PHP base extensions
Added class inheritance

* Fixed memory leak with constants

Created C wrapper which is compiled and linked in the `build.rs`
script. In the process removed the `build_id()` function as now
we can just export the macro via a function which is defined in
`wrapper.c`.

* Fixed lint issue

* Added functions to set zval as different strings

Regular strings, persistent strings and interned strings

* Updated README with requirements

* Fixed lint issues

* Changed properties to use proper function

* Free zend string when it is changed for a persistent one

* WIP: overriding zend objects

* Added comments to the top of modules.

* Fixed some comments

* Initialize hash map with initial size when converting from HashMap and
Vec

* Removed unused imports

* WIP: object overrides

* Added DerefMut implementation for ZendClassObject

Tidied up lints that clippy was complaining about, removed debugging
statements.

* Fixed pointer dereference error in macro

* Added missing comments for trait

* All functions now take mutable references vs ptr

Removed SetZval implementation for *mut Zval.
Made bindings public, removed duplicate bindings.
Fixed `create_object` handler not working.
Note to self: smaller commits.

* Showcase ability to use shared object

* WIP: debugging property errors

Changed `function` to `method` in classes
Fixed doctest for `c_str`

* Disabled class properties temporarily

See #16

* Initialize args array with size
2021-04-02 14:18:45 +13:00
David
2a8313bb68
Check PHP API version in build script (#11)
Ensure that the user is compiling with a supported version
of PHP.
2021-03-11 12:34:47 +13:00
David Cole
a7d542735f added readme, license, updated cargo.toml 2021-03-09 20:56:14 +13:00
David Cole
61ed3c8a15 initial commit
added php wrapper
2021-03-09 12:40:12 +13:00