The Trunk: Traits-ar.251.mcz

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

The Trunk: Traits-ar.251.mcz

commits-2
Andreas Raab uploaded a new version of Traits to project The Trunk:
http://source.squeak.org/trunk/Traits-ar.251.mcz

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

Name: Traits-ar.251
Author: ar
Time: 28 December 2009, 1:59:42 am
UUID: 2e05e673-cd6e-4940-b6b4-3769d9a22211
Ancestors: Traits-nice.250

Preparations for NanoTraits: Vector traits creation through ClassDescription. Some utility methods to make interactions between Nano and Berne traits easier.

=============== Diff against Traits-nice.250 ===============

Item was added:
+ ----- Method: TraitComposition>>asArray (in category 'converting') -----
+ asArray
+ ^self transformations asArray!

Item was changed:
  ----- Method: Trait class>>named:uses:category: (in category 'instance creation') -----
  named: aSymbol uses: aTraitCompositionOrCollection category: aString
+ "Dispatch through ClassDescription for alternative implementations"
+ ^ClassDescription newTraitNamed: aSymbol uses: aTraitCompositionOrCollection category: aString!
- | env |
- env := self environment.
- ^self
- named: aSymbol
- uses: aTraitCompositionOrCollection
- category: aString
- env: env!

Item was added:
+ ----- Method: TraitComposition>>removeTraitUser: (in category 'accessing') -----
+ removeTraitUser: aClass
+ self traits do:[:each| each removeUser: aClass].!

Item was changed:
  ----- Method: TraitBehavior>>hasTraitComposition (in category 'traits') -----
  hasTraitComposition
+ ^traitComposition notNil and:[traitComposition isEmpty not]!
- ^traitComposition notNil!

Item was added:
+ ----- Method: Trait class>>newTraitNamed:uses:category: (in category 'instance creation') -----
+ newTraitNamed: aSymbol uses: aTraitCompositionOrCollection category: aString
+ "Creates a new trait."
+ | env |
+ env := self environment.
+ ^self
+ named: aSymbol
+ uses: aTraitCompositionOrCollection
+ category: aString
+ env: env!

Item was added:
+ ----- Method: Behavior>>allTraits (in category '*Traits') -----
+ allTraits
+ "Answer all the traits that are used by myself without their transformations"
+ ^self traitComposition isEmpty
+ ifTrue:[#()]
+ ifFalse:[self traitComposition allTraits].!

Item was added:
+ ----- Method: Trait class>>newTraitComposition (in category 'accessing') -----
+ newTraitComposition
+ "Creates a new TraitComposition"
+ ^TraitComposition new!

Item was added:
+ ----- Method: Trait class>>allTraitsDo: (in category 'accessing') -----
+ allTraitsDo: aBlock
+ "Evaluate aBlock with all the instance and class traits present in the system"
+ Trait allInstances , ClassTrait allInstances do: [:trait | aBlock value: trait].!

Item was added:
+ ----- Method: TraitDescription>>printUsersOf:on:level: (in category 'printing') -----
+ printUsersOf: aClass on: aStream level: indent
+ aStream crtab: indent.
+ aStream nextPutAll: aClass name.
+ aClass isTrait ifTrue:[
+ aClass users do:[:each| self printUsersOf: each on: aStream level: indent+1].
+ ].
+ !

Item was changed:
  ----- Method: SequenceableCollection>>asTraitComposition (in category '*Traits') -----
  asTraitComposition
  "For convenience the composition {T1. T2 ...} is the same as T1 + T2 + ..."
  ^self isEmpty
  ifFalse: [
  self size = 1
  ifTrue: [self first asTraitComposition]
  ifFalse: [
  self copyWithoutFirst
  inject: self first
  into: [:left :right | left + right]]]
+ ifTrue: [ClassDescription newTraitComposition]!
- ifTrue: [
- TraitComposition new]!

Item was added:
+ ----- Method: Trait class>>initialize (in category 'class initialization') -----
+ initialize "Trait initialize"
+ "If no current trait implementation is installed yet, install myself."
+ ClassDescription traitImpl
+ ifNil:[ClassDescription traitImpl: self].!

Item was added:
+ ----- Method: TraitDescription>>printHierarchy (in category 'printing') -----
+ printHierarchy
+ "For hierarchy view in the browser; print the users of a trait"
+ ^String streamContents:[:s| self printUsersOf: self on: s level: 0].!