Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:63973 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 41329 invoked from network); 19 Nov 2012 15:25:22 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Nov 2012 15:25:22 -0000 Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.42 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.215.42 mail-la0-f42.google.com Received: from [209.85.215.42] ([209.85.215.42:47361] helo=mail-la0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 72/00-41116-16F4AA05 for ; Mon, 19 Nov 2012 10:25:22 -0500 Received: by mail-la0-f42.google.com with SMTP id s15so3912286lag.29 for ; Mon, 19 Nov 2012 07:25:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=fWgm8YxcJMouBQejGko853dfHOnysseiXfxXyc4VLxA=; b=c5V1N468urB+JZKvSbrz4eNomssYeODAsRr+x7rI2HgQEHQEXz3KmNVOZuF6OSz05H 2nIv5oOiLx0NK+++aqBtox+xT86UmI/hB9Ec9wFGiGnHuBkbZc0ALzN2mAWKMCI/P0Vx N9ZtvPEjAjy9cTkYp8izk5ckjt02BM8MT5aVSbPr+FKS1+gXJu+qUBqreorBKNakYBo4 Esgd1gSWTmqXMsBUqf6pB2RKTZ/yUvTTECr5h4lnlvIVh3n65vRha7q94lcPVA0BzXa6 H6WbCOCbezo5yoJqHnzd7UEnZg0FEPGZnFFFu8QADI+Bbe30HBfsGph9JXQONEX6lOZN pnkg== MIME-Version: 1.0 Received: by 10.112.87.40 with SMTP id u8mr2447918lbz.50.1353338718038; Mon, 19 Nov 2012 07:25:18 -0800 (PST) Received: by 10.112.83.100 with HTTP; Mon, 19 Nov 2012 07:25:17 -0800 (PST) In-Reply-To: <50A9B0E0.7040508@sugarcrm.com> References: <50A9B0E0.7040508@sugarcrm.com> Date: Mon, 19 Nov 2012 16:25:17 +0100 Message-ID: To: Stas Malyshev Cc: PHP internals Content-Type: multipart/alternative; boundary=bcaec554df408cac8e04cedab9c4 Subject: Re: [PHP-DEV] Functions for getting long / double from zval with casts From: nikita.ppv@gmail.com (Nikita Popov) --bcaec554df408cac8e04cedab9c4 Content-Type: text/plain; charset=ISO-8859-1 On Mon, Nov 19, 2012 at 5:09 AM, Stas Malyshev wrote: > Hi! > > > Hi internals! > > > > It happens quite often that you need to extract an integer from a zval > and > > you also want it to work for integers in strings, etc. In order to do so > > you currently have to cast the zval to integer. This is always rather > > complicated because you often don't want to actually change the passed > > Where it happens quite often outside of function arguments (where it is > covered by parameter parsing APIs)? > It's just something that crops up every now and again. E.g. when you take it from an array or something like that. > Should it handle all conversions the engine performs or only from string? > Should be the normal casting behavior. > We could probably expose zendi_convert_to_long() and similar ones, but > I'm not sure what the use case for these would be. Could you give more > background on this? > zendi_convert_to_long() isn't really what I'm looking for. All the current convert functions convert a zval, which is not what you normally need, at least that's the feeling that I got. So what you end up doing is something like this: long result; Z_ADDREF_P(zval); convert_to_long_ex(&zval); result = Z_LVAL_P(zval); zval_ptr_dtor(&zval); Which seems overly complicated to me. What I'm looking for is something like this: long result = zval_get_long_with_cast(zval); Or maybe I'm missing something about how to easily get an integer from a value? Nikita --bcaec554df408cac8e04cedab9c4--