Storing morphs displayed in the world in a GOODS db

Avi Bryant avi at beta4.com
Tue Sep 28 10:06:25 UTC 2004


On Sep 27, 2004, at 6:12 PM, John Pierce wrote:

>> Slightly more general would be to add
>> a field type something like KKAutoloadReferenceField that would always
>> bring the full object in right away, rather than using a proxy, and
>> mark cachedBitPattern as having this field type
>
> What implications would this have when committing changes at a later
> time?  It seems like you are, in essence, making the cachedBitPattern
> instVar an immediate value (sort of).

It wouldn't have any implications.  Not all objects get proxied anyway 
- when you request an object, the GOODS server usually sends back a 
cluster of related objects that it thinks might be useful to you, and 
so the ones you didn't directly request never go through the proxy 
stage.  And the client lib is designed so that proxies are only 
involved at the very highest level (nothing below KKDatabase in the 
stack ever sees them).  So forcing a few more objects to be directly 
loaded rather than proxied isn't a big deal it all.

> So would class-side of Color somehow participate in this algorithm to
> declare that cachedBitPattern was one of these
> KKAutoloadReferenceFields (or no proxy permitted on this instVar)?

Yes, it would implement

Color class>>cachedBitPatternDescriptor
	^ KKSingleFieldContainer autoloadReferenceField

> Tell me more.  How can I do this just to play with the idea?  Do I
> need to be aware of the other immediate values and pick a number that
> represents my color class?  I assume I have to implement writing the
> tagged field in this case.

Yes.  Currently tags 1 through 5 are used, so we could designate 6 as 
being for Color.  You would have to add two methods to Color for 
encoding to work, and modify the decoding method to match:

Color>>goodsIsImmediateValue
	^ true

Color>>goodsWriteTaggedOn: aStream
	aStream nextPut: 6; nextInt32Put: rgb

KKReferenceField>>fieldFromTag: sid value: oid
	^ sid = 0
		ifTrue: [nil]
		ifFalse: [(sid bitAnd: 16r00FF) caseOf:
					{[1] -> [self decodeUnsignedInteger: oid].
					 [2] -> [oid = 1].
					 [3] -> [Float fromIEEE32Bit: oid].
					 [4] -> [self referenceAt: oid * -1].
					 [5] -> [Character value: oid]
					 [6] -> [Color basicNew setRGB: oid}]




More information about the Squeak-dev mailing list