summaryrefslogtreecommitdiff
path: root/src/script/api
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 /src/script/api
parentf6fdd296d47e1ce44c07aab81098c20a5260f7fd (diff)
downloadqtscript-4629dc71525a638c0bae89ad67990a1ff14ea9c4.tar.gz
Doc: Modularize QtScript documentation.
Change-Id: I042d9bafe4f48a8cd23306f0864b6872776d0153 Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
Diffstat (limited to 'src/script/api')
-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
7 files changed, 43 insertions, 43 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()
*/