summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCasper van Donderen <casper.vandonderen@nokia.com>2012-06-05 12:51:07 +0200
committerQt by Nokia <qt-info@nokia.com>2012-06-05 15:18:03 +0200
commit4629dc71525a638c0bae89ad67990a1ff14ea9c4 (patch)
treeff81b70586896e7b2f1c718e3b5385fae4483cc3
parentf6fdd296d47e1ce44c07aab81098c20a5260f7fd (diff)
downloadqtscript-4629dc71525a638c0bae89ad67990a1ff14ea9c4.tar.gz
Doc: Modularize QtScript documentation.
Change-Id: I042d9bafe4f48a8cd23306f0864b6872776d0153 Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
-rw-r--r--src/script/api/qscriptable.cpp4
-rw-r--r--src/script/api/qscriptclass.cpp2
-rw-r--r--src/script/api/qscriptcontext.cpp6
-rw-r--r--src/script/api/qscriptengine.cpp56
-rw-r--r--src/script/api/qscriptengineagent.cpp4
-rw-r--r--src/script/api/qscriptvalue.cpp8
-rw-r--r--src/script/api/qscriptvalueiterator.cpp6
-rw-r--r--src/script/doc/images/qtscript-debugger.png (renamed from doc/src/images/qtscript-debugger.png)bin127509 -> 127509 bytes
-rw-r--r--src/script/doc/qtscript.qdocconf93
-rw-r--r--src/script/doc/snippets/code/doc_src_qtscript.cpp (renamed from doc/src/snippets/code/doc_src_qtscript.cpp)0
-rw-r--r--src/script/doc/snippets/code/doc_src_qtscript.js (renamed from doc/src/snippets/code/doc_src_qtscript.js)0
-rw-r--r--src/script/doc/snippets/code/doc_src_qtscript.pro43
-rw-r--r--src/script/doc/snippets/code/doc_src_qtscript.qdoc (renamed from doc/src/snippets/code/doc_src_qtscript.qdoc)0
-rw-r--r--src/script/doc/snippets/code/doc_src_qtscriptextensions.js (renamed from doc/src/snippets/code/doc_src_qtscriptextensions.js)0
-rw-r--r--src/script/doc/snippets/code/src_script_qscriptable.cpp (renamed from doc/src/snippets/code/src_script_qscriptable.cpp)0
-rw-r--r--src/script/doc/snippets/code/src_script_qscriptclass.cpp (renamed from doc/src/snippets/code/src_script_qscriptclass.cpp)0
-rw-r--r--src/script/doc/snippets/code/src_script_qscriptcontext.cpp (renamed from doc/src/snippets/code/src_script_qscriptcontext.cpp)0
-rw-r--r--src/script/doc/snippets/code/src_script_qscriptengine.cpp (renamed from doc/src/snippets/code/src_script_qscriptengine.cpp)0
-rw-r--r--src/script/doc/snippets/code/src_script_qscriptengineagent.cpp (renamed from doc/src/snippets/code/src_script_qscriptengineagent.cpp)0
-rw-r--r--src/script/doc/snippets/code/src_script_qscriptvalue.cpp (renamed from doc/src/snippets/code/src_script_qscriptvalue.cpp)0
-rw-r--r--src/script/doc/snippets/code/src_script_qscriptvalueiterator.cpp (renamed from doc/src/snippets/code/src_script_qscriptvalueiterator.cpp)0
-rw-r--r--src/script/doc/snippets/qtscript/evaluation/main.cpp (renamed from doc/src/snippets/qtscript/evaluation/main.cpp)0
-rw-r--r--src/script/doc/snippets/qtscript/registeringobjects/main.cpp (renamed from doc/src/snippets/qtscript/registeringobjects/main.cpp)0
-rw-r--r--src/script/doc/snippets/qtscript/registeringvalues/main.cpp (renamed from doc/src/snippets/qtscript/registeringvalues/main.cpp)0
-rw-r--r--src/script/doc/src/ecmascript.qdoc (renamed from doc/src/scripting/ecmascript.qdoc)0
-rw-r--r--src/script/doc/src/external-resources.qdoc42
-rw-r--r--src/script/doc/src/qtscript.qdoc84
-rw-r--r--src/script/doc/src/qtscriptdebugger-manual.qdoc (renamed from doc/src/scripting/qtscriptdebugger-manual.qdoc)4
-rw-r--r--src/script/doc/src/qtscriptextensions.qdoc (renamed from doc/src/scripting/qtscriptextensions.qdoc)2
-rw-r--r--src/script/doc/src/scripting.qdoc (renamed from doc/src/scripting/scripting.qdoc)186
-rw-r--r--src/script/script.pro2
-rw-r--r--src/scripttools/debugging/qscriptenginedebugger.cpp10
32 files changed, 408 insertions, 144 deletions
diff --git a/src/script/api/qscriptable.cpp b/src/script/api/qscriptable.cpp
index af25685..6348fb7 100644
--- a/src/script/api/qscriptable.cpp
+++ b/src/script/api/qscriptable.cpp
@@ -65,7 +65,7 @@ QT_BEGIN_NAMESPACE
The following is what subclassing QScriptable typically looks
like:
- \snippet doc/src/snippets/code/src_script_qscriptable.cpp 0
+ \snippet code/src_script_qscriptable.cpp 0
The only difference from regular QObject subclassing is that you
also inherit from QScriptable.
@@ -73,7 +73,7 @@ QT_BEGIN_NAMESPACE
In the implementation of your slots, you can then use the functions
inherited from QScriptable:
- \snippet doc/src/snippets/code/src_script_qscriptable.cpp 1
+ \snippet code/src_script_qscriptable.cpp 1
\sa {Default Prototypes Example}, QScriptEngine::newFunction()
*/
diff --git a/src/script/api/qscriptclass.cpp b/src/script/api/qscriptclass.cpp
index 68de186..6a1cc2a 100644
--- a/src/script/api/qscriptclass.cpp
+++ b/src/script/api/qscriptclass.cpp
@@ -357,7 +357,7 @@ bool QScriptClass::supportsExtension(Extension extension) const
result of the function call. In the following example the sum of the
arguments to the script function are added up and returned:
- \snippet doc/src/snippets/code/src_script_qscriptclass.cpp 0
+ \snippet code/src_script_qscriptclass.cpp 0
If you implement the HasInstance extension, Qt Script will call this
function as part of evaluating the \c{instanceof} operator, as
diff --git a/src/script/api/qscriptcontext.cpp b/src/script/api/qscriptcontext.cpp
index bd9b696..8996654 100644
--- a/src/script/api/qscriptcontext.cpp
+++ b/src/script/api/qscriptcontext.cpp
@@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE
QScriptEngine::newFunction()) that will be called from script
code. For example, when the script code
- \snippet doc/src/snippets/code/src_script_qscriptcontext.cpp 0
+ \snippet code/src_script_qscriptcontext.cpp 0
is evaluated, a QScriptContext will be created, and the context will
carry the arguments as QScriptValues; in this particular case, the
@@ -76,7 +76,7 @@ QT_BEGIN_NAMESPACE
native "instance method", you typically fetch the thisObject() and access
one or more of its properties:
- \snippet doc/src/snippets/code/src_script_qscriptcontext.cpp 1
+ \snippet code/src_script_qscriptcontext.cpp 1
Use isCalledAsConstructor() to determine if the function was called
as a constructor (e.g. \c{"new foo()"} (as constructor) or just
@@ -100,7 +100,7 @@ QT_BEGIN_NAMESPACE
evaluated in the context of the parent context, e.g. to implement an
include() function:
- \snippet doc/src/snippets/code/src_script_qscriptcontext.cpp 2
+ \snippet code/src_script_qscriptcontext.cpp 2
Use backtrace() to get a human-readable backtrace associated with
this context. This can be useful for debugging purposes when
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp
index 8002454..8b3b844 100644
--- a/src/script/api/qscriptengine.cpp
+++ b/src/script/api/qscriptengine.cpp
@@ -106,7 +106,7 @@ QT_BEGIN_NAMESPACE
Use evaluate() to evaluate script code; this is the C++ equivalent
of the built-in script function \c{eval()}.
- \snippet doc/src/snippets/code/src_script_qscriptengine.cpp 0
+ \snippet code/src_script_qscriptengine.cpp 0
evaluate() returns a QScriptValue that holds the result of the
evaluation. The QScriptValue class provides functions for converting
@@ -116,13 +116,13 @@ QT_BEGIN_NAMESPACE
The following code snippet shows how a script function can be
defined and then invoked from C++ using QScriptValue::call():
- \snippet doc/src/snippets/code/src_script_qscriptengine.cpp 1
+ \snippet code/src_script_qscriptengine.cpp 1
As can be seen from the above snippets, a script is provided to the
engine in the form of a string. One common way of loading scripts is
by reading the contents of a file and passing it to evaluate():
- \snippet doc/src/snippets/code/src_script_qscriptengine.cpp 2
+ \snippet code/src_script_qscriptengine.cpp 2
Here we pass the name of the file as the second argument to
evaluate(). This does not affect evaluation in any way; the second
@@ -139,7 +139,7 @@ QT_BEGIN_NAMESPACE
want to configure a script engine by adding one or more properties
to the Global Object:
- \snippet doc/src/snippets/code/src_script_qscriptengine.cpp 3
+ \snippet code/src_script_qscriptengine.cpp 3
Adding custom properties to the scripting environment is one of the
standard means of providing a scripting API that is specific to your
@@ -159,7 +159,7 @@ QT_BEGIN_NAMESPACE
Calling clearExceptions() will cause any uncaught exceptions to be
cleared.
- \snippet doc/src/snippets/code/src_script_qscriptengine.cpp 4
+ \snippet code/src_script_qscriptengine.cpp 4
The checkSyntax() function can be used to determine whether code can be
usefully passed to evaluate().
@@ -182,7 +182,7 @@ QT_BEGIN_NAMESPACE
properties of the proxy object. No binding code is needed because it
is done dynamically using the Qt meta object system.
- \snippet doc/src/snippets/code/src_script_qscriptengine.cpp 5
+ \snippet code/src_script_qscriptengine.cpp 5
Use qScriptConnect() to connect a C++ signal to a script function;
this is the Qt Script equivalent of QObject::connect(). When a
@@ -243,17 +243,17 @@ QT_BEGIN_NAMESPACE
argument to newFunction(). Here is an example of a function that
returns the sum of its first two arguments:
- \snippet doc/src/snippets/code/src_script_qscriptengine.cpp 6
+ \snippet code/src_script_qscriptengine.cpp 6
To expose this function to script code, you can set it as a property
of the Global Object:
- \snippet doc/src/snippets/code/src_script_qscriptengine.cpp 7
+ \snippet code/src_script_qscriptengine.cpp 7
Once this is done, script code can call your function in the exact
same manner as a "normal" script function:
- \snippet doc/src/snippets/code/src_script_qscriptengine.cpp 8
+ \snippet code/src_script_qscriptengine.cpp 8
\section1 Long-running Scripts
@@ -2078,12 +2078,12 @@ QScriptValue QScriptEngine::undefinedValue()
wrapping a custom type, by having registered the defaultPrototype()
of that type. Example:
- \snippet doc/src/snippets/code/src_script_qscriptengine.cpp 9
+ \snippet code/src_script_qscriptengine.cpp 9
To wrap a custom type and provide a constructor for it, you'd typically
do something like this:
- \snippet doc/src/snippets/code/src_script_qscriptengine.cpp 10
+ \snippet code/src_script_qscriptengine.cpp 10
*/
QScriptValue QScriptEngine::newFunction(QScriptEngine::FunctionSignature fun,
const QScriptValue &prototype,
@@ -2336,7 +2336,7 @@ QScriptValue QScriptEngine::newActivationObject()
functions (analogous to how properties work in \l{Qt's Property
System}). Example:
- \snippet doc/src/snippets/code/src_script_qscriptengine.cpp 11
+ \snippet code/src_script_qscriptengine.cpp 11
When the property \c{foo} of the script object is subsequently
accessed in script code, \c{getSetFoo()} will be invoked to handle
@@ -2351,7 +2351,7 @@ QScriptValue QScriptEngine::newActivationObject()
(QScriptValue::PropertyGetter or QScriptValue::PropertySetter) when
setting the property, e.g.:
- \snippet doc/src/snippets/code/src_script_qscriptengine.cpp 12
+ \snippet code/src_script_qscriptengine.cpp 12
\sa QScriptValue::call()
*/
@@ -2449,7 +2449,7 @@ QScriptValue QScriptEngine::newDate(const QDateTime &value)
Example:
- \snippet doc/src/snippets/code/src_script_qscriptengine.cpp 27
+ \snippet code/src_script_qscriptengine.cpp 27
\sa newQObject(), scriptValueFromQMetaObject()
*/
@@ -2471,7 +2471,7 @@ QScriptValue QScriptEngine::newQMetaObject(
This function is used in combination with one of the
Q_SCRIPT_DECLARE_QMETAOBJECT() macro. Example:
- \snippet doc/src/snippets/code/src_script_qscriptengine.cpp 13
+ \snippet code/src_script_qscriptengine.cpp 13
\sa QScriptEngine::newQMetaObject()
*/
@@ -2525,27 +2525,27 @@ QScriptValue QScriptEngine::newQMetaObject(
different results.)
Given the input
- \snippet doc/src/snippets/code/src_script_qscriptengine.cpp 14
+ \snippet code/src_script_qscriptengine.cpp 14
canEvaluate() will return true, since the program appears to be complete.
Given the input
- \snippet doc/src/snippets/code/src_script_qscriptengine.cpp 15
+ \snippet code/src_script_qscriptengine.cpp 15
canEvaluate() will return false, since the if-statement is not complete,
but is syntactically correct so far.
Given the input
- \snippet doc/src/snippets/code/src_script_qscriptengine.cpp 16
+ \snippet code/src_script_qscriptengine.cpp 16
canEvaluate() will return true, but evaluate() will throw a
SyntaxError given the same input.
Given the input
- \snippet doc/src/snippets/code/src_script_qscriptengine.cpp 17
+ \snippet code/src_script_qscriptengine.cpp 17
canEvaluate() will return true, even though the code is clearly not
syntactically valid QtScript code. evaluate() will throw a
SyntaxError when this code is evaluated.
Given the input
- \snippet doc/src/snippets/code/src_script_qscriptengine.cpp 18
+ \snippet code/src_script_qscriptengine.cpp 18
canEvaluate() will return true, but evaluate() will throw a
ReferenceError if \c{foo} is not defined in the script
environment.
@@ -2695,7 +2695,7 @@ QScriptContext *QScriptEngine::currentContext() const
\l{QScriptContext::activationObject()}{activationObject}() to initialize
local variables that will be available to scripts. Example:
- \snippet doc/src/snippets/code/src_script_qscriptengine.cpp 19
+ \snippet code/src_script_qscriptengine.cpp 19
In the above example, the new variable "tmp" defined in the script
will be local to the context; in other words, the script doesn't
@@ -3945,28 +3945,28 @@ QStringList QScriptEngine::importedExtensions() const
specify custom conversion of our type \c{MyStruct}. Here's the C++
type:
- \snippet doc/src/snippets/code/src_script_qscriptengine.cpp 20
+ \snippet code/src_script_qscriptengine.cpp 20
We must declare it so that the type will be known to QMetaType:
- \snippet doc/src/snippets/code/src_script_qscriptengine.cpp 21
+ \snippet code/src_script_qscriptengine.cpp 21
Next, the \c{MyStruct} conversion functions. We represent the
\c{MyStruct} value as a script object and just copy the properties:
- \snippet doc/src/snippets/code/src_script_qscriptengine.cpp 22
+ \snippet code/src_script_qscriptengine.cpp 22
Now we can register \c{MyStruct} with the engine:
- \snippet doc/src/snippets/code/src_script_qscriptengine.cpp 23
+ \snippet code/src_script_qscriptengine.cpp 23
Working with \c{MyStruct} values is now easy:
- \snippet doc/src/snippets/code/src_script_qscriptengine.cpp 24
+ \snippet code/src_script_qscriptengine.cpp 24
If you want to be able to construct values of your custom type
from script code, you have to register a constructor function for
the type. For example:
- \snippet doc/src/snippets/code/src_script_qscriptengine.cpp 25
+ \snippet code/src_script_qscriptengine.cpp 25
\sa qScriptRegisterSequenceMetaType(), qRegisterMetaType()
*/
@@ -4006,7 +4006,7 @@ QStringList QScriptEngine::importedExtensions() const
type, it must be declared using Q_DECLARE_METATYPE() as well.
Example:
- \snippet doc/src/snippets/code/src_script_qscriptengine.cpp 26
+ \snippet code/src_script_qscriptengine.cpp 26
\sa qScriptRegisterMetaType()
*/
diff --git a/src/script/api/qscriptengineagent.cpp b/src/script/api/qscriptengineagent.cpp
index 7317431..48bb997 100644
--- a/src/script/api/qscriptengineagent.cpp
+++ b/src/script/api/qscriptengineagent.cpp
@@ -66,12 +66,12 @@ QT_BEGIN_NAMESPACE
Evaluating the following script will result in scriptUnload()
being called immediately after evaluation has completed:
- \snippet doc/src/snippets/code/src_script_qscriptengineagent.cpp 0
+ \snippet code/src_script_qscriptengineagent.cpp 0
Evaluating the following script will \b{not} result in a call to
scriptUnload() when evaluation has completed:
- \snippet doc/src/snippets/code/src_script_qscriptengineagent.cpp 1
+ \snippet code/src_script_qscriptengineagent.cpp 1
The script isn't unloaded because it defines a function (\c{cube})
that remains in the script environment after evaluation has
diff --git a/src/script/api/qscriptvalue.cpp b/src/script/api/qscriptvalue.cpp
index 45e164c..9fb15c7 100644
--- a/src/script/api/qscriptvalue.cpp
+++ b/src/script/api/qscriptvalue.cpp
@@ -71,7 +71,7 @@
QScriptValues. Use setProperty() to set a property of an object, and
call property() to retrieve the value of a property.
- \snippet doc/src/snippets/code/src_script_qscriptvalue.cpp 0
+ \snippet code/src_script_qscriptvalue.cpp 0
Each property can have a set of attributes; these are specified as
the third (optional) argument to setProperty(). The attributes of a
@@ -79,7 +79,7 @@
following code snippet creates a property that cannot be modified by
script code:
- \snippet doc/src/snippets/code/src_script_qscriptvalue.cpp 1
+ \snippet code/src_script_qscriptvalue.cpp 1
If you want to iterate over the properties of a script object, use
the QScriptValueIterator class.
@@ -1551,7 +1551,7 @@ QScriptValue::PropertyFlags QScriptValue::propertyFlags(const QScriptString &nam
QScriptEngine::hasUncaughtException() to determine if an exception
occurred.
- \snippet doc/src/snippets/code/src_script_qscriptvalue.cpp 2
+ \snippet code/src_script_qscriptvalue.cpp 2
\sa construct()
*/
@@ -1629,7 +1629,7 @@ QScriptValue QScriptValue::call(const QScriptValue &thisObject,
One common usage of this function is to forward native function
calls to another function:
- \snippet doc/src/snippets/code/src_script_qscriptvalue.cpp 3
+ \snippet code/src_script_qscriptvalue.cpp 3
\sa construct(), QScriptContext::argumentsObject()
*/
diff --git a/src/script/api/qscriptvalueiterator.cpp b/src/script/api/qscriptvalueiterator.cpp
index 3b1c176..ddaff90 100644
--- a/src/script/api/qscriptvalueiterator.cpp
+++ b/src/script/api/qscriptvalueiterator.cpp
@@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE
beginning of the sequence of properties. Here's how to iterate over
all the properties of a QScriptValue:
- \snippet doc/src/snippets/code/src_script_qscriptvalueiterator.cpp 0
+ \snippet code/src_script_qscriptvalueiterator.cpp 0
The next() advances the iterator. The name(), value() and flags()
functions return the name, value and flags of the last item that was
@@ -66,14 +66,14 @@ QT_BEGIN_NAMESPACE
own properties; i.e. it does not follow the prototype chain. You can
use a loop like this to follow the prototype chain:
- \snippet doc/src/snippets/code/src_script_qscriptvalueiterator.cpp 1
+ \snippet code/src_script_qscriptvalueiterator.cpp 1
Note that QScriptValueIterator will not automatically skip over
properties that have the QScriptValue::SkipInEnumeration flag set;
that flag only affects iteration in script code. If you want, you
can skip over such properties with code like the following:
- \snippet doc/src/snippets/code/src_script_qscriptvalueiterator.cpp 2
+ \snippet code/src_script_qscriptvalueiterator.cpp 2
\sa QScriptValue::property()
*/
diff --git a/doc/src/images/qtscript-debugger.png b/src/script/doc/images/qtscript-debugger.png
index c417d0b..c417d0b 100644
--- a/doc/src/images/qtscript-debugger.png
+++ b/src/script/doc/images/qtscript-debugger.png
Binary files differ
diff --git a/src/script/doc/qtscript.qdocconf b/src/script/doc/qtscript.qdocconf
new file mode 100644
index 0000000..19c8bfd
--- /dev/null
+++ b/src/script/doc/qtscript.qdocconf
@@ -0,0 +1,93 @@
+include(global/qt-html-templates-offline.qdocconf)
+include(global/qt-cpp-ignore.qdocconf)
+
+project = QtScript
+description = Qt Script Reference Documentation
+url = http://qt-project.org/doc/qt-5.0/qtscript
+version = 5.0.0
+
+sourceencoding = UTF-8
+outputencoding = UTF-8
+naturallanguage = en_US
+qhp.projects = QtScript
+
+qhp.QtScript.file = qtscript.qhp
+qhp.QtScript.namespace = org.qt-project.qtscript.500
+qhp.QtScript.virtualFolder = qdoc
+qhp.QtScript.indexTitle = Qt Script Reference Documentation
+qhp.QtScript.indexRoot =
+
+qhp.QtScript.filterAttributes = qtscript 5.0.0 qtrefdoc
+qhp.QtScript.customFilters.Qt.name = QtScript 5.0.0
+qhp.QtScript.customFilters.Qt.filterAttributes = qtscript 5.0.0
+qhp.QtScript.subprojects = classes overviews examples
+qhp.QtScript.subprojects.classes.title = Classes
+qhp.QtScript.subprojects.classes.indexTitle = Qt Script's Classes
+qhp.QtScript.subprojects.classes.selectors = class fake:headerfile
+qhp.QtScript.subprojects.classes.sortPages = true
+qhp.QtScript.subprojects.overviews.title = Overviews
+qhp.QtScript.subprojects.overviews.indexTitle = All Overviews and HOWTOs
+qhp.QtScript.subprojects.overviews.selectors = fake:page,group,module
+qhp.QtScript.subprojects.examples.title = Qt Script Examples
+qhp.QtScript.subprojects.examples.indexTitle = Qt Script Examples
+qhp.QtScript.subprojects.examples.selectors = fake:example
+
+dita.metadata.default.author = Qt Project
+dita.metadata.default.permissions = all
+dita.metadata.default.publisher = Qt Project
+dita.metadata.default.copyryear = 2012
+dita.metadata.default.copyrholder = Nokia
+dita.metadata.default.audience = programmer
+
+sources.fileextensions = "*.c++ *.cc *.cpp *.cxx *.mm *.qml *.qdoc"
+headers.fileextensions = "*.ch *.h *.h++ *.hh *.hpp *.hxx"
+
+examples.fileextensions = "*.cpp *.h *.js *.xq *.svg *.xml *.ui *.qhp *.qhcp *.qml *.css"
+examples.imageextensions = "*.png"
+
+outputdir = ../../../doc/qtscript
+tagfile = ../../../doc/qtscript/qtscript.tags
+
+HTML.generatemacrefs = "true"
+HTML.nobreadcrumbs = "true"
+
+HTML.templatedir = .
+
+HTML.stylesheets = global/style/offline.css
+
+HTML.headerstyles = \
+ " <link rel=\"stylesheet\" type=\"text/css\" href=\"style/offline.css\" />\n"
+
+HTML.endheader = \
+ "</head>\n" \
+
+defines = Q_QDOC \
+ QT_.*_SUPPORT \
+ QT_.*_LIB \
+ QT_COMPAT \
+ QT_KEYPAD_NAVIGATION \
+ QT_NO_EGL \
+ Q_WS_.* \
+ Q_OS_.* \
+ Q_BYTE_ORDER \
+ QT_DEPRECATED \
+ QT_DEPRECATED_* \
+ Q_NO_USING_KEYWORD \
+ __cplusplus \
+ Q_COMPILER_INITIALIZER_LISTS
+
+versionsym = QT_VERSION_STR
+
+codeindent = 1
+
+depends += qtcore
+
+headerdirs += ..
+
+sourcedirs += ..
+
+exampledirs += ../../../examples \
+ ../ \
+ snippets
+
+imagedirs += images
diff --git a/doc/src/snippets/code/doc_src_qtscript.cpp b/src/script/doc/snippets/code/doc_src_qtscript.cpp
index 2ec5efc..2ec5efc 100644
--- a/doc/src/snippets/code/doc_src_qtscript.cpp
+++ b/src/script/doc/snippets/code/doc_src_qtscript.cpp
diff --git a/doc/src/snippets/code/doc_src_qtscript.js b/src/script/doc/snippets/code/doc_src_qtscript.js
index ccc7d40..ccc7d40 100644
--- a/doc/src/snippets/code/doc_src_qtscript.js
+++ b/src/script/doc/snippets/code/doc_src_qtscript.js
diff --git a/src/script/doc/snippets/code/doc_src_qtscript.pro b/src/script/doc/snippets/code/doc_src_qtscript.pro
new file mode 100644
index 0000000..b0ed6f8
--- /dev/null
+++ b/src/script/doc/snippets/code/doc_src_qtscript.pro
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#! [1]
+QT += script
+#! [1]
diff --git a/doc/src/snippets/code/doc_src_qtscript.qdoc b/src/script/doc/snippets/code/doc_src_qtscript.qdoc
index 988f055..988f055 100644
--- a/doc/src/snippets/code/doc_src_qtscript.qdoc
+++ b/src/script/doc/snippets/code/doc_src_qtscript.qdoc
diff --git a/doc/src/snippets/code/doc_src_qtscriptextensions.js b/src/script/doc/snippets/code/doc_src_qtscriptextensions.js
index cdc498f..cdc498f 100644
--- a/doc/src/snippets/code/doc_src_qtscriptextensions.js
+++ b/src/script/doc/snippets/code/doc_src_qtscriptextensions.js
diff --git a/doc/src/snippets/code/src_script_qscriptable.cpp b/src/script/doc/snippets/code/src_script_qscriptable.cpp
index d7193ca..d7193ca 100644
--- a/doc/src/snippets/code/src_script_qscriptable.cpp
+++ b/src/script/doc/snippets/code/src_script_qscriptable.cpp
diff --git a/doc/src/snippets/code/src_script_qscriptclass.cpp b/src/script/doc/snippets/code/src_script_qscriptclass.cpp
index 04c8dcc..04c8dcc 100644
--- a/doc/src/snippets/code/src_script_qscriptclass.cpp
+++ b/src/script/doc/snippets/code/src_script_qscriptclass.cpp
diff --git a/doc/src/snippets/code/src_script_qscriptcontext.cpp b/src/script/doc/snippets/code/src_script_qscriptcontext.cpp
index 8f9f51e..8f9f51e 100644
--- a/doc/src/snippets/code/src_script_qscriptcontext.cpp
+++ b/src/script/doc/snippets/code/src_script_qscriptcontext.cpp
diff --git a/doc/src/snippets/code/src_script_qscriptengine.cpp b/src/script/doc/snippets/code/src_script_qscriptengine.cpp
index 76daa0c..76daa0c 100644
--- a/doc/src/snippets/code/src_script_qscriptengine.cpp
+++ b/src/script/doc/snippets/code/src_script_qscriptengine.cpp
diff --git a/doc/src/snippets/code/src_script_qscriptengineagent.cpp b/src/script/doc/snippets/code/src_script_qscriptengineagent.cpp
index 206cd2f..206cd2f 100644
--- a/doc/src/snippets/code/src_script_qscriptengineagent.cpp
+++ b/src/script/doc/snippets/code/src_script_qscriptengineagent.cpp
diff --git a/doc/src/snippets/code/src_script_qscriptvalue.cpp b/src/script/doc/snippets/code/src_script_qscriptvalue.cpp
index 5fa8e48..5fa8e48 100644
--- a/doc/src/snippets/code/src_script_qscriptvalue.cpp
+++ b/src/script/doc/snippets/code/src_script_qscriptvalue.cpp
diff --git a/doc/src/snippets/code/src_script_qscriptvalueiterator.cpp b/src/script/doc/snippets/code/src_script_qscriptvalueiterator.cpp
index e26b999..e26b999 100644
--- a/doc/src/snippets/code/src_script_qscriptvalueiterator.cpp
+++ b/src/script/doc/snippets/code/src_script_qscriptvalueiterator.cpp
diff --git a/doc/src/snippets/qtscript/evaluation/main.cpp b/src/script/doc/snippets/qtscript/evaluation/main.cpp
index 6917c47..6917c47 100644
--- a/doc/src/snippets/qtscript/evaluation/main.cpp
+++ b/src/script/doc/snippets/qtscript/evaluation/main.cpp
diff --git a/doc/src/snippets/qtscript/registeringobjects/main.cpp b/src/script/doc/snippets/qtscript/registeringobjects/main.cpp
index 32dc699..32dc699 100644
--- a/doc/src/snippets/qtscript/registeringobjects/main.cpp
+++ b/src/script/doc/snippets/qtscript/registeringobjects/main.cpp
diff --git a/doc/src/snippets/qtscript/registeringvalues/main.cpp b/src/script/doc/snippets/qtscript/registeringvalues/main.cpp
index 1aa100e..1aa100e 100644
--- a/doc/src/snippets/qtscript/registeringvalues/main.cpp
+++ b/src/script/doc/snippets/qtscript/registeringvalues/main.cpp
diff --git a/doc/src/scripting/ecmascript.qdoc b/src/script/doc/src/ecmascript.qdoc
index 4abb8f4..4abb8f4 100644
--- a/doc/src/scripting/ecmascript.qdoc
+++ b/src/script/doc/src/ecmascript.qdoc
diff --git a/src/script/doc/src/external-resources.qdoc b/src/script/doc/src/external-resources.qdoc
new file mode 100644
index 0000000..ee75931
--- /dev/null
+++ b/src/script/doc/src/external-resources.qdoc
@@ -0,0 +1,42 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms
+** and conditions contained in a signed written agreement between you
+** and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \externalpage http://www.ecma-international.org/publications/standards/Ecma-262.htm
+ \title ECMA-262
+*/
+
+/*!
+ \externalpage http://www.davidflanagan.com/javascript5/
+ \title JavaScript: The Definitive Guide
+*/
+
+/*!
+ \externalpage http://qt.nokia.com/products/library/modular-class-library#info_scripting
+ \title Qt Script for Applications (QSA)
+*/
+
diff --git a/src/script/doc/src/qtscript.qdoc b/src/script/doc/src/qtscript.qdoc
new file mode 100644
index 0000000..077f811
--- /dev/null
+++ b/src/script/doc/src/qtscript.qdoc
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms
+** and conditions contained in a signed written agreement between you
+** and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \module QtScript
+ \title QtScript Module
+ \since 4.3
+ \ingroup modules
+
+ \brief The QtScript module provides classes for making Qt applications scriptable.
+
+ The QtScript module only provides core scripting facilities; the
+ QtScriptTools module provides additional Qt Script-related
+ components that application developers may find useful.
+
+ To include the definitions of the module's classes, use the
+ following directive:
+
+ \snippet code/doc_src_qtscript.cpp 0
+
+ To link against the module, add this line to your \l qmake \c .pro file:
+
+ \snippet code/doc_src_qtscript.pro 1
+
+ For detailed information on how to make your application
+ scriptable with QtScript, see \l{Making Applications
+ Scriptable}.
+
+ \section1 License Information
+
+ Qt Commercial Edition licensees that wish to distribute applications that
+ use the QtScript module need to be aware of their obligations under the
+ GNU Library General Public License (LGPL).
+
+ Developers using the Open Source Edition can choose to redistribute
+ the module under the appropriate version of the GNU LGPL.
+
+ \legalese
+ QtScript is licensed under the GNU Library General Public License.
+ Individual contributor names and copyright dates can be found
+ inline in the code.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ \endlegalese
+
+*/
+
diff --git a/doc/src/scripting/qtscriptdebugger-manual.qdoc b/src/script/doc/src/qtscriptdebugger-manual.qdoc
index a6ea206..4120464 100644
--- a/doc/src/scripting/qtscriptdebugger-manual.qdoc
+++ b/src/script/doc/src/qtscriptdebugger-manual.qdoc
@@ -55,7 +55,7 @@
\list
\li The \c{debugger} statement is encountered in the script.
- \li Clicking the \gui Interrupt menu item from the \gui Debug
+ \li Clicking the \uicontrol Interrupt menu item from the \uicontrol Debug
menu in the main window.
\li A breakpoint is reached.
\li An uncaught script exception is thrown.
@@ -66,7 +66,7 @@
stack shown. New breakpoints can be set.
The debugger will resume, i.e., give the control back to the script
- engine, when the user clicks \gui Continue menu item from the \gui
+ engine, when the user clicks \uicontrol Continue menu item from the \uicontrol
Debug menu. It will be invoked again if one of the conditions
described in the list above is met.
diff --git a/doc/src/scripting/qtscriptextensions.qdoc b/src/script/doc/src/qtscriptextensions.qdoc
index 51e5bc4..86870f8 100644
--- a/doc/src/scripting/qtscriptextensions.qdoc
+++ b/src/script/doc/src/qtscriptextensions.qdoc
@@ -68,7 +68,7 @@
An example of a simple \c{__init__.js}:
- \snippet doc/src/snippets/code/doc_src_qtscriptextensions.js 0
+ \snippet code/doc_src_qtscriptextensions.js 0
QScriptEngine will look for a QScriptExtensionPlugin that provides
the relevant extension by querying each plugin for its keys()
diff --git a/doc/src/scripting/scripting.qdoc b/src/script/doc/src/scripting.qdoc
index 8e3158a..d421eab 100644
--- a/doc/src/scripting/scripting.qdoc
+++ b/src/script/doc/src/scripting.qdoc
@@ -70,7 +70,7 @@
evaluate() function, passing the script code (text) to evaluate
as argument.
- \snippet doc/src/snippets/qtscript/evaluation/main.cpp 0
+ \snippet qtscript/evaluation/main.cpp 0
The return value will be the result of the evaluation (represented
as a QScriptValue object); this can be converted to standard C++
@@ -80,7 +80,7 @@
them with the script engine. This is most easily done by setting
properties of the script engine's \e{Global Object}:
- \snippet doc/src/snippets/qtscript/registeringvalues/main.cpp 0
+ \snippet qtscript/registeringvalues/main.cpp 0
This places the properties in the script environment, thus making them
available to script code.
@@ -97,7 +97,7 @@
Here's an example of making an instance of a QObject subclass
available to script code under the name \c{"myObject"}:
- \snippet doc/src/snippets/qtscript/registeringobjects/main.cpp 0
+ \snippet qtscript/registeringobjects/main.cpp 0
This will create a global variable called \c{myObject} in the
script environment. The variable serves as a proxy to the
@@ -144,7 +144,7 @@
script function. In the following example a script signal handler is
defined that will handle the QLineEdit::textChanged() signal:
- \snippet doc/src/snippets/code/doc_src_qtscript.cpp 47
+ \snippet code/doc_src_qtscript.cpp 47
The first two arguments to qScriptConnect() are the same
as you would pass to QObject::connect() to establish a normal C++
@@ -155,7 +155,7 @@
("slot") itself. The following example shows how the \c this argument
can be put to use:
- \snippet doc/src/snippets/code/doc_src_qtscript.cpp 48
+ \snippet code/doc_src_qtscript.cpp 48
We create two QLineEdit objects and define a single signal handler
function. The connections use the same handler function, but the
@@ -179,13 +179,13 @@
In this form of connection, the argument to \c{connect()} is the
function to connect to the signal.
- \snippet doc/src/snippets/code/doc_src_qtscript.js 2
+ \snippet code/doc_src_qtscript.js 2
The argument can be a Qt Script function, as in the above
example, or it can be a QObject slot, as in
the following example:
- \snippet doc/src/snippets/code/doc_src_qtscript.js 3
+ \snippet code/doc_src_qtscript.js 3
When the argument is a QObject slot, the argument types of the
signal and slot do not necessarily have to be compatible;
@@ -196,7 +196,7 @@
\c{disconnect()} function, passing the function to disconnect
as argument:
- \snippet doc/src/snippets/code/doc_src_qtscript.js 4
+ \snippet code/doc_src_qtscript.js 4
When a script function is invoked in response to a signal, the
\c this object will be the Global Object.
@@ -214,11 +214,11 @@
\c{clicked} signal; passing the form as the \c this object
makes sense in such a case.
- \snippet doc/src/snippets/code/doc_src_qtscript.js 5
+ \snippet code/doc_src_qtscript.js 5
To disconnect from the signal, pass the same arguments to \c{disconnect()}:
- \snippet doc/src/snippets/code/doc_src_qtscript.js 6
+ \snippet code/doc_src_qtscript.js 6
\section3 Signal to Named Member Function Connections
@@ -234,11 +234,11 @@
Note that the function is resolved when the connection is made, not
when the signal is emitted.
- \snippet doc/src/snippets/code/doc_src_qtscript.js 7
+ \snippet code/doc_src_qtscript.js 7
To disconnect from the signal, pass the same arguments to \c{disconnect()}:
- \snippet doc/src/snippets/code/doc_src_qtscript.js 8
+ \snippet code/doc_src_qtscript.js 8
\section3 Error Handling
@@ -247,14 +247,14 @@
You can obtain an error message from the resulting \c{Error} object.
Example:
- \snippet doc/src/snippets/code/doc_src_qtscript.js 9
+ \snippet code/doc_src_qtscript.js 9
\section3 Emitting Signals from Scripts
To emit a signal from script code, you simply invoke the signal
function, passing the relevant arguments:
- \snippet doc/src/snippets/code/doc_src_qtscript.js 10
+ \snippet code/doc_src_qtscript.js 10
It is currently not possible to define a new signal in a script;
i.e., all signals must be defined by C++ classes.
@@ -267,13 +267,13 @@
\c{myOverloadedSlot(int)} and \c{myOverloadedSlot(QString)}, the following
script code will behave reasonably:
- \snippet doc/src/snippets/code/doc_src_qtscript.js 11
+ \snippet code/doc_src_qtscript.js 11
You can specify a particular overload by using array-style property access
with the \l{QMetaObject::normalizedSignature()}{normalized signature} of
the C++ function as the property name:
- \snippet doc/src/snippets/code/doc_src_qtscript.js 12
+ \snippet code/doc_src_qtscript.js 12
If the overloads have different number of arguments, QtScript will
pick the overload with the argument count that best matches the
@@ -291,11 +291,11 @@
property will automatically be invoked. For example, if your
C++ class has a property declared as follows:
- \snippet doc/src/snippets/code/doc_src_qtscript.cpp 13
+ \snippet code/doc_src_qtscript.cpp 13
then script code can do things like the following:
- \snippet doc/src/snippets/code/doc_src_qtscript.js 14
+ \snippet code/doc_src_qtscript.js 14
\section2 Accessing Child QObjects
@@ -306,12 +306,12 @@
\c{"okButton"}, you can access this object in script code through
the expression
- \snippet doc/src/snippets/code/doc_src_qtscript.js 15
+ \snippet code/doc_src_qtscript.js 15
Since \c{objectName} is itself a Q_PROPERTY, you can manipulate
the name in script code to, for example, rename an object:
- \snippet doc/src/snippets/code/doc_src_qtscript.js 16
+ \snippet code/doc_src_qtscript.js 16
You can also use the functions \c{findChild()} and \c{findChildren()}
to find children. These two functions behave identically to
@@ -320,7 +320,7 @@
For example, we can use these functions to find objects using strings
and regular expressions:
- \snippet doc/src/snippets/code/doc_src_qtscript.js 17
+ \snippet code/doc_src_qtscript.js 17
You typically want to use \c{findChild()} when manipulating a form
that uses nested layouts; that way the script is isolated from the
@@ -367,7 +367,7 @@
For example, a constructor function that constructs QObjects
only to be used in the script environment is a good candidate:
- \snippet doc/src/snippets/code/doc_src_qtscript.cpp 18
+ \snippet code/doc_src_qtscript.cpp 18
\section3 Auto-Ownership
@@ -638,7 +638,7 @@
For example, the following class definition enables scripting only for
certain functions:
- \snippet doc/src/snippets/code/doc_src_qtscript.cpp 19
+ \snippet code/doc_src_qtscript.cpp 19
In the example above, aNonScriptableFunction() is not declared as a
slot, so it will not be available in QtScript. The other three
@@ -649,7 +649,7 @@
It is possible to make any function script-invokable by specifying
the \c{Q_INVOKABLE} modifier when declaring the function:
- \snippet doc/src/snippets/code/doc_src_qtscript.cpp 20
+ \snippet code/doc_src_qtscript.cpp 20
Once declared with \c{Q_INVOKABLE}, the method can be invoked from
QtScript code just as if it were a slot. Although such a method is
@@ -668,14 +668,14 @@
In the previous example, if we wanted to get or set a property using
QtScript we would have to write code like the following:
- \snippet doc/src/snippets/code/doc_src_qtscript.js 21
+ \snippet code/doc_src_qtscript.js 21
Scripting languages often provide a property syntax to modify and
retrieve properties (in our case the enabled state) of an
object. Many script programmers would want to write the above code
like this:
- \snippet doc/src/snippets/code/doc_src_qtscript.js 22
+ \snippet code/doc_src_qtscript.js 22
To make this possible, you must define properties in the C++ QObject
subclass. For example, the following \c MyObject class declaration
@@ -683,7 +683,7 @@
\c{setEnabled(bool)} as its setter function and \c{isEnabled()} as its
getter function:
- \snippet doc/src/snippets/code/doc_src_qtscript.cpp 23
+ \snippet code/doc_src_qtscript.cpp 23
The only difference from the original code is the use of the macro
\c{Q_PROPERTY}, which takes the type and name of the property, and
@@ -694,7 +694,7 @@
declaring the property; by default, the \c{SCRIPTABLE} attribute is
\c true. For example:
- \snippet doc/src/snippets/code/doc_src_qtscript.cpp 24
+ \snippet code/doc_src_qtscript.cpp 24
\section2 Reacting to C++ Objects Signals in Scripts
@@ -709,14 +709,14 @@
regardless of whether the signal will be connected to a slot in C++
or in QtScript.
- \snippet doc/src/snippets/code/doc_src_qtscript.cpp 25
+ \snippet code/doc_src_qtscript.cpp 25
The only change we have made to the code in the previous section is
to declare a signals section with the relevant signal. Now, the
script writer can define a function and connect to the object like
this:
- \snippet doc/src/snippets/code/doc_src_qtscript.js 26
+ \snippet code/doc_src_qtscript.js 26
\section2 Design of Application Objects
@@ -758,7 +758,7 @@
still allowing pointers to your custom objects to flow seamlessly
between C++ and scripts. Example:
- \snippet doc/src/snippets/code/doc_src_qtscript.cpp 43
+ \snippet code/doc_src_qtscript.cpp 43
\section1 Function Objects and Native Functions
@@ -784,23 +784,23 @@
result. The following script defines a Qt Script object that has a
toKelvin() function:
- \snippet doc/src/snippets/code/doc_src_qtscript.js 90
+ \snippet code/doc_src_qtscript.js 90
The toKelvin() function takes a temperature in Kelvin as argument, and
returns the temperature converted to Celsius. The following snippet shows
how the toKelvin() function might be obtained and called from C++:
- \snippet doc/src/snippets/code/doc_src_qtscript.cpp 91
+ \snippet code/doc_src_qtscript.cpp 91
If a script defines a global function, you can access the function as a
property of QScriptEngine::globalObject(). For example, the following script
defines a global function add():
- \snippet doc/src/snippets/code/doc_src_qtscript.js 56
+ \snippet code/doc_src_qtscript.js 56
C++ code might call the add() function as follows:
- \snippet doc/src/snippets/code/doc_src_qtscript.cpp 92
+ \snippet code/doc_src_qtscript.cpp 92
As already mentioned, functions are just values in Qt Script; a function by
itself is not "tied to" a particular object. This is why you have to specify
@@ -822,7 +822,7 @@
is invoked determines the \c this object when the function body is executed,
as the following script example illustrates:
- \snippet doc/src/snippets/code/doc_src_qtscript.js 49
+ \snippet code/doc_src_qtscript.js 49
An important thing to note is that in Qt Script, unlike C++ and Java, the
\c this object is not part of the execution scope. This means that
@@ -830,14 +830,14 @@
use the \c this keyword to access the object's properties. For example,
the following script probably doesn't do what you want:
- \snippet doc/src/snippets/code/doc_src_qtscript.js 50
+ \snippet code/doc_src_qtscript.js 50
You will get a reference error saying that 'a is not defined' or, worse,
two totally unrelated global variables \c a and \c b will be used to
perform the computation, if they exist. Instead, the script should look
like this:
- \snippet doc/src/snippets/code/doc_src_qtscript.js 51
+ \snippet code/doc_src_qtscript.js 51
Accidentally omitting the \c this keyword is a typical source of
error for programmers who are used to the scoping rules of C++ and Java.
@@ -850,7 +850,7 @@
your function as if it were a "normal" script function. Here is how the
previous \c{getProperty()} function can be written in C++:
- \snippet doc/src/snippets/code/doc_src_qtscript.cpp 52
+ \snippet code/doc_src_qtscript.cpp 52
Call QScriptEngine::newFunction() to wrap the function. This will
produce a special type of function object that carries a pointer to
@@ -911,7 +911,7 @@
script would normally define an \c{add()} function that takes two
arguments, adds them together and returns the result:
- \snippet doc/src/snippets/code/doc_src_qtscript.js 56
+ \snippet code/doc_src_qtscript.js 56
When a script function is defined with formal parameters, their
names can be viewed as mere aliases of properties of the \c
@@ -920,12 +920,12 @@
variable. This means that the \c{add()} function can equivalently be
written like this:
- \snippet doc/src/snippets/code/doc_src_qtscript.js 57
+ \snippet code/doc_src_qtscript.js 57
This latter form closely matches what a native implementation
typically looks like:
- \snippet doc/src/snippets/code/doc_src_qtscript.cpp 58
+ \snippet code/doc_src_qtscript.cpp 58
\section3 Checking the Number of Arguments
@@ -936,13 +936,13 @@
really needs two arguments in order to do something useful. This
can be expressed by the script definition as follows:
- \snippet doc/src/snippets/code/doc_src_qtscript.js 59
+ \snippet code/doc_src_qtscript.js 59
This would result in an error being thrown if a script invokes
\c{add()} with anything other than two arguments. The native
function can be modified to perform the same check:
- \snippet doc/src/snippets/code/doc_src_qtscript.cpp 62
+ \snippet code/doc_src_qtscript.cpp 62
\section3 Checking the Types of Arguments
@@ -960,7 +960,7 @@
stricter semantics (namely, that it should only add numeric
operands), the argument types can be tested:
- \snippet doc/src/snippets/code/doc_src_qtscript.js 60
+ \snippet code/doc_src_qtscript.js 60
Then an invocation like \c{add("foo", new Array())} will
cause an error to be thrown.
@@ -968,12 +968,12 @@
The C++ version can call QScriptValue::isNumber() to perform similar
tests:
- \snippet doc/src/snippets/code/doc_src_qtscript.cpp 63
+ \snippet code/doc_src_qtscript.cpp 63
A less strict script implementation might settle for performing an
explicit to-number conversion before applying the \c{+} operator:
- \snippet doc/src/snippets/code/doc_src_qtscript.js 61
+ \snippet code/doc_src_qtscript.js 61
In a native implementation, this is equivalent to calling
QScriptValue::toNumber() without performing any type test first,
@@ -1006,21 +1006,21 @@
\c{concat("Qt", " ", "Script ", 101)} would return "Qt Script 101".
A script definition of \c{concat()} might look like this:
- \snippet doc/src/snippets/code/doc_src_qtscript.js 64
+ \snippet code/doc_src_qtscript.js 64
Here is an equivalent native implementation:
- \snippet doc/src/snippets/code/doc_src_qtscript.cpp 65
+ \snippet code/doc_src_qtscript.cpp 65
A second use case for a variable number of arguments is to implement
optional arguments. Here's how a script definition typically does
it:
- \snippet doc/src/snippets/code/doc_src_qtscript.js 66
+ \snippet code/doc_src_qtscript.js 66
And here's the native equivalent:
- \snippet doc/src/snippets/code/doc_src_qtscript.cpp 67
+ \snippet code/doc_src_qtscript.cpp 67
A third use case for a variable number of arguments is to simulate
C++ overloads. This involves checking the number of arguments and/or
@@ -1049,7 +1049,7 @@
call to another function. In script code, this is what it
typically looks like:
- \snippet doc/src/snippets/code/doc_src_qtscript.js 68
+ \snippet code/doc_src_qtscript.js 68
For example, \c{foo(10, 20, 30)} would result in the \c{foo()} function
executing the equivalent of \c{bar(10, 20, 30)}. This is useful if
@@ -1060,7 +1060,7 @@
function that has the exact same "signature". In C++, the forwarding
function might look like this:
- \snippet doc/src/snippets/code/doc_src_qtscript.cpp 69
+ \snippet code/doc_src_qtscript.cpp 69
\li The arguments object can serve as input to a QScriptValueIterator,
providing a generic way to iterate over the arguments. A debugger
@@ -1078,7 +1078,7 @@
Some script functions are constructors; they are expected to initialize
new objects. The following snippet is a small example:
- \snippet doc/src/snippets/code/doc_src_qtscript.js 75
+ \snippet code/doc_src_qtscript.js 75
There is nothing special about constructor functions. In fact, any
script function can act as a constructor function (i.e., any function
@@ -1124,7 +1124,7 @@
The following example implements a constructor function that always
creates and initializes a new object:
- \snippet doc/src/snippets/code/doc_src_qtscript.cpp 76
+ \snippet code/doc_src_qtscript.cpp 76
Given this constructor, scripts would be able to use either the
expression \c{new Person("Bob")} or \c{Person("Bob")} to create a
@@ -1160,7 +1160,7 @@
returns the function object being invoked. The following example
shows how this might be used:
- \snippet doc/src/snippets/code/doc_src_qtscript.cpp 55
+ \snippet code/doc_src_qtscript.cpp 55
\section2 Native Functions as Arguments to Functions
@@ -1169,13 +1169,13 @@
naturally. As an example, here's a native comparison function
that compares its two arguments numerically:
- \snippet doc/src/snippets/code/doc_src_qtscript.cpp 53
+ \snippet code/doc_src_qtscript.cpp 53
The above function can be passed as argument to the standard
\c{Array.prototype.sort} function to sort an array numerically,
as the following C++ code illustrates:
- \snippet doc/src/snippets/code/doc_src_qtscript.cpp 54
+ \snippet code/doc_src_qtscript.cpp 54
Note that, in this case, we are truly treating the native function
object as a value \mdash i.e., we don't store it as a property of the
@@ -1210,7 +1210,7 @@
itself. This technique is typically used in conjunction with
QScriptEngine::pushContext(), as in the following example:
- \snippet doc/src/snippets/code/doc_src_qtscript.cpp 77
+ \snippet code/doc_src_qtscript.cpp 77
We create a temporary execution context, create a local variable
for it, evaluate the script, and finally restore the old context.
@@ -1233,7 +1233,7 @@
define a native combined getter/setter that transforms the value
slightly:
- \snippet doc/src/snippets/code/doc_src_qtscript.cpp 78
+ \snippet code/doc_src_qtscript.cpp 78
The example uses the internal data of the object to store and
retrieve the transformed value. Alternatively, the property
@@ -1246,12 +1246,12 @@
The following C++ code shows how an object property can be defined
in terms of the native getter/setter:
- \snippet doc/src/snippets/code/doc_src_qtscript.cpp 79
+ \snippet code/doc_src_qtscript.cpp 79
When the property is accessed, like in the following script, the
getter/setter does its job behind the scenes:
- \snippet doc/src/snippets/code/doc_src_qtscript.js 80
+ \snippet code/doc_src_qtscript.js 80
\note It is important that the setter function, not just the getter,
returns the value of the property; i.e., the setter should \e{not}
@@ -1272,7 +1272,7 @@
Property getters and setters can be defined and installed by script
code as well, as in the following example:
- \snippet doc/src/snippets/code/doc_src_qtscript.js 81
+ \snippet code/doc_src_qtscript.js 81
Getters and setters can only be used to implement "a priori
properties"; i.e., the technique can't be used to react to an access
@@ -1348,7 +1348,7 @@
including the \c{hasOwnProperty()} function and \c{toString()}
function:
- \snippet doc/src/snippets/code/doc_src_qtscript.js 27
+ \snippet code/doc_src_qtscript.js 27
The \c{toString()} function itself is not defined in \c{o} (since we
did not assign anything to \c{o.toString}), so instead the
@@ -1388,7 +1388,7 @@
The following code defines a simple constructor function for a class
called \c{Person}:
- \snippet doc/src/snippets/code/doc_src_qtscript.js 28
+ \snippet code/doc_src_qtscript.js 28
Next, you want to set up \c{Person.prototype} as your prototype
object; i.e., define the interface that should be common to all
@@ -1403,19 +1403,19 @@
\c{Object.prototype}, to give your \c{Person} objects a more
appropriate string representation:
- \snippet doc/src/snippets/code/doc_src_qtscript.js 29
+ \snippet code/doc_src_qtscript.js 29
This resembles the process of reimplementing a virtual function
in C++. Henceforth, when the property named \c{toString} is
looked up in a \c{Person} object, it will be resolved in
\c{Person.prototype}, not in \c{Object.prototype} as before:
- \snippet doc/src/snippets/code/doc_src_qtscript.js 30
+ \snippet code/doc_src_qtscript.js 30
There are also some other interesting things we can learn about a
\c{Person} object:
- \snippet doc/src/snippets/code/doc_src_qtscript.js 31
+ \snippet code/doc_src_qtscript.js 31
The \c{hasOwnProperty()} function is not inherited from
\c{Person.prototype}, but rather from \c{Object.prototype}, which is
@@ -1432,13 +1432,13 @@
following example shows how one can create a subclass of \c{Person}
called \c{Employee}:
- \snippet doc/src/snippets/code/doc_src_qtscript.js 32
+ \snippet code/doc_src_qtscript.js 32
Again, you can use the \c{instanceof} to verify that the
class relationship between \c{Employee} and \c{Person} has been
correctly established:
- \snippet doc/src/snippets/code/doc_src_qtscript.js 33
+ \snippet code/doc_src_qtscript.js 33
This shows that the prototype chain of \c{Employee} objects is the
same as that of \c{Person} objects, but with \c{Employee.prototype}
@@ -1483,25 +1483,25 @@
preceding section can be implemented in terms of the Qt Script API.
We begin with the native constructor function:
- \snippet doc/src/snippets/code/doc_src_qtscript.cpp 34
+ \snippet code/doc_src_qtscript.cpp 34
Here's the native equivalent of the \c{Person.prototype.toString}
function we saw before:
- \snippet doc/src/snippets/code/doc_src_qtscript.cpp 35
+ \snippet code/doc_src_qtscript.cpp 35
The \c{Person} class can then be initialized as follows:
- \snippet doc/src/snippets/code/doc_src_qtscript.cpp 36
+ \snippet code/doc_src_qtscript.cpp 36
The implementation of the \c{Employee} subclass is similar. We
use QScriptValue::call() to call the super-class (Person) constructor:
- \snippet doc/src/snippets/code/doc_src_qtscript.cpp 37
+ \snippet code/doc_src_qtscript.cpp 37
The \c{Employee} class can then be initialized as follows:
- \snippet doc/src/snippets/code/doc_src_qtscript.cpp 38
+ \snippet code/doc_src_qtscript.cpp 38
When implementing the prototype object of a class, you may want to use
the QScriptable class, as it enables you to define the API of your
@@ -1527,7 +1527,7 @@
modify the underlying C++ value, lets you modify the actual value
contained in the script value (and not a copy of it).
- \snippet doc/src/snippets/code/doc_src_qtscript.cpp 39
+ \snippet code/doc_src_qtscript.cpp 39
\section2 Implementing Constructors for Value-based Types
@@ -1535,7 +1535,7 @@
by wrapping a native factory function. For example, the following
function implements a simple constructor for QPoint:
- \snippet doc/src/snippets/code/doc_src_qtscript.cpp 44
+ \snippet code/doc_src_qtscript.cpp 44
In the above code we simplified things a bit, e.g. we didn't check
the argument count to decide which QPoint C++ constructor to use.
@@ -1570,16 +1570,16 @@
The following snippet shows a constructor function that constructs
QXmlStreamReader objects that are stored using QSharedPointer:
- \snippet doc/src/snippets/code/doc_src_qtscript.cpp 93
+ \snippet code/doc_src_qtscript.cpp 93
Prototype functions can use qscriptvalue_cast() to cast the \c this object
to the proper type:
- \snippet doc/src/snippets/code/doc_src_qtscript.cpp 94
+ \snippet code/doc_src_qtscript.cpp 94
The prototype and constructor objects are set up in the usual way:
- \snippet doc/src/snippets/code/doc_src_qtscript.cpp 95
+ \snippet code/doc_src_qtscript.cpp 95
Scripts can now construct QXmlStreamReader objects by calling the \c
XmlStreamReader constructor, and when the Qt Script object is
@@ -1649,12 +1649,12 @@
somewhere else. The following code shows a custom print() that adds
text to a QPlainTextEdit.
- \snippet doc/src/snippets/code/doc_src_qtscript.cpp 45
+ \snippet code/doc_src_qtscript.cpp 45
The following code shows how the custom print() function may be
initialized and used.
- \snippet doc/src/snippets/code/doc_src_qtscript.cpp 46
+ \snippet code/doc_src_qtscript.cpp 46
A pointer to the QPlainTextEdit is stored as an internal property
of the script function itself, so that it can be retrieved when
@@ -1686,7 +1686,7 @@
function. Essentially all that is necessary to achieve this is to use
the qsTr() script function. Example:
- \snippet doc/src/snippets/code/doc_src_qtscript.js 82
+ \snippet code/doc_src_qtscript.js 82
This accounts for 99% of the user-visible strings you're likely to write.
@@ -1695,7 +1695,7 @@
unique in your project, you should use the qsTranslate() function and pass a
suitable context as the first argument. Example:
- \snippet doc/src/snippets/code/doc_src_qtscript.js 83
+ \snippet code/doc_src_qtscript.js 83
If you need to have translatable text completely outside a function, there
are two functions to help: QT_TR_NOOP() and QT_TRANSLATE_NOOP(). They merely
@@ -1704,18 +1704,18 @@
Example of QT_TR_NOOP():
- \snippet doc/src/snippets/code/doc_src_qtscript.js 84
+ \snippet code/doc_src_qtscript.js 84
Example of QT_TRANSLATE_NOOP():
- \snippet doc/src/snippets/code/doc_src_qtscript.js 85
+ \snippet code/doc_src_qtscript.js 85
\section2 Use String.prototype.arg() for Dynamic Text
The String.prototype.arg() function (which is modeled after QString::arg())
offers a simple means for substituting arguments:
- \snippet doc/src/snippets/code/doc_src_qtscript.js 86
+ \snippet code/doc_src_qtscript.js 86
\section2 Produce Translations
@@ -1756,12 +1756,12 @@
When running \c lupdate, you must specify the location of the script(s),
and the name of the TS file to produce. Examples:
- \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 87
+ \snippet code/doc_src_qtscript.qdoc 87
will extract translatable text from \c myscript.qs and create the
translation file \c myscript_la.qs.
- \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 88
+ \snippet code/doc_src_qtscript.qdoc 88
will extract translatable text from all files ending with \c{.qs} in the
\c scripts folder and create the translation file \c scripts_la.qs.
@@ -1770,7 +1770,7 @@
the \c SOURCES and \c TRANSLATIONS variables appropriately; then run
\c lupdate with the project file as input.
- \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 89
+ \snippet code/doc_src_qtscript.qdoc 89
When running \c lrelease, you must specify the name of the TS input
file; or, if you are using a qmake project file to manage script
@@ -1810,7 +1810,7 @@
This property has the QScriptValue::Undeletable flag set.
For example:
- \snippet doc/src/snippets/code/doc_src_qtscript.js 40
+ \snippet code/doc_src_qtscript.js 40
\li \c{Object.prototype.__defineGetter__} \br
This function installs a
@@ -1820,7 +1820,7 @@
\c this object will be the object whose property is accessed.
For example:
- \snippet doc/src/snippets/code/doc_src_qtscript.js 41
+ \snippet code/doc_src_qtscript.js 41
\li \c{Object.prototype.__defineSetter__} \br
This function installs a
@@ -1830,7 +1830,7 @@
\c this object will be the object whose property is accessed.
For example:
- \snippet doc/src/snippets/code/doc_src_qtscript.js 42
+ \snippet code/doc_src_qtscript.js 42
\li \c{Function.prototype.connect} \br
This function connects
diff --git a/src/script/script.pro b/src/script/script.pro
index 3c0e5de..a9dac69 100644
--- a/src/script/script.pro
+++ b/src/script/script.pro
@@ -21,6 +21,8 @@ HEADERS += qtscriptversion.h
CONFIG += building-libs
+QMAKE_DOCS = $$PWD/doc/qtscript.qdocconf
+
WEBKITDIR = $$PWD/../3rdparty/javascriptcore
GENERATED_SOURCES_DIR = generated
diff --git a/src/scripttools/debugging/qscriptenginedebugger.cpp b/src/scripttools/debugging/qscriptenginedebugger.cpp
index 3a1333b..b6a8eef 100644
--- a/src/scripttools/debugging/qscriptenginedebugger.cpp
+++ b/src/scripttools/debugging/qscriptenginedebugger.cpp
@@ -86,7 +86,7 @@ public:
To attach the debugger to a script engine, call the attachTo()
function.
- \snippet doc/src/snippets/code/src.scripttools.qscriptenginedebugger.cpp 0
+ \snippet code/src.scripttools.qscriptenginedebugger.cpp 0
Once the debugger has been attached to a script engine, you can
proceed to evaluate scripts as usual, e.g. by calling
@@ -98,7 +98,7 @@ public:
you trigger the action before you begin to \l{QScriptEngine::}{evaluate()}
the script.
- \snippet doc/src/snippets/scriptdebugger.cpp 2
+ \snippet scriptdebugger.cpp 2
By default, the \l{standardWindow()}{standard debugger window} is shown when
evaluation is suspended. This can be changed by calling the
@@ -140,7 +140,7 @@ public:
the function call does not return until the user has finished
interacting with the debugger.
- \snippet doc/src/snippets/code/src.scripttools.qscriptenginedebugger.cpp 1
+ \snippet code/src.scripttools.qscriptenginedebugger.cpp 1
When the Qt Script debugger is running, the C++ application itself
is not "frozen". This means that it is possible that more scripts
@@ -431,7 +431,7 @@ QScriptEngineDebugger::DebuggerState QScriptEngineDebugger::state() const
\l{QScriptEngineDebugger::CodeWidget}{code window} and a
\l{QScriptEngineDebugger::StackWidget}{stack widget}.
- \snippet doc/src/snippets/scriptdebugger.cpp 0
+ \snippet scriptdebugger.cpp 0
Note that you need to set setAutoShowStandardWindow() to false; if
not, the standard window will be shown regardless.
@@ -454,7 +454,7 @@ QWidget *QScriptEngineDebugger::widget(DebuggerWidget widget) const
wish to spice things up with your own groovy icons. The code
example below shows how to add actions to a QToolBar.
- \snippet doc/src/snippets/scriptdebugger.cpp 1
+ \snippet scriptdebugger.cpp 1
Note that QScriptEngineDebugger has already added the actions to
its \l{DebuggerWidget}{standard widgets} and \l{standardWindow()}{standard window}.