Levente Uzonyi uploaded a new version of Files to project The Trunk:
http://source.squeak.org/trunk/Files-ul.111.mcz
==================== Summary ====================
Name: Files-ul.111
Author: ul
Time: 16 July 2011, 11:27:11.356 am
UUID: 42445191-7bd0-324c-bcca-079ee8b5da96
Ancestors: Files-ul.110
- FileStream class >> #detectFile:do: can accept a FileStream as it's first argument
- pass FileStreams instead of blocks to #detectFile:do:
=============== Diff against Files-ul.110 ===============
Item was changed:
----- Method: DirectoryEntryFile>>contentsFrom:to: (in category 'stream access') -----
contentsFrom: startPosition to: endPosition
"Answer my contents from startPosition to endPosition."
^ FileStream
+ detectFile: self readStream
- detectFile: [ self readStream ]
do:
[ : stream |
stream
position: startPosition ;
next: endPosition - startPosition + 1 ]!
Item was changed:
----- Method: FileStream class>>detectFile:do: (in category 'instance creation') -----
+ detectFile: aBlockOrFileStream do: anotherBlock
+
+ ^aBlockOrFileStream value "Assume that FileStreams return self for #value."
+ ifNotNil: [ :file | [ anotherBlock value: file ] ensure: [ file close ] ]!
- detectFile: aBlock do: anotherBlock
- ^aBlock value
- ifNil: [nil]
- ifNotNil: [:file| [anotherBlock value: file] ensure: [file close]]!
Item was changed:
----- Method: FileStream class>>fileNamed:do: (in category 'instance creation') -----
fileNamed: fileName do: aBlock
"Avi Bryant says, ''This idiom is quite common in other languages that make heavy use of closures (i.e. Lisp (with-file 'foo' (f) ...) and Ruby (File.open('foo'){|f|...})). It's time Squeak had it, too.''
Returns the result of aBlock."
+ ^self detectFile: (self fileNamed: fileName) do: aBlock!
- ^ self detectFile: [ self fileNamed: fileName ] do: aBlock!
Item was changed:
----- Method: FileStream class>>forceNewFileNamed:do: (in category 'instance creation') -----
forceNewFileNamed: fileName do: aBlock
"Avi Bryant says, ''This idiom is quite common in other languages that make heavy use of closures (i.e. Lisp (with-file 'foo' (f) ...) and Ruby (File.open('foo'){|f|...})). It's time Squeak had it, too.''
Returns the result of aBlock."
+ ^self detectFile: (self forceNewFileNamed: fileName) do: aBlock!
- ^ self detectFile: [ self forceNewFileNamed: fileName ] do: aBlock!
Item was changed:
----- Method: FileStream class>>newFileNamed:do: (in category 'instance creation') -----
newFileNamed: fileName do: aBlock
"Avi Bryant says, ''This idiom is quite common in other languages that make heavy use of closures (i.e. Lisp (with-file 'foo' (f) ...) and Ruby (File.open('foo'){|f|...})). It's time Squeak had it, too.''
Returns the result of aBlock."
+ ^self detectFile: (self newFileNamed: fileName) do: aBlock!
- ^ self detectFile: [ self newFileNamed: fileName ] do: aBlock!
Item was changed:
----- Method: FileStream class>>oldFileNamed:do: (in category 'instance creation') -----
oldFileNamed: fileName do: aBlock
"Avi Bryant says, ''This idiom is quite common in other languages that make heavy use of closures (i.e. Lisp (with-file 'foo' (f) ...) and Ruby (File.open('foo'){|f|...})). It's time Squeak had it, too.''
Returns the result of aBlock."
+ ^self detectFile: (self oldFileNamed: fileName) do: aBlock!
- ^ self detectFile: [ self oldFileNamed: fileName ] do: aBlock!
Item was changed:
----- Method: FileStream class>>readOnlyFileNamed:do: (in category 'instance creation') -----
readOnlyFileNamed: fileName do: aBlock
"Avi Bryant says, ''This idiom is quite common in other languages that make heavy use of closures (i.e. Lisp (with-file 'foo' (f) ...) and Ruby (File.open('foo'){|f|...})). It's time Squeak had it, too.''
Returns the result of aBlock."
+ ^self detectFile: (self readOnlyFileNamed: fileName) do: aBlock!
- ^ self detectFile: [ self readOnlyFileNamed: fileName ] do: aBlock!
Levente Uzonyi uploaded a new version of Files to project The Trunk:
http://source.squeak.org/trunk/Files-ul.111.mcz
==================== Summary ====================
Name: Files-ul.111
Author: ul
Time: 16 July 2011, 11:27:11.356 am
UUID: 42445191-7bd0-324c-bcca-079ee8b5da96
Ancestors: Files-ul.110
- FileStream class >> #detectFile:do: can accept a FileStream as it's first argument
- pass FileStreams instead of blocks to #detectFile:do:
=============== Diff against Files-ul.110 ===============
Item was changed:
----- Method: DirectoryEntryFile>>contentsFrom:to: (in category 'stream access') -----
contentsFrom: startPosition to: endPosition
"Answer my contents from startPosition to endPosition."
^ FileStream
+ detectFile: self readStream
- detectFile: [ self readStream ]
do:
[ : stream |
stream
position: startPosition ;
next: endPosition - startPosition + 1 ]!
Item was changed:
----- Method: FileStream class>>detectFile:do: (in category 'instance creation') -----
+ detectFile: aBlockOrFileStream do: anotherBlock
+
+ ^aBlockOrFileStream value "Assume that FileStreams return self for #value."
+ ifNotNil: [ :file | [ anotherBlock value: file ] ensure: [ file close ] ]!
- detectFile: aBlock do: anotherBlock
- ^aBlock value
- ifNil: [nil]
- ifNotNil: [:file| [anotherBlock value: file] ensure: [file close]]!
Item was changed:
----- Method: FileStream class>>fileNamed:do: (in category 'instance creation') -----
fileNamed: fileName do: aBlock
"Avi Bryant says, ''This idiom is quite common in other languages that make heavy use of closures (i.e. Lisp (with-file 'foo' (f) ...) and Ruby (File.open('foo'){|f|...})). It's time Squeak had it, too.''
Returns the result of aBlock."
+ ^self detectFile: (self fileNamed: fileName) do: aBlock!
- ^ self detectFile: [ self fileNamed: fileName ] do: aBlock!
Item was changed:
----- Method: FileStream class>>forceNewFileNamed:do: (in category 'instance creation') -----
forceNewFileNamed: fileName do: aBlock
"Avi Bryant says, ''This idiom is quite common in other languages that make heavy use of closures (i.e. Lisp (with-file 'foo' (f) ...) and Ruby (File.open('foo'){|f|...})). It's time Squeak had it, too.''
Returns the result of aBlock."
+ ^self detectFile: (self forceNewFileNamed: fileName) do: aBlock!
- ^ self detectFile: [ self forceNewFileNamed: fileName ] do: aBlock!
Item was changed:
----- Method: FileStream class>>newFileNamed:do: (in category 'instance creation') -----
newFileNamed: fileName do: aBlock
"Avi Bryant says, ''This idiom is quite common in other languages that make heavy use of closures (i.e. Lisp (with-file 'foo' (f) ...) and Ruby (File.open('foo'){|f|...})). It's time Squeak had it, too.''
Returns the result of aBlock."
+ ^self detectFile: (self newFileNamed: fileName) do: aBlock!
- ^ self detectFile: [ self newFileNamed: fileName ] do: aBlock!
Item was changed:
----- Method: FileStream class>>oldFileNamed:do: (in category 'instance creation') -----
oldFileNamed: fileName do: aBlock
"Avi Bryant says, ''This idiom is quite common in other languages that make heavy use of closures (i.e. Lisp (with-file 'foo' (f) ...) and Ruby (File.open('foo'){|f|...})). It's time Squeak had it, too.''
Returns the result of aBlock."
+ ^self detectFile: (self oldFileNamed: fileName) do: aBlock!
- ^ self detectFile: [ self oldFileNamed: fileName ] do: aBlock!
Item was changed:
----- Method: FileStream class>>readOnlyFileNamed:do: (in category 'instance creation') -----
readOnlyFileNamed: fileName do: aBlock
"Avi Bryant says, ''This idiom is quite common in other languages that make heavy use of closures (i.e. Lisp (with-file 'foo' (f) ...) and Ruby (File.open('foo'){|f|...})). It's time Squeak had it, too.''
Returns the result of aBlock."
+ ^self detectFile: (self readOnlyFileNamed: fileName) do: aBlock!
- ^ self detectFile: [ self readOnlyFileNamed: fileName ] do: aBlock!
Levente Uzonyi uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-ul.448.mcz
==================== Summary ====================
Name: System-ul.448
Author: ul
Time: 16 July 2011, 11:12:48.138 am
UUID: de5c8937-c539-c34d-ac36-3a3302b78212
Ancestors: System-bf.447
Added accessors for #maxExternalSemaphores.
=============== Diff against System-bf.447 ===============
Item was added:
+ ----- Method: SmalltalkImage>>maxExternalSemaphores (in category 'vm parameters') -----
+ maxExternalSemaphores
+ "The size of table where external semaphores are registered. Only in Cog"
+ self isRunningCog ifFalse: [^nil].
+ ^self vmParameterAt: 49!
Item was added:
+ ----- Method: SmalltalkImage>>maxExternalSemaphores: (in category 'vm parameters') -----
+ maxExternalSemaphores: aSize
+ "Changes the size of table where external semaphores are registered.
+ The size can only grow, and will always be the next power of two larger than the parameter.
+
+ Setting this at any time other than start-up can potentially lose requests.
+ i.e. during the realloc new storage is allocated, t
+ he old contents are copied and then pointers are switched.
+ Requests occurring during copying won't be seen if they occur to indices already copied.
+ The intended use is to set the table to some adequate maximum at start-up"
+
+ self isRunningCog ifFalse: [^0].
+ "The vm-header field is a short, maximum 64k entries. Well, on most platforms anyways "
+ (aSize < 0 or: [aSize > 16rFFFF]) ifTrue: [^DomainError signalFrom: 0 to: 16rFFFF].
+ ^self vmParameterAt: 49 put: aSize!
Levente Uzonyi uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-ul.448.mcz
==================== Summary ====================
Name: System-ul.448
Author: ul
Time: 16 July 2011, 11:12:48.138 am
UUID: de5c8937-c539-c34d-ac36-3a3302b78212
Ancestors: System-bf.447
Added accessors for #maxExternalSemaphores.
=============== Diff against System-bf.447 ===============
Item was added:
+ ----- Method: SmalltalkImage>>maxExternalSemaphores (in category 'vm parameters') -----
+ maxExternalSemaphores
+ "The size of table where external semaphores are registered. Only in Cog"
+ self isRunningCog ifFalse: [^nil].
+ ^self vmParameterAt: 49!
Item was added:
+ ----- Method: SmalltalkImage>>maxExternalSemaphores: (in category 'vm parameters') -----
+ maxExternalSemaphores: aSize
+ "Changes the size of table where external semaphores are registered.
+ The size can only grow, and will always be the next power of two larger than the parameter.
+
+ Setting this at any time other than start-up can potentially lose requests.
+ i.e. during the realloc new storage is allocated, t
+ he old contents are copied and then pointers are switched.
+ Requests occurring during copying won't be seen if they occur to indices already copied.
+ The intended use is to set the table to some adequate maximum at start-up"
+
+ self isRunningCog ifFalse: [^0].
+ "The vm-header field is a short, maximum 64k entries. Well, on most platforms anyways "
+ (aSize < 0 or: [aSize > 16rFFFF]) ifTrue: [^DomainError signalFrom: 0 to: 16rFFFF].
+ ^self vmParameterAt: 49 put: aSize!
Levente Uzonyi uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-ul.448.mcz
==================== Summary ====================
Name: System-ul.448
Author: ul
Time: 16 July 2011, 11:12:48.138 am
UUID: de5c8937-c539-c34d-ac36-3a3302b78212
Ancestors: System-bf.447
Added accessors for #maxExternalSemaphores.
=============== Diff against System-bf.447 ===============
Item was added:
+ ----- Method: SmalltalkImage>>maxExternalSemaphores (in category 'vm parameters') -----
+ maxExternalSemaphores
+ "The size of table where external semaphores are registered. Only in Cog"
+ self isRunningCog ifFalse: [^nil].
+ ^self vmParameterAt: 49!
Item was added:
+ ----- Method: SmalltalkImage>>maxExternalSemaphores: (in category 'vm parameters') -----
+ maxExternalSemaphores: aSize
+ "Changes the size of table where external semaphores are registered.
+ The size can only grow, and will always be the next power of two larger than the parameter.
+
+ Setting this at any time other than start-up can potentially lose requests.
+ i.e. during the realloc new storage is allocated, t
+ he old contents are copied and then pointers are switched.
+ Requests occurring during copying won't be seen if they occur to indices already copied.
+ The intended use is to set the table to some adequate maximum at start-up"
+
+ self isRunningCog ifFalse: [^0].
+ "The vm-header field is a short, maximum 64k entries. Well, on most platforms anyways "
+ (aSize < 0 or: [aSize > 16rFFFF]) ifTrue: [^DomainError signalFrom: 0 to: 16rFFFF].
+ ^self vmParameterAt: 49 put: aSize!
Levente Uzonyi uploaded a new version of Tools to project The Trunk:
http://source.squeak.org/trunk/Tools-btc.367.mcz
==================== Summary ====================
Name: Tools-btc.367
Author: btc
Time: 12 July 2011, 12:07:30.194 am
UUID: bdc1afda-eed5-904b-9987-572aac977a16
Ancestors: Tools-bf.366
Single stepping through debugger can observe an anOrderedCollection object in an inconsistent state after creation but before initialisation. This threw an error when the inspector asked for the size of the object - now handled.
=============== Diff against Tools-bf.366 ===============
Item was changed:
----- Method: OrderedCollectionInspector>>fieldList (in category 'as yet unclassified') -----
fieldList
object ifNil: [ ^ OrderedCollection new].
^ self baseFieldList ,
+ (self objectSize <= (self i1 + self i2)
+ ifTrue: [(1 to: self objectSize)
- (object size <= (self i1 + self i2)
- ifTrue: [(1 to: object size)
collect: [:i | i printString]]
+ ifFalse: [(1 to: self i1) , (self objectSize - (self i2-1) to: self objectSize)
- ifFalse: [(1 to: self i1) , (object size-(self i2-1) to: object size)
collect: [:i | i printString]])
"
OrderedCollection new inspect
(OrderedCollection newFrom: #(3 5 7 123)) inspect
(OrderedCollection newFrom: (1 to: 1000)) inspect
"!
Item was added:
+ ----- Method: OrderedCollectionInspector>>objectSize (in category 'as yet unclassified') -----
+ objectSize
+ "Single stepping through a debugger can observe the object state after creation but before initiialisation."
+ "Thus 'object size' may throw an axception for trying to do arithmetic on nil."
+
+ [ object size ] on: Exception do: [ ^ 0 ].
+ ^ object size.!
Levente Uzonyi uploaded a new version of Tools to project The Trunk:
http://source.squeak.org/trunk/Tools-btc.367.mcz
==================== Summary ====================
Name: Tools-btc.367
Author: btc
Time: 12 July 2011, 12:07:30.194 am
UUID: bdc1afda-eed5-904b-9987-572aac977a16
Ancestors: Tools-bf.366
Single stepping through debugger can observe an anOrderedCollection object in an inconsistent state after creation but before initialisation. This threw an error when the inspector asked for the size of the object - now handled.
=============== Diff against Tools-bf.366 ===============
Item was changed:
----- Method: OrderedCollectionInspector>>fieldList (in category 'as yet unclassified') -----
fieldList
object ifNil: [ ^ OrderedCollection new].
^ self baseFieldList ,
+ (self objectSize <= (self i1 + self i2)
+ ifTrue: [(1 to: self objectSize)
- (object size <= (self i1 + self i2)
- ifTrue: [(1 to: object size)
collect: [:i | i printString]]
+ ifFalse: [(1 to: self i1) , (self objectSize - (self i2-1) to: self objectSize)
- ifFalse: [(1 to: self i1) , (object size-(self i2-1) to: object size)
collect: [:i | i printString]])
"
OrderedCollection new inspect
(OrderedCollection newFrom: #(3 5 7 123)) inspect
(OrderedCollection newFrom: (1 to: 1000)) inspect
"!
Item was added:
+ ----- Method: OrderedCollectionInspector>>objectSize (in category 'as yet unclassified') -----
+ objectSize
+ "Single stepping through a debugger can observe the object state after creation but before initiialisation."
+ "Thus 'object size' may throw an axception for trying to do arithmetic on nil."
+
+ [ object size ] on: Exception do: [ ^ 0 ].
+ ^ object size.!
Levente Uzonyi uploaded a new version of Tools to project The Trunk:
http://source.squeak.org/trunk/Tools-btc.367.mcz
==================== Summary ====================
Name: Tools-btc.367
Author: btc
Time: 12 July 2011, 12:07:30.194 am
UUID: bdc1afda-eed5-904b-9987-572aac977a16
Ancestors: Tools-bf.366
Single stepping through debugger can observe an anOrderedCollection object in an inconsistent state after creation but before initialisation. This threw an error when the inspector asked for the size of the object - now handled.
=============== Diff against Tools-bf.366 ===============
Item was changed:
----- Method: OrderedCollectionInspector>>fieldList (in category 'as yet unclassified') -----
fieldList
object ifNil: [ ^ OrderedCollection new].
^ self baseFieldList ,
+ (self objectSize <= (self i1 + self i2)
+ ifTrue: [(1 to: self objectSize)
- (object size <= (self i1 + self i2)
- ifTrue: [(1 to: object size)
collect: [:i | i printString]]
+ ifFalse: [(1 to: self i1) , (self objectSize - (self i2-1) to: self objectSize)
- ifFalse: [(1 to: self i1) , (object size-(self i2-1) to: object size)
collect: [:i | i printString]])
"
OrderedCollection new inspect
(OrderedCollection newFrom: #(3 5 7 123)) inspect
(OrderedCollection newFrom: (1 to: 1000)) inspect
"!
Item was added:
+ ----- Method: OrderedCollectionInspector>>objectSize (in category 'as yet unclassified') -----
+ objectSize
+ "Single stepping through a debugger can observe the object state after creation but before initiialisation."
+ "Thus 'object size' may throw an axception for trying to do arithmetic on nil."
+
+ [ object size ] on: Exception do: [ ^ 0 ].
+ ^ object size.!
Levente Uzonyi uploaded a new version of Tools to project The Trunk:
http://source.squeak.org/trunk/Tools-btc.368.mcz
==================== Summary ====================
Name: Tools-btc.368
Author: btc
Time: 13 July 2011, 12:09:33.417 am
UUID: 04b62880-e5a2-3445-8440-482d7c7586fb
Ancestors: Tools-btc.367
Single stepping through a debugger might observe the state of an OrderedCollection instance after creation by basicNew but before initiialisation. Thus 'object size' throws a DNU error for arithmetic on a nil value that needs to be handled.
=============== Diff against Tools-bf.366 ===============
Item was changed:
----- Method: OrderedCollectionInspector>>fieldList (in category 'as yet unclassified') -----
fieldList
object ifNil: [ ^ OrderedCollection new].
^ self baseFieldList ,
+ (self objectSize <= (self i1 + self i2)
+ ifTrue: [(1 to: self objectSize)
- (object size <= (self i1 + self i2)
- ifTrue: [(1 to: object size)
collect: [:i | i printString]]
+ ifFalse: [(1 to: self i1) , (self objectSize - (self i2-1) to: self objectSize)
- ifFalse: [(1 to: self i1) , (object size-(self i2-1) to: object size)
collect: [:i | i printString]])
"
OrderedCollection new inspect
(OrderedCollection newFrom: #(3 5 7 123)) inspect
(OrderedCollection newFrom: (1 to: 1000)) inspect
"!
Item was added:
+ ----- Method: OrderedCollectionInspector>>objectSize (in category 'as yet unclassified') -----
+ objectSize
+ "Single stepping through a debugger might observe the state of an OrderedCollection
+ instance after creation by basicNew but before initiialisation. Thus 'object size'
+ throws a DNU error for arithmetic on a nil value that needs to be handled here."
+
+ ^ [ object size ] on: Error do: [ 0 ]
+ !
Levente Uzonyi uploaded a new version of Tools to project The Trunk:
http://source.squeak.org/trunk/Tools-btc.368.mcz
==================== Summary ====================
Name: Tools-btc.368
Author: btc
Time: 13 July 2011, 12:09:33.417 am
UUID: 04b62880-e5a2-3445-8440-482d7c7586fb
Ancestors: Tools-btc.367
Single stepping through a debugger might observe the state of an OrderedCollection instance after creation by basicNew but before initiialisation. Thus 'object size' throws a DNU error for arithmetic on a nil value that needs to be handled.
=============== Diff against Tools-bf.366 ===============
Item was changed:
----- Method: OrderedCollectionInspector>>fieldList (in category 'as yet unclassified') -----
fieldList
object ifNil: [ ^ OrderedCollection new].
^ self baseFieldList ,
+ (self objectSize <= (self i1 + self i2)
+ ifTrue: [(1 to: self objectSize)
- (object size <= (self i1 + self i2)
- ifTrue: [(1 to: object size)
collect: [:i | i printString]]
+ ifFalse: [(1 to: self i1) , (self objectSize - (self i2-1) to: self objectSize)
- ifFalse: [(1 to: self i1) , (object size-(self i2-1) to: object size)
collect: [:i | i printString]])
"
OrderedCollection new inspect
(OrderedCollection newFrom: #(3 5 7 123)) inspect
(OrderedCollection newFrom: (1 to: 1000)) inspect
"!
Item was added:
+ ----- Method: OrderedCollectionInspector>>objectSize (in category 'as yet unclassified') -----
+ objectSize
+ "Single stepping through a debugger might observe the state of an OrderedCollection
+ instance after creation by basicNew but before initiialisation. Thus 'object size'
+ throws a DNU error for arithmetic on a nil value that needs to be handled here."
+
+ ^ [ object size ] on: Error do: [ 0 ]
+ !