<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Bert,<div class=""><br class=""></div><div class="">No, we use ImageSegment directly (we’ve subclassed ImageSegment). Here’s the short version:</div><div class=""><br class=""></div><div class="">1. we copy the roots:</div><div class=""><br class=""></div><div class=""><div class="">self</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>copyFromRoots: (Array with: anObject)</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>sizeHint: self fileSize // 2</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>areUnique: true.</div></div><div class=""><br class=""></div><div class="">2. we write the segment onto a MutliByteFileStream (which we’ve subclassed):</div><div class=""><br class=""></div><div class=""><div class="">NSSegmentStream</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>forceNewFileNamed: fileName</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>do: [ :stream | stream writeObject: self ].</div></div><div class=""><br class=""></div><div class="">where #writeObject: is implemented as:</div><div class=""><br class=""></div><div class=""><div class="">writeObject: anObject</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>(SmartRefStream on: self) nextPutObjOnly: anObject</div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">We load the segment back by:</div><div class=""><br class=""></div><div class="">1. opening a MultiByteFileStream and sending the installation message:</div><div class=""><br class=""></div><div class=""><div class="">NSSegmentStream</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>readOnlyFileNamed: (aDirectory fullNameFor: filename)</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>do: [ :stream |</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                </span>self</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                        </span>installSegmentFrom: stream</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                        </span>andDo: aBlock ]</div></div><div class=""><br class=""></div><div class="">2. #installSegmentFrom:andDo: basically sends #readObject to the file stream:</div><div class=""><br class=""></div><div class=""><div class="">readObject</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>"This is a hack to allow for the old segments (mixed code and objects)</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>to be loaded without the #inform: in #nextAndClose opening a UI element."</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>^ self binary peek = ReferenceStream versionCode</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                </span>ifTrue: [ (SmartRefStream on: self) nextAndClose ]</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                </span>ifFalse: [</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                        </span>| object |</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                        </span>self</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                                </span>ascii;</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                                </span>fileIn.</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                        </span>object := SmartRefStream scannedObject.</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                        </span>SmartRefStream scannedObject: nil.</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                        </span>object ]</div></div><div class=""><br class=""></div><div class="">3. and once we have the segment we send #install to it</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">We’ve made some modifications here and there (e.g. to suppress UI elements) but the above is the gist of it. I can give you the full source if you need it.</div><div class="">It’s possible that this is all overkill or parallels functionality found in other places. I’ve inherited the code and haven’t spent the time exploring improvements in that area.</div><div class=""><br class=""></div><div class="">Cheers,</div><div class="">Max</div><div class=""><br class=""></div><div class=""><div><blockquote type="cite" class=""><div class="">On 26 Sep 2016, at 19:39, <a href="mailto:squeak-dev-request@lists.squeakfoundation.org" class="">squeak-dev-request@lists.squeakfoundation.org</a> wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Hi Max,</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">I'd be interested to learn how you are using ImageSegments. Is it</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">using CodeLoader?</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">- Bert -</span></div></blockquote></div><br class=""></div></body></html>