[Cuis-dev] [Recovered] AGAIN! This is the third /efourth time
rabbit
rabbit at callistohouse.org
Sun Jul 9 08:55:13 PDT 2023
Hey, I am a touch frustrated. Recovered with <49>. The code I wrote to generate classes and methods has been corrupting my image, or rather mucking to the changes. I was having old code versions being loaded and breaking bad. I was publishing a lot of garbage because when running the BoxOfKittens, I was generating several SharedNears, now called Neighbors. This subclass generation and the method compilation is being done it the following methods...I am just going to leave it turned off for now and stay focused on my objective. It is an example of corruption occurring, if that helps anyone. If one could tell me how to better generate these artifacts, that would be outstanding!•
•••
The #buildOnClass is called from a class creation method
> buildOnClass: eClazz
>
> |refClass |
> refClass := self stubClass
> subclass: (eClazz name, 'Stub') asSymbol
> instanceVariableNames: ''
> classVariableNames: ''
> poolDictionaries: ''
> category: self userClassCategoryString.
>
> "Copy all methods, up to Object, to the new refClass, with redirectMessage forwarding."
> self copyMethodsToClass: refClass fromClass: eClazz upToClass: Object.
>
> ^ refClass
> •••
> copyMethodsToClass: refClass fromClass: valueClazz upToClass: rootClass
> | arguments classes newMethodString |
> "Collect classes to contribute message protocol."
> classes := valueClazz allSuperclasses select: [ :clazz | (Object ~~ rootClass) and: [ Object inheritsFrom: clazz] ].
>
> "contribute message protocols."
> classes do: [:thisClazz |
> thisClazz methodDictionary keysAndValuesDo: [:selector :method |
> arguments := method tempNames first: method numArgs.
> newMethodString := self buildForwardingMethod: selector contents arguments: arguments.
> Compiler
> compile: newMethodString
> environment: refClass environment
> notifying: nil
> trailer: method trailer
> ifFail: [nil]]].
>
> •••
>
> buildForwardingMethod: selector arguments: arguments
>
> | argumentString selectorStream |
> argumentString := ((arguments inject: ''writeStream into: [:stream :argument | stream nextPutAll: argument, ' ']) contents).
> selectorStream := '' writeStream.
> (selector subStrings: $:) with: arguments do: [:keyword :argument | selectorStream nextPutAll: keyword, ': ', argument, ' '].
> ^ selectorStream contents, '
>
> ^self redirectMessage: (Message selector: ', selector asSymbol printString, ' arguments: #{', argumentString, '}).'
Alright then,
--
••• rabbit ❤️🔥🐰
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20230709/36d87f59/attachment.htm>
More information about the Cuis-dev
mailing list