Skip to content

Commit 3555a34

Browse files
committed
more function-based methods
1 parent ab294eb commit 3555a34

File tree

2 files changed

+35
-10
lines changed

2 files changed

+35
-10
lines changed

phper-sys/php_wrapper.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,10 @@ void phper_zval_str(zval *zv, zend_string *s) {
198198
ZVAL_STR(zv, s);
199199
}
200200

201+
void phper_zval_undef(zval *zv) {
202+
ZVAL_UNDEF(zv);
203+
}
204+
201205
void phper_convert_to_long(zval *op) {
202206
convert_to_long(op);
203207
}
@@ -451,11 +455,39 @@ uint32_t phper_zend_num_args(const zend_execute_data *execute_data) {
451455
return ZEND_NUM_ARGS();
452456
}
453457

458+
uint32_t phper_zend_call_num_args(const zend_execute_data *execute_data) {
459+
return ZEND_CALL_NUM_ARGS(execute_data);
460+
}
461+
462+
void phper_zend_set_call_num_args(zend_execute_data *execute_data, uint32_t num) {
463+
ZEND_CALL_NUM_ARGS(execute_data) = num;
464+
}
465+
466+
uint32_t phper_zend_call_info(zend_execute_data *execute_data) {
467+
return ZEND_CALL_INFO(execute_data);
468+
}
469+
470+
void phper_zend_add_call_flag(zend_execute_data *execute_data, uint32_t flag) {
471+
ZEND_ADD_CALL_FLAG(execute_data, flag);
472+
}
473+
474+
uint32_t phper_zend_call_may_have_undef() {
475+
return ZEND_CALL_MAY_HAVE_UNDEF;
476+
}
477+
454478
bool phper_zend_get_parameters_array_ex(uint32_t param_count,
455479
zval *argument_array) {
456480
return zend_get_parameters_array_ex(param_count, argument_array) != 0;
457481
}
458482

483+
int phper_zend_result_success() {
484+
return SUCCESS;
485+
}
486+
487+
int phper_zend_result_failure() {
488+
return FAILURE;
489+
}
490+
459491
// ==================================================
460492
// memory apis:
461493
// ==================================================

phper/src/values.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -179,21 +179,14 @@ impl ExecuteData {
179179
/// Gets associated `$this` object if exists.
180180
pub fn get_this(&mut self) -> Option<&ZObj> {
181181
unsafe {
182-
let val = ZVal::from_ptr(phper_get_this(&mut self.inner));
183-
val.as_z_obj()
182+
ZVal::try_from_ptr(phper_get_this(&mut self.inner))?.as_z_obj()
184183
}
185184
}
186185

187186
/// Gets associated mutable `$this` object if exists.
188187
pub fn get_this_mut(&mut self) -> Option<&mut ZObj> {
189188
unsafe {
190-
let ptr = phper_get_this(&mut self.inner);
191-
if ptr.is_null() {
192-
None
193-
} else {
194-
let val = ZVal::from_mut_ptr(ptr);
195-
val.as_mut_z_obj()
196-
}
189+
ZVal::try_from_mut_ptr(phper_get_this(&mut self.inner))?.as_mut_z_obj()
197190
}
198191
}
199192

@@ -209,7 +202,7 @@ impl ExecuteData {
209202
}
210203
}
211204

212-
pub unsafe fn get_parameters_array(&mut self) -> Vec<ManuallyDrop<ZVal>> {
205+
pub(crate) unsafe fn get_parameters_array(&mut self) -> Vec<ManuallyDrop<ZVal>> {
213206
unsafe {
214207
let num_args = self.num_args();
215208
let mut arguments = vec![zeroed::<zval>(); num_args];

0 commit comments

Comments
 (0)