Joshua Gargus uploaded a new version of Tools to project The Trunk:
http://source.squeak.org/trunk/Tools-jcg.247.mcz ==================== Summary ==================== Name: Tools-jcg.247 Author: jcg Time: 23 June 2010, 12:13:50.59 pm UUID: a06587b9-7aaf-412f-a9a1-c49d97fb8110 Ancestors: Tools-cmm.246 Workspaces can now look up variable-bindings in a user-specified list of SharedPools. See the class-side methods #addLookupPool:, #removeLookupPool:, and #clearLookupPools. =============== Diff against Tools-cmm.246 =============== Item was added: + ----- Method: Workspace class>>removeLookupPool: (in category 'lookup pools') ----- + removeLookupPool: sharedPool + "Workspaces should no longer look up bindings in the specified SharedPool." + LookupPools ifNil: [^self]. + LookupPools remove: sharedPool ifAbsent: [].! Item was added: + ----- Method: Workspace>>lookupInPools: (in category 'binding') ----- + lookupInPools: aString + "Iterate through all of the lookup pools to find a match for the specified name." + LookupPools ifNil: [^nil]. + LookupPools do: [:pool | (pool bindingOf: aString) ifNotNil: [:assoc | ^assoc value]]. + ^nil + ! Item was added: + ----- Method: Workspace class>>clearLookupPools (in category 'lookup pools') ----- + clearLookupPools + LookupPools := nil. + ! Item was changed: ----- Method: Workspace>>bindingOf: (in category 'binding') ----- bindingOf: aString - mustDeclareVariables ifTrue: [^ nil]. "I want to have workspace that force the user to declare variables. Still subclasses may want to do something else" + bindings ifNil: [self initializeBindings]. + (bindings includesKey: aString) ifFalse: [ + | val | + val := self lookupInPools: aString. + val + ifNotNil: [ + "Caveat: since we're not inserting the pool's Association into + the dictionary, assigning a new value to the variable will only + affect the one Workspace (i.e. you can't assign to a variable in a + SharedPool)." + bindings at: aString put: val] + ifNil: [aString first isUppercase + ifTrue: [^nil] + ifFalse: [bindings at: aString put: nil]] + ]. - bindings isNil - ifTrue: [self initializeBindings]. - (bindings includesKey: aString) - ifFalse: [bindings at: aString put: nil]. ^ bindings associationAt: aString! Item was added: + ----- Method: Workspace class>>addLookupPool: (in category 'lookup pools') ----- + addLookupPool: sharedPool + "Add a SharedPool that bindings should be looked up in." + LookupPools ifNil: [LookupPools := IdentitySet new]. + LookupPools add: sharedPool! Item was changed: StringHolder subclass: #Workspace instanceVariableNames: 'bindings acceptDroppedMorphs acceptAction mustDeclareVariables shouldStyle' + classVariableNames: 'LookupPools ShouldStyle' - classVariableNames: 'ShouldStyle' poolDictionaries: '' category: 'Tools-Base'! !Workspace commentStamp: 'ls 10/14/2003 12:13' prior: 0! A Workspace is a text area plus a lot of support for executable code. It is a great place to execute top-level commands to compute something useful, and it is a great place to develop bits of a program before those bits get put into class methods. To open a new workspace, execute: Workspace open A workspace can have its own variables, called "workspace variables", to hold intermediate results. For example, if you type into a workspace "x := 5" and do-it, then later you could type in "y := x * 2" and y would become 10. Additionally, in Morphic, a workspace can gain access to morphs that are on the screen. If acceptDroppedMorphss is turned on, then whenever a morph is dropped on the workspace, a variable will be created which references that morph. This functionality is toggled with the window-wide menu of a workspace. The instance variables of this class are: bindings - holds the workspace variables for this workspace acceptDroppedMorphss - whether dropped morphs should create new variables! |
Free forum by Nabble | Edit this page |