Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:43096 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 24588 invoked from network); 18 Feb 2009 18:52:51 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Feb 2009 18:52:51 -0000 Authentication-Results: pb1.pair.com smtp.mail=quickshiftin@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=quickshiftin@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.180 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: quickshiftin@gmail.com X-Host-Fingerprint: 209.85.217.180 mail-gx0-f180.google.com Received: from [209.85.217.180] ([209.85.217.180:54719] helo=mail-gx0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5C/0B-05623-2095C994 for ; Wed, 18 Feb 2009 13:52:51 -0500 Received: by gxk28 with SMTP id 28so113917gxk.23 for ; Wed, 18 Feb 2009 10:52:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=EWaeXfHTKaTJRzafYybeHcd42ILRyyCtZp/TwjeYxXc=; b=IMq2yfaDsnR7hyNKOjwbfxe+tjDyUZl2mP62tPF74G5NJ38lx/tLVqAa0g2lUZm/vv 9aiLkiE7feXXlMMLG/Un5U6TiYA0ogjoqVMo5kKjb0gBFYjchNpohtghn4pJwQMSxSgF NPP3XZ1/QH5eMVj6EQz9nc0vUPmSVCyLBoOAM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=JATQ0Fk6FZJiLMXspdy9BJ0GTpIFJ4ZioV7EazSmUPZ0pxLcljESr9kuWkc0Oj1vzo rJaA14LAN0HSBj8RLPbXWQUCpK3y9xrqtYz5OD51pG03+UFKdB+VnuDVKCAbUs2meSCe Ej8ljpsMlT1i9IpwWhFzkXeduiTeH3hwDWZvs= MIME-Version: 1.0 Received: by 10.231.19.204 with SMTP id c12mr1547427ibb.5.1234983167511; Wed, 18 Feb 2009 10:52:47 -0800 (PST) Date: Wed, 18 Feb 2009 11:52:47 -0700 Message-ID: <7dd2dc0b0902181052y41d65ec6x49646b0a8e6f5b64@mail.gmail.com> To: internals@lists.php.net Content-Type: multipart/alternative; boundary=00221532cf6c00cf7c046335edfd Subject: zend_call_method() - support for up to n params - no va_list From: quickshiftin@gmail.com (Nathan Nobbe) --00221532cf6c00cf7c046335edfd Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Wed, Feb 18, 2009 at 6:16 AM, Johannes Schl=C3=BCter = wrote: > But I don't think that a new limitation is any better: Tomorrow we have > to change it again as somebody has a reason to use 5 parameters, so if > it is changed it should be changed to take any number of arguments and > no fixed limit.... (or add a new API for that) given Johannes' feedback this morning, i created another patch, which adds zend_call_method_va(), it accepts an array of zvals. then i changed zend_call_method() to build the array and call zend_call_method_va(). it seems like this meets all the objectives. . support for n parameters . no emalloc calls . no va_list usage . zend_call_method() backwards compatible (lesser extent) your feedback appreciated, -nathan (and i did the diff in the right direction this time :D) --- zend_interfaces.ORIG.c 2009-02-17 20:24:47.000000000 -0700 +++ zend_interfaces.c 2009-02-18 11:44:53.000000000 -0700 @@ -29,9 +29,10 @@ ZEND_API zend_class_entry *zend_ce_arrayaccess; ZEND_API zend_class_entry *zend_ce_serializable; -/* {{{ zend_call_method + +/* {{{ zend_call_method_va Only returns the returned zval if retval_ptr !=3D NULL */ -ZEND_API zval* zend_call_method(zval **object_pp, zend_class_entry *obj_ce= , zend_function **fn_proxy, char *function_name, int function_name_len, zval **retval_ptr_ptr, int param_count, zval* arg1, zval* arg2 TSRMLS_DC) +ZEND_API zval* zend_call_method_va(zval **object_pp, zend_class_entry *obj_ce, zend_function **fn_proxy, char *function_name, int function_name_len, zval **retval_ptr_ptr, int param_count, zval** params TSRMLS_DC) { int result; zend_fcall_info fci; @@ -39,11 +40,6 @@ zval *retval; HashTable *function_table; - zval **params[2]; - - params[0] =3D &arg1; - params[1] =3D &arg2; - fci.size =3D sizeof(fci); /*fci.function_table =3D NULL; will be read form zend_class_entry of object if needed */ fci.object_ptr =3D object_pp ? *object_pp : NULL; @@ -107,6 +103,19 @@ } /* }}} */ +/* {{{ zend_call_method + Only returns the returned zval if retval_ptr !=3D NULL */ +ZEND_API zval* zend_call_method(zval **object_pp, zend_class_entry *obj_ce= , zend_function **fn_proxy, char *function_name, int function_name_len, zval **retval_ptr_ptr, int param_count, zval* arg1, zval* arg2 TSRMLS_DC) +{ + zval **params[2]; + + params[0] =3D &arg1; + params[1] =3D &arg2; + + return zend_call_method_va(object_pp, obj_ce, fn_proxy, function_name, function_name_len, retval_ptr_ptr, param_count, params TSRMLS_CC); +} +/* }}} */ + /* iterator interface, c-level functions used by engine */ /* {{{ zend_user_it_new_iterator */ --- zend_interfaces.ORIG.h 2009-02-17 20:24:36.000000000 -0700 +++ zend_interfaces.h 2009-02-18 11:28:55.000000000 -0700 @@ -38,6 +38,8 @@ zval *value; } zend_user_iterator; +ZEND_API zval* zend_call_method_va(zval **object_pp, zend_class_entry *obj_ce, zend_function **fn_proxy, char *function_name, int function_name_len, zval **retval_ptr_ptr, int param_count, zval** params TSRMLS_DC); + ZEND_API zval* zend_call_method(zval **object_pp, zend_class_entry *obj_ce= , zend_function **fn_proxy, char *function_name, int function_name_len, zval **retval_ptr_ptr, int param_count, zval* arg1, zval* arg2 TSRMLS_DC); #define zend_call_method_with_0_params(obj, obj_ce, fn_proxy, function_name, retval) \ --00221532cf6c00cf7c046335edfd--