mirror of
https://github.com/danog/ext-php-rs.git
synced 2024-12-03 10:07:44 +01:00
Merge pull request #259 from davidcole1340/function-helper
Add function type helper function
This commit is contained in:
commit
80e448c0a1
@ -6,6 +6,8 @@ use crate::{
|
||||
types::{ZendClassObject, ZendObject, Zval},
|
||||
};
|
||||
|
||||
use super::function::Function;
|
||||
|
||||
/// Execute data passed when a function is called from PHP.
|
||||
///
|
||||
/// This generally contains things related to the call, including but not
|
||||
@ -194,6 +196,16 @@ impl ExecuteData {
|
||||
self.This.object_mut()
|
||||
}
|
||||
|
||||
/// Attempt to retrieve the function that is being called.
|
||||
pub fn function(&self) -> Option<&Function> {
|
||||
unsafe { self.func.as_ref() }
|
||||
}
|
||||
|
||||
/// Attempt to retrieve the previous execute data on the call stack.
|
||||
pub fn previous(&self) -> Option<&Self> {
|
||||
unsafe { self.prev_execute_data.as_ref() }
|
||||
}
|
||||
|
||||
/// Translation of macro `ZEND_CALL_ARG(call, n)`
|
||||
/// zend_compile.h:578
|
||||
///
|
||||
|
@ -9,6 +9,7 @@ use crate::{
|
||||
zend_call_known_function, zend_fetch_function_str, zend_function, zend_function_entry,
|
||||
zend_hash_str_find_ptr_lc,
|
||||
},
|
||||
flags::FunctionType,
|
||||
types::Zval,
|
||||
};
|
||||
|
||||
@ -50,6 +51,10 @@ impl FunctionEntry {
|
||||
pub type Function = zend_function;
|
||||
|
||||
impl Function {
|
||||
pub fn function_type(&self) -> FunctionType {
|
||||
FunctionType::from(unsafe { self.type_ })
|
||||
}
|
||||
|
||||
pub fn try_from_function(name: &str) -> Option<Self> {
|
||||
unsafe {
|
||||
let res = zend_fetch_function_str(name.as_ptr() as *const c_char, name.len());
|
||||
|
Loading…
Reference in New Issue
Block a user