Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108051 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 37920 invoked from network); 9 Jan 2020 14:11:19 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 9 Jan 2020 14:11:19 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 58196180505 for ; Thu, 9 Jan 2020 04:16:58 -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,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 9 Jan 2020 04:16:57 -0800 (PST) Received: by mail-lf1-f50.google.com with SMTP id r14so5032998lfm.5 for ; Thu, 09 Jan 2020 04:16:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=5A72tVyE2qo0zWgyFproU94ulQInQNxyy69XxKNIsq0=; b=C+XULhkb5Ou3NwxUvSlgGtYGEqFtLIVum9BnokF+qHJSvuwoBQlNpL/zRboGJ+jclr 5c3OvZne98O83XTFT1TGSZvCYbYS9a9wYqyeBOWSD0iPIu5vDkAjJ04l9RJIF/FTjGzJ qr8jqVJHdufcUDDcXMxvLiaIhPYvg+TCeQ+vXXZAvyKeT3xEf+Rs77Y5M8Ki31s46w6o bsqbxxpOZM1r3m6IbZH/b2bGgjLT7yPJ+rZSL8RYFQ4EWZRAAODjsygsYv6wS6gNQ9nx RUlCBBwZoLY04F/e2MPof+2bBe9W2908IziPUETXf84/AElXmWWHmmRgzuyDp3brOjJF 4ZZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=5A72tVyE2qo0zWgyFproU94ulQInQNxyy69XxKNIsq0=; b=Riph73N/pahT9S/hqJxMEeb1yfZLdGYZW+//Bb3d7ZraxYt1eTPM4dVtVKIMcxXA6p kFyPMzvyKdHloarKrBUGFUrNGGFVH2uSTUmGVEQNK8OdYDx6jBGypNZbQtuBcFLZvGcE r14YpfZSYqJK/DUzXyHpMwAaLPpxBRMwQW8pSahIB1K0GqBHfTePYy87AV1NguBpfPFJ pJMcKWRusmkkTsZ7quLvpqm7dQThiG3q3aYrVfOdaZb/cky31Hfa5fAurBpKfkMJLrWT 6FN4tkG58wvbp0BWKdL4hJgUuP3uIaeVwYPZrS0oUnwcbnsQlRuFAg6+KnQP0+uQ9xiu 9PJQ== X-Gm-Message-State: APjAAAW8ilTfKrF7zHaLGLpeS4pAypExN7qwBoqgGbDWkdTE/BycXM0Z d0e+WOmR8FIyhw2Skkmm3jKM73B4MPnc7nIERG5rWd0i X-Google-Smtp-Source: APXvYqxT5FhxPJQk5KeNiD/dlsO8JiTDp56PiBCPMTJIgln8OmQtScx2NSILjSsm1SSbyX90TNxZO8lKK18gT3HpYus= X-Received: by 2002:a19:5e16:: with SMTP id s22mr6075355lfb.33.1578572216247; Thu, 09 Jan 2020 04:16:56 -0800 (PST) MIME-Version: 1.0 References: <003401d5c634$3b617760$b2246620$@noctuint.cz> <004b01d5c636$e36f1820$aa4d4860$@noctuint.cz> In-Reply-To: <004b01d5c636$e36f1820$aa4d4860$@noctuint.cz> Date: Thu, 9 Jan 2020 13:16:40 +0100 Message-ID: To: mdolezal@noctuint.cz Cc: PHP internals Content-Type: multipart/alternative; boundary="00000000000033aff7059bb3fc6d" Subject: Re: [PHP-DEV] zend_call_method with arguments passed by reference From: nikita.ppv@gmail.com (Nikita Popov) --00000000000033aff7059bb3fc6d Content-Type: text/plain; charset="UTF-8" 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 > 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 have > nothing to copy back manually. > fci.params *should* contain the changed parameters after the call, at least assuming no_separation=0. 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 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 > > 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 > > zend_call_method from Zend/zend_interfaces.c (to use more arguments > > than 2). > > > > > > Now I found out that it does not work with arguments passed by > > reference, such as: > > > > public function FuncWithRef(array &$changeThis) > > > > > > > > if values are changed in the PHP code then zval values back in C 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 > > with params simply by > > > > > > > > params[0] = &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 > > solve this? > > > > I am mainly searching for and comparing code snippets in PHP/ext > > 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 > > > > --00000000000033aff7059bb3fc6d--