Le 24/3/16 17:48, Denis Kudriashov a écrit :
Hello.

I finished new version of Ghost:

  * DNU approach for basic proxies instead of #cannotInterpret: trick
    (trick used only for class proxies)

Does it mean that we cannot proxy classes?

  * Abstract proxy classes uses Ghost name instead of Proxy: there are
    GHObjectGhost and GHClassGhost.
  * GHProxyHandler renamed to GHGhostBehaviour. Concrete ghosts should
    implement #ghostBehaviour instead of #proxyHandler.
  * GHGhostBehaviour should define #currentMetaLevel to specify set of
    messages which should not be intercepted. Such meta messages will
    be executed under ghost instance by subclass of GHMetaMessages.

    In previous version there was dictionary which maps meta message
    selector to implementation selector. It was not suitable. Now meta
    messages should be directly implemented on particular
    GHMetaMessages subclass and all it methods are considered meta.

    So GhostBehaviour should return instance of GHMetaLevel with meta
    messages implementation class:

      o GHMetaLevel with: GHEmptyMetaMessages "when all possible
        messages should intercepted"
      o GHMetaLevel with: GHStandartMetaMessages "when tools specific
        messages should not be intercepted"

    For example standard meta messages implements #inspect:

        GHStandartMetaMessages>>inspect

        "Create and schedule an Inspector in which the user can
        examine the receiver's variables."

        ^ Smalltalk tools inspector inspect: *ghost*


  * Traits for methods explicitly defined on ghosts: TMinimalProxy,
    TNotNilProxy, TIdentifiedProxy (with #=, #hash, #class). Concrete
    proxies can add this traits to itself independently from meta
    level. For example traits supply convenient methods to retrieve
    ghost information in polymorphic way with objects:
      o ghost isGhost
      o ghost ghostClass "returns actual class of receiver"
      o ghost ghostPrintString "returns string which represents ghost
        from meta level point of view"

    This traits are suitable and they provide some kind of
    optimisation for proxies (methods from traits are executed
    directly instead of complex meta messages mechanizm). But maybe
    they are superfluous. For example they can't be reused for class
    proxies which substitute real object classes (to intercept all
    instance messages).

  * GHClassGhost able to replace class of real objects. It implements
    cannotInterpret: trick to intercept all instance messages.
    Subclasses should define two behaviours: #ghostBehaviour (as any
    other ghost) and #instancesBehaviour which will process instance
    messages. In previous version it was different message to same
    #ghostBehaviour.
  * New kind of proxies:
      o GHObjectVirus. It is special kind of GHClassProxy. It infects
        real object to intercept it messages. From meta level infected
        object looks like healthy object which means that meta
        messages are executed by infected object itself. As class
        virus looks like real victim class. So in case when virus is
        created with standard meta level tools will not differ him
        from health object. There are special messages which allow ask
        object about viruses:
          + infectedObject isInfectedByVirus
          + infectedObject virus
          + infectedObject recoverFromVirus

      o GHLearningObject. It is suitable proxy which retrieves all
        unknown methods from teacher class. Thank's Stephan for this idea.

        This kind of proxy allows me easily find required set of
        messages to support inspectors and debuggers. You can create
        instance of learning object by:

            GHLearningObject withTeacher: Object.

        And any operation with it will fill studiedMessages
        dictionary. In my case I opened GTInspector on it and got all
        messages which was needed for him.

  * Ghosts works correctly with latest Pharo 5 tools (basic inspector,
    GTInspector, SpecDebugger, GTDebugger). Required methods for tools
    are extracted to 'Ghost-GTSupport' package.
  * Repackaging:
      o Ghost-ObjectProxies. It contains all core classes and abstract
        GHObjectGhost which is based on DNU
      o Ghost-ClassProxies. It contains code for proxy which can
        substitute class of real object. GHClassGhost implements
        cannotInterpret: trick to intercept all instance messages. And
        it implement support for debugging such methods.
      o Ghost-LearningObject
      o Ghost-ObjectVirus
      o Ghost-GTSupport
      o test packages
  * All code moved to Pharo repository
    http://smalltalkhub.com/#!/~Pharo/Ghost
    <http://smalltalkhub.com/#%21/%7EPharo/Ghost> (in includes
    packages from CAR repo too)


You can load new version by:

    Gofer it
    smalltalkhubUser: 'Pharo' project: 'Ghost';
    configurationOf: 'Ghost';
    loadStable


I use it now in Seamless and Mocketry.



Reply via email to