On 4/28/2010 2:44 PM, Henrik Sperre Johansen wrote:
My point was rather the pragmas in Squeak are more closely coupled with
the point it is actually defined, in that you defined the pragma itself
in the accessor method for the variable, rather than having 1-N
declarations in a single method, pointing to 1-N places where those
settings values can actually be found.
Right. The other advantage is that the simple "pragma" (which we've
already established isn't a pragma at all) is trivial to support. Here
is an implementation for Pharo, taking all of six methods (it would have
been three methods if the Settings framework had been structured a
little different :-)
Oh, and as a free goodie you get the ability to browse the implementors
of both, #systemsettings as well as
#preference:category:description:type: if you're curious where and how
these annotations are used.
Cheers,
- Andreas
'From PharoCore1.1ALPHA of ''19 October 2009'' [Latest update: #11312] on 28 April 2010 at 10:46:34 pm'!
"Change Set: SqueakPrefs-ar
Date: 28 April 2010
Author: asasa
Adds Squeak's preference annotations"!
!SettingBrowser methodsFor: 'styles' stamp: 'asasa 4/28/2010 18:26'!
squeakPreferenceKeyword
^#preference:category:description:type:! !
!SettingBrowser methodsFor: 'user interface' stamp: 'asasa 4/28/2010 18:26'!
newTreeHolder
^ SettingTree new acceptableKeywords: {self defaultSettingGroupKeyword. self squeakPreferenceKeyword}! !
!SettingTree methodsFor: 'accessing' stamp: 'asasa 4/28/2010 18:33'!
acceptableKeywords: keywords
self collector filter: [:prg | prg methodClass isMeta and: [keywords includes: prg keyword]].
nodeList := nil.
self collector reset.
! !
!SettingTreeBuilder methodsFor: 'accessing' stamp: 'asasa 4/28/2010 18:21'!
buildPragma: aPragma
currentPragma := aPragma.
self perform: aPragma keyword withArguments: aPragma arguments.
^ nodeList! !
!SettingTreeBuilder methodsFor: 'pragmas' stamp: 'asasa 4/28/2010 22:45'!
preference: prefName category: category description: description type: type
"Process a Squeak preference pragma"
"Create the group if it doesn't exist yet"
(self nodeList anySatisfy:[:any| any item name = category])
ifFalse:[self group: category asSymbol].
"Add the preference"
(self setting: prefName)
type: type;
parent: category asSymbol;
target: currentPragma methodClass instanceSide;
getSelector: currentPragma selector;
setSelector: currentPragma selector asMutator;
description: description.
! !
!SettingTreeBuilder methodsFor: 'pragmas' stamp: 'asasa 4/28/2010 22:46'!
systemsettings
"Process a <systemsettings> pragma"
currentPragma methodClass theNonMetaClass perform: currentPragma selector with: self.! !
!SettingTreeBuilder reorganize!
('accessing' buildPragma: nodeClass nodeList)
('public tree building' group: launcher: pickOne: range: setting:)
('private tree building' nodeClass:name: parent:while:)
('pragmas' preference:category:description:type: systemsettings)
!
!SettingTree reorganize!
('accessing' acceptableKeywords: collector itemSortBlock nodeList sortBlock updateList)
('checking' checkForUnknownParent checkForUnknownTarget)
('querying' childrenOf: deeplyDetect: deeplySelect: deeplySelect:in: pragmasDo: retainedNodesFromList: settingTreeRoots unclassified)
('updating' whenChangedSend:to:)
('private tree building' emptyNodeNamed: nodeNamed: nodeNamed:ifAbsent:)
!
_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project