ImageStripper

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

ImageStripper

gabe.krupa
I was trying to refactor the ImageStipper so I could subclass and
override some behavior--like getting rid of the annoying "Development
system will now exit" dialog.

But I get an error that my ImageStripper subclass doesn't understand
the newly refactored/extracted method.

I've attached an example package that illustrates this.  The
#saveExecutable: method has been refactored to push the dialog to a
method #exeDeployedMessage:, which I've turned into an empty method.

The #exeDeployedMessage: is in the 'must not strip' category, so it
shouldn't be removed.  What gives?

I can just change the source for #saveExecutable: in ImageStripper, but
I'm trying to figure out what's going on.  Does anyone know why I'm
getting #doesNotUnderstand: when deploying?

Cheers,

GK

========== ImageStripper.pac ===========

| package |
package := Package name: 'ImgStrip'.
package paxVersion: 0;
        basicComment: ''.

package imageStripperBytes: (ByteArray fromHexString:
'21535442203120460F11000400000054657374496D616765537472697070657200000000000000005200000008000000496D675374726970520000000F000000496D6753747269707065722E6578659A000000000000005200000008000000496D67537472697052000000120000005465737453657373696F6E4D616E61676572EFBF250000000000000000000000000000000000000000000000000000000000000000000000000000000000').

package classNames
        add: #TestImageStripper;
        add: #TestSessionManager;
        yourself.

package binaryGlobalNames: (Set new
        yourself).

package globalAliases: (Set new
        yourself).

package allResourceNames: (Set new
        yourself).

package setPrerequisites: (IdentitySet new
        add: 'Object Arts\Dolphin\Base\Dolphin';
        add: 'Object Arts\Dolphin\MVP\Base\Dolphin MVP Base';
        add: 'Object Arts\Dolphin\Lagoon\Lagoon Image Stripper';
        yourself).

package!

"Class Definitions"!

ImageStripper subclass: #TestImageStripper
        instanceVariableNames: ''
        classVariableNames: ''
        poolDictionaries: ''
        classInstanceVariableNames: ''!
RuntimeSessionManager subclass: #TestSessionManager
        instanceVariableNames: ''
        classVariableNames: ''
        poolDictionaries: ''
        classInstanceVariableNames: ''!

"Global Aliases"!


"Loose Methods"!

"End of package definition"!

"Source Globals"!

"Classes"!

TestImageStripper guid: (GUID fromString:
'{B491069C-01BA-41D5-AE31-3E4CA1963C51}')!
TestImageStripper comment: ''!
!TestImageStripper categoriesForClass!MVP-Models! !
!TestImageStripper methodsFor!

exeDeployedMessage: exePath
        "This is where the annoying 'about to exit' dialog goes."!

saveExecutable: exePath
        "Private - Save a snapshot of the currrent image to an executable.
This is appended to the
        executable stub at the <readableString> path, exePath.
        Following the completion of this process the development system MUST
exit"

        | image exeFile retainImage |
        self finalActions.
        image := File change: exePath extension: 'tmp'.
        retainImage := self keepImageFile.
        self snapshot: image.

        "We can't send any more messages to the receiver after this point as
its method dictionary
         has been removed."

        "Now tack the image onto the end of the stub."
        exeFile := File open: exePath mode: #append.

        [| imageFile |
        imageFile := File open: image mode: #read.

        [| imageData |
        imageData := ByteArray new: imageFile size.
        imageFile read: imageData.
        exeFile write: imageData]
                        ensure:
                                [imageFile close.
                                retainImage ifFalse: [File delete: image]]]
                        ensure: [exeFile close].
        self exeDeployedMessage: exePath.

        "Tidy up the 'Please wait' message we wrote directly to the deskop"
        VMLibrary default removeDesktopMessage: termWnd.

        "No arguments - just exit"
        SessionManager current primQuit: 0! !
!TestImageStripper categoriesFor: #exeDeployedMessage:!must not
strip!operations!private! !
!TestImageStripper categoriesFor: #saveExecutable:!operations!private!
!

TestSessionManager guid: (GUID fromString:
'{F9D56D82-95C6-4098-B014-AC07FD51E5FB}')!
TestSessionManager comment: ''!
!TestSessionManager categoriesForClass!System-Support! !
"Binary Globals"!

"Resources"!


Reply | Threaded
Open this post in threaded view
|

Re: ImageStripper

Ian Bartholomew-19
GK,

> I can just change the source for #saveExecutable: in ImageStripper, but
> I'm trying to figure out what's going on.  Does anyone know why I'm
> getting #doesNotUnderstand: when deploying?

If you look in the middle of the #saveExecutable method you will find the
comment ...

 "We can't send any more messages to the receiver after
this point as its method dictionary has been removed."

Your #exeDeployedMessage message send comes after that point so it is doing
exactly what the comment is warning about - sending a message to the
receiver.

I would imagine the "must not strip" category does not come into it at the
removal of the ImageStripper, and subclasses, is treated as a special case -
it's hardcoded into the image stripping process.
ImageStripper>>removeMyClass looks like a good starting point if you want
to track it down a bit more.

--
Ian

Use the Reply-To address to contact me.
Mail sent to the From address is ignored.


Reply | Threaded
Open this post in threaded view
|

Re: ImageStripper

Bill Schwab
In reply to this post by gabe.krupa
> I was trying to refactor the ImageStipper so I could subclass and
> override some behavior--like getting rid of the annoying "Development
> system will now exit" dialog.

FWIW, I just comment out the code.  It would be nice to have a more
public way to disable the feature for benefit of batch deployments.

Have a good one,

Bill


--
Wilhelm K. Schwab, Ph.D.
[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: ImageStripper

gabe.krupa
In reply to this post by Ian Bartholomew-19
Ian,

Many thanks.

Ahem... I'll just crawl back to the corner from which I came, now.

--Gabe


Reply | Threaded
Open this post in threaded view
|

Re: ImageStripper

Ian Bartholomew-19
Gabe,

> Ahem... I'll just crawl back to the corner from which I came, now.


No, don't do that :-).  It was a fair question about a part of the image
that is quite complex and not often looked at.  Playing around with the code
in these areas can be quite rewarding, but it can also be very easy to miss
some subtle bits of coding - I've done it myself often enough.

Nobody here minds answering questions, we're a friendly bunch!

--
Ian

Use the Reply-To address to contact me.
Mail sent to the From address is ignored.