mirror of
https://github.com/danog/ext-php-rs.git
synced 2024-11-30 04:39:04 +01:00
Cargo fmt
This commit is contained in:
parent
c87c0dcdb6
commit
891fa4ad3d
@ -35,7 +35,7 @@ pub mod zend;
|
|||||||
/// A module typically glob-imported containing the typically required macros
|
/// A module typically glob-imported containing the typically required macros
|
||||||
/// and imports.
|
/// and imports.
|
||||||
pub mod prelude {
|
pub mod prelude {
|
||||||
|
|
||||||
pub use crate::builders::ModuleBuilder;
|
pub use crate::builders::ModuleBuilder;
|
||||||
#[cfg(any(docs, feature = "closure"))]
|
#[cfg(any(docs, feature = "closure"))]
|
||||||
#[cfg_attr(docs, doc(cfg(feature = "closure")))]
|
#[cfg_attr(docs, doc(cfg(feature = "closure")))]
|
||||||
|
@ -9,8 +9,9 @@ use crate::{
|
|||||||
convert::{FromZendObject, FromZval, FromZvalMut, IntoZval, IntoZvalDyn},
|
convert::{FromZendObject, FromZval, FromZvalMut, IntoZval, IntoZvalDyn},
|
||||||
error::{Error, Result},
|
error::{Error, Result},
|
||||||
ffi::{
|
ffi::{
|
||||||
ext_php_rs_zend_object_release, zend_call_known_function, zend_object, zend_objects_new,
|
ext_php_rs_zend_object_release, object_properties_init, zend_call_known_function,
|
||||||
HashTable, ZEND_ISEMPTY, ZEND_PROPERTY_EXISTS, ZEND_PROPERTY_ISSET, zend_hash_str_find_ptr_lc, zend_function, object_properties_init,
|
zend_function, zend_hash_str_find_ptr_lc, zend_object, zend_objects_new, HashTable,
|
||||||
|
ZEND_ISEMPTY, ZEND_PROPERTY_EXISTS, ZEND_PROPERTY_ISSET,
|
||||||
},
|
},
|
||||||
flags::DataType,
|
flags::DataType,
|
||||||
rc::PhpRc,
|
rc::PhpRc,
|
||||||
@ -49,8 +50,8 @@ impl ZendObject {
|
|||||||
}
|
}
|
||||||
object_properties_init(ptr, ce as *const _ as *mut _);
|
object_properties_init(ptr, ce as *const _ as *mut _);
|
||||||
ptr
|
ptr
|
||||||
},
|
}
|
||||||
Some(v) => v(ce as *const _ as *mut _)
|
Some(v) => v(ce as *const _ as *mut _),
|
||||||
};
|
};
|
||||||
|
|
||||||
ZBox::from_raw(
|
ZBox::from_raw(
|
||||||
@ -132,7 +133,6 @@ impl ZendObject {
|
|||||||
(self.ce as *const ClassEntry).eq(&(T::get_metadata().ce() as *const _))
|
(self.ce as *const ClassEntry).eq(&(T::get_metadata().ce() as *const _))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn try_call_method(&self, name: &str, params: Vec<&dyn IntoZvalDyn>) -> Result<Zval> {
|
pub fn try_call_method(&self, name: &str, params: Vec<&dyn IntoZvalDyn>) -> Result<Zval> {
|
||||||
let mut retval = Zval::new();
|
let mut retval = Zval::new();
|
||||||
@ -147,10 +147,10 @@ impl ZendObject {
|
|||||||
let res = zend_hash_str_find_ptr_lc(
|
let res = zend_hash_str_find_ptr_lc(
|
||||||
&(*self.ce).function_table,
|
&(*self.ce).function_table,
|
||||||
name.as_ptr() as *const i8,
|
name.as_ptr() as *const i8,
|
||||||
name.len()
|
name.len(),
|
||||||
) as *mut zend_function;
|
) as *mut zend_function;
|
||||||
if res.is_null() {
|
if res.is_null() {
|
||||||
return Err(Error::Callable)
|
return Err(Error::Callable);
|
||||||
}
|
}
|
||||||
zend_call_known_function(
|
zend_call_known_function(
|
||||||
res,
|
res,
|
||||||
|
@ -208,7 +208,9 @@ impl Zval {
|
|||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn try_call_method(&self, name: &str, params: Vec<&dyn IntoZvalDyn>) -> Result<Zval> {
|
pub fn try_call_method(&self, name: &str, params: Vec<&dyn IntoZvalDyn>) -> Result<Zval> {
|
||||||
self.object().ok_or(Error::Object)?.try_call_method(name, params)
|
self.object()
|
||||||
|
.ok_or(Error::Object)?
|
||||||
|
.try_call_method(name, params)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the value of the zval if it is a reference.
|
/// Returns the value of the zval if it is a reference.
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
//! Builder and objects for creating classes in the PHP world.
|
//! Builder and objects for creating classes in the PHP world.
|
||||||
|
|
||||||
use crate::{ffi::{zend_class_entry}, flags::ClassFlags, types::{ZendStr, ZendObject}, zend::ExecutorGlobals, boxed::ZBox};
|
use crate::{
|
||||||
|
boxed::ZBox,
|
||||||
|
ffi::zend_class_entry,
|
||||||
|
flags::ClassFlags,
|
||||||
|
types::{ZendObject, ZendStr},
|
||||||
|
zend::ExecutorGlobals,
|
||||||
|
};
|
||||||
use std::{convert::TryInto, fmt::Debug, ops::DerefMut};
|
use std::{convert::TryInto, fmt::Debug, ops::DerefMut};
|
||||||
|
|
||||||
/// A PHP class entry.
|
/// A PHP class entry.
|
||||||
|
@ -1,8 +1,16 @@
|
|||||||
//! Builder for creating functions and methods in PHP.
|
//! Builder for creating functions and methods in PHP.
|
||||||
|
|
||||||
use std::{fmt::Debug, os::raw::c_char, ptr::self};
|
use std::{fmt::Debug, os::raw::c_char, ptr};
|
||||||
|
|
||||||
use crate::{ffi::{zend_function_entry, zend_fetch_function_str, zend_function, zend_hash_str_find_ptr_lc, zend_call_known_function}, convert::IntoZvalDyn, types::Zval, error::Result};
|
use crate::{
|
||||||
|
convert::IntoZvalDyn,
|
||||||
|
error::Result,
|
||||||
|
ffi::{
|
||||||
|
zend_call_known_function, zend_fetch_function_str, zend_function, zend_function_entry,
|
||||||
|
zend_hash_str_find_ptr_lc,
|
||||||
|
},
|
||||||
|
types::Zval,
|
||||||
|
};
|
||||||
|
|
||||||
use super::ClassEntry;
|
use super::ClassEntry;
|
||||||
|
|
||||||
@ -58,14 +66,14 @@ impl Function {
|
|||||||
let res = zend_hash_str_find_ptr_lc(
|
let res = zend_hash_str_find_ptr_lc(
|
||||||
&ce.function_table,
|
&ce.function_table,
|
||||||
name.as_ptr() as *const i8,
|
name.as_ptr() as *const i8,
|
||||||
name.len()
|
name.len(),
|
||||||
) as *mut zend_function;
|
) as *mut zend_function;
|
||||||
if res.is_null() {
|
if res.is_null() {
|
||||||
return None
|
return None;
|
||||||
}
|
}
|
||||||
return Some(*res)
|
return Some(*res);
|
||||||
}
|
},
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_function(name: &str) -> Self {
|
pub fn from_function(name: &str) -> Self {
|
||||||
|
@ -4,7 +4,6 @@ use std::ops::{Deref, DerefMut};
|
|||||||
|
|
||||||
use parking_lot::{const_rwlock, RwLock, RwLockReadGuard, RwLockWriteGuard};
|
use parking_lot::{const_rwlock, RwLock, RwLockReadGuard, RwLockWriteGuard};
|
||||||
|
|
||||||
|
|
||||||
use crate::boxed::ZBox;
|
use crate::boxed::ZBox;
|
||||||
#[cfg(php82)]
|
#[cfg(php82)]
|
||||||
use crate::ffi::zend_atomic_bool_store;
|
use crate::ffi::zend_atomic_bool_store;
|
||||||
@ -144,4 +143,4 @@ impl<T> DerefMut for GlobalWriteGuard<T> {
|
|||||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||||
self.globals
|
self.globals
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,8 @@ use std::ffi::CString;
|
|||||||
pub use _type::ZendType;
|
pub use _type::ZendType;
|
||||||
pub use class::ClassEntry;
|
pub use class::ClassEntry;
|
||||||
pub use ex::ExecuteData;
|
pub use ex::ExecuteData;
|
||||||
pub use function::FunctionEntry;
|
|
||||||
pub use function::Function;
|
pub use function::Function;
|
||||||
|
pub use function::FunctionEntry;
|
||||||
pub use globals::ExecutorGlobals;
|
pub use globals::ExecutorGlobals;
|
||||||
pub use handlers::ZendObjectHandlers;
|
pub use handlers::ZendObjectHandlers;
|
||||||
pub use module::ModuleEntry;
|
pub use module::ModuleEntry;
|
||||||
|
Loading…
Reference in New Issue
Block a user