mirror of
https://github.com/danog/ext-php-rs.git
synced 2024-11-30 04:39:04 +01:00
add ability to define abstract methods (#171)
* add ability to define abstract methods `new_abstract` can be used for interface and abstract class methods. * rustfmt
This commit is contained in:
parent
5f33598fcf
commit
4133a0fe78
@ -85,7 +85,7 @@ impl ClassBuilder {
|
|||||||
/// * `func` - The function entry to add to the class.
|
/// * `func` - The function entry to add to the class.
|
||||||
/// * `flags` - Flags relating to the function. See [`MethodFlags`].
|
/// * `flags` - Flags relating to the function. See [`MethodFlags`].
|
||||||
pub fn method(mut self, mut func: FunctionEntry, flags: MethodFlags) -> Self {
|
pub fn method(mut self, mut func: FunctionEntry, flags: MethodFlags) -> Self {
|
||||||
func.flags = flags.bits();
|
func.flags |= flags.bits();
|
||||||
self.methods.push(func);
|
self.methods.push(func);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
args::{Arg, ArgInfo},
|
args::{Arg, ArgInfo},
|
||||||
error::{Error, Result},
|
error::{Error, Result},
|
||||||
flags::DataType,
|
flags::{DataType, MethodFlags},
|
||||||
types::Zval,
|
types::Zval,
|
||||||
zend::{ExecuteData, FunctionEntry, ZendType},
|
zend::{ExecuteData, FunctionEntry, ZendType},
|
||||||
};
|
};
|
||||||
@ -64,6 +64,30 @@ impl<'a> FunctionBuilder<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Create a new function builder for an abstract function that can be used
|
||||||
|
/// on an abstract class or an interface.
|
||||||
|
///
|
||||||
|
/// # Parameters
|
||||||
|
///
|
||||||
|
/// * `name` - The name of the function.
|
||||||
|
pub fn new_abstract<T: Into<String>>(name: T) -> Self {
|
||||||
|
Self {
|
||||||
|
name: name.into(),
|
||||||
|
function: FunctionEntry {
|
||||||
|
fname: ptr::null(),
|
||||||
|
handler: None,
|
||||||
|
arg_info: ptr::null(),
|
||||||
|
num_args: 0,
|
||||||
|
flags: MethodFlags::Abstract.bits(),
|
||||||
|
},
|
||||||
|
args: vec![],
|
||||||
|
n_req: None,
|
||||||
|
retval: None,
|
||||||
|
ret_as_ref: false,
|
||||||
|
ret_as_null: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Creates a constructor builder, used to build the constructor
|
/// Creates a constructor builder, used to build the constructor
|
||||||
/// for classes.
|
/// for classes.
|
||||||
///
|
///
|
||||||
|
Loading…
Reference in New Issue
Block a user