1
|
1 |
"{ Package: 'stx:goodies/metacello' }"
|
|
2 |
|
|
3 |
MetacelloAbstractVersionConstructor subclass:#MetacelloToolBoxConstructor
|
|
4 |
instanceVariableNames:'currentSection methodSections'
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
|
7 |
category:'Metacello-Core-Constructors'
|
|
8 |
!
|
|
9 |
|
|
10 |
|
|
11 |
!MetacelloToolBoxConstructor methodsFor:'api'!
|
|
12 |
|
|
13 |
for: attribute do: aBlock
|
|
14 |
"conditional version support"
|
|
15 |
|
|
16 |
| methodSection |
|
|
17 |
methodSection := (MetacelloVersionMethodSection new)
|
|
18 |
attribute: attribute;
|
|
19 |
block: aBlock;
|
|
20 |
yourself.
|
|
21 |
currentSection ~~ nil
|
|
22 |
ifTrue: [ currentSection addMethodSection: methodSection ]
|
|
23 |
ifFalse: [ self methodSections add: methodSection]
|
|
24 |
!
|
|
25 |
|
|
26 |
for: attribute version: aString
|
|
27 |
"conditional symbolicVersion support"
|
|
28 |
|
|
29 |
self methodSections
|
|
30 |
add:
|
|
31 |
((MetacelloSymbolicVersionSpec new)
|
|
32 |
attribute: attribute;
|
|
33 |
versionString: aString;
|
|
34 |
yourself)
|
|
35 |
! !
|
|
36 |
|
|
37 |
!MetacelloToolBoxConstructor methodsFor:'enumeration'!
|
|
38 |
|
|
39 |
methodSectionsDo: aBlock
|
|
40 |
|
|
41 |
self methodSection: self do: aBlock
|
|
42 |
!
|
|
43 |
|
|
44 |
methodSectionsInEvaluationOrder: attributes do: aBlock
|
|
45 |
"breadth first traversal ... to collect selected sections, then evaluate individual sections in attribute order"
|
|
46 |
|
|
47 |
| selected |
|
|
48 |
selected := OrderedCollection new.
|
|
49 |
self methodSection: self inEvaluationOrder: attributes do: [:methodSection | selected add: methodSection ].
|
|
50 |
attributes
|
|
51 |
do: [ :attribute | (selected select: [ :methodSection | methodSection attribute == attribute ]) do: aBlock ].
|
|
52 |
! !
|
|
53 |
|
|
54 |
!MetacelloToolBoxConstructor methodsFor:'extraction'!
|
|
55 |
|
|
56 |
extractMethodSectionsFor: sourceVersionString
|
|
57 |
| coll pragma |
|
|
58 |
coll := self extractAllVersionPragmas at: sourceVersionString ifAbsent: [ ^ #() ].
|
|
59 |
coll size > 1
|
|
60 |
ifTrue: [ self error: 'More than one pragma defining ' , sourceVersionString printString ].
|
|
61 |
pragma := coll at: 1.
|
|
62 |
self evaluatePragma: pragma.
|
|
63 |
self methodSections do: [ :methodSection | self evaluateMethodSection: methodSection version: sourceVersionString ].
|
|
64 |
!
|
|
65 |
|
|
66 |
extractSymbolicVersionSpecsFor: sourceVersionSymbol
|
|
67 |
| coll versionSpec pragma |
|
|
68 |
coll := self extractSymbolicVersionPragmas at: sourceVersionSymbol ifAbsent: [ ^ #() ].
|
|
69 |
coll size > 1
|
|
70 |
ifTrue: [ self error: 'More than one pragma defining ' , sourceVersionSymbol printString ].
|
|
71 |
pragma := coll at: 1.
|
|
72 |
self evaluatePragma: pragma.
|
|
73 |
^ self methodSections
|
|
74 |
|
|
75 |
! !
|
|
76 |
|
|
77 |
!MetacelloToolBoxConstructor methodsFor:'initialization'!
|
|
78 |
|
|
79 |
reset
|
|
80 |
super reset. "not needed, but included for completeness"
|
|
81 |
methodSections := nil
|
|
82 |
! !
|
|
83 |
|
|
84 |
!MetacelloToolBoxConstructor methodsFor:'private'!
|
|
85 |
|
|
86 |
evaluateMethodSection: methodSection version: sourceVersionString
|
|
87 |
| versionSpec |
|
|
88 |
versionSpec := self project versionSpec.
|
|
89 |
versionSpec versionString: sourceVersionString.
|
|
90 |
methodSection versionSpec: versionSpec.
|
|
91 |
currentSection := methodSection.
|
|
92 |
self with: versionSpec during: methodSection block.
|
|
93 |
methodSection methodSections do: [ :ms | self evaluateMethodSection: ms version: sourceVersionString ]
|
|
94 |
!
|
|
95 |
|
|
96 |
methodSection: methodSection do: aBlock
|
|
97 |
|
|
98 |
methodSection methodSections do: aBlock.
|
|
99 |
methodSection methodSections do: [ :ms | self methodSection: ms do: aBlock ]
|
|
100 |
!
|
|
101 |
|
|
102 |
methodSection: methodSection inEvaluationOrder: attributes do: aBlock
|
|
103 |
|
|
104 |
| selected |
|
|
105 |
selected := OrderedCollection new.
|
|
106 |
attributes
|
|
107 |
do: [ :attribute |
|
|
108 |
methodSection methodSections
|
|
109 |
do: [ :ms |
|
|
110 |
attribute == ms attribute
|
|
111 |
ifTrue: [ selected add: ms ] ] ].
|
|
112 |
selected do: aBlock.
|
|
113 |
attributes size == 1
|
|
114 |
ifTrue: [ ^ self ].
|
|
115 |
selected
|
|
116 |
do: [ :ms | self methodSection: ms inEvaluationOrder: (attributes copyFrom: 2 to: attributes size) do: aBlock ]
|
|
117 |
!
|
|
118 |
|
|
119 |
methodSections
|
|
120 |
|
|
121 |
methodSections == nil ifTrue: [ methodSections := OrderedCollection new ].
|
|
122 |
^methodSections
|
|
123 |
! !
|
|
124 |
|
|
125 |
!MetacelloToolBoxConstructor class methodsFor:'documentation'!
|
|
126 |
|
|
127 |
version_SVN
|
|
128 |
^ '$Id:: $'
|
|
129 |
! !
|