Skip to content

Add zend_call_known_function() API family#5692

Closed
nikic wants to merge 2 commits into
php:masterfrom
nikic:call-method-1
Closed

Add zend_call_known_function() API family#5692
nikic wants to merge 2 commits into
php:masterfrom
nikic:call-method-1

Conversation

@nikic

@nikic nikic commented Jun 9, 2020

Copy link
Copy Markdown
Member

This adds the following APIs:

void zend_call_known_function(
    zend_function *fn, zend_object *object, zend_class_entry *called_scope,
    zval *retval_ptr, int param_count, zval *params);

void zend_call_known_instance_method(
    zend_function *fn, zend_object *object, zval *retval_ptr, int param_count, zval *params);
void zend_call_known_instance_method_with_0_params(
    zend_function *fn, zend_object *object, zval *retval_ptr);
void zend_call_known_instance_method_with_1_params(
    zend_function *fn, zend_object *object, zval *retval_ptr, zval *param);
void zend_call_known_instance_method_with_2_params(
    zend_function *fn, zend_object *object, zval *retval_ptr, zval *param1, zval *param2);

These are used to perform a call if you already have the zend_function you want to call. zend_call_known_function() is the base API, the rest are just really thin wrappers around it for the common case of instance method calls.

cc @twose This splits out the part of the zend_call_method functionality that does not require a method name at all.

cc @morrisonlevi I believe you asked me about this at some point.

@twose

twose commented Jun 9, 2020

Copy link
Copy Markdown
Member

nice, it looks good to me

@Girgias

Girgias commented Jun 9, 2020

Copy link
Copy Markdown
Member

Shouldn't the param_count argument be a uint32_t?

@nikic

nikic commented Jun 9, 2020

Copy link
Copy Markdown
Member Author

Shouldn't the param_count argument be a uint32_t?

Done!

@twose

twose commented Jun 9, 2020

Copy link
Copy Markdown
Member

Shouldn't the param_count argument be a uint32_t?

Done!

Shouldn't the param_count argument of zend_call_method be a uint32_t too?

@php-pulls php-pulls closed this in 257dbb0 Jun 9, 2020
@nikic

nikic commented Jun 9, 2020

Copy link
Copy Markdown
Member Author

@twose I've adjusted the zend_call_method type while merging.

I've also replaced a few more cases where the new function is useful, found by git grep "ZVAL_UNDEF.*function_name". There are still a couple more candidates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants