VM Maker: ImageFormat-dtl.50.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

VM Maker: ImageFormat-dtl.50.mcz

commits-2
 
David T. Lewis uploaded a new version of ImageFormat to project VM Maker:
http://source.squeak.org/VMMaker/ImageFormat-dtl.50.mcz

==================== Summary ====================

Name: ImageFormat-dtl.50
Author: dtl
Time: 10 January 2021, 3:38:11.803376 pm
UUID: 13859148-5b61-4b2a-8b6b-7cf0cfdb74fe
Ancestors: ImageFormat-dtl.49

Provide ImageFileHeader class>>headerAndFlagsFrom: to read header from an image file and remember the endianness flag used during the read. Intended to enable ImageSnapshot to be instantiated from an image file as well as directly from a VM primitive.

=============== Diff against ImageFormat-dtl.49 ===============

Item was added:
+ ----- Method: ImageFileHeader class>>headerAndFlagFrom: (in category 'instance creation') -----
+ headerAndFlagFrom: aStream
+ "Answer an array with new image file header and with boolean, true if
+ the image file in aStream was saved from a littleEndian machine."
+
+ ^self headerAndFlagFrom: aStream startingAt: 0!

Item was added:
+ ----- Method: ImageFileHeader class>>headerAndFlagFrom:startingAt: (in category 'instance creation') -----
+ headerAndFlagFrom: aStream startingAt: imageOffset
+ "Answer an array with new image file header and with boolean, true if
+ the image file in aStream was saved from a littleEndian machine."
+
+ ^self headerAndFlagFrom: aStream startingAt: imageOffset into: OrderedCollection new!

Item was added:
+ ----- Method: ImageFileHeader class>>headerAndFlagFrom:startingAt:into: (in category 'private') -----
+ headerAndFlagFrom: aStream startingAt: imageOffset into: aCollection
+ "Answer an array with new image file header and with boolean, true if
+ the image file in aStream was saved from a littleEndian machine."
+
+ | formatInfo imageFormat cls hdr remainder bytesRead |
+ formatInfo := self readImageVersionFrom: aStream startingAt: imageOffset.
+ imageFormat := formatInfo first.
+ aCollection add: imageFormat asInteger.
+ cls := self concreteClass: imageFormat.
+ hdr := cls new imageFormat: imageFormat.
+ bytesRead := hdr readFieldsFrom: aStream littleEndian: formatInfo second into: aCollection.
+ remainder := hdr headerSize - bytesRead.
+ self assert: remainder >= 0. "n.b. Mantis 7455 bug in original 64 bit image due to VMM error"
+ aStream next: (hdr headerSize - bytesRead).
+ ^{ hdr fromEntryStream: aCollection readStream . formatInfo second }
+ !

Item was changed:
  ----- Method: ImageFileHeader class>>readFrom:startingAt:into: (in category 'private') -----
  readFrom: aStream startingAt: imageOffset into: aCollection
 
+ ^(self headerAndFlagFrom: aStream startingAt: imageOffset into: aCollection) first
- | formatInfo imageFormat cls hdr remainder bytesRead |
- formatInfo := self readImageVersionFrom: aStream startingAt: imageOffset.
- imageFormat := formatInfo first.
- aCollection add: imageFormat asInteger.
- cls := self concreteClass: imageFormat.
- hdr := cls new imageFormat: imageFormat.
- bytesRead := hdr readFieldsFrom: aStream littleEndian: formatInfo second into: aCollection.
- remainder := hdr headerSize - bytesRead.
- self assert: remainder >= 0. "n.b. Mantis 7455 bug in original 64 bit image due to VMM error"
- aStream next: (hdr headerSize - bytesRead).
- ^hdr fromEntryStream: aCollection readStream.
  !

Reply | Threaded
Open this post in threaded view
|

Re: VM Maker: ImageFormat-dtl.50.mcz

David T. Lewis
 
On Sun, Jan 10, 2021 at 08:38:14PM +0000, [hidden email] wrote:

>  
> David T. Lewis uploaded a new version of ImageFormat to project VM Maker:
> http://source.squeak.org/VMMaker/ImageFormat-dtl.50.mcz
>
> ==================== Summary ====================
>
> Name: ImageFormat-dtl.50
> Author: dtl
> Time: 10 January 2021, 3:38:11.803376 pm
> UUID: 13859148-5b61-4b2a-8b6b-7cf0cfdb74fe
> Ancestors: ImageFormat-dtl.49
>
> Provide ImageFileHeader class>>headerAndFlagsFrom: to read header from an image file and remember the endianness flag used during the read. Intended to enable ImageSnapshot to be instantiated from an image file as well as directly from a VM primitive.
>
>

Saved twice on source.squeak.org to fix a typo in the commit notice, sorry
for the noise.

Dave