本文整理汇总了C++中QScriptValueList::append方法的典型用法代码示例。如果您正苦于以下问题:C++ QScriptValueList::append方法的具体用法?C++ QScriptValueList::append怎么用?C++ QScriptValueList::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScriptValueList
的用法示例。
在下文中一共展示了QScriptValueList::append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleResponse
void QScriptDebuggerScriptedConsoleCommandJob::handleResponse(
const QScriptDebuggerResponse &response,
int commandId)
{
Q_D(QScriptDebuggerScriptedConsoleCommandJob);
// ### generalize
QScriptEngine *engine = d->command->globalObject.engine();
engine->setGlobalObject(d->command->globalObject);
QScriptValueList args;
args.append(qScriptValueFromValue(engine, response));
args.append(QScriptValue(engine, commandId));
QScriptDebuggerConsoleGlobalObject *global;
global = qobject_cast<QScriptDebuggerConsoleGlobalObject*>(d->command->globalObject.toQObject());
Q_ASSERT(global != 0);
global->setScheduler(this);
global->setResponseHandler(this);
global->setMessageHandler(d->messageHandler);
global->setConsole(d->console);
d->commandCount = 0;
QScriptValue ret = d->command->responseFunction.call(QScriptValue(), args);
global->setScheduler(0);
global->setResponseHandler(0);
global->setMessageHandler(0);
global->setConsole(0);
if (ret.isError()) {
qWarning("*** internal error: %s", qPrintable(ret.toString()));
}
if (d->commandCount == 0)
finish();
}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.vendor,代码行数:30,代码来源:qscriptdebuggerscriptedconsolecommand.cpp
示例2: process
void SmsGatewayQuery::process(const QString &number)
{
auto engine = m_smsScriptsManager->engine();
auto jsGatewayQueryObject = engine->evaluate("new GatewayQuery()");
auto jsGetGateway = jsGatewayQueryObject.property("getGateway");
QScriptValueList arguments;
arguments.append(number);
arguments.append(engine->newQObject(this));
jsGetGateway.call(jsGatewayQueryObject, arguments);
}
示例3: start
void QScriptDebuggerScriptedConsoleCommandJob::start()
{
Q_D(QScriptDebuggerScriptedConsoleCommandJob);
QScriptEngine *engine = d->command->globalObject.engine();
engine->setGlobalObject(d->command->globalObject);
QScriptValueList args;
for (int i = 0; i < d->arguments.size(); ++i)
args.append(QScriptValue(engine, d->arguments.at(i)));
QScriptDebuggerConsoleGlobalObject *global;
global = qobject_cast<QScriptDebuggerConsoleGlobalObject*>(engine->globalObject().toQObject());
Q_ASSERT(global != 0);
global->setScheduler(this);
global->setResponseHandler(this);
global->setMessageHandler(d->messageHandler);
global->setConsole(d->console);
d->commandCount = 0;
QScriptValue ret = d->command->execFunction.call(QScriptValue(), args);
global->setScheduler(0);
global->setResponseHandler(0);
global->setMessageHandler(0);
global->setConsole(0);
if (ret.isError()) {
qWarning("*** internal error: %s", qPrintable(ret.toString()));
}
if (d->commandCount == 0)
finish();
}
示例4: processSignIn
void Session::processSignIn(const QString &data) {
try {
switch (m_sessionState) {
case SessionClosed:
break;
case SigningIn: {
QScriptValue processSignIn = m_scriptObject.property("processSignIn");
QScriptValueList args;
args.append(data.trimmed());
processSignIn.call(m_scriptObject, args);
break;
}
case SignedIn: {
CommandEvent event(m_player, data);
event.process();
break;
}
}
ScriptEngine *engine = ScriptEngine::instance();
if (engine->hasUncaughtException()) {
LogUtil::logException("Script Exception: %1\n"
"In Session::processSignIn()", engine->uncaughtException());
}
} catch (GameException &exception) {
LogUtil::logError("Exception in Session::processSignIn(): %1", exception.what());
}
}
示例5: open
void Session::open() {
try {
setSessionState(SigningIn);
ScriptEngine *engine = ScriptEngine::instance();
m_scriptObject = engine->evaluate("new SessionHandler()");
if (engine->hasUncaughtException()) {
LogUtil::logException("Script Exception: %1\n"
"In Session::open()", engine->uncaughtException());
return;
}
QScriptValue setSession = m_scriptObject.property("setSession");
QScriptValueList args;
args.append(engine->toScriptValue(this));
setSession.call(m_scriptObject, args);
if (engine->hasUncaughtException()) {
LogUtil::logException("Script Exception: %1\n"
"In Session::open()", engine->uncaughtException());
}
} catch (GameException &exception) {
LogUtil::logError("Exception in Session::open(): %1", exception.what());
}
}
示例6: extractMentions
QStringList STTwitterText::extractMentions(const QString &text){
QMutexLocker locker(g_processMutex);
QString inText=removeUni6(text).trimmed().normalized(QString::NormalizationForm_C);
QScriptValue caller();
QScriptValueList args;
args.append(inText);
QScriptValue result=g_extractMentionsFunction->call(caller, args);
if(g_engine->hasUncaughtException()){
int line = g_engine->uncaughtExceptionLineNumber();
QByteArray str=g_engine->uncaughtException().toString().toUtf8();
qFatal("Exception while evaluating twttr.txt.extractMentions at line %d: %s", line, str.data());
}
if(result.isUndefined()){
qFatal("Undefined returned by extractMentions");
}
if(!result.isArray()){
qFatal("Non-array object returned by extractMentions");
}
int length=result.property("length").toInteger();
QStringList res;
for(int i=0;i<length;i++){
res<<result.property(i).toString();
}
return res;
}
示例7: doPendingEvaluate
/*!
Executes the pending evaluate, if any.
*/
void QScriptDebuggerBackend::doPendingEvaluate(bool postEvent)
{
Q_D(QScriptDebuggerBackend);
QString program = d->pendingEvaluateProgram;
if (program.isEmpty())
return;
int contextIndex = d->pendingEvaluateContextIndex;
QScriptContext *ctx = context(contextIndex);
Q_ASSERT(ctx != 0);
QString fileName = d->pendingEvaluateFileName;
int lineNumber = d->pendingEvaluateLineNumber;
d->pendingEvaluateProgram = QString();
d->pendingEvaluateFileName = QString();
d->pendingEvaluateLineNumber = -1;
d->pendingEvaluateContextIndex = -1;
// push a new context and initialize its scope chain etc.
{
QScriptContext *evalContext = engine()->pushContext();
QScriptValueList scopeChain = ctx->scopeChain();
if (scopeChain.isEmpty())
scopeChain.append(engine()->globalObject());
while (!scopeChain.isEmpty())
evalContext->pushScope(scopeChain.takeLast());
evalContext->setActivationObject(ctx->activationObject());
evalContext->setThisObject(ctx->thisObject());
}
d->agent->enterContinueMode();
// set a flag so that any exception that happens in
// the evaluate() is not sent to the debugger
d->ignoreExceptions = true;
bool hadException = engine()->hasUncaughtException();
QScriptValue ret = engine()->evaluate(program, fileName, lineNumber);
d->ignoreExceptions = false;
if (!hadException && engine()->hasUncaughtException())
engine()->clearExceptions();
engine()->popContext();
QScriptDebuggerValue retret(ret);
QScriptDebuggerEvent e(QScriptDebuggerEvent::InlineEvalFinished);
e.setScriptValue(retret);
if (!ret.isUndefined())
e.setMessage(ret.toString()); // for convenience -- we always need it
e.setNestedEvaluate(engine()->isEvaluating());
if (postEvent) {
QScriptDebuggerEventEvent *de = new QScriptDebuggerEventEvent(e);
d->postEvent(de);
} else {
event(e);
}
}
示例8: scopeChain
/*!
\internal
\since 4.5
Returns the scope chain of this QScriptContext.
*/
QScriptValueList QScriptContext::scopeChain() const
{
Q_D(const QScriptContext);
// make sure arguments properties are initialized
const QScriptContextPrivate *ctx = d;
while (ctx) {
(void)ctx->activationObject();
ctx = ctx->previous;
}
QScriptValueList result;
QScriptEnginePrivate *eng_p = QScriptEnginePrivate::get(engine());
QScriptValueImpl scope = d->m_scopeChain;
while (scope.isObject()) {
if (scope.classInfo() == eng_p->m_class_with)
result.append(eng_p->toPublic(scope.prototype()));
else
result.append(eng_p->toPublic(scope));
scope = scope.scope();
}
return result;
}
示例9: call
// Check the overhead of the extension "call"
void tst_QScriptClass::call()
{
QScriptEngine eng;
ExtensionScriptClass cls(&eng);
QScriptValue obj = eng.newObject(&cls);
QScriptValue thisObject;
QScriptValueList args;
args.append(123);
QBENCHMARK {
for (int i = 0; i < iterationNumber; ++i)
(void)obj.call(thisObject, args);
}
}
示例10: foreach
QScriptValue& DerivedNetworkValue::getValue() {
if (!_value.isValid() && _baseValue->isLoaded()) {
RootNetworkValue* root = static_cast<RootNetworkValue*>(_baseValue.data());
ScriptCache* cache = root->getProgram()->getCache();
QScriptValue generator = _baseValue->getValue().property(cache->getGeneratorString());
if (generator.isFunction()) {
QScriptValueList arguments;
foreach (const ParameterInfo& parameter, root->getParameterInfo()) {
arguments.append(cache->getEngine()->newVariant(_parameters.value(parameter.name)));
}
_value = generator.call(QScriptValue(), arguments);
} else {
示例11: scopeChain
/*!
\internal
\since 4.5
Returns the scope chain of this QScriptContext.
*/
QScriptValueList QScriptContext::scopeChain() const
{
activationObject(); //ensure the creation of the normal scope for native context
const JSC::CallFrame *frame = QScriptEnginePrivate::frameForContext(this);
QScriptEnginePrivate *engine = QScript::scriptEngineFromExec(frame);
QScript::APIShim shim(engine);
QScriptValueList result;
JSC::ScopeChainNode *node = frame->scopeChain();
JSC::ScopeChainIterator it(node);
for (it = node->begin(); it != node->end(); ++it) {
JSC::JSObject *object = *it;
if (!object)
continue;
if (object->inherits(&QScript::QScriptActivationObject::info)
&& (static_cast<QScript::QScriptActivationObject*>(object)->delegate() != 0)) {
// Return the object that property access is being delegated to
object = static_cast<QScript::QScriptActivationObject*>(object)->delegate();
}
result.append(engine->scriptValueFromJSCValue(object));
}
return result;
}
示例12: lengthOfTweet
int STTwitterText::lengthOfTweet(const QString &text){
QMutexLocker locker(g_processMutex);
//g_engine->globalObject().setProperty("text", );
QString inText=removeUni6(text).trimmed().normalized(QString::NormalizationForm_C);
QScriptValue caller();
QScriptValueList args;
args.append(inText);
QScriptValue result=g_tweetLengthFunction->call(caller, args);
if(g_engine->hasUncaughtException()){
int line = g_engine->uncaughtExceptionLineNumber();
QByteArray str=g_engine->uncaughtException().toString().toUtf8();//result.toString().toUtf8();
qFatal("Exception while evaluating twttr.txt.getTweetLength at line %d: %s", line, str.data());
}
if(result.isUndefined()){
qFatal("Undefined returned by getTweetLength");
}
int vl=result.toInteger();
//qDebug()<<vl;
return vl;
}
示例13: run
void ScriptableWorker::run()
{
if ( hasLogLevel(LogDebug) ) {
bool isEval = m_args.length() == Arguments::Rest + 2
&& m_args.at(Arguments::Rest) == "eval";
for (int i = Arguments::Rest + (isEval ? 1 : 0); i < m_args.length(); ++i) {
QString indent = isEval ? QString("EVAL:")
: (QString::number(i - Arguments::Rest + 1) + " ");
foreach (const QByteArray &line, m_args.at(i).split('\n')) {
SCRIPT_LOG( indent + getTextData(line) );
indent = " ";
}
}
}
bool hasData;
const quintptr id = m_args.at(Arguments::ActionId).toULongLong(&hasData);
QVariantMap data;
if (hasData)
data = Action::data(id);
const QString currentPath = getTextData(m_args.at(Arguments::CurrentPath));
QScriptEngine engine;
ScriptableProxy proxy(m_wnd, data);
Scriptable scriptable(&proxy);
scriptable.initEngine(&engine, currentPath, data);
if (m_socket) {
QObject::connect( proxy.signaler(), SIGNAL(sendMessage(QByteArray,int)),
m_socket, SLOT(sendMessage(QByteArray,int)) );
QObject::connect( &scriptable, SIGNAL(sendMessage(QByteArray,int)),
m_socket, SLOT(sendMessage(QByteArray,int)) );
QObject::connect( m_socket, SIGNAL(messageReceived(QByteArray,int)),
&scriptable, SLOT(setInput(QByteArray)) );
QObject::connect( m_socket, SIGNAL(disconnected()),
&scriptable, SLOT(abort()) );
QObject::connect( &scriptable, SIGNAL(destroyed()),
m_socket, SLOT(deleteAfterDisconnected()) );
if ( m_socket->isClosed() ) {
SCRIPT_LOG("TERMINATED");
return;
}
m_socket->start();
}
QObject::connect( &scriptable, SIGNAL(requestApplicationQuit()),
qApp, SLOT(quit()) );
QByteArray response;
int exitCode;
if ( m_args.length() <= Arguments::Rest ) {
SCRIPT_LOG("Error: bad command syntax");
exitCode = CommandBadSyntax;
} else {
const QString cmd = getTextData( m_args.at(Arguments::Rest) );
#ifdef HAS_TESTS
if ( cmd == "flush" && m_args.length() == Arguments::Rest + 2 ) {
log( "flush ID: " + getTextData(m_args.at(Arguments::Rest + 1)), LogAlways );
scriptable.sendMessageToClient(QByteArray(), CommandFinished);
return;
}
#endif
QScriptValue fn = engine.globalObject().property(cmd);
if ( !fn.isFunction() ) {
SCRIPT_LOG("Error: unknown command");
const QString msg =
Scriptable::tr("Name \"%1\" doesn't refer to a function.").arg(cmd);
response = createLogMessage(msg, LogError).toUtf8();
exitCode = CommandError;
} else {
/* Special arguments:
* "-" read this argument from stdin
* "--" read all following arguments without control sequences
*/
QScriptValueList fnArgs;
bool readRaw = false;
for ( int i = Arguments::Rest + 1; i < m_args.length(); ++i ) {
const QByteArray &arg = m_args.at(i);
if (!readRaw && arg == "--") {
readRaw = true;
} else {
const QScriptValue value = readRaw || arg != "-"
? scriptable.newByteArray(arg)
: scriptable.input();
fnArgs.append(value);
}
}
engine.evaluate(m_pluginScript);
QScriptValue result = fn.call(QScriptValue(), fnArgs);
//.........这里部分代码省略.........
示例14: execute
//.........这里部分代码省略.........
response.setError(QScriptDebuggerResponse::InvalidContextIndex);
} break;
case QScriptDebuggerCommand::GetContextInfo: {
QScriptContext *ctx = backend->context(command.contextIndex());
if (ctx)
response.setResult(QScriptContextInfo(ctx));
else
response.setError(QScriptDebuggerResponse::InvalidContextIndex);
} break;
case QScriptDebuggerCommand::GetThisObject: {
QScriptContext *ctx = backend->context(command.contextIndex());
if (ctx)
response.setResult(ctx->thisObject());
else
response.setError(QScriptDebuggerResponse::InvalidContextIndex);
} break;
case QScriptDebuggerCommand::GetActivationObject: {
QScriptContext *ctx = backend->context(command.contextIndex());
if (ctx)
response.setResult(ctx->activationObject());
else
response.setError(QScriptDebuggerResponse::InvalidContextIndex);
} break;
case QScriptDebuggerCommand::GetScopeChain: {
QScriptContext *ctx = backend->context(command.contextIndex());
if (ctx) {
QScriptDebuggerValueList dest;
QScriptValueList src = ctx->scopeChain();
for (int i = 0; i < src.size(); ++i)
dest.append(src.at(i));
response.setResult(dest);
} else {
response.setError(QScriptDebuggerResponse::InvalidContextIndex);
}
} break;
case QScriptDebuggerCommand::ContextsCheckpoint: {
response.setResult(QVariant::fromValue(backend->contextsCheckpoint()));
} break;
case QScriptDebuggerCommand::GetPropertyExpressionValue: {
QScriptContext *ctx = backend->context(command.contextIndex());
int lineNumber = command.lineNumber();
QVariant attr = command.attribute(QScriptDebuggerCommand::UserAttribute);
QStringList path = attr.toStringList();
if (!ctx || path.isEmpty())
break;
QScriptContextInfo ctxInfo(ctx);
if (ctx->callee().isValid()
&& ((lineNumber < ctxInfo.functionStartLineNumber())
|| (lineNumber > ctxInfo.functionEndLineNumber()))) {
break;
}
QScriptValueList objects;
int pathIndex = 0;
if (path.at(0) == QLatin1String("this")) {
objects.append(ctx->thisObject());
++pathIndex;
} else {
objects << ctx->scopeChain();
}
for (int i = 0; i < objects.size(); ++i) {
示例15: run
void ScriptableWorker::run()
{
MONITOR_LOG("starting");
QScriptEngine engine;
ScriptableProxy proxy(m_wnd);
Scriptable scriptable(&proxy);
scriptable.initEngine( &engine, QString::fromUtf8(m_args.at(Arguments::CurrentPath)),
m_args.at(Arguments::ActionId) );
if (m_socket) {
QObject::connect( &scriptable, SIGNAL(sendMessage(QByteArray,int)),
m_socket, SLOT(sendMessage(QByteArray,int)) );
QObject::connect( m_socket, SIGNAL(messageReceived(QByteArray,int)),
&scriptable, SLOT(setInput(QByteArray)) );
QObject::connect( m_socket, SIGNAL(disconnected()),
&scriptable, SLOT(abort()) );
QObject::connect( &scriptable, SIGNAL(destroyed()),
m_socket, SLOT(deleteAfterDisconnected()) );
if ( m_socket->isClosed() ) {
MONITOR_LOG("terminated");
return;
}
m_socket->start();
}
QObject::connect( &scriptable, SIGNAL(requestApplicationQuit()),
qApp, SLOT(quit()) );
QByteArray response;
int exitCode;
if ( m_args.length() <= Arguments::Rest ) {
MONITOR_LOG("Error: bad command syntax");
exitCode = CommandBadSyntax;
} else {
const QString cmd = QString::fromUtf8( m_args.at(Arguments::Rest) );
if ( hasLogLevel(LogDebug) ) {
MONITOR_LOG("Client arguments:");
for (int i = Arguments::Rest; i < m_args.length(); ++i)
MONITOR_LOG( " " + QString::fromUtf8(m_args.at(i)) );
}
#ifdef HAS_TESTS
if ( cmd == "flush" && m_args.length() == Arguments::Rest + 2 ) {
MONITOR_LOG( "flush ID: " + QString::fromUtf8(m_args.at(Arguments::Rest + 1)) );
scriptable.sendMessageToClient(QByteArray(), CommandFinished);
return;
}
#endif
QScriptValue fn = engine.globalObject().property(cmd);
if ( !fn.isFunction() ) {
MONITOR_LOG("Error: unknown command");
response = createLogMessage("CopyQ client",
Scriptable::tr("Name \"%1\" doesn't refer to a function.")
.arg(cmd),
LogError).toUtf8();
exitCode = CommandError;
} else {
QScriptValueList fnArgs;
for ( int i = Arguments::Rest + 1; i < m_args.length(); ++i )
fnArgs.append( scriptable.newByteArray(m_args.at(i)) );
QScriptValue result = fn.call(QScriptValue(), fnArgs);
if ( engine.hasUncaughtException() ) {
const QString exceptionText = engine.uncaughtException().toString();
MONITOR_LOG( QString("Error: exception in command \"%1\": %2")
.arg(cmd).arg(exceptionText) );
response = createLogMessage("CopyQ client", exceptionText, LogError).toUtf8();
exitCode = CommandError;
} else {
response = serializeScriptValue(result);
exitCode = CommandFinished;
}
}
}
scriptable.sendMessageToClient(response, exitCode);
MONITOR_LOG("finished");
}