Skip to content

Commit 1e41b50

Browse files
Prepared for v0.5.0 release (#79)
- Bumped versions - Updated changelog - Updated docs.rs bindings - Updated documentation about rename methods
1 parent afdac8e commit 1e41b50

File tree

5 files changed

+108
-37
lines changed

5 files changed

+108
-37
lines changed

CHANGELOG.md

Lines changed: 85 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,78 @@
11
# Changelog
22

3+
## Version 0.5.0
4+
5+
### Breaking changes
6+
7+
- Method names are now renamed to snake case by default [#63].
8+
- Refactored `ZendHashTable` into an owned and borrowed variant [#76].
9+
- Creating a new hashtable is done through the `OwnedHashTable` struct, which
10+
is then dereferenced to `&HashTable`, as `String` is to `&str`.
11+
- Refactored `ZendString` into an owned and borrowed variant [#77].
12+
- Creating a new Zend string is done through the `ZendString` struct, which is
13+
then dereferenced to `&ZendStr`, as `String` is to `&str`.
14+
- Class properties are now defined as struct properties, removing the old
15+
property system in the process [#69].
16+
17+
### Enhancements
18+
19+
- Added interfaces and parent class to the `Debug` implementation for
20+
`ClassEntry` [@72b0491].
21+
- Rust unit type `()` now has a datatype of `void` [@8b3ed08].
22+
- Functions returning Rust objects will now display their full classname in
23+
reflection [#64].
24+
- Fixed alignment of class objects in memory [#66].
25+
26+
Thanks to the contributors for this release:
27+
28+
- @davidcole1340
29+
- @vodik
30+
31+
[#63]: https://github.com/davidcole1340/ext-php-rs/pull/63
32+
[#76]: https://github.com/davidcole1340/ext-php-rs/pull/76
33+
[#77]: https://github.com/davidcole1340/ext-php-rs/pull/77
34+
[#69]: https://github.com/davidcole1340/ext-php-rs/pull/69
35+
[#64]: https://github.com/davidcole1340/ext-php-rs/pull/64
36+
[#66]: https://github.com/davidcole1340/ext-php-rs/pull/66
37+
[@72b0491]: https://github.com/davidcole1340/ext-php-rs/commit/72b0491
38+
[@8b3ed08]: https://github.com/davidcole1340/ext-php-rs/commit/8b3ed08
39+
40+
## Version 0.2.0 - 0.4.0
41+
42+
- Added macros!
43+
- Missed a bit :(
44+
345
## Version 0.1.0
446

547
- `Zval::reference()` returns a reference instead of a dereferenced pointer.
648
- Added `ZendHashTable::iter()` - note this is changing in a future version.
7-
- `ClassBuilder::extends()` now takes a reference rather than a pointer to match the
8-
return type of `ClassEntry::exception()`.
49+
- `ClassBuilder::extends()` now takes a reference rather than a pointer to match
50+
the return type of `ClassEntry::exception()`.
951
- `ClassEntry::build()` now returns a reference - same reason as above.
1052
- Improve library 'safety' by removing `unwrap` calls:
11-
- `.build()` returns `Result` on `FunctionBuilder`, `ClassBuilder` and `ModuleBuilder`.
12-
- `.property()` and `.constant()` return `Result` on `ClassBuilder`.
13-
- `.register_constant()` returns `Result`.
14-
- `.try_call()` on callables now return `Result` rather than `Option`.
15-
- `throw()` and `throw_with_code()` now returns `Result`.
16-
- `new()` and `new_interned()` on `ZendString` now returns a `Result`.
17-
- For `ZendHashTable`:
18-
- `insert()`, `insert_at_index()` now returns a `Result<HashTableInsertResult>`, where `Err` failed,
19-
`Ok(Ok)` inserts successfully without overwrite, and `Ok(OkWithOverwrite(&Zval))` inserts successfully
20-
with overwrite.
21-
- `push()` now returns a `Result`.
22-
- Converting from a `Vec` or `HashMap` to a `ZendHashTable` is fallible, so it now implementes `TryFrom` as
23-
opposed to `From`.
24-
- For `Zval`:
25-
- `set_string()` now returns a `Result`, and takes a second parameter (persistent).
26-
- `set_persistent_string()` has now been removed in favour of `set_string()`.
27-
- `set_interned_string()` also returns a `Result`.
28-
- `set_array()` now only takes a `ZendHashTable`, you must convert your `Vec` or `HashMap`
29-
by calling `try_into()` and handling the error.
53+
- `.build()` returns `Result` on `FunctionBuilder`, `ClassBuilder` and
54+
`ModuleBuilder`.
55+
- `.property()` and `.constant()` return `Result` on `ClassBuilder`.
56+
- `.register_constant()` returns `Result`.
57+
- `.try_call()` on callables now return `Result` rather than `Option`.
58+
- `throw()` and `throw_with_code()` now returns `Result`.
59+
- `new()` and `new_interned()` on `ZendString` now returns a `Result`.
60+
- For `ZendHashTable`:
61+
- `insert()`, `insert_at_index()` now returns a
62+
`Result<HashTableInsertResult>`, where `Err` failed, `Ok(Ok)` inserts
63+
successfully without overwrite, and `Ok(OkWithOverwrite(&Zval))` inserts
64+
successfully with overwrite.
65+
- `push()` now returns a `Result`.
66+
- Converting from a `Vec` or `HashMap` to a `ZendHashTable` is fallible, so
67+
it now implementes `TryFrom` as opposed to `From`.
68+
- For `Zval`:
69+
- `set_string()` now returns a `Result`, and takes a second parameter
70+
(persistent).
71+
- `set_persistent_string()` has now been removed in favour of
72+
`set_string()`.
73+
- `set_interned_string()` also returns a `Result`.
74+
- `set_array()` now only takes a `ZendHashTable`, you must convert your
75+
`Vec` or `HashMap` by calling `try_into()` and handling the error.
3076

3177
## Version 0.0.7
3278

@@ -36,19 +82,28 @@ return type of `ClassEntry::exception()`.
3682

3783
## Version 0.0.6
3884

39-
- Fixed `panic!` when a PHP binary string was given to a function (@davidcole1340) [c:d73788e]
40-
- Fixed memory leak when returning an array from Rust to PHP (@davidcole1340) #34
41-
- Documentation is now deployed to [GitHub Pages](https://davidcol1340.github.io/ext-php-rs) (@davidcole1340) #35
42-
- Added ability to unpack and pack binary strings similar to PHP (@davidcole1340) #32
85+
- Fixed `panic!` when a PHP binary string was given to a function
86+
(@davidcole1340) [c:d73788e]
87+
- Fixed memory leak when returning an array from Rust to PHP (@davidcole1340)
88+
#34
89+
- Documentation is now deployed to
90+
[GitHub Pages](https://davidcol1340.github.io/ext-php-rs) (@davidcole1340) #35
91+
- Added ability to unpack and pack binary strings similar to PHP
92+
(@davidcole1340) #32
4393
- Allowed `default-features` to be true for Bindgen (@willbrowningme) #36
4494

4595
## Version 0.0.5
4696

47-
- Relicensed project under MIT or Apache 2.0 as per Rust crate guidelines (@davidcole1340) [c:439f2ae]
48-
- Added `parse_args!` macro to simplify argument parsing (@davidcole1340) [c:45c7242]
49-
- Added ability to throw exceptions from Rust to PHP (@davidcole1340) [c:45c7242]
97+
- Relicensed project under MIT or Apache 2.0 as per Rust crate guidelines
98+
(@davidcole1340) [c:439f2ae]
99+
- Added `parse_args!` macro to simplify argument parsing (@davidcole1340)
100+
[c:45c7242]
101+
- Added ability to throw exceptions from Rust to PHP (@davidcole1340)
102+
[c:45c7242]
50103
- Added ability to register global constants (@davidcole1340) [c:472e26e]
51104
- Implemented `From<ZendHashTable>` for `Vec` (@davidcole1340) [c:3917c41]
52-
- Expanded implementations for converting to `Zval` from primitives (@davidcole1340) [c:d4c6aa2]
105+
- Expanded implementations for converting to `Zval` from primitives
106+
(@davidcole1340) [c:d4c6aa2]
53107
- Replaced unit errors with an `Error` enum (@davidcole1340) [c:f11451f]
54-
- Added `Debug` and `Clone` implementations for most structs (@davidcole1340) [c:62a43e6]
108+
- Added `Debug` and `Clone` implementations for most structs (@davidcole1340)
109+
[c:62a43e6]

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@ repository = "https://github.com/davidcole1340/ext-php-rs"
55
homepage = "https://github.com/davidcole1340/ext-php-rs"
66
license = "MIT OR Apache-2.0"
77
keywords = ["php", "ffi", "zend"]
8-
version = "0.4.0"
8+
version = "0.5.0"
99
authors = ["David Cole <[email protected]>"]
1010
edition = "2018"
1111
categories = ["api-bindings"]
1212

1313
[dependencies]
1414
bitflags = "1.2.1"
1515
parking_lot = "0.11.2"
16-
ext-php-rs-derive = { version = "=0.4.0", path = "./ext-php-rs-derive" }
16+
ext-php-rs-derive = { version = "=0.5.0", path = "./ext-php-rs-derive" }
1717

1818
[build-dependencies]
19-
bindgen = { version = ">= 0.57.0, < 0.58.1" }
19+
bindgen = { version = "0.59" }
2020
regex = "1"
21-
cc = "1.0.67"
21+
cc = "1.0"
2222

2323
[features]
2424
alloc = []

docsrs_bindings.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ pub const IS_CONSTANT_AST: u32 = 11;
3232
pub const IS_CALLABLE: u32 = 12;
3333
pub const IS_VOID: u32 = 14;
3434
pub const IS_MIXED: u32 = 16;
35+
pub const IS_PTR: u32 = 13;
3536
pub const _IS_BOOL: u32 = 17;
3637
pub const Z_TYPE_FLAGS_SHIFT: u32 = 8;
3738
pub const IS_TYPE_REFCOUNTED: u32 = 1;
@@ -221,7 +222,6 @@ pub struct _zend_refcounted {
221222
pub gc: zend_refcounted_h,
222223
}
223224
#[repr(C)]
224-
#[derive(Copy, Clone)]
225225
pub struct _zend_string {
226226
pub gc: zend_refcounted_h,
227227
pub h: zend_ulong,
@@ -388,6 +388,9 @@ pub struct zend_get_gc_buffer {
388388
pub end: *mut zval,
389389
pub start: *mut zval,
390390
}
391+
extern "C" {
392+
pub fn zval_ptr_dtor(zval_ptr: *mut zval);
393+
}
391394
pub type zend_object_iterator = _zend_object_iterator;
392395
#[repr(C)]
393396
#[derive(Debug, Copy, Clone)]

ext-php-rs-derive/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description = "Derive macros for ext-php-rs."
44
repository = "https://github.com/davidcole1340/ext-php-rs"
55
homepage = "https://github.com/davidcole1340/ext-php-rs"
66
license = "MIT OR Apache-2.0"
7-
version = "0.4.0"
7+
version = "0.5.0"
88
authors = ["David Cole <[email protected]>"]
99
edition = "2018"
1010

guide/src/macros/impl.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,27 @@ methods is they are bounded by their class object.
1717
Class methods can take a `&self` or `&mut self` parameter. They cannot take a
1818
consuming `self` parameter. Static methods can omit this `self` parameter.
1919

20-
Options are passed as separate attributes:
20+
By default, all methods are renamed in PHP to the camel-case variant of the Rust
21+
method name. This can be changed on the `#[php_impl]` attribute, by passing one
22+
of the following as the `rename_methods` option:
23+
24+
- `"none"` - does not rename the methods.
25+
- `"camelCase"` - renames all methods to camel case (default).
26+
- `"snake_case"` - renames all methods to snake case.
27+
28+
For example, to disable renaming, change the `#[php_impl]` attribute to
29+
`#[php_impl(rename_methods = "none")]`.
30+
31+
The rest of the options are passed as separate attributes:
2132

2233
- `#[defaults(i = 5, b = "hello")]` - Sets the default value for parameter(s).
2334
- `#[optional(i)]` - Sets the first optional parameter. Note that this also sets
2435
the remaining parameters as optional, so all optional parameters must be a
2536
variant of `Option<T>`.
2637
- `#[public]`, `#[protected]` and `#[private]` - Sets the visibility of the
2738
method.
39+
- `#[rename("method_name")]` - Renames the PHP method to a different identifier,
40+
without renaming the Rust method name.
2841

2942
The `#[defaults]` and `#[optional]` attributes operate the same as the
3043
equivalent function attribute parameters.

0 commit comments

Comments
 (0)