|
12 | 12 |
|
13 | 13 | use crate::{ |
14 | 14 | arrays::ZArr, |
15 | | - errors::{ClassNotFoundError, InitializeObjectError}, |
| 15 | + errors::{ClassNotFoundError, InitializeObjectError, Throwable}, |
16 | 16 | functions::{Function, FunctionEntry, Method, MethodEntity}, |
17 | 17 | objects::{StateObj, StateObject, ZObj, ZObject}, |
18 | 18 | strings::ZStr, |
@@ -206,24 +206,26 @@ impl<T: 'static> ClassEntity<T> { |
206 | 206 | } |
207 | 207 | } |
208 | 208 |
|
209 | | - pub fn add_method<F, R>( |
| 209 | + pub fn add_method<F, Z, E>( |
210 | 210 | &mut self, name: impl Into<String>, vis: Visibility, handler: F, |
211 | 211 | ) -> &mut MethodEntity |
212 | 212 | where |
213 | | - F: Fn(&mut StateObj<T>, &mut [ZVal]) -> R + Send + Sync + 'static, |
214 | | - R: Into<ZVal> + 'static, |
| 213 | + F: Fn(&mut StateObj<T>, &mut [ZVal]) -> Result<Z, E> + 'static, |
| 214 | + Z: Into<ZVal> + 'static, |
| 215 | + E: Throwable + 'static, |
215 | 216 | { |
216 | 217 | self.method_entities |
217 | 218 | .push(MethodEntity::new(name, Rc::new(Method::new(handler)), vis)); |
218 | 219 | self.method_entities.last_mut().unwrap() |
219 | 220 | } |
220 | 221 |
|
221 | | - pub fn add_static_method<F, R>( |
| 222 | + pub fn add_static_method<F, Z, E>( |
222 | 223 | &mut self, name: impl Into<String>, vis: Visibility, handler: F, |
223 | 224 | ) -> &mut MethodEntity |
224 | 225 | where |
225 | | - F: Fn(&mut [ZVal]) -> R + Send + Sync + 'static, |
226 | | - R: Into<ZVal> + 'static, |
| 226 | + F: Fn(&mut [ZVal]) -> Result<Z, E> + 'static, |
| 227 | + Z: Into<ZVal> + 'static, |
| 228 | + E: Throwable + 'static, |
227 | 229 | { |
228 | 230 | let mut entity = MethodEntity::new(name, Rc::new(Function::new(handler)), vis); |
229 | 231 | entity.r#static(true); |
|
0 commit comments