Details

    • Sub-task
    • Resolution: Invalid
    • P3: Somewhat important
    • 4.8.0
    • Qt Script
    • None

    Description

      http://doc.trolltech.com/4.7/qscriptcontext.html#argumentsObject

      argumentsObject() corresponds to the built-in arguments property in JS function calls:

      (function() { return arguments[0]; })(123); // 123
      

      Modern implementations like JSC and V8 don't create an arguments object unless it's really needed. Therefore, it's possible that there is no arguments object for QScriptContext::argumentsObject() to return. We can fake it by returning e.g. a plain array that's populated with the arguments, but would have to jump through some hoops in order to satisfy the "mirroring" behavior of the arguments properties.

      The main use case for calling argumentsObject(), rather than argument() and argumentCount(), is for function call proxying:

      QScriptValue fun(QScriptContext *ctx, QScriptEngine *eng)
      {
          return someOtherFunction.call(ctx->thisObject(), ctx->argumentsObject());
      }
      

      This is very convenient. The alternative would be to manually construct a QScriptValueList using argument()/argumentCount() and use the overload of QScriptValue::call() that takes a list.

      An alternative, more high-level API would be an arguments() function that returns a QScriptValueList. This preserves the convenience, but introduces the overhead of constructing the list. (Internally, we have to construct such a list anyway, even with argumentsObject(), though, for passing on to JSC or V8.)

      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:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes