[squeak-dev] The Trunk: Files-ul.104.mcz
commits at source.squeak.org
commits at source.squeak.org
Thu Mar 17 01:04:52 UTC 2011
Levente Uzonyi uploaded a new version of Files to project The Trunk:
http://source.squeak.org/trunk/Files-ul.104.mcz
==================== Summary ====================
Name: Files-ul.104
Author: ul
Time: 16 March 2011, 11:49:07.351 pm
UUID: 6857a09e-25e3-d345-b01f-41700e7bda67
Ancestors: Files-ul.103
- introduced CurrentReadOnlySourceFiles which is an exception used to fetch the current read only copies of SourceFiles
- added a new method to SourceFileArray that extracts both the fileIndex and filePosition from a source pointer and passes them to a block.
=============== Diff against Files-ul.103 ===============
Item was added:
+ Exception subclass: #CurrentReadOnlySourceFiles
+ instanceVariableNames: ''
+ classVariableNames: ''
+ poolDictionaries: ''
+ category: 'Files-System'!
+
+ !CurrentReadOnlySourceFiles commentStamp: 'ul 3/16/2011 23:08' prior: 0!
+ I'm useful to avoid the creation of several read-only copies of the source files. Use me instead of SourceFiles in your code when you need a read-only copy, like here:
+
+ CurrentReadOnlySourceFiles at: 1.
+
+ To reuse the source files, surround your code the following way:
+
+ | currentReadOnlySourceFiles |
+ ...
+ [ <your code using the source files> ]
+ on: CurrentReadOnlySourceFiles
+ do: [ :ex |
+ ex resume: (currentReadOnlySourceFiles
+ ifNil: [ currentReadOnlySourceFiles := ex defaultAction ]) ].
+ ...
+
+ Note that it's still better to store the source files in a variable in your code, than throwing many exceptions performance wise.!
Item was added:
+ ----- Method: CurrentReadOnlySourceFiles classSide>>at: (in category 'as yet unclassified') -----
+ at: sourceFileIndex
+
+ ^self signal at: sourceFileIndex!
Item was added:
+ ----- Method: CurrentReadOnlySourceFiles>>defaultAction (in category 'as yet unclassified') -----
+ defaultAction
+ "Return a read-only copy of SourceFiles."
+
+ ^SourceFiles collect: [ :each |
+ each ifNotNil: [
+ [ each readOnlyCopy ]
+ on: FileDoesNotExistException
+ do: [ :ex | nil "file does not exist happens in secure mode" ] ] ]!
Item was added:
+ ----- Method: SourceFileArray>>fileIndexAndPositionFromSourcePointer:do: (in category 'sourcePointer conversion') -----
+ fileIndexAndPositionFromSourcePointer: sourcePointer do: aBlock
+
+ ^aBlock
+ value: (self fileIndexFromSourcePointer: sourcePointer)
+ value: (self filePositionFromSourcePointer: sourcePointer)!
More information about the Squeak-dev
mailing list
|