XMLWordPrintable

Details

    • Sub-task
    • Resolution: Invalid
    • P2: Important
    • 4.8.0
    • Qt Script
    • None

    Description

      The typical use case for QScriptContext::activationObject()/setActivationObject() is to implement an eval-like native function, like the myInclude() function described in the docs: http://doc.trolltech.com/4.7/qscriptcontext.html#details

      The general problem with exposing the activation object can be summed up by the following paragraph from the ECMA-262 spec, 3rd edition: "The activation object is purely a specification mechanism. It is impossible for an ECMAScript program to access the activation object. It can access members of the activation object, but not the activation object itself."

      Both JavaScriptCore and V8 optimize away the activation object if they can. Thus, we shouldn't expose it.
      However, the "Make-native-function-behave-eval-ish" functionality is quite useful, so a replacement API is needed.

      The other known use case for activationObject() is to access variable and function declarations made in a custom scope. The QtDeclarative implementation relies on this.

      QScriptContext *ctx = engine.pushContext();
      engine.evaluate("var foo = 10; function bar() { }");
      // ctx->activationObject() has properties "foo" and "bar"
      

      By calling setActivationObject() you could also install your own custom activation object which would intercept the declarations as they are executed.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            kenthans Kent Hansen (Inactive)
            kenthans Kent Hansen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes