Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88415 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 73140 invoked from network); 22 Sep 2015 18:16:50 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Sep 2015 18:16:50 -0000 Authentication-Results: pb1.pair.com header.from=zardozrocks@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=zardozrocks@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.180 as permitted sender) X-PHP-List-Original-Sender: zardozrocks@gmail.com X-Host-Fingerprint: 209.85.223.180 mail-io0-f180.google.com Received: from [209.85.223.180] ([209.85.223.180:33675] helo=mail-io0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 07/A0-00408-01B91065 for ; Tue, 22 Sep 2015 14:16:49 -0400 Received: by iofh134 with SMTP id h134so22846551iof.0 for ; Tue, 22 Sep 2015 11:16:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=fK3bUa0k+DXA981ceMDLL5FDcwDlx2ojHLkxA5m+Y9g=; b=zxGc9t1u1Q1EkHHB1yB1KXkaHkFLzgon/POjvCr4spWPZ82keVOJHgiIxwM2fJjQLZ RbFKL55gN4qwAGPbhMP3xX4CmC1Ftk4Aur2lCewvOF5ooXlP+StAg08j0zNHm1vps516 Y5s2fQjvjwfX6c0JCTaeg1988ldyPlr2GhVC9eBWWF05KwW/Yyyc7wmOAdUlaEhFLPtE ymBdIPtjbNkZO86FmVyMImswUsYiyFhacUPrGfnQfZW8xZBWEdjX/5705AD2SkCZE3mo LALMCkOkiQYgio1ZiWKGgb2O0fOVdukSBDx6BoU0mv0rrplXvJiQla2fotL+TfsqRng5 3+hQ== MIME-Version: 1.0 X-Received: by 10.107.25.71 with SMTP id 68mr31946347ioz.46.1442945806150; Tue, 22 Sep 2015 11:16:46 -0700 (PDT) Received: by 10.107.31.148 with HTTP; Tue, 22 Sep 2015 11:16:46 -0700 (PDT) Date: Tue, 22 Sep 2015 11:16:46 -0700 Message-ID: To: internals Content-Type: multipart/alternative; boundary=001a113ff20e34b21405205a00dd Subject: Data serialization of objects, want to iterate 'sealed' properties then dynamic ones From: zardozrocks@gmail.com (j adams) --001a113ff20e34b21405205a00dd Content-Type: text/plain; charset=UTF-8 I'm working on a data serialization routine wherein I must iterate through an object's properties while distinguishing between "sealed" properties (i.e., those specified by class definitions) and "dynamic" properties" (i.e., those assigned ad-hoc to some object that are not party of any class definition). I found the source of the php function get_object_vars(): http://lxr.php.net/xref/PHP_5_6/Zend/zend_builtin_functions.c#985 However, I am still pretty confused. PHP source is *full* of macros and has basically no comments. Hoping for some tips to keep me on the right track. I'm pretty sure I can get something kludgy working, but I want my code to be orthodox and work well. QUESTIONS 1) Sadly, this approach is unable to distinguish "sealed" properties from dynamic ones. If anyone can refer me to some source (or outline a general approach) which can first iterate sealed properties and then iterate only dynamic ones, that would be extremely helpful. 2) What does zend_objects_get_address do? This reference looks very different than the usual macro, e.g. Z_OBJ_HT_P 3) Am I correct in understanding that zend_check_property_access simply checks if the property in question is availabe in the scope in which this function call gets executed? Is this the canonical/orthodox way to make this check? 4) What does zend_unmangle_property_name do? Why is this function changed to zend_unmangle_property_name_ex in 5.5 and later? 5) Why do we call Z_ADDREF_PP(value) here? Is this reference counting to prevent garbage collection? 6) An IS_INTERNED check is added in php 5.6 and yet the macro for IS_INTERNED is zero. What's that all about? 7) The code looks quite different between the different versions: 5.3 - http://lxr.php.net/xref/PHP_5_3/Zend/zend_builtin_functions.c#950 5.5 - http://lxr.php.net/xref/PHP_5_5/Zend/zend_builtin_functions.c#982 5.6 - http://lxr.php.net/xref/PHP_5_6/Zend/zend_builtin_functions.c#985 From what I can tell there is at least one difference between 5.3 and 5.6 -- zend_unmangle_property_name_ex does not exist before 5.5. Can anyone recommend how to make code that'll work in 5.3-5.6? Also, with 7 coming out I'd like it work there too. Any answers or assistance would be greatly appreciated. --001a113ff20e34b21405205a00dd--