Add wrapper for zend_exec_stringl with exception handling#67
Draft
vodik wants to merge 1 commit intoextphprs:masterfrom
Draft
Add wrapper for zend_exec_stringl with exception handling#67vodik wants to merge 1 commit intoextphprs:masterfrom
vodik wants to merge 1 commit intoextphprs:masterfrom
Conversation
vodik
commented
Sep 14, 2021
Comment on lines
+23
to
+24
| unsafe { ext_php_rs_executor_globals().as_mut() } | ||
| .expect("Static executor globals were invalid") |
Collaborator
Author
There was a problem hiding this comment.
Kept this private because I don't know in general if this is thread safe. As I understand it, the take_exception function should be safe.
| std::mem::swap(&mut exception_ptr, &mut globals.exception); | ||
|
|
||
| if !exception_ptr.is_null() { | ||
| Some(unsafe { Box::from_raw(exception_ptr) }) |
Collaborator
Author
There was a problem hiding this comment.
As I understand the php source code, we're responsible for freeing it if we take it.
vodik
commented
Sep 14, 2021
| /// The main error type which is passed by the library inside the custom | ||
| /// [`Result`] type. | ||
| #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)] | ||
| #[derive(Debug, Clone)] |
Collaborator
Author
There was a problem hiding this comment.
By the way, what's the benefit of having ordering on an error enum?
Collaborator
Author
|
Example in use: #[php_function]
pub fn example_eval() -> Result<Vec<String>> {
ext_php_rs::php::eval::eval("['a', 'b', 'c']").unwrap().extract()
} |
Collaborator
Author
|
Also I suspect this might be a bug, but it seems like wrapped functions are unable to directly return zvals? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a wrapper around eval. This function exposes zend's behaviour (expects an expression which is automatically prepended with "return"), which is different PHP's builtin's behaviour.
I'm not sure if it would make sense to make a PHP equivalent
evalas well (should be really easy to make), so I don't know if we want to be conservative with the exported name.The eval portion works nicely, but I have no idea how to go from
ZendObjecttoPHPException. Currently working around this by shoving theZendObjectintoError, but this feels icky.