Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108066 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 87338 invoked from network); 9 Jan 2020 17:22:38 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 9 Jan 2020 17:22:38 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 60B921804A8 for ; Thu, 9 Jan 2020 07:28:19 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS42189 45.92.236.0/22 X-Spam-Virus: No X-Envelope-From: Received: from mail.noctuint.cz (mail.noctuint.cz [45.92.238.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 9 Jan 2020 07:28:18 -0800 (PST) Received: from mail.noctuint.cz (localhost [127.0.0.1]) by mail.noctuint.cz (Postfix) with ESMTP id 62C95610CC1; Thu, 9 Jan 2020 16:28:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=noctuint.cz; h=from:to:cc :references:in-reply-to:subject:date:message-id:mime-version :content-type:content-transfer-encoding; s=mail; bh=BTE/MGWeFVJM 3cHmfnvlBSHuwVI=; b=LI7aia6BX2AP6HCsXVcCNPzmddXz/UILAa7NCPBuOIYz lqW7mLWq7+PXze0mO/Y7DZcrsehELQ0SQcTWBn2RSK/F+tTLMN+Ihp0dU/aGKdru fjslXCdCc5G0N4WFSqtVr2Uz8+Eyvr5+4GhEvy1PpNkn2jS4TSG/toQDWBupZCo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=noctuint.cz; h=from:to:cc :references:in-reply-to:subject:date:message-id:mime-version :content-type:content-transfer-encoding; q=dns; s=mail; b=LMmDI2 Ok/3TIOGaAku14Vsdv/38Noe/kQVqnxFrQOhRXe39b/wso/ruXvMZgj81IOx+drv k0xXmv7ChR/X0W0/5iiYJ9cCWiJsFiRkFftilUaVWQUsKwH4J4C5FkFgS/eCByGK uHyc1ySBhtsj4zq0WWsLV3pS0xLx0Z1nc9oQc= Received: from nbmdolezal (unknown [82.142.101.30]) by mail.noctuint.cz (Postfix) with ESMTPSA id F1D08610CC0; Thu, 9 Jan 2020 16:28:15 +0100 (CET) Reply-To: To: "'Nikita Popov'" Cc: "'PHP internals'" References: <003401d5c634$3b617760$b2246620$@noctuint.cz> <004b01d5c636$e36f1820$aa4d4860$@noctuint.cz> In-Reply-To: Date: Thu, 9 Jan 2020 16:28:12 +0100 Message-ID: <008d01d5c701$69bd8360$3d388a20$@noctuint.cz> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQIm0QP2lWPEtE74Z2zXpcTPc0o8WgKNlciDAY0CtugBpTvF86cSYLAQ Content-Language: cs Subject: RE: [PHP-DEV] zend_call_method with arguments passed by reference From: internals@lists.php.net ("mdolezal.noctuint.cz via internals") Thanks a lot Nikita, that=E2=80=99s it. I was not aware of no_separation influence, it was = set to 1 in zend_call_method both in PHP5 and PHP7 so I didn't touch it = during migration. I need to copy the arguments properly back now but = basically it's working. Thanks again, Martin =20 -----Original Message----- From: Nikita Popov =20 Sent: Thursday, January 9, 2020 1:17 PM To: mdolezal@noctuint.cz Cc: PHP internals Subject: Re: [PHP-DEV] zend_call_method with arguments passed by = reference On Wed, Jan 8, 2020 at 4:18 PM wrote: > Thank you for your answer Nikita. > Can you please give me more details what you mean? I can try that = approach. > zend_call_method copies the args to params array which is assigned to=20 > zend_fcall_info fci. > I can pass there for example "test" zval string. > Then the mentioned lower level zend_call_function() is called with fci = > as parameter, that's what I do. > In PHP code "test" is changed to "changed". > But after the call the fci.params are not changed, still "test", so I=20 > have nothing to copy back manually. > fci.params *should* contain the changed parameters after the call, at = least assuming no_separation=3D0. It's not clear to me under what = circumstances that wouldn't work. Nikita > -----Original Message----- > From: Nikita Popov > Sent: Wednesday, January 8, 2020 4:06 PM > To: mdolezal@noctuint.cz > Cc: PHP internals > Subject: Re: [PHP-DEV] zend_call_method with arguments passed by=20 > reference > > On Wed, Jan 8, 2020 at 3:59 PM mdolezal.noctuint.cz via internals <=20 > internals@lists.php.net> wrote: > > > Hello, > > > > I hope this is the appropriate mailing list, please redirect me to=20 > > better please if required. > > > > > > > > I am currently rewriting our PHP extension from PHP5 to PHP7. > > > > To call PHP methods from our C/C++ code we use slightly modified=20 > > zend_call_method from Zend/zend_interfaces.c (to use more arguments=20 > > than 2). > > > > > > Now I found out that it does not work with arguments passed by=20 > > reference, such as: > > > > public function FuncWithRef(array &$changeThis) > > > > > > > > if values are changed in the PHP code then zval values back in C=20 > > part after zend_call_function call are not influenced. > > > > With PHP5 the value was overwritten and could be used later in C = code. > > > > Previously the zend_fcall_info struct for function call was filled=20 > > with params simply by > > > > > > > > params[0] =3D &arg1; > > > > > > > > In PHP7 this is changed to > > > > > > > > ZVAL_COPY_VALUE(¶ms[0], arg1); > > > > > > > > After function is executed (zend_call_function) both fci.params and > > arg1 contain still the original zval values, > > > > changes made in PHP code are not available. Is there any way how to=20 > > solve this? > > > > I am mainly searching for and comparing code snippets in PHP/ext=20 > > folder to see how things were rewritten from PHP5 to PHP7. > > > > Sorry if I missed something obvious and thank you for your help. > > > > It looks like the implementation of zend_call_method() does not=20 > support this, as it does not copy parameters back after the call. I'd=20 > suggest to use the lower level zend_call_function() for the cases=20 > where you need this for now. > > Nikita > > > >