src/script/api/qscriptcontext.cpp
changeset 37 758a864f9613
parent 33 3e2da88830cd
equal deleted inserted replaced
36:ef0373b55136 37:758a864f9613
   321   Returns true if the function was called as a constructor
   321   Returns true if the function was called as a constructor
   322   (e.g. \c{"new foo()"}); otherwise returns false.
   322   (e.g. \c{"new foo()"}); otherwise returns false.
   323 
   323 
   324   When a function is called as constructor, the thisObject()
   324   When a function is called as constructor, the thisObject()
   325   contains the newly constructed object to be initialized.
   325   contains the newly constructed object to be initialized.
       
   326 
       
   327   \note This function is only guaranteed to work for a context
       
   328   corresponding to native functions.
   326 */
   329 */
   327 bool QScriptContext::isCalledAsConstructor() const
   330 bool QScriptContext::isCalledAsConstructor() const
   328 {
   331 {
   329     JSC::CallFrame *frame = const_cast<JSC::ExecState*>(QScriptEnginePrivate::frameForContext(this));
   332     JSC::CallFrame *frame = const_cast<JSC::ExecState*>(QScriptEnginePrivate::frameForContext(this));
   330     QScript::APIShim shim(QScript::scriptEngineFromExec(frame));
   333     QScript::APIShim shim(QScript::scriptEngineFromExec(frame));
   410 
   413 
   411 /*!
   414 /*!
   412   Returns the activation object of this QScriptContext. The activation
   415   Returns the activation object of this QScriptContext. The activation
   413   object provides access to the local variables associated with this
   416   object provides access to the local variables associated with this
   414   context.
   417   context.
       
   418 
       
   419   \note The activation object might not be available if there is no
       
   420   active QScriptEngineAgent, as it might be optimized.
   415 
   421 
   416   \sa argument(), argumentsObject()
   422   \sa argument(), argumentsObject()
   417 */
   423 */
   418 
   424 
   419 QScriptValue QScriptContext::activationObject() const
   425 QScriptValue QScriptContext::activationObject() const
   470 /*!
   476 /*!
   471   Sets the activation object of this QScriptContext to be the given \a
   477   Sets the activation object of this QScriptContext to be the given \a
   472   activation.
   478   activation.
   473 
   479 
   474   If \a activation is not an object, this function does nothing.
   480   If \a activation is not an object, this function does nothing.
       
   481 
       
   482   \note For a context corresponding to a JavaScript function, this is only
       
   483   guarenteed to work if there was an QScriptEngineAgent active on the
       
   484   engine while the function was evaluated.
   475 */
   485 */
   476 void QScriptContext::setActivationObject(const QScriptValue &activation)
   486 void QScriptContext::setActivationObject(const QScriptValue &activation)
   477 {
   487 {
   478     if (!activation.isObject())
   488     if (!activation.isObject())
   479         return;
   489         return;