Ignore:
Timestamp:
Jul 27, 2010, 8:37:25 AM (15 years ago)
Author:
[email protected]
Message:

2010-07-27 Caio Marcelo de Oliveira Filho <[email protected]>

Reviewed by Kenneth Rohde Christiansen.

[Qt] Implement QScriptEngine::newFunction() parts that doesn't depend on QScriptContext
https://bugs.webkit.org/show_bug.cgi?id=42174

Since our function can be called in Javascript both as a function
and as a constructor, we couldn't use the existing
JSObjectMakeFunctionWithCallback() and JSObjectMakeConstructor().

Instead, a JSClassRef was created, implementing the needed
callbacks (the callAsConstructor is not there yet because its
behaviour depends on QScriptContext).

For the moment, QScriptContext is defined as a void type, since we
still don't use it.

The variant of newFunction() that also takes an external argument
was also implemented. The details of implementation were added to
the qscriptfunction{.c,_p.h} files.

This commit also adds tests, some of them from Qt's upstream.

  • api/QtScript.pro:
  • api/qscriptengine.cpp: (QScriptEngine::newFunction):
  • api/qscriptengine.h:
  • api/qscriptengine_p.cpp: (QScriptEnginePrivate::QScriptEnginePrivate): (QScriptEnginePrivate::~QScriptEnginePrivate): (QScriptEnginePrivate::newFunction):
  • api/qscriptengine_p.h:
  • api/qscriptfunction.cpp: Added. (qt_NativeFunction_finalize): (qt_NativeFunction_callAsFunction): (qt_NativeFunctionWithArg_finalize): (qt_NativeFunctionWithArg_callAsFunction):
  • api/qscriptfunction_p.h: Added. (QNativeFunctionData::QNativeFunctionData): (QNativeFunctionWithArgData::QNativeFunctionWithArgData):
  • api/qscriptoriginalglobalobject_p.h: (QScriptOriginalGlobalObject::QScriptOriginalGlobalObject): (QScriptOriginalGlobalObject::~QScriptOriginalGlobalObject): (QScriptOriginalGlobalObject::functionPrototype):
  • tests/qscriptengine/tst_qscriptengine.cpp: (myFunction): (myFunctionWithArg): (myFunctionThatReturns): (myFunctionThatReturnsWithoutEngine): (myFunctionThatReturnsWrongEngine): (tst_QScriptEngine::newFunction):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/qt/api/QtScript.pro

    r63318 r64130  
    2929            $$PWD/qscriptprogram.cpp \
    3030            $$PWD/qscriptsyntaxcheckresult.cpp \
     31            $$PWD/qscriptfunction.cpp
    3132
    3233HEADERS +=  $$PWD/qtscriptglobal.h \
     
    4445            $$PWD/qscriptsyntaxcheckresult.h \
    4546            $$PWD/qscriptoriginalglobalobject_p.h \
    46 
     47            $$PWD/qscriptfunction_p.h
    4748
    4849!static: DEFINES += QT_MAKEDLL
Note: See TracChangeset for help on using the changeset viewer.