Skip to content

Commit 9398f5e

Browse files
committed
Add ExecuteData get_argument method.
1 parent a86b165 commit 9398f5e

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

phper-sys/php_wrapper.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,7 @@ void phper_zval_ptr_dtor_nogc(zval *zval_ptr) {
184184
bool phper_z_refcounted_p(zval *zval_ptr) {
185185
return Z_REFCOUNTED_P(zval_ptr);
186186
}
187+
188+
zval *phper_execute_data_call_arg(zend_execute_data *execute_data, int index) {
189+
return ZEND_CALL_ARG(execute_data, index);
190+
}

phper-sys/php_wrapper.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,6 @@ void phper_zval_ptr_dtor_nogc(zval *zval_ptr);
6464

6565
bool phper_z_refcounted_p(zval *zval_ptr);
6666

67+
zval *phper_execute_data_call_arg(zend_execute_data *execute_data, int index);
68+
6769
#endif //PHPER_PHP_WRAPPER_H

phper/src/values.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use std::{
1717
collections::{BTreeMap, HashMap},
1818
convert::TryInto,
1919
mem::{transmute, zeroed},
20+
os::raw::c_int,
2021
str,
2122
str::Utf8Error,
2223
};
@@ -97,6 +98,13 @@ impl ExecuteData {
9798
}
9899
transmute(arguments)
99100
}
101+
102+
pub fn get_parameter(&mut self, index: usize) -> &mut Val {
103+
unsafe {
104+
let val = phper_execute_data_call_arg(self.as_mut_ptr(), index as c_int);
105+
Val::from_mut_ptr(val)
106+
}
107+
}
100108
}
101109

102110
/// Wrapper of [crate::sys::zval].

0 commit comments

Comments
 (0)