本文整理汇总了C++中kjs::JSObject::put方法的典型用法代码示例。如果您正苦于以下问题:C++ JSObject::put方法的具体用法?C++ JSObject::put怎么用?C++ JSObject::put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kjs::JSObject
的用法示例。
在下文中一共展示了JSObject::put方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
{
kde = false;
}
#endif
else
{
printUsage(appName);
return 0;
}
}
else
{
if (!script.isEmpty())
scriptArgs.append(KJS::jsString(arg));
else
script = arg;
}
}
}
else
{
printUsage(appName);
return 0;
}
// Setup QApplication
QCoreApplication *app;
#ifndef QT_ONLY
if (kde)
{
KAboutData aboutData( "kjscmd", 0, ki18n("KJSCmd"), "0.2",
ki18n(""
"Utility for running KJSEmbed scripts \n" ),
KAboutData::License_LGPL,
ki18n("(C) 2005-2006 The KJSEmbed Authors") );
KCmdLineOptions options;
options.add("e", ki18n("Execute script without gui support"));
options.add("exec", ki18n("Execute script without gui support"));
options.add("i", ki18n("start interactive kjs interpreter"));
options.add("interactive", ki18n("start interactive kjs interpreter"));
options.add("n", ki18n("start without KDE KApplication support."));
options.add("no-kde", ki18n("start without KDE KApplication support."));
options.add("!+command", ki18n("Script to execute"));
KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.
KCmdLineArgs::init( argc, argv, &aboutData );
app = new KApplication(gui);
}
else
#endif
if (gui)
{
qDebug("no KDE");
app = new QApplication( argc, argv );
dynamic_cast<QApplication*>(app)->connect( app, SIGNAL(lastWindowClosed()), SLOT(quit()) );
}
else
{
qDebug("no GUI");
app = new QCoreApplication(argc, argv);
}
qDebug(" New %s %dms", app->metaObject()->className(), time.elapsed());
app->setApplicationName( appName );
// Setup Interpreter
time.restart();
Engine kernel;
qDebug(" New engine %dms", time.elapsed());
time.restart();
KJS::Interpreter *js = kernel.interpreter();
js->setShouldPrintExceptions(true);
KJS::ExecState *exec = js->globalExec();
// Publish bindings
KJS::JSObject *appObject = kernel.addObject( app, "Application" );
KJS::JSObject *argObject = js->builtinArray()->construct( exec, scriptArgs );
appObject->put( exec, "args", argObject );
Engine::ExitStatus result = Engine::Failure;
if (!script.isEmpty())
{
result = kernel.runFile(toUString(script));
}
else // exec shell
{
result = kernel.runFile( ":/console.js" );
}
if ( result != Engine::Success )
{
KJS::Completion jsres = kernel.completion();
(*KJSEmbed::conerr()) << toQString(jsres.value()->toString(exec)) << endl;
}
return (int)result;
}
示例2: convertEvent
KJS::JSObject *convertEvent(KJS::ExecState *exec, const QDragMoveEvent *ev)
{
KJS::JSObject *mev = convertEvent(exec, (QDropEvent *)ev);
mev->put(exec, "answerRect", convertToValue(exec, ev->answerRect()));
return mev;
}