Commit Graph

257 Commits

Author SHA1 Message Date
David Cole
5ac8aeecc4 Moved contribution section of README 2021-05-16 15:27:32 +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
a75fcb50d2
Added ability to unpack and pack from Rust (#32)
* Added ability to `unpack` and `pack` from Rust

* Updated `Pack::pack_into` documentation

* Replaced constant with new flags, fixed example

* Accept slices/arrays when using `Zval::set_binary`
2021-05-05 22:43:06 +12:00
David
fcdd9332f5
Build and deploy docs to Github pages (#35)
* Added Github action for building and publishing docs

* Create index redirect page for docs

* Only deploy on master, fixed redirect
2021-05-04 11:42:52 +12:00
David
042c70af97
Fixed memory leak when returning an array (#34) 2021-05-03 19:59:29 +12:00
David Cole
d73788e093 Fixed extension panicing with invalid string 2021-05-01 22:06:56 +12:00
David Cole
e5a092d5f7 v0.0.5: bumped version and changelog 2021-04-24 13:39:06 +12:00
David
d1e719ef7a
Only run CI on pushes to master and PRs 2021-04-24 13:29:53 +12:00
David
62a43e64d9
Added Debug and Clone implementations (#30)
* Implemented Debug and Clone for most types

* Added `throw!` macro to throw and return
2021-04-24 13:28:05 +12:00
David
f11451fe58
Replace unit errors with error enum (#29)
* WIP: Replacing unit type errors with actual error

* Tidied up errors
2021-04-24 12:22:56 +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
7042018222 Added Clang to requirements 2021-04-20 16:40:35 +12:00
David Cole
281d82fe5b Added TryFrom implementation for HashMap 2021-04-18 23:07:21 +12:00
David
d4c6aa26ba
Replaced manual TryFrom implementations with macro (#24)
* Updated traits for building Zval

* Replaced manual implementations with macro impl
2021-04-18 23:04:43 +12:00
David
815452f799
Refactored ZendHashTable conversions (#23)
We shouldn't really be returning Zval objects, rather references to Zval
objects. There is currently a memory leak with arrays that need to be
resolved.
2021-04-18 21:57:40 +12:00
David Cole
87f1503ca5 Fixed HashTable -> Vec 2021-04-18 20:56:06 +12:00
David Cole
3917c413b5 Added From<ZendHashTable> impl for Vec 2021-04-18 20:50:00 +12:00
David Cole
75f99c6837 Updated Discord invite to use vanity URL 2021-04-18 17:02:04 +12:00
David Cole
136cc4138d Added opus-php to examples 2021-04-18 17:01:31 +12:00
David
472e26e8fb
Added ability to register constants (#22) 2021-04-18 16:48:58 +12:00
David
349d497793
Added ability to throw exceptions (#21)
* Exceptions have static lifetimes

* Added functions for throwing exceptions

Changed the `ClassEntry` implementation to unwrap the result before
returning, as these types are guaranteed to be valid. Also replaced the
'a lifetime with 'static lifetimes.
2021-04-18 15:52:02 +12:00
David Cole
35808d9e49 Updated inline documentation 2021-04-18 14:41:51 +12:00
David Cole
45c7242f1e Added parse_args! macro for parsing arguments 2021-04-18 14:35:04 +12:00
David Cole
f1a63c3600 Release 0.0.4 2021-04-17 21:59:59 +12:00
David Cole
5f89a5f970 Fixed typo v2 2021-04-17 00:25:07 +12:00
David Cole
b08fad5aad Fixed typo 2021-04-17 00:20:17 +12:00
David Cole
53e69f3820 Fixed CI by installing LLVM 2021-04-17 00:17:02 +12:00
David Cole
e38d987d15 Added gitignore to derive crate 2021-04-17 00:07:37 +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
3503b10289
Added Discord link to README 2021-04-09 12:36:30 +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
5f4b3f09f7 Updated README 2021-04-02 18:19:37 +13:00
David Cole
a0e38847b1 Updated README 2021-04-02 18:18:08 +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
b6b4974236
Added ability to call functions given from PHP (#18)
* Added ability to call functions given from PHP

* Return an `Option` rather than a `Result`
2021-04-02 18:02:55 +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
68aecf5816
Fixed incorrect build ID not letting extension run (#15) 2021-03-16 10:55:22 +13:00
David
8685b1bf1d
Added support for PHP arrays (#13)
* Refactored types

Moved types into their own files within the types directory

* Moved Zval set logic into object
Updated example

* WIP: Implementation of hashtable

* Added ability to retrieve zend hashtable from Zval

* Change `ZendHashTable::push` to work with zend functions

Implement iterator for ZendHashTable

* Implemented immutable iterator for ZendHashTable

* Added implementations for converting HashMap and vectors to
ZendHashTable

* Changed ZendHashTable to a wrapper, zval array

Better design, allows for `Drop` implementation for arrays that
are created and unused.

* Allow `Zval::set_array` to be passed Vec and HashMap

* Added methods to retrieve values from Zend hashtable

* Added methods to remove values from Zend hashtable
2021-03-12 21:10:39 +13:00
David
e1ca2129fe
Add github actions for building and linting (#12)
* Added github build workflow

* Added lint workflow

* Fixed clippy errors

* Fixed clippy warnings

* Allow warnings on generated code

* Final clippy fix... hopefully
2021-03-11 13:41:05 +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
8f108a61c3
Returning from functions (#9)
* Added ability to set value of zval

This allows the return value to now be set.
See the example in `example/skel/src.lib`.

* Added PHP internals book to resources

* Pass self as pointer to keep consistency
2021-03-11 01:06:58 +13:00
David
0dd1a3f80f
Added argument overloading (#8)
* Added argument overloading

If a double is requested but a long is available, we can cast the
long into a double. This is required if the user gives an integer
into a double field.

As well as this, if a string is requested but a long or double is
available, we can cast both of these into a string.

* Check if zval is present before setting in arg

* Added optional argument example

* Updated documentation for ZendLong

* WIP: added null checks
2021-03-10 21:09:18 +13:00
David
9fbe186098
Added argument parsing for functions (#6)
* Moved not required argument logic into function

Seemed more logical, as you can't have a required argument after the
not required argument. Usage:

```rs
FunctionBuilder::new("skeleton_version", skeleton_version)
    .arg(Arg::new("req_arg1", DataType::String))
    .arg(Arg::new("req_arg1", DataType::String))
    .not_required()
    .arg(Arg::new("not_req_arg1", DataType::String))
    .build()
```

* Added zend_value implementation

Helper functions to retrieve the value from zvals

* Started work on argument parser

* Added PHP version support notice

Due to the way the Zend API changes and the fact that the
stable interface is exposed via C macros, there is no
support for versions lower than PHP 8.0. In the future
we can support PHP 7.4 through Rust features.

* Added TryFrom implementations for Zval -> Types

* Added ability to select arguments from ExecutionData

* Added ability to parse arguments and retrieve val

See `example/skel/src/lib.rs` for usage.
2021-03-10 19:50:44 +13:00
David
52f9d40050
Added support for functions (#1)
* started work on functions

can now add functions, but can't return from them

* arg defaults to required
2021-03-10 11:43:17 +13:00
David Cole
0211148a1a hide public c functions from docs (wrapped by macros) 2021-03-09 21:02:56 +13:00