[bug #55810] sizeof() and whos() returns 0 bytes for classdef objects

Thomas <[email protected]>
Newsgroups gmane.comp.gnu.octave.bugs
Message-ID <[email protected]>
Please use the bug tracker to post updates to a bug report.  The mailing list is intended as a read-only notification stream.  Info posted to this mailing list address won't appear in the tracker database where it is most useful.

Follow-up Comment #9, bug #55810 (group octave):

I've attached a patch that adds support for sizeof calculations on classdefs.
Since classdefs store their properties using the same storage class as a
struct in the Octave internals, the struct sizeof calculation was slightly
refactored (but not changed in terms of behaviour/output) in order to
accomodate a classdef querying the byte size. See the patch commit log for
more details. A few tests were added to go along with this patch. `make check`
passes on my machine with this patch.

I've operated under the assumption that a value class and a struct use the
same byte size calculation of summing up the byte sizes of all the properties.
If someone can prove that wrong, I'd be happy to see an example.

For a handle class, I returned the size of a machine word, since a handle
class is passed around as a pointer to one underlying object. MATLAB returns a
slightly higher byte calculation (see
https://octave.discourse.group/t/help-with-matlab-compatibility-of-byte-size-of-handle-classes/7442/1
for more details), which I assume takes into account some header info about a
handle class, but I do not think this is a particularly important
compatibility detail.

The underlying motivation for this patch is to implement a quick up-front
check on whether certain classdef can be loaded and saved without loss of data
(i.e. if there's a byte difference, something probably went wrong).

(file #58389)

    _______________________________________________________

Additional Item Attachment:

Name: bug55810.patch                 Size: 11KiB
    <https://file.savannah.gnu.org/file/bug55810.patch?file_id=58389>


    AGPL NOTICE

These attachments are served by Savane. You can download the corresponding
source code of Savane at
https://savannah.gnu.org/source/savane-9b684d621d606340ec3f8b1a290873daf3ff5474.tar.gz


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?55810>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
signature.asc (application/pgp-signature, 228 B)
-----BEGIN PGP SIGNATURE-----

iHUEABYIAB0WIQQk97aszIMMAvLLwm6qLAuaBUf3TgUCacB5rgAKCRCqLAuaBUf3
TsGKAQDOqBTSWecBEZeOLzpIveNWvLvfEPIqnTeGMXs5cUBCxAD+Mdmw7KRSxiLj
CHHitNB4cjCBKh/2OvVdO7rQsn2ukwU=
=SVps
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.