Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorganise modules #91

Closed
davidcole1340 opened this issue Oct 1, 2021 · 2 comments · Fixed by #101
Closed

Reorganise modules #91

davidcole1340 opened this issue Oct 1, 2021 · 2 comments · Fixed by #101
Labels
enhancement New feature or request

Comments

@davidcole1340
Copy link
Owner

Module paths are currently long and convoluted. Can easily be shortened (drop ::php, re-export types from ::types instead of exporting modules).

@davidcole1340 davidcole1340 added the enhancement New feature or request label Oct 1, 2021
@vodik
Copy link
Collaborator

vodik commented Oct 1, 2021

My though is it's probably best to match PHP's own namespacing rules here to keep things easily findable for anyone who has experience with php-src. The first two snake case segments of PHP functions are probably a good guide for organization. For example:

Random sampling from by current build.rs (note for the following examples I'll omit the crate namespace):

  • zend_ce_arithmetic_error -> zend::ce::arithmetic_error
  • zend_hash_str_find -> zend::hash::str_find -> though likely best wrapped as zend::hash::HashTable::find
  • sapi_activate -> sapi::activate
  • php_module_startup -> php::modules::startup
  • php_execute_script -> php::execute_script

Useful reports can be done from there (e.g. use ext_php_rs::zend::HashTable or use ext_php_rs::HashTable) and maybe even a prelude.

@davidcole1340
Copy link
Owner Author

What do you think of this:

- `ext_php_rs`
  - `bindings` - ffi bindings re-exported from `ext-php-rs-sys` crate
  - `error` - rust error
    - `Error`
    - `Result`
  - `alloc` - allocation related
    - `efree`
    - `emalloc`
    - `ZBox`
  - `rc` - zend reference counting
    - `ZRc`
    - `ZRefcounted`
  - `exceptions` - exception related
    - `PhpException`
    - `PhpResult`
    - `throw/throw_with_code`
  - `binary` - relating to binary packing
    - `Binary`
    - `Pack`
  - `closure` - relating to PHP closures, feature gated
    - `Closure`
  - `args` - argument parsing
    - `Parser`
    - `Arg`
  - `props` - relating to PHP class properties
    - `FieldProp`
    - `Property`
  - `types` - all raw PHP types - in separate modules but re-exported through
    `types`. not including Rust types like `Closure`, `ClassObject` etc.
    - `Zval`
    - `ZHashTable`
    - `ZStr`
    - `ZLong`
    - `ZObject`
    - `ZClassObject`
    - `ZCallable`
  - `conv` - any conversion traits
    - `IntoZval`
    - `FromZval`
    - `IntoZvalDyn`
    - `IntoZendObject`
    - `FromZendObject`
    - `IntoConst`
  - `zend` - raw types relating to zend executor
    - `ExecuteData`
    - `Class`
    - `Module`
    - `Function`
    - `ExecutorGlobals`
    - `ArgInfo`
  - `builders` - builders (primarily for `zend` types)
    - `ClassBuilder`
    - `ModuleBuilder`
    - `FunctionBuilder`
  - `flags` - flags and enums
    - `DataType`
    - `...Flags`
  - `prelude`
    - macros, conversion traits etc. anything used regularly. glob imported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants