<html><head></head><body> Hey. I started this thread due to my corrupting my image and changes when generating classes and compiling methods incorrectly.<div dir="auto"><br></div><div dir="auto">Would someone be able to guide me through correct class and method generation, please? </div><div dir="auto"><br></div><div dir="auto"><br></div><div dir="auto">Gratefully,</div><div dir="auto">rabbit ❤️🔥🐰</div><div dir="auto"><caret></caret><br><blockquote class="protonmail_quote" type="cite" dir="auto"><div dir="auto"><blockquote type="cite" class="protonmail_quote" dir="auto"><blockquote class="protonmail_quote" type="cite" dir="auto"><div dir="auto"><div dir="auto">On Sun, Jul 9, 2023 at 11:55, rabbit via Cuis-dev <<a class="" href="mailto:On Sun, Jul 9, 2023 at 11:55, rabbit via Cuis-dev <<a href=">cuis-dev@lists.cuis.st</a>> wrote:<blockquote type="cite" class="protonmail_quote" dir="auto">
<p>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!•
</p>
<pre cols="72" class="moz-signature">•••
</pre>
<p></p>
<p>The #buildOnClass is called from a class creation method<br>
</p>
<blockquote>
<p>buildOnClass: eClazz<br>
<br>
|refClass |<br>
refClass := self stubClass<br>
subclass: (eClazz name, 'Stub') asSymbol<br>
instanceVariableNames: ''<br>
classVariableNames: ''<br>
poolDictionaries: ''<br>
category: self userClassCategoryString.<br>
<br>
"Copy all methods, up to Object, to the new refClass, with
redirectMessage forwarding."<br>
self copyMethodsToClass: refClass fromClass: eClazz
upToClass: Object.<br>
<br>
^ refClass <br>
</p>
</blockquote>
<blockquote>
<pre cols="72" class="moz-signature">•••</pre>
</blockquote>
<blockquote>copyMethodsToClass: refClass fromClass: valueClazz
upToClass: rootClass<br>
</blockquote>
<blockquote>
<p><br>
| arguments classes newMethodString |<br>
"Collect classes to contribute message protocol."<br>
classes := valueClazz allSuperclasses select: [ :clazz |
(Object ~~ rootClass) and: [ Object inheritsFrom: clazz] ].<br>
<br>
"contribute message protocols."<br>
classes do: [:thisClazz | <br>
thisClazz methodDictionary keysAndValuesDo: [:selector
:method | <br>
arguments := method tempNames first: method numArgs.<br>
newMethodString := self buildForwardingMethod:
selector contents arguments: arguments.<br>
Compiler <br>
compile: newMethodString<br>
environment: refClass environment <br>
notifying: nil <br>
trailer: method trailer <br>
ifFail: [nil]]].<br>
</p>
<pre cols="72" class="moz-signature">•••</pre>
buildForwardingMethod: selector arguments: arguments<br>
<br>
| argumentString selectorStream |<br>
argumentString := ((arguments inject: ''writeStream into:
[:stream :argument | stream nextPutAll: argument, ' ']) contents).<br>
selectorStream := '' writeStream.<br>
(selector subStrings: $:) with: arguments do: [:keyword
:argument | selectorStream nextPutAll: keyword, ': ', argument, '
'].<br>
^ selectorStream contents, '<br>
<br>
^self redirectMessage: (Message selector: ', selector
asSymbol printString, ' arguments: #{', argumentString, '}).'<br>
</blockquote>
Alright then,<br>
<pre cols="72" class="moz-signature" dir="auto">--
••• rabbit ❤️🔥🐰</pre></blockquote></div></div></blockquote></blockquote></div></blockquote></div></body></html>