Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108037 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 66907 invoked from network); 8 Jan 2020 17:13:10 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 8 Jan 2020 17:13:10 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 52BB91804AC for ; Wed, 8 Jan 2020 07:18:35 -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 ; Wed, 8 Jan 2020 07:18:34 -0800 (PST) Received: from mail.noctuint.cz (localhost [127.0.0.1]) by mail.noctuint.cz (Postfix) with ESMTP id A551460E5F8; Wed, 8 Jan 2020 16:18:32 +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=3TWcDHtQBzKO kCTaLnjNnp0PCgA=; b=UdjMQP6gXiSTkDZIrwKU46TXC1V9Ryll53f35pqpfsyK Jdy2EdB1YAxLQzisluEGdVa2nZflR2gMxGd51qmBx2IDpICqHW0Lr1D5qFtiGKVM TMBV1SCDzcrm9zH9TcSk9TU7ZdESQi9Kj2BossPOGGNTHdtbm9rLUGJObEKQNSs= 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=O+FQQt OF2Y/Uzco/z95dmQV6upCYpWDyRSLFZy9J0KAGOjx7HLZMkKxePmC31FjpsuzKdk eWG0E29v/9T3DHMaPtYT3h4lv0yyxZrheIKBWKA0cueZ1ioq56kDVkTD03e3C0Fk H9vTZoO9gqtEJ7YML44dKr6nd1og4Uhi7YnnQ= Received: from nbmdolezal (unknown [82.142.101.30]) by mail.noctuint.cz (Postfix) with ESMTPSA id 3EC2160E5F7; Wed, 8 Jan 2020 16:18:32 +0100 (CET) Reply-To: To: "'Nikita Popov'" Cc: "'PHP internals'" References: <003401d5c634$3b617760$b2246620$@noctuint.cz> In-Reply-To: Date: Wed, 8 Jan 2020 16:18:31 +0100 Message-ID: <004b01d5c636$e36f1820$aa4d4860$@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: AQIm0QP2lWPEtE74Z2zXpcTPc0o8WgKNlciDpypdzhA= 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") 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 = zend_fcall_info fci.=20 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 = have nothing to copy back manually. -----Original Message----- From: Nikita Popov =20 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 = reference On Wed, Jan 8, 2020 at 3:59 PM mdolezal.noctuint.cz via internals < = 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 part=20 > 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=20 > 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 support = this, as it does not copy parameters back after the call. I'd suggest to = use the lower level zend_call_function() for the cases where you need = this for now. Nikita