Struct ext_php_rs::ffi::_zend_executor_globals
source · #[repr(C)]pub struct _zend_executor_globals {Show 76 fields
pub uninitialized_zval: zval,
pub error_zval: zval,
pub symtable_cache: [*mut zend_array; 32],
pub symtable_cache_limit: *mut *mut zend_array,
pub symtable_cache_ptr: *mut *mut zend_array,
pub symbol_table: zend_array,
pub included_files: HashTable,
pub bailout: *mut jmp_buf,
pub error_reporting: c_int,
pub exit_status: c_int,
pub function_table: *mut HashTable,
pub class_table: *mut HashTable,
pub zend_constants: *mut HashTable,
pub vm_stack_top: *mut zval,
pub vm_stack_end: *mut zval,
pub vm_stack: zend_vm_stack,
pub vm_stack_page_size: usize,
pub current_execute_data: *mut _zend_execute_data,
pub fake_scope: *mut zend_class_entry,
pub jit_trace_num: u32,
pub precision: zend_long,
pub ticks_count: c_int,
pub persistent_constants_count: u32,
pub persistent_functions_count: u32,
pub persistent_classes_count: u32,
pub in_autoload: *mut HashTable,
pub full_tables_cleanup: bool,
pub no_extensions: bool,
pub vm_interrupt: zend_atomic_bool,
pub timed_out: zend_atomic_bool,
pub hard_timeout: zend_long,
pub regular_list: HashTable,
pub persistent_list: HashTable,
pub user_error_handler_error_reporting: c_int,
pub user_error_handler: zval,
pub user_exception_handler: zval,
pub user_error_handlers_error_reporting: zend_stack,
pub user_error_handlers: zend_stack,
pub user_exception_handlers: zend_stack,
pub error_handling: zend_error_handling_t,
pub exception_class: *mut zend_class_entry,
pub timeout_seconds: zend_long,
pub capture_warnings_during_sccp: c_int,
pub ini_directives: *mut HashTable,
pub modified_ini_directives: *mut HashTable,
pub error_reporting_ini_entry: *mut zend_ini_entry,
pub objects_store: zend_objects_store,
pub exception: *mut zend_object,
pub prev_exception: *mut zend_object,
pub opline_before_exception: *const zend_op,
pub exception_op: [zend_op; 3],
pub current_module: *mut _zend_module_entry,
pub active: bool,
pub flags: zend_uchar,
pub assertions: zend_long,
pub ht_iterators_count: u32,
pub ht_iterators_used: u32,
pub ht_iterators: *mut HashTableIterator,
pub ht_iterators_slots: [HashTableIterator; 16],
pub saved_fpu_cw_ptr: *mut c_void,
pub trampoline: zend_function,
pub call_trampoline_op: zend_op,
pub weakrefs: HashTable,
pub exception_ignore_args: bool,
pub exception_string_param_max_len: zend_long,
pub get_gc_buffer: zend_get_gc_buffer,
pub main_fiber_context: *mut zend_fiber_context,
pub current_fiber_context: *mut zend_fiber_context,
pub active_fiber: *mut zend_fiber,
pub fiber_stack_size: zend_long,
pub record_errors: bool,
pub num_errors: u32,
pub errors: *mut *mut zend_error_info,
pub filename_override: *mut zend_string,
pub lineno_override: zend_long,
pub reserved: [*mut c_void; 6],
}
Fields§
§uninitialized_zval: zval
§error_zval: zval
§symtable_cache: [*mut zend_array; 32]
§symtable_cache_limit: *mut *mut zend_array
§symtable_cache_ptr: *mut *mut zend_array
§symbol_table: zend_array
§included_files: HashTable
§bailout: *mut jmp_buf
§error_reporting: c_int
§exit_status: c_int
§function_table: *mut HashTable
§class_table: *mut HashTable
§zend_constants: *mut HashTable
§vm_stack_top: *mut zval
§vm_stack_end: *mut zval
§vm_stack: zend_vm_stack
§vm_stack_page_size: usize
§current_execute_data: *mut _zend_execute_data
§fake_scope: *mut zend_class_entry
§jit_trace_num: u32
§precision: zend_long
§ticks_count: c_int
§persistent_constants_count: u32
§persistent_functions_count: u32
§persistent_classes_count: u32
§in_autoload: *mut HashTable
§full_tables_cleanup: bool
§no_extensions: bool
§vm_interrupt: zend_atomic_bool
§timed_out: zend_atomic_bool
§hard_timeout: zend_long
§regular_list: HashTable
§persistent_list: HashTable
§user_error_handler_error_reporting: c_int
§user_error_handler: zval
§user_exception_handler: zval
§user_error_handlers_error_reporting: zend_stack
§user_error_handlers: zend_stack
§user_exception_handlers: zend_stack
§error_handling: zend_error_handling_t
§exception_class: *mut zend_class_entry
§timeout_seconds: zend_long
§capture_warnings_during_sccp: c_int
§ini_directives: *mut HashTable
§modified_ini_directives: *mut HashTable
§error_reporting_ini_entry: *mut zend_ini_entry
§objects_store: zend_objects_store
§exception: *mut zend_object
§prev_exception: *mut zend_object
§opline_before_exception: *const zend_op
§exception_op: [zend_op; 3]
§current_module: *mut _zend_module_entry
§active: bool
§flags: zend_uchar
§assertions: zend_long
§ht_iterators_count: u32
§ht_iterators_used: u32
§ht_iterators: *mut HashTableIterator
§ht_iterators_slots: [HashTableIterator; 16]
§saved_fpu_cw_ptr: *mut c_void
§trampoline: zend_function
§call_trampoline_op: zend_op
§weakrefs: HashTable
§exception_ignore_args: bool
§exception_string_param_max_len: zend_long
§get_gc_buffer: zend_get_gc_buffer
§main_fiber_context: *mut zend_fiber_context
§current_fiber_context: *mut zend_fiber_context
§active_fiber: *mut zend_fiber
§fiber_stack_size: zend_long
§record_errors: bool
§num_errors: u32
§errors: *mut *mut zend_error_info
§filename_override: *mut zend_string
§lineno_override: zend_long
§reserved: [*mut c_void; 6]
Implementations§
source§impl _zend_executor_globals
impl _zend_executor_globals
sourcepub fn get() -> GlobalReadGuard<Self>
pub fn get() -> GlobalReadGuard<Self>
Returns a reference to the PHP executor globals.
The executor globals are guarded by a RwLock. There can be multiple immutable references at one time but only ever one mutable reference. Attempting to retrieve the globals while already holding the global guard will lead to a deadlock. Dropping the globals guard will release the lock.
sourcepub fn class_table(&self) -> Option<&ZendHashTable>
pub fn class_table(&self) -> Option<&ZendHashTable>
Attempts to retrieve the global class hash table.
sourcepub fn take_exception() -> Option<ZBox<ZendObject>>
pub fn take_exception() -> Option<ZBox<ZendObject>>
Attempts to extract the last PHP exception captured by the interpreter.
Returned inside a ZBox
.
This function requires the executor globals to be mutably held, which could lead to a deadlock if the globals are already borrowed immutably or mutably.
Examples found in repository?
src/types/callable.rs (line 128)
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
pub fn try_call(&self, params: Vec<&dyn IntoZvalDyn>) -> Result<Zval> {
if !self.0.is_callable() {
return Err(Error::Callable);
}
let mut retval = Zval::new();
let len = params.len();
let params = params
.into_iter()
.map(|val| val.as_zval(false))
.collect::<Result<Vec<_>>>()?;
let packed = params.into_boxed_slice();
let result = unsafe {
_call_user_function_impl(
std::ptr::null_mut(),
self.0.as_ref() as *const crate::ffi::_zval_struct as *mut crate::ffi::_zval_struct,
&mut retval,
len as _,
packed.as_ptr() as *mut _,
std::ptr::null_mut(),
)
};
if result < 0 {
Err(Error::Callable)
} else if let Some(e) = ExecutorGlobals::take_exception() {
Err(Error::Exception(e))
} else {
Ok(retval)
}
}
More examples
src/types/object.rs (line 340)
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358
fn from_zend_object(obj: &ZendObject) -> Result<Self> {
let mut ret = Zval::new();
unsafe {
zend_call_known_function(
(*obj.ce).__tostring,
obj as *const _ as *mut _,
obj.ce,
&mut ret,
0,
std::ptr::null_mut(),
std::ptr::null_mut(),
);
}
if let Some(err) = ExecutorGlobals::take_exception() {
// TODO: become an error
let class_name = obj.get_class_name();
panic!(
"Uncaught exception during call to {}::__toString(): {:?}",
class_name.expect("unable to determine class name"),
err
);
} else if let Some(output) = ret.extract() {
Ok(output)
} else {
// TODO: become an error
let class_name = obj.get_class_name();
panic!(
"{}::__toString() must return a string",
class_name.expect("unable to determine class name"),
);
}
}