[Gambas-user] some questions of: Struct

nando nando_f at ...951...
Mon Jan 17 03:55:26 CET 2011


Thank you for your reply.
For #2: I meant, the serialization is
in order of the struct as defined.


---------- Original Message -----------
From: Benoît Minisini <gambas at ...1...>
To: nando_f at ...951..., mailing list for gambas users
<gambas-user at lists.sourceforge.net>
Sent: Mon, 17 Jan 2011 03:18:07 +0100
Subject: Re: [Gambas-user] some questions of: Struct

> > Benoit,
> > 1) What version is struct implemented?
> 
> I think you want to know that structures are implemented in Gambas 3 only.
> 
> > 2) Reading and writing a struct to a stream (file, etc) is an exact copy of
> > the struct?
> 
> Of course not. Data is serialized.
> 
> Writing (or reading) a structure is exactly like writing (or reading) each 
> field with the WRITE (or READ) instruction. This is done recursively if there 
> are structures inside structures.
> 
> Consequently, as soon as you don't use strings, the data written to the stream 
> will look like what is stored in memory, but without padding (see the next 
> question).
> 
> > 3) Does struct pad with bytes to fit alignments or is it exact
> > as defined?
> 
> There is padding, so that an short is stored at a memory address multiple of 
> 2, an integer or a single at a memory address multiple of 4, a long, a float 
> or a date at a memory address multiple of 8. A more complex datatype (a 
> pointer, an object reference, an embedded structure or array) is stored at an 
> address multiple of 4 on a 32 bits system, and at an address multiple of 8 on 
> a 64 bits system. Finally, an entire object is padded so that its size is a 
> multiple of 4 on a 32 bits system, and a multiple of 8 on a 64 bits system.
> 
> > 4) This is similar to RECORD in VB.
> 
> I don't know.
> 
> Regards,
> 
> -- 
> Benoît Minisini
> 
> ------------------------------------------------------------------------------
> Protect Your Site and Customers from Malware Attacks
> Learn about various malware tactics and how to avoid them. Understand 
> malware threats, the impact they can have on your business, and how you 
> can protect your company and customers by using code signing.
> http://p.sf.net/sfu/oracle-sfdevnl
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
------- End of Original Message -------





More information about the User mailing list