source: trunk/doc/src/snippets/code/src_script_qscriptcontext.cpp@ 244

Last change on this file since 244 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

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