Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113424 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 53048 invoked from network); 9 Mar 2021 11:11:28 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 9 Mar 2021 11:11:28 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 805DF1804D3 for ; Tue, 9 Mar 2021 03:03:27 -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=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.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 ; Tue, 9 Mar 2021 03:03:23 -0800 (PST) Received: by mail-ed1-f50.google.com with SMTP id w9so19225739edc.11 for ; Tue, 09 Mar 2021 03:03:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:to:references:from:subject:message-id:date:user-agent :mime-version:in-reply-to; bh=J6adTOGsb5pxiUo/VTZ9lUxlKiIWpG00NnGJaD2kCxc=; b=basOCqGG2cfaiYLWzC4skmbHlzduyFftveJO5wB7oEZdBwlhJVKb/n5UlVH7Dxaf6J RDwuE2uznZBqbC96OATGKg95to45GX61a1Yu2t6Wcuh+oUZkBG/X4bMRT8XnU3j3aas6 ma8JPBwQbHkERu48t2j7xjpDVfONEYV9V8xTwxcZL/3l28dBoKOi2f3bNMdjK+LB4vDP Xmkdxs+HcOmzioevDlxN5BL1ryNK2O5QQ5PStwtpwX2a+Sq0fEEa/sK5YW8y7aBwyPCl NCWEjFwspAkaeRXc+oxee9oEAob5KBG3W+gg/5gqmxz0BlxmF6L/405Ty/3BDpyGv8SC iqyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:to:references:from:subject:message-id :date:user-agent:mime-version:in-reply-to; bh=J6adTOGsb5pxiUo/VTZ9lUxlKiIWpG00NnGJaD2kCxc=; b=TSlr2HPwqZE0Ce0CuunusuCS/8arJqO7KFPoLRTEv1HdBfldaT01m6FSQtg69aU2EC 2Cfir+LAm63pkHTOlibS1QdDBE2AZaTmd8t8iT8PCeTTC6PWyZYn5s3Hj4Rt3Qxue2Lh 434H4qjPeBZPkYKcX3Og03ojTj0z/PtdZ+NclF0aAMd87Rvyjf32EftVx10YTfwADec4 WnWTzpZVOBaxhvsluzmhwFALtBapZ5dj2Qndix8ATPIqK4jq49pFrdw+rPvIUK89ywso 71PnWbSH6jYE1FJtvActLT2TI47rDWay0Y3OuVLFnUtbJj5h5tjiA0TIJVkDW7s3W5c7 pl2Q== X-Gm-Message-State: AOAM5338wJ89TlnHZMDpBE/fo4CBjBO3EYr6TNelX8NmZACjQo1FTGum Mog3CE0ITuuirUx6wOQVx3KssRZzzCw= X-Google-Smtp-Source: ABdhPJxcoUVut4Hyr2uDlEEI0ghERL3A34ZuPmuJi3xgtJEMmcDtlN8Lmaugq0hoXyYeXSMO5YxUrg== X-Received: by 2002:a50:a086:: with SMTP id 6mr3319420edo.70.1615287800675; Tue, 09 Mar 2021 03:03:20 -0800 (PST) Received: from [192.168.2.100] (92-62-16-109.customer.bnet.at. [92.62.16.109]) by smtp.googlemail.com with ESMTPSA id p9sm4508727edu.79.2021.03.09.03.03.19 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 09 Mar 2021 03:03:19 -0800 (PST) Sender: Michael Wallner To: internals@lists.php.net References: Message-ID: Date: Tue, 9 Mar 2021 12:03:19 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="KQY8bCffdXdCgP6izHI3Ib339sKFDGWYn" Subject: Re: [PHP-DEV] Tracking Object Property Changes From: mike@php.net (Michael Wallner) --KQY8bCffdXdCgP6izHI3Ib339sKFDGWYn Content-Type: multipart/mixed; boundary="AsiArKZNFU5tkTSyAsQwVPv1zTiAMjSiE"; protected-headers="v1" From: Michael Wallner To: internals@lists.php.net Message-ID: Subject: Re: [PHP-DEV] Tracking Object Property Changes References: In-Reply-To: --AsiArKZNFU5tkTSyAsQwVPv1zTiAMjSiE Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: quoted-printable Hi Joseph! Is this for educational purposes or real world usage? I ask, because, if you don't have to adhere to a predefined C-API you would avoid lots of headache by baking all this stuff into your PHP objects with the APIs provided by Zend. But then again, it would be way more efficient to just write it all in PHP code. More comments following inline. On 09/03/2021 03.32, Joseph Montanez wrote: > I am not sure what to title this but the gist is that I have two struct= s > with a one way dependency: >=20 > // Vector3 type > typedef struct Vector3 { > float x; > float y; > float z; > } Vector3; >=20 > // Ray type (useful for raycast) > typedef struct Ray { > Vector3 position; // Ray position (origin) > Vector3 direction; // Ray direction > } Ray; As these are embedded structs instead of pointers to, neither do point to the memory of the other. > The PHP Ray object is defined as so: > typedef struct _skeleton_ray_object { > Ray ray; > HashTable *prop_handler; > zend_object std; ^^^^^^^^^^^^^^^^ NOTE: This has to be the last line in your object struct because of an VLA at the end of the zend_object struct. See your xyz_new() function where you allocate additional zend_object_properties_size() bytes for that VLA (variable length array). >=20 > skeleton_vector3_object *position; > skeleton_vector3_object *direction; > } skeleton_ray_object; >=20 > When I update either vector3 object, I don't have a way to propagate th= e > changes back to the parent object(Ray). This means the raw Ray struct i= s > never updated. Is there a built-in way to handle propagation (listeners= ) in > a PHP extension or will I need to hand roll this? Yes, you gotta write all of this on your own, but let me repeat that this is a lot of boilerplate which also may entail lots of headache. --=20 Regards, Mike --AsiArKZNFU5tkTSyAsQwVPv1zTiAMjSiE-- --KQY8bCffdXdCgP6izHI3Ib339sKFDGWYn Content-Type: application/pgp-signature; name="OpenPGP_signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="OpenPGP_signature" -----BEGIN PGP SIGNATURE----- wsB5BAABCAAjFiEEHsPHHd1jWDGjN9aESA4+FLCkx8cFAmBHVfcFAwAAAAAACgkQSA4+FLCkx8f/ Pgf/YJS6e5wayGkUy968F0EHGmgbzfJpuyGlG2JMnBLgQtuJYLa6QpKtrkUlYa8dZGgscmhkgx5f 8JDk6TN1WUG0tRg2ZhGbcAAgm2pJXMuHFnoTj7LQ3pH4tvG7jMA0FLJ2QzHhMj2lt9wj/FdOEh8P sie4hoI653t5KCKr1zHAqq8aiVcw89MzwIjtC9HPFo/DNYgZi2vvWJxFznoQP8llQ1GWUYkwfShi sfp4eFLcMdWcrijOZPrCq+mNrCkLWxdK+2HV8uWN0R5aAnDq1UyaBGAUhMEXp8u5AdRGrY6rucue XZP5gYkyivWIcikir3gXp9pk7ZRofumaVcuPqFR9Tg== =taXz -----END PGP SIGNATURE----- --KQY8bCffdXdCgP6izHI3Ib339sKFDGWYn--