VM Maker: ImageFormat-dtl.50.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message 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:26:52.350451 pm
UUID: 90f06857-91ab-4950-a856-957d3bb6ddc0
Ancestors: ImageFormat-dtl.49

Provide ImageHileHeader 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.
  !