The Trunk: Environments-cwp.15.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Environments-cwp.15.mcz

commits-2
Colin Putney uploaded a new version of Environments to project The Trunk:
http://source.squeak.org/trunk/Environments-cwp.15.mcz

==================== Summary ====================

Name: Environments-cwp.15
Author: cwp
Time: 9 March 2013, 8:15:12.639 pm
UUID: 57b74903-5b1b-495e-86c9-97bde295a0ce
Ancestors: Environments-cwp.14

Added the ability to rename classes as they are imported or exported.

=============== Diff against Environments-cwp.14 ===============

Item was added:
+ SystemOrganization addCategory: #'Environments-Core'!
+ SystemOrganization addCategory: #'Environments-Policies'!
+ SystemOrganization addCategory: #'Environments-Loading'!

Item was removed:
- SystemOrganization addCategory: #'Environments-Core'!

Item was added:
+ NamePolicy subclass: #AddPrefixNamePolicy
+ instanceVariableNames: 'prefix'
+ classVariableNames: ''
+ poolDictionaries: ''
+ category: 'Environments-Policies'!

Item was added:
+ ----- Method: AddPrefixNamePolicy class>>prefix: (in category 'as yet unclassified') -----
+ prefix: aString
+ ^ self basicNew initializeWithPrefix: aString!

Item was added:
+ ----- Method: AddPrefixNamePolicy>>initializeWithPrefix: (in category 'as yet unclassified') -----
+ initializeWithPrefix: aString
+ self initialize.
+ prefix := aString!

Item was added:
+ ----- Method: AddPrefixNamePolicy>>name:do: (in category 'as yet unclassified') -----
+ name: aSymbol do: aBlock
+ ^ (aSymbol beginsWith: prefix) ifFalse:
+ [aBlock value: (prefix, aSymbol) asSymbol].
+ !

Item was added:
+ LookupKey subclass: #Alias
+ instanceVariableNames: 'source'
+ classVariableNames: ''
+ poolDictionaries: ''
+ category: 'Environments-Core'!

Item was added:
+ ----- Method: Alias class>>key:source: (in category 'as yet unclassified') -----
+ key: aSymbol source: anAssociation
+ ^ self basicNew initializeWithKey: aSymbol source: anAssociation!

Item was added:
+ ----- Method: Alias>>asBinding: (in category 'converting') -----
+ asBinding: aSymbol
+ ^ Alias key: aSymbol source: source!

Item was added:
+ ----- Method: Alias>>initializeWithKey:source: (in category 'as yet unclassified') -----
+ initializeWithKey: aSymbol source: anAssociation
+ self initialize.
+ key := aSymbol.
+ source := anAssociation!

Item was added:
+ ----- Method: Alias>>isSpecialReadBinding (in category 'as yet unclassified') -----
+ isSpecialReadBinding
+ ^ true!

Item was added:
+ ----- Method: Alias>>isSpecialWriteBinding (in category 'as yet unclassified') -----
+ isSpecialWriteBinding
+ ^ true!

Item was added:
+ ----- Method: Alias>>value (in category 'as yet unclassified') -----
+ value
+ ^ source value!

Item was added:
+ ----- Method: Alias>>value: (in category 'as yet unclassified') -----
+ value: anObject
+ source value: anObject!

Item was added:
+ NamePolicy subclass: #AllNamePolicy
+ instanceVariableNames: ''
+ classVariableNames: ''
+ poolDictionaries: ''
+ category: 'Environments-Policies'!

Item was added:
+ ----- Method: AllNamePolicy>>name:do: (in category 'as yet unclassified') -----
+ name: aSymbol do: aBlock
+ ^ aBlock value: aSymbol!

Item was added:
+ ----- Method: Association>>asBinding: (in category '*environments') -----
+ asBinding: aSymbol
+ ^ Alias key: aSymbol source: self!

Item was added:
+ LookupKey subclass: #Binding
+ instanceVariableNames: 'value'
+ classVariableNames: ''
+ poolDictionaries: ''
+ category: 'Environments-Core'!

Item was added:
+ ----- Method: Binding class>>key:value: (in category 'as yet unclassified') -----
+ key: key value: value
+ ^ self basicNew initializeWithKey: key value: value!

Item was added:
+ ----- Method: Binding>>asBinding: (in category 'as yet unclassified') -----
+ asBinding: aSymbol
+ ^ self class key: aSymbol value: value!

Item was added:
+ ----- Method: Binding>>canAssign (in category 'as yet unclassified') -----
+ canAssign
+ ^ false!

Item was added:
+ ----- Method: Binding>>initializeWithKey:value: (in category 'as yet unclassified') -----
+ initializeWithKey: kObject value: vObject
+ self initialize.
+ key := kObject.
+ value := vObject.!

Item was added:
+ ----- Method: Binding>>isSpecialWriteBinding (in category 'as yet unclassified') -----
+ isSpecialWriteBinding
+ ^ true!

Item was added:
+ ----- Method: Binding>>value (in category 'as yet unclassified') -----
+ value
+ ^ value!

Item was added:
+ ----- Method: Binding>>value: (in category 'as yet unclassified') -----
+ value: anObject
+ (AttemptToWriteReadOnlyGlobal signal: 'Cannot store into read-only bindings')
+ ifTrue: [value := anObject]!

Item was added:
+ Object subclass: #BindingPolicy
+ instanceVariableNames: 'namespace policy next'
+ classVariableNames: ''
+ poolDictionaries: ''
+ category: 'Environments-Policies'!

Item was added:
+ ----- Method: BindingPolicy class>>namespace: (in category 'as yet unclassified') -----
+ namespace: aNamespace
+ ^ self namespace: aNamespace next: nil!

Item was added:
+ ----- Method: BindingPolicy class>>namespace:next: (in category 'as yet unclassified') -----
+ namespace: aNamespace next: anImport
+ ^ self
+ namespace: aNamespace
+ policy: AllNamePolicy new
+ next: anImport!

Item was added:
+ ----- Method: BindingPolicy class>>namespace:policy: (in category 'as yet unclassified') -----
+ namespace: aNamespace policy: aNamePolicy
+ ^ self namespace: aNamespace policy: aNamePolicy next: nil!

Item was added:
+ ----- Method: BindingPolicy class>>namespace:policy:next: (in category 'as yet unclassified') -----
+ namespace: aNamespace policy: aNamePolicy next: anImport
+ ^ self basicNew
+ initializeWithNamespace: aNamespace
+ policy: aNamePolicy
+ next: anImport!

Item was added:
+ ----- Method: BindingPolicy class>>null (in category 'as yet unclassified') -----
+ null
+ ^ self namespace: IdentityDictionary new!

Item was added:
+ ----- Method: BindingPolicy>>initializeWithNamespace:policy:next: (in category 'initialize-release') -----
+ initializeWithNamespace: aNamespace policy: aNamePolicy next: anImport
+ self initialize.
+ namespace := aNamespace.
+ policy := aNamePolicy.
+ next := anImport!

Item was added:
+ ----- Method: BindingPolicy>>name:do: (in category 'private') -----
+ name: aSymbol do: aBlock
+ ^ policy name: aSymbol do: aBlock!

Item was changed:
  Object subclass: #Environment
+ instanceVariableNames: 'info imports exports contents bindings public undeclared'
+ classVariableNames: 'Default Instances'
- instanceVariableNames: 'contents lookup undeclared exports info'
- classVariableNames: 'Default'
  poolDictionaries: ''
  category: 'Environments-Core'!

Item was changed:
+ ----- Method: Environment class>>default (in category 'accessing') -----
- ----- Method: Environment class>>default (in category 'as yet unclassified') -----
  default
  ^ Default!

Item was changed:
+ ----- Method: Environment class>>default: (in category 'accessing') -----
- ----- Method: Environment class>>default: (in category 'as yet unclassified') -----
  default: anEnvironment
  Default := anEnvironment!

Item was changed:
+ ----- Method: Environment class>>initialize (in category 'class initialization') -----
- ----- Method: Environment class>>initialize (in category 'as yet unclassified') -----
  initialize
  self uninstall!

Item was changed:
+ ----- Method: Environment class>>install (in category 'class initialization') -----
- ----- Method: Environment class>>install (in category 'as yet unclassified') -----
  install
  | smalltalk env |
+ self environment class == self ifTrue:
+ [Transcript
+ cr;
+ show: 'Can''t install environments; they''re already installed'.
+ ^ self].
+
- self environment class == self ifTrue: [self error: 'Already installed'].
  smalltalk := Smalltalk globals.
  env := self basicNew initializeWithSystemDictionary: smalltalk.
+ Default := env.
+ Instances at: env info name put: env.
  (smalltalk at: #Undeclared) becomeForward: (env at: #Undeclared).
  smalltalk becomeForward: env.
  Smalltalk garbageCollect.!

Item was removed:
- ----- Method: Environment class>>name: (in category 'as yet unclassified') -----
- name: aString
- ^ self basicNew initializeWithName: aString!

Item was added:
+ ----- Method: Environment class>>named: (in category 'instance creation') -----
+ named: aSymbol
+ ^ Instances
+ at: aSymbol
+ ifAbsentPut: [self withName: aSymbol]!

Item was changed:
+ ----- Method: Environment class>>uninstall (in category 'class initialization') -----
- ----- Method: Environment class>>uninstall (in category 'as yet unclassified') -----
  uninstall
  | globals sysdict |
  self environment class == self ifFalse:
  [Transcript
  cr;
  show: 'Can''t uninstall environments; they''re not currently installed'.
  ^ self].
 
  globals := Smalltalk globals instVarNamed: 'contents'.
  sysdict := SystemDictionary new: globals size.
  globals associationsDo: [:ea | sysdict add: ea].
  Smalltalk globals becomeForward: sysdict.!

Item was added:
+ ----- Method: Environment class>>withName: (in category 'instance creation') -----
+ withName: aString
+ ^ self basicNew initializeWithName: aString!

Item was changed:
+ ----- Method: Environment>>associationAt: (in category 'emulating') -----
- ----- Method: Environment>>associationAt: (in category 'accessing') -----
  associationAt: aSymbol
  "Senders of this should probably be using #bindingOf:"
 
  self flag: #review.
  ^ contents associationAt: aSymbol!

Item was changed:
+ ----- Method: Environment>>associationAt:ifAbsent: (in category 'emulating') -----
- ----- Method: Environment>>associationAt:ifAbsent: (in category 'accessing') -----
  associationAt: aSymbol ifAbsent: aBlock
  "Senders of this should probably be using #bindingOf:"
 
  self flag: #review.
  ^ contents associationAt: aSymbol ifAbsent: aBlock!

Item was changed:
+ ----- Method: Environment>>associationOrUndeclaredAt: (in category 'emulating') -----
- ----- Method: Environment>>associationOrUndeclaredAt: (in category 'compatibility') -----
  associationOrUndeclaredAt: key
+ ^ bindings associationAt: key ifAbsent:
+ [undeclared at: key put: nil.
+ undeclared associationAt: key]
+ !
- lookup do:
- [:ns | (ns includesKey: key) ifTrue: [^ ns associationAt: key]].
- undeclared at: key put: nil.
- ^ undeclared associationAt: key!

Item was changed:
+ ----- Method: Environment>>at: (in category 'emulating') -----
- ----- Method: Environment>>at: (in category 'accessing') -----
  at: aSymbol
  ^ contents at: aSymbol!

Item was changed:
+ ----- Method: Environment>>at:ifAbsent: (in category 'emulating') -----
- ----- Method: Environment>>at:ifAbsent: (in category 'accessing') -----
  at: aSymbol ifAbsent: aBlock
  ^ contents at: aSymbol ifAbsent: aBlock!

Item was changed:
+ ----- Method: Environment>>at:ifAbsentPut: (in category 'emulating') -----
- ----- Method: Environment>>at:ifAbsentPut: (in category 'accessing') -----
  at: aSymbol ifAbsentPut: aBlock
  ^ contents
  at: aSymbol
  ifAbsentPut: aBlock!

Item was changed:
+ ----- Method: Environment>>at:ifPresent: (in category 'emulating') -----
- ----- Method: Environment>>at:ifPresent: (in category 'accessing') -----
  at: aSymbol ifPresent: aBlock
  ^ contents at: aSymbol ifPresent: aBlock!

Item was changed:
+ ----- Method: Environment>>at:ifPresent:ifAbsent: (in category 'emulating') -----
- ----- Method: Environment>>at:ifPresent:ifAbsent: (in category 'compatibility') -----
  at: aSymbol ifPresent: presentBlock ifAbsent: absentBlock
  ^ contents
  at: aSymbol
  ifPresent: presentBlock
  ifAbsent: absentBlock.!

Item was changed:
+ ----- Method: Environment>>at:ifPresentAndInMemory: (in category 'emulating') -----
- ----- Method: Environment>>at:ifPresentAndInMemory: (in category 'compatibility') -----
  at: key ifPresentAndInMemory: aBlock
  ^ contents
  at: key
  ifPresent:
  [:v |
  v isInMemory ifTrue:
  [aBlock value: v]]!

Item was changed:
+ ----- Method: Environment>>at:put: (in category 'emulating') -----
- ----- Method: Environment>>at:put: (in category 'accessing') -----
  at: aSymbol put: anObject
+ | binding |
+ binding := anObject isBehavior
+ ifTrue: [Binding key: aSymbol value: anObject]
+ ifFalse: [Association key: aSymbol value: anObject].
+ contents add: binding.
+ exports bind: binding.
+ ^ anObject
+ !
- (contents includesKey: aSymbol) ifFalse:
- [contents declare: aSymbol from: undeclared].
- contents at: aSymbol put: anObject.
- anObject isBehavior ifTrue:
- [(contents associationAt: aSymbol) beReadOnlyBinding].
- ^ anObject!

Item was changed:
  ----- Method: Environment>>bindingOf:ifAbsent: (in category 'binding') -----
  bindingOf: aSymbol ifAbsent: aBlock
+ ^ bindings associationAt: aSymbol ifAbsent:
+ [(imports bindingOf: aSymbol)
+ ifNil: aBlock
+ ifNotNil: [:foreign | bindings add: (foreign asBinding: aSymbol)]]!
- lookup do:
- [:dict |
- (dict includesKey: aSymbol) ifTrue:
- [^ dict associationAt: aSymbol]].
- ^ aBlock value!

Item was changed:
+ ----- Method: Environment>>do: (in category 'emulating') -----
- ----- Method: Environment>>do: (in category 'enumerating') -----
  do: aBlock
  "Evaluate aBlock for each of the receiver's values."
 
  contents valuesDo: aBlock!

Item was changed:
+ ----- Method: Environment>>environment (in category 'emulating') -----
- ----- Method: Environment>>environment (in category 'compatibility') -----
  environment
  ^ self!

Item was changed:
  ----- Method: Environment>>export: (in category 'configuring') -----
+ export: spec
+ exports := Export
+ namespace: public
+ policy: (ExplicitNamePolicy spec: spec)
+ next: exports.
+ self publicizeContents!
- export: aSymbol
- exports add: (contents associationAt: aSymbol)!

Item was added:
+ ----- Method: Environment>>exportAddingPrefix: (in category 'configuring') -----
+ exportAddingPrefix: aString
+ exports := Export
+ namespace: public
+ policy: (AddPrefixNamePolicy prefix: aString)
+ next: exports.
+ self publicizeContents!

Item was added:
+ ----- Method: Environment>>exportRemovingPrefix: (in category 'configuring') -----
+ exportRemovingPrefix: aString
+ exports := Export
+ namespace: public
+ policy: (RemovePrefixNamePolicy prefix: aString)
+ next: exports.
+ self publicizeContents.!

Item was added:
+ ----- Method: Environment>>exportSelf (in category 'configuring') -----
+ exportSelf
+ exports := Export namespace: public next: exports.
+ self publicizeContents.!

Item was added:
+ ----- Method: Environment>>from:import: (in category 'configuring') -----
+ from: anEnvironment import: spec
+ imports := Import
+ namespace: anEnvironment public
+ policy: (ExplicitNamePolicy spec: spec)
+ next: imports.
+ !

Item was changed:
  ----- Method: Environment>>hasBindingThatBeginsWith: (in category 'binding') -----
  hasBindingThatBeginsWith: aString
+ bindings associationsDo:
+ [:ea | (ea key beginsWith: aString) ifTrue: [^ true]].
+ ^ false
+
+ !
- lookup do:
- [:dict |
- dict associationsDo:
- [:asc | (asc key beginsWith: aString) ifTrue:
- [^ true]]].
- ^ false!

Item was added:
+ ----- Method: Environment>>import: (in category 'configuring') -----
+ import: anEnvironment
+ imports := Import namespace: anEnvironment public next: imports.
+ self rebindUndeclared!

Item was added:
+ ----- Method: Environment>>import:addingPrefix: (in category 'configuring') -----
+ import: anEnvironment addingPrefix: aString
+ "This implementation is slightly counter-intuitive. The local name has a prefix,
+ so we have to remove it before doing the look up in the other environment."
+
+ imports := Import
+ namespace: anEnvironment public
+ policy: (RemovePrefixNamePolicy prefix: aString)
+ next: imports.
+ self rebindUndeclared.!

Item was added:
+ ----- Method: Environment>>import:removingPrefix: (in category 'configuring') -----
+ import: anEnvironment removingPrefix: aString
+ "This implementation is slightly counter-intuitive. The local name doesn't have a
+ prefix, so we have to add one when look it up in the other environment."
+
+ imports := Import
+ namespace: anEnvironment public
+ policy: (AddPrefixNamePolicy prefix: aString)
+ next: imports.
+ self rebindUndeclared.!

Item was removed:
- ----- Method: Environment>>importEnvironment: (in category 'configuring') -----
- importEnvironment: anEnvironment
- lookup := lookup copyWith: anEnvironment exports!

Item was added:
+ ----- Method: Environment>>importSelf (in category 'configuring') -----
+ importSelf
+ imports := Import namespace: contents next: imports.
+ self rebindUndeclared!

Item was removed:
- ----- Method: Environment>>importSmalltalk (in category 'configuring') -----
- importSmalltalk
- lookup := lookup copyWith: Smalltalk globals!

Item was changed:
+ ----- Method: Environment>>includes: (in category 'emulating') -----
- ----- Method: Environment>>includes: (in category 'compatibility') -----
  includes: key
  ^ contents includes: key!

Item was changed:
+ ----- Method: Environment>>includesKey: (in category 'emulating') -----
- ----- Method: Environment>>includesKey: (in category 'compatibility') -----
  includesKey: key
  ^ contents includesKey: key!

Item was added:
+ ----- Method: Environment>>info (in category 'accessing') -----
+ info
+ ^ info!

Item was changed:
  ----- Method: Environment>>initialize (in category 'initialize-release') -----
  initialize
+ bindings := IdentityDictionary new.
- undeclared := IdentityDictionary new.
  contents := IdentityDictionary new.
+ public := IdentityDictionary new.
+ undeclared := IdentityDictionary new.
+ imports := Import null.
+ exports := Export null.
+ self importSelf.!
- lookup := {contents}.
- exports := contents.
- !

Item was changed:
+ ----- Method: Environment>>keyAtIdentityValue: (in category 'emulating') -----
- ----- Method: Environment>>keyAtIdentityValue: (in category 'compatibility') -----
  keyAtIdentityValue: anObject
  ^ contents keyAtIdentityValue: anObject.!

Item was changed:
+ ----- Method: Environment>>keyAtIdentityValue:ifAbsent: (in category 'emulating') -----
- ----- Method: Environment>>keyAtIdentityValue:ifAbsent: (in category 'accessing') -----
  keyAtIdentityValue: anObject ifAbsent: aBlock
  ^ contents keyAtIdentityValue: anObject ifAbsent: aBlock!

Item was changed:
+ ----- Method: Environment>>keys (in category 'emulating') -----
- ----- Method: Environment>>keys (in category 'compatibility') -----
  keys
  ^ contents keys!

Item was changed:
+ ----- Method: Environment>>keysDo: (in category 'emulating') -----
- ----- Method: Environment>>keysDo: (in category 'enumerating') -----
  keysDo: aBlock
  "Evaluate aBlock for each of the receiver's keys."
 
  contents keysDo: aBlock!

Item was added:
+ ----- Method: Environment>>migrate (in category 'initialize-release') -----
+ migrate
+ bindings := IdentityDictionary new.
+ public := IdentityDictionary new.
+ imports := Import namespace: contents.
+ exports :=  Export namespace: public.
+ contents keysAndValuesDo:
+ [:name :value |
+ bindings at: name put: value.
+ public at: name put: value]
+ !

Item was changed:
+ ----- Method: Environment>>objectForDataStream: (in category 'emulating') -----
- ----- Method: Environment>>objectForDataStream: (in category 'compatibility') -----
  objectForDataStream: refStrm
  | dp |
  "I am about to be written on an object file.  Write a reference to Smalltalk instead."
 
  dp := DiskProxy global: #Smalltalk selector: #globals args: #().
  refStrm replace: self with: dp.
  ^ dp!

Item was added:
+ ----- Method: Environment>>public (in category 'accessing') -----
+ public
+ ^ public!

Item was added:
+ ----- Method: Environment>>publicizeContents (in category 'private') -----
+ publicizeContents
+ contents associationsDo: [:binding | exports bind: binding].
+ !

Item was added:
+ ----- Method: Environment>>rebindUndeclared (in category 'private') -----
+ rebindUndeclared
+ undeclared keys do:
+ [:name |
+ (imports valueOf: name) ifNotNil:
+ [:v |
+ bindings declare: name from: undeclared.
+ bindings at: name put: v]]!

Item was removed:
- ----- Method: Environment>>requireExplicitExports (in category 'configuring') -----
- requireExplicitExports
- exports == contents ifTrue:
- [exports := IdentityDictionary new]!

Item was changed:
+ ----- Method: Environment>>scopeFor:from:envtAndPathIfFound: (in category 'emulating') -----
- ----- Method: Environment>>scopeFor:from:envtAndPathIfFound: (in category 'compatibility') -----
  scopeFor: aSymbol from: lower envtAndPathIfFound: aBlock
  ^ (contents includesKey: aSymbol)
  ifTrue: [aBlock value: self value: String new]
  !

Item was changed:
+ ----- Method: Environment>>select: (in category 'emulating') -----
- ----- Method: Environment>>select: (in category 'compatibility') -----
  select: aBlock
  ^ contents select: aBlock!

Item was changed:
+ ----- Method: Environment>>storeDataOn: (in category 'emulating') -----
- ----- Method: Environment>>storeDataOn: (in category 'compatibility') -----
  storeDataOn: aDataStream
  "I don't get stored.  Use a DiskProxy"
 
  self error: 'use a DiskProxy to store me'!

Item was changed:
  ----- Method: Environment>>valueOf:ifAbsent: (in category 'binding') -----
  valueOf: aSymbol ifAbsent: aBlock
+ ^ bindings at: aSymbol ifAbsent: aBlock!
- lookup do:
- [:dict |
- dict at: aSymbol ifPresent:
- [:value | ^ value]].
- ^ aBlock value!

Item was changed:
+ ----- Method: Environment>>veryDeepCopyWith: (in category 'emulating') -----
- ----- Method: Environment>>veryDeepCopyWith: (in category 'compatibility') -----
  veryDeepCopyWith: aCopier
  ^ self!

Item was changed:
  Object subclass: #EnvironmentLoader
  instanceVariableNames: 'environment'
  classVariableNames: ''
  poolDictionaries: ''
+ category: 'Environments-Loading'!
- category: 'Environments-Core'!

Item was changed:
  Notification subclass: #EnvironmentRequest
  instanceVariableNames: ''
  classVariableNames: ''
  poolDictionaries: ''
+ category: 'Environments-Loading'!
- category: 'Environments-Core'!

Item was added:
+ NamePolicy subclass: #ExplicitNamePolicy
+ instanceVariableNames: 'aliases'
+ classVariableNames: ''
+ poolDictionaries: ''
+ category: 'Environments-Policies'!

Item was added:
+ ----- Method: ExplicitNamePolicy class>>aliases: (in category 'as yet unclassified') -----
+ aliases: aCollection
+ ^ self basicNew initializeWithAliases: aCollection!

Item was added:
+ ----- Method: ExplicitNamePolicy class>>flattenSpec:into: (in category 'as yet unclassified') -----
+ flattenSpec: anObject into: names
+ anObject isSymbol ifTrue:
+ [^ names at: anObject put: anObject].
+ anObject isVariableBinding ifTrue:
+ [^ names add: anObject].
+ anObject isDictionary ifTrue:
+ [^ names addAll: anObject].
+ anObject do:
+ [:ea | self flattenSpec: ea into: names]!

Item was added:
+ ----- Method: ExplicitNamePolicy class>>spec: (in category 'as yet unclassified') -----
+ spec: anObject
+ | aliases |
+ (anObject isKindOf: NamePolicy) ifTrue: [^ anObject].
+ aliases := IdentityDictionary new.
+ self flattenSpec: anObject into: aliases.
+ ^ self aliases: aliases!

Item was added:
+ ----- Method: ExplicitNamePolicy>>initializeWithAliases: (in category 'as yet unclassified') -----
+ initializeWithAliases: aCollection
+ self initialize.
+ aliases := IdentityDictionary withAll: aCollection!

Item was added:
+ ----- Method: ExplicitNamePolicy>>name:do: (in category 'as yet unclassified') -----
+ name: aSymbol do: aBlock
+ ^ aBlock value: (aliases at: aSymbol ifAbsent: [^ nil])!

Item was added:
+ BindingPolicy subclass: #Export
+ instanceVariableNames: ''
+ classVariableNames: ''
+ poolDictionaries: ''
+ category: 'Environments-Policies'!

Item was added:
+ ----- Method: Export>>bind: (in category 'binding') -----
+ bind: aBinding
+
+ self name: aBinding key do:
+ [:foreign | ^ namespace add: (aBinding asBinding: foreign)].
+ ^ next ifNotNil: [next bind: aBinding]!

Item was added:
+ ----- Method: Export>>bind:to: (in category 'binding') -----
+ bind: aSymbol to: anObject
+ ^ self bind: aSymbol -> anObject!

Item was added:
+ BindingPolicy subclass: #Import
+ instanceVariableNames: ''
+ classVariableNames: ''
+ poolDictionaries: ''
+ category: 'Environments-Policies'!

Item was added:
+ ----- Method: Import>>bindingOf: (in category 'binding') -----
+ bindingOf: aSymbol
+ self name: aSymbol do:
+ [:foreign |
+ ^ namespace
+ associationAt: foreign
+ ifAbsent: [next ifNotNil: [next bindingOf: aSymbol]]].
+ ^ next ifNotNil: [next bindingOf: aSymbol]!

Item was added:
+ ----- Method: Import>>valueOf: (in category 'binding') -----
+ valueOf: aSymbol
+ ^ (self bindingOf: aSymbol) value!

Item was added:
+ Object subclass: #NamePolicy
+ instanceVariableNames: ''
+ classVariableNames: ''
+ poolDictionaries: ''
+ category: 'Environments-Policies'!

Item was added:
+ ----- Method: NamePolicy>>name:do: (in category 'as yet unclassified') -----
+ name: aSymbol do: aBlock
+ self subclassResponsibility!

Item was added:
+ ----- Method: ReadOnlyVariableBinding>>asBinding: (in category '*environments') -----
+ asBinding: aSymbol
+ ^ Binding key: aSymbol value: value!

Item was added:
+ NamePolicy subclass: #RemovePrefixNamePolicy
+ instanceVariableNames: 'prefix'
+ classVariableNames: ''
+ poolDictionaries: ''
+ category: 'Environments-Policies'!

Item was added:
+ ----- Method: RemovePrefixNamePolicy class>>prefix: (in category 'as yet unclassified') -----
+ prefix: aString
+ ^ self basicNew initializeWithPrefix: aString!

Item was added:
+ ----- Method: RemovePrefixNamePolicy>>initializeWithPrefix: (in category 'as yet unclassified') -----
+ initializeWithPrefix: aString
+ self initialize.
+ prefix := aString!

Item was added:
+ ----- Method: RemovePrefixNamePolicy>>name:do: (in category 'as yet unclassified') -----
+ name: aSymbol do: aBlock
+ ^ (aSymbol beginsWith: prefix)
+ ifTrue: [aBlock value: (aSymbol allButFirst: prefix size) asSymbol]!


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Environments-cwp.15.mcz

Colin Putney-3




On Sat, Mar 9, 2013 at 8:30 PM, <[hidden email]> wrote:
 
==================== Summary ====================

Name: Environments-cwp.15
Author: cwp
Time: 9 March 2013, 8:15:12.639 pm
UUID: 57b74903-5b1b-495e-86c9-97bde295a0ce
Ancestors: Environments-cwp.14

Added the ability to rename classes as they are imported or exported.


With this update, Environments now understand the following messages:

import: anEnvironment
Imports all the bindings from the other environment, with no renaming

import: anEnvironment addingPrefix: aString 
Imports all the bindings from the given environment which have keys that do not begin with the specified prefix. The bindings are made visible in the receiver with the prefix added. For example, if the other environment has classes named Foo and XXBar, Foo will be imported as XXFoo, but XXBar will not be imported.

import: anEnvironment removingPrefix: aString 
Imports all bindings from the given environment which have keys that begin with the specified prefix. The bindings are made visible in the receiver with the prefix removed. For example, if the other environment has classes named Foo and XXBar, XXBar will be imported as Bar, but Foo will not be imported.

importSelf
Imports all the classes and globals defined in the receiver visible to methods compiled in the receiver, with no renaming.

from: anEnvironment import: aSpec
Imports only the specified bindings from the given environment. The specification may be any of the following: a symbol, an association, a dictionary or an array of specifications. These all do what you'd expect, giving you either a straight import or an alias. 

exportSelf
Makes all the classes and globals defined in the environment public (available for import by other environments).

export: aSpec
Makes the specified classes and globals public, using the same specifications as #from:import:.

exportAddingPrefix: aString
Makes the classes and globals that don't have the given prefix public, adding the prefix, similar to #import:addingPrefix:.

exportRemovingPrefix: aString
Makes the classes and globals that do have the given prefix public, removing the prefix, similar to #import:removingPrefix:.


This covers all the use cases I can think of, so now I'm going to move on and start working on making the rest of the system environment-aware. UI for easily opening a class browser on an environment. Tools for defining and modifying environments during development. Environment support in Monticello, SystemNavigator, SystemChangeNotifier etc. 

Cheers,

Colin