--- a/UIPainterView.st Thu Feb 17 16:00:43 2000 +0100
+++ b/UIPainterView.st Thu Feb 17 16:01:27 2000 +0100
@@ -731,7 +731,8 @@
AspectsAsInstances ifTrue:[
code := (code , '\' ,
' ' , aspect , ' isNil ifTrue:[\' ,
- ' ' , aspect , ' := ' , ' ' , modelGen , '.\' ,
+ ' ' , aspect , ' := ' , ' ' , modelGen , '.\' ,
+ '"/ ' , aspect , ' addDependent:self.\' ,
' ].\' ,
' ^ ' , aspect ,'.\' ,
'!! !!\\')
@@ -742,10 +743,12 @@
' (holder := builder bindingAt:#' , aspect , ') isNil ifTrue:[\' ,
' holder := ', modelGen, '.\',
' builder aspectAt:#' , aspect , ' put:holder.\',
+ '"/ holder addDependent:self.\' ,
' ].\' ,
' ^ holder.\' ,
'!! !!\\')
].
+
^ code withCRs
"Modified: / 29.7.1998 / 11:29:16 / cg"
@@ -758,7 +761,7 @@
Return a string ready to compile into the application class."
|cls code skip protoSpec thisCode
- definedMethodSelectors iVars t|
+ definedMethodSelectors iVars t exportSels|
definedMethodSelectors := IdentitySet new.
@@ -807,10 +810,11 @@
definedMethodSelectors add:sym.
] ifTrue:[
Transcript showCR:'no code generated for aspect: ' , sym , ' (method already exists)'
- ]
- ]
+ ].
+ ].
].
+ "/ for each aspect, generate getter (if not yet implemented)
self generateCodeFrom:(aProp spec aspectSelectors) in:cls
do:[:aSel|
|sym|
@@ -823,6 +827,21 @@
]
].
+ "/ exported aspects - need setter methods
+ exportSels := (treeView exportedAspects ? #()) collect:[:entry | (entry subAspect , ':') asSymbol].
+ self generateCodeFrom:exportSels in:cls
+ do:[:aSel|
+ |sym aspect|
+
+ sym := aSel asSymbol.
+ (definedMethodSelectors includes:sym) ifFalse:[
+ aspect := (aSel copyWithoutLast:1) asSymbol.
+ thisCode := (self generateAspectSetMethodFor:aspect spec:protoSpec inClass:cls).
+ code := code , thisCode.
+ definedMethodSelectors add:sym.
+ ]
+ ].
+
self generateCodeFrom:(aProp spec actionSelectors) in:cls
do:[:aSel|
|sym|
@@ -915,6 +934,47 @@
!
+generateAspectSetMethodFor:aspect spec:protoSpec inClass:targetClass
+ |code|
+
+ code := '!!' , targetClass name , ' methodsFor:''aspects - exported''!!\\' ,
+ aspect , ':something\' ,
+ ' "automatically generated by UIPainter ..."\\' ,
+ ' "This method is used when I am embedded as subApplication,"\' ,
+ ' "and the mainApp wants to connect its aspects to mine."\'.
+
+ AspectsAsInstances ifTrue:[
+ code := (code , '\' ,
+ ' "/ ' , aspect , ' notNil ifTrue:[\' ,
+ ' "/ ' , aspect , ' removeDependent:self.\' ,
+ ' "/ ].\' ,
+ ' ' , aspect ,' := something.\' ,
+ ' "/ ' , aspect ,' notNil ifTrue:[\' ,
+ ' "/ ' , aspect , ' addDependent:self.\' ,
+ ' "/ ].\' ,
+ ' ^ self.\' ,
+ '!! !!\\')
+ ] ifFalse:[
+ code := (code , '\' ,
+ ' "/ |holder|\' ,
+ '\' ,
+ ' "/ (holder := builder bindingAt:#' , aspect , ') notNil ifTrue:[\' ,
+ ' "/ holder removeDependent:self.\' ,
+ ' "/ ].\' ,
+ ' builder aspectAt:#' , aspect , ' put:something.\',
+ ' "/ something notNil ifTrue:[\' ,
+ ' "/ something addDependent:self.\' ,
+ ' "/ ].\' ,
+ ' ^ self.\' ,
+ '!! !!\\')
+ ].
+
+ ^ code withCRs
+
+ "Modified: / 29.7.1998 / 11:29:16 / cg"
+ "Modified: / 22.9.1999 / 12:33:47 / stefan"
+!
+
generateCodeFrom:aListOfSelectors in:aClass do:aBlock
self class redefineAspectMethods ifTrue:[