Chris Muller uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-cmm.1113.mcz
==================== Summary ====================
Name: Kernel-cmm.1113
Author: cmm
Time: 31 August 2017, 1:55:06.158647 pm
UUID: 05c89229-0279-4842-b0d0-dacb2713a4b6
Ancestors: Kernel-tbn.1112
Provide #pinned: so clients don't have to write duplicate code (e.g., "myCondition ifTrue: [myObject pin] ifFalse: [myObject unpin]") while allowing frameworks to hook #pinned: if necessary (without overriding a primitive).
=============== Diff against Kernel-tbn.1112 ===============
Item was changed:
----- Method: Object>>pin (in category 'pinning') -----
pin
+ "Ensure the receiver is pinned and answer whether it was pinned."
+ ^ self pinned: true!
- "The VM's garbage collector routinely moves objects as it reclaims and compacts
- memory. But it can also pin an object so that it will not be moved, which can make
- it easier to pass objects out through the FFI. Objects are unpinnned when created.
- This method ensures an object is pinned, and answers whether it was already pinned."
- ^self setPinned: true!
Item was added:
+ ----- Method: Object>>pinned: (in category 'pinning') -----
+ pinned: aBoolean
+ "The VM's garbage collector routinely moves objects as it reclaims and compacts memory. But it can also pin an object so that it will not be moved, which can make it easier to pass objects out through the FFI. Objects are unpinnned when created.
+ Answer whether the receiver was pinned."
+ ^ self setPinned: aBoolean!
Item was changed:
----- Method: Object>>setPinned: (in category 'private') -----
setPinned: aBoolean
+ "Primitive which pins or unpins the receiver and answers whether it was already pinned."
- "The VM's garbage collector routinely moves objects as it reclaims and compacts
- memory. But it can also pin an object so that it will not be moved, which can make
- it easier to pass objects out through the FFI. Objects are unpinnned when created.
- This primitive either pins or unpins an object, and answers if it was already pinned."
<primitive: 184 error: ec>
^self primitiveFailed!
Item was changed:
----- Method: Object>>unpin (in category 'pinning') -----
unpin
+ "Ensure the receiver is unpinned and answer whether it was pinned."
+ ^ self pinned: false!
- "The VM's garbage collector routinely moves objects as it reclaims and compacts
- memory. But it can also pin an object so that it will not be moved, which can make
- it easier to pass objects out through the FFI. Objects are unpinnned when created.
- This method ensures an object is unpinned, and answers whether it was pinned."
- ^self setPinned: false!
Patrick Rein uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-tonyg.734.mcz
==================== Summary ====================
Name: Collections-tonyg.734
Author: tonyg
Time: 23 February 2017, 2:08:07.162997 pm
UUID: 9edf6f29-ea5e-4c3b-9d05-03c54d4ba86c
Ancestors: Collections-topa.733
Factor out #upToPosition:, which lets us address the discrepancy between position counting bytes in MultiByteFileStream, but #next: expecting a count of items in #upToAll:. This is the first half of a fix for Mantis #4665. See also MultilingualTests-tonyg.22.
=============== Diff against Collections-topa.733 ===============
Item was changed:
----- Method: PositionableStream>>upToAll: (in category 'accessing') -----
upToAll: aCollection
"Answer a subcollection from the current access position to the occurrence (if any, but not inclusive) of aCollection. If aCollection is not in the stream, answer the entire rest of the stream."
| startPos endMatch result |
startPos := self position.
(self match: aCollection)
ifTrue: [endMatch := self position.
self position: startPos.
+ result := self upToPosition: endMatch - aCollection size.
- result := self next: endMatch - startPos - aCollection size.
self position: endMatch.
^ result]
ifFalse: [self position: startPos.
^ self upToEnd]!
Item was added:
+ ----- Method: PositionableStream>>upToPosition: (in category 'accessing') -----
+ upToPosition: anInteger
+ "Answer a subcollection containing items starting from the current position and ending including the given position. Usefully different to #next: in that in the case of MultiByteFileStream, and perhaps others, positions measure in terms of encoded items, while #next: convention is to name a number of items, independent of their encoding in the underlying buffer."
+ ^ self next: anInteger - position
+ !
Patrick Rein uploaded a new version of Multilingual to project The Trunk:
http://source.squeak.org/trunk/Multilingual-tonyg.218.mcz
==================== Summary ====================
Name: Multilingual-tonyg.218
Author: tonyg
Time: 23 February 2017, 2:13:59.45456 pm
UUID: 86e12680-7d6d-400c-8215-62a8315f01f1
Ancestors: Multilingual-tfel.217
Override PositionableStream>>#upToPosition:, introduced in Collections-tonyg.734, in order to reflect the fact that positions count bytes here; previously, #next: was being used, but that method expects a count of characters, not bytes. This is the second half of a fix for Mantis #4665. See also MultilingualTests-tonyg.22.
=============== Diff against Multilingual-tfel.217 ===============
Item was added:
+ ----- Method: MultiByteFileStream>>upToPosition: (in category 'accessing') -----
+ upToPosition: anInteger
+ "Answer a subcollection containing items starting from the current position and ending including the given position. Usefully different to #next: in that positions measure *bytes* from the file, where #next: wants to measure *characters*."
+ ^self collectionSpecies new: 1000 streamContents: [ :stream |
+ | ch |
+ [ (ch := self next) == nil or: [ position > anInteger ] ]
+ whileFalse: [ stream nextPut: ch ] ]!
Patrick Rein uploaded a new version of MultilingualTests to project The Trunk:
http://source.squeak.org/trunk/MultilingualTests-tonyg.22.mcz
==================== Summary ====================
Name: MultilingualTests-tonyg.22
Author: tonyg
Time: 23 February 2017, 2:01:47.977527 pm
UUID: 76769ce3-a15d-46a7-acbd-8acfbd56fcc9
Ancestors: MultilingualTests-pre.21
Test cases from Mantis #4665.
=============== Diff against MultilingualTests-pre.21 ===============
Item was added:
+ ----- Method: MultiByteFileStreamTest>>testUpToAllAscii (in category 'testing') -----
+ testUpToAllAscii
+ "This test case is inspired by Mantis #4665."
+ "Compare to testUpToAllUtf."
+
+ | in out fn resultA resultB |
+ fn :='testUpToAll.in'.
+ out := FileDirectory default forceNewFileNamed: fn.
+ out nextPutAll: 'A<'. "Encodes to byte sequence 413C"
+ out close.
+
+ in := FileDirectory default readOnlyFileNamed: fn.
+ resultA := in upToAll: '<'.
+ in close.
+
+ in := FileDirectory default readOnlyFileNamed: fn.
+ resultB := in upTo: $<.
+ in close.
+
+ self assert: resultA = resultB
+ !
Item was added:
+ ----- Method: MultiByteFileStreamTest>>testUpToAllUtf (in category 'testing') -----
+ testUpToAllUtf
+ "This test case is adapted from Mantis #4665."
+ "MultiByteFileStream was relying on PositionableStream>>#match: to discover the position immediately following the delimiter collection. It would then use #next: to retrieve a number of *characters* computed as the difference in stream positions. However, stream positions are measured in *bytes*, not characters, so this would lead to misalignment when the skipped text included UTF-8 encoded characters."
+
+ | in out fn resultA resultB |
+ fn :='testUpToAll.in'.
+ out := FileDirectory default forceNewFileNamed: fn.
+ out nextPutAll: 231 asCharacter asString, '<'. "Encodes to byte sequence C3A73C"
+ out close.
+
+ in := FileDirectory default readOnlyFileNamed: fn.
+ resultA := in upToAll: '<'.
+ in close.
+
+ in := FileDirectory default readOnlyFileNamed: fn.
+ resultB := in upTo: $<.
+ in close.
+
+ self assert: resultA = resultB
+ !
Patrick Rein uploaded a new version of MultilingualTests to project The Trunk:
http://source.squeak.org/trunk/MultilingualTests-pre.26.mcz
==================== Summary ====================
Name: MultilingualTests-pre.26
Author: pre
Time: 31 August 2017, 3:17:33.9894 pm
UUID: 6916746b-6a8d-734a-8457-6d2af090fe4b
Ancestors: MultilingualTests-pre.25, MultilingualTests-tonyg.22
Merges MultilingualTests-tonyg.22 which tests a fix for Mantis #4665 and deals with the difference in counting at the public interface of streams and counting the steps in the underlying buffer.
=============== Diff against MultilingualTests-pre.25 ===============
Item was added:
+ ----- Method: MultiByteFileStreamTest>>testUpToAllAscii (in category 'testing') -----
+ testUpToAllAscii
+ "This test case is inspired by Mantis #4665."
+ "Compare to testUpToAllUtf."
+
+ | in out fn resultA resultB |
+ fn :='testUpToAll.in'.
+ out := FileDirectory default forceNewFileNamed: fn.
+ out nextPutAll: 'A<'. "Encodes to byte sequence 413C"
+ out close.
+
+ in := FileDirectory default readOnlyFileNamed: fn.
+ resultA := in upToAll: '<'.
+ in close.
+
+ in := FileDirectory default readOnlyFileNamed: fn.
+ resultB := in upTo: $<.
+ in close.
+
+ self assert: resultA = resultB
+ !
Item was added:
+ ----- Method: MultiByteFileStreamTest>>testUpToAllUtf (in category 'testing') -----
+ testUpToAllUtf
+ "This test case is adapted from Mantis #4665."
+ "MultiByteFileStream was relying on PositionableStream>>#match: to discover the position immediately following the delimiter collection. It would then use #next: to retrieve a number of *characters* computed as the difference in stream positions. However, stream positions are measured in *bytes*, not characters, so this would lead to misalignment when the skipped text included UTF-8 encoded characters."
+
+ | in out fn resultA resultB |
+ fn :='testUpToAll.in'.
+ out := FileDirectory default forceNewFileNamed: fn.
+ out nextPutAll: 231 asCharacter asString, '<'. "Encodes to byte sequence C3A73C"
+ out close.
+
+ in := FileDirectory default readOnlyFileNamed: fn.
+ resultA := in upToAll: '<'.
+ in close.
+
+ in := FileDirectory default readOnlyFileNamed: fn.
+ resultB := in upTo: $<.
+ in close.
+
+ self assert: resultA = resultB
+ !
Patrick Rein uploaded a new version of Multilingual to project The Trunk:
http://source.squeak.org/trunk/Multilingual-pre.230.mcz
==================== Summary ====================
Name: Multilingual-pre.230
Author: pre
Time: 31 August 2017, 3:15:51.6494 pm
UUID: 739e6436-0d72-4048-a12a-93a0801c2872
Ancestors: Multilingual-pre.229, Multilingual-tonyg.218
Merges Multilingual-tonyg.218 which is part of a fix for Mantis #4665 and deals with the difference in counting at the public interface of streams and counting the steps in the underlying buffer.
=============== Diff against Multilingual-pre.229 ===============
Item was added:
+ ----- Method: MultiByteFileStream>>upToPosition: (in category 'accessing') -----
+ upToPosition: anInteger
+ "Answer a subcollection containing items starting from the current position and ending including the given position. Usefully different to #next: in that positions measure *bytes* from the file, where #next: wants to measure *characters*."
+ ^self collectionSpecies new: 1000 streamContents: [ :stream |
+ | ch |
+ [ (ch := self next) == nil or: [ position > anInteger ] ]
+ whileFalse: [ stream nextPut: ch ] ]!
Patrick Rein uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-pre.763.mcz
==================== Summary ====================
Name: Collections-pre.763
Author: pre
Time: 31 August 2017, 3:14:26.5764 pm
UUID: ffff1838-0f68-9e49-bd57-6263eaebd8d7
Ancestors: Collections-pre.762, Collections-tonyg.734
Merges Collections-tonyg.734 which fixes Mantis #4665 and deals with the difference in counting at the public interface of streams and counting the steps in the underlying buffer.
=============== Diff against Collections-pre.762 ===============
Item was changed:
----- Method: PositionableStream>>upToAll: (in category 'accessing') -----
upToAll: aCollection
"Answer a subcollection from the current access position to the occurrence (if any, but not inclusive) of aCollection. If aCollection is not in the stream, answer the entire rest of the stream."
| startPos endMatch result |
startPos := self position.
(self match: aCollection)
ifTrue: [endMatch := self position.
self position: startPos.
+ result := self upToPosition: endMatch - aCollection size.
- result := self next: endMatch - startPos - aCollection size.
self position: endMatch.
^ result]
ifFalse: [self position: startPos.
^ self upToEnd]!
Item was added:
+ ----- Method: PositionableStream>>upToPosition: (in category 'accessing') -----
+ upToPosition: anInteger
+ "Answer a subcollection containing items starting from the current position and ending including the given position. Usefully different to #next: in that in the case of MultiByteFileStream, and perhaps others, positions measure in terms of encoded items, while #next: convention is to name a number of items, independent of their encoding in the underlying buffer."
+ ^ self next: anInteger - position
+ !