blob: a2f18158620bdaa6cf594fc8bb2b1f75583b82e1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
//! [0]
foo(20.5, "hello", new Object())
//! [0]
//! [1]
QScriptValue Person_prototype_fullName(QScriptContext *context, QScriptEngine *engine)
{
QScriptValue self = context->thisObject();
QString result;
result += self.property("firstName").toString();
result += QLatin1String(" ");
result += self.property("lastName").toString();
return result;
}
//! [1]
//! [2]
QScriptValue myInclude(QScriptContext *ctx, QScriptEngine *eng)
{
QString fileName = ctx->argument(0).toString();
QString contents = readTheFile(fileName);
ctx->setActivationObject(ctx->parentContext()->activationObject());
ctx->setThisObject(ctx->parentContext()->thisObject());
return eng->evaluate(contents, fileName);
}
//! [2]
|