25 #include <QtCore/QCoreApplication>
26 #include <QtCore/QFile>
27 #include <QtGui/QMessageBox>
28 #include <QtCore/QTextStream>
29 #include <QtCore/QDebug>
30 #include <QtCore/QMetaType>
33 #include <kstandarddirs.h>
42 using namespace KJSEmbed;
49 return KJS::jsBoolean( QCoreApplication::exec() );
57 KJS::JSObject *
object = args[0]->toObject(exec);
68 KJS::UString filename = args[0]->toString(exec);
69 qDebug() <<
"include: " <<
toQString(filename);
71 KJS::Completion c =
Engine::runFile( exec->dynamicInterpreter(), filename );
73 if ( c.complType() == KJS::Normal )
76 if (c.complType() == KJS::ReturnValue)
78 if (c.isValueCompletion())
84 if (c.complType() == KJS::Throw)
87 int line = c.value()->toObject(exec)->get(exec,
"line")->toUInt32(exec);
89 toUString(i18n(
"Error encountered while processing include '%1' line %2: %3",
toQString(filename), line, message)));
95 toUString(i18n(
"include only takes 1 argument, not %1.", args.size())));
106 if( args.size() == 1)
108 KJS::UString filename = args[0]->toString(exec);
109 QString qualifiedFilename = KStandardDirs::locate(
"scripts",
toQString(filename) );
110 if ( !qualifiedFilename.isEmpty() )
113 if ( c.complType() == KJS::Normal )
114 return KJS::jsNull();
116 if (c.complType() == KJS::ReturnValue)
118 if (c.isValueCompletion())
121 return KJS::jsNull();
124 if (c.complType() == KJS::Throw)
127 int line = c.value()->toObject(exec)->get(exec,
"line")->toUInt32(exec);
129 toUString(i18n(
"Error encountered while processing include '%1' line %2: %3",
toQString(filename), line, message)));
133 QString msg = i18n(
"File %1 not found.",
toQString(filename) );
139 toUString(i18n(
"library only takes 1 argument, not %1.", args.size())));
142 return KJS::jsNull();
150 if (args.size() == 1)
154 QMessageBox::warning(0, i18n(
"Alert"), message, QMessageBox::Ok, QMessageBox::NoButton);
156 return KJS::jsNull();
162 if (args.size() == 1)
165 int result = QMessageBox::question (0, i18n(
"Confirm"), message, QMessageBox::Yes, QMessageBox::No);
166 if (result == QMessageBox::Yes)
167 return KJS::jsBoolean(
true);
169 return KJS::jsBoolean(
false);
175 if (args.size() == 1)
177 QString thetypename =
toQString(args[0]->toString(exec));
178 return KJS::jsBoolean( QMetaType::type( thetypename.toLatin1().data() ) );
180 return KJS::jsBoolean(
false);
186 if (args.size() == 1)
188 KJS::JSObject *obj = args[0]->toObject(exec);
191 return KJS::jsBoolean(
true);
194 return KJS::jsBoolean(
false);
200 if (args.size() == 1)
202 KJS::JSObject *obj = args[0]->toObject(exec);
205 return KJS::jsBoolean(
true);
208 return KJS::jsBoolean(
false);
213 {
"exec", 0, KJS::DontDelete|KJS::ReadOnly, &
callExec},
214 {
"dump", 1, KJS::DontDelete|KJS::ReadOnly, &
callDump},
215 {
"include", 1, KJS::DontDelete|KJS::ReadOnly, &
callInclude},
217 {
"library", 1, KJS::DontDelete|KJS::ReadOnly, &
callLibrary},
219 {
"alert", 1, KJS::DontDelete|KJS::ReadOnly, &
callAlert},
220 {
"confirm", 1, KJS::DontDelete|KJS::ReadOnly, &
callConfirm},
222 {
"isVariant", 1, KJS::DontDelete|KJS::ReadOnly, &
callIsVariant},
223 {
"isObject", 1, KJS::DontDelete|KJS::ReadOnly, &
callIsObject},