Eneboo - Documentación para desarrolladores
|
00001 /**************************************************************************** 00002 ** $Id: qsengine.h 1.1.5 edited 2006-02-23T15:39:57$ 00003 ** 00004 ** Copyright (C) 2001-2006 Trolltech AS. All rights reserved. 00005 ** 00006 ** This file is part of the Qt Script for Applications framework (QSA). 00007 ** 00008 ** This file may be distributed and/or modified under the terms of the 00009 ** GNU General Public License version 2 as published by the Free Software 00010 ** Foundation and appearing in the file LICENSE.GPL included in the 00011 ** packaging of this file. 00012 ** 00013 ** Licensees holding a valid Qt Script for Applications license may use 00014 ** this file in accordance with the Qt Script for Applications License 00015 ** Agreement provided with the Software. 00016 ** 00017 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00018 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00019 ** 00020 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 00021 ** information about QSA Commercial License Agreements. 00022 ** See http://www.trolltech.com/gpl/ for GPL licensing information. 00023 ** 00024 ** Contact info@trolltech.com if any conditions of this licensing are 00025 ** not clear to you. 00026 ** 00027 *****************************************************************************/ 00028 00029 #ifndef QSENGINE_H 00030 #define QSENGINE_H 00031 00032 #include "qsobject.h" 00033 #include "qstimeouttrigger.h" 00034 #include <qstringlist.h> 00035 #include <qvaluelist.h> 00036 #include <qobject.h> 00037 00038 class QSList; 00039 00040 class Global; 00041 #ifdef QSDEBUGGER 00042 class Debugger; 00043 #endif 00044 00048 class QUICKCORE_EXPORT QSEngine : public QObject 00049 { 00050 friend class QSEngineImp; 00051 friend class QSObject; 00052 friend class Global; 00053 Q_OBJECT 00054 public: 00055 enum CheckMode { 00056 CheckNormal = 0, 00057 DisallowGlobal 00058 }; 00059 00064 QSEngine(QObject *parent = 0, const char *name = 0); 00068 virtual ~QSEngine(); 00073 void init(); 00077 int recursion() const; 00086 bool evaluate(const char *code); 00093 bool evaluate(const QSObject &thisV, const QString &code, int linezero = 0); 00099 bool evaluate(const QString &code); 00105 bool call(const QString &func, const QSList &args); 00106 bool call(QSObject *scope, const QString &func, const QSList &args); 00112 void clear(); 00117 QSObject returnValue() const; 00118 00119 void setReturnValue(const QSObject &v); 00120 00124 int errorType() const; 00128 QValueList<uint> errorLines() const; 00133 QStringList errorMessages() const; 00139 bool checkSyntax(const QString &code, int checkMode = DisallowGlobal, 00140 bool deleteNodes = TRUE); 00147 void enableDebug(); 00148 00149 QSEnv *env() const; 00150 #ifdef QSDEBUGGER 00151 Debugger *debugger() const; 00152 #endif 00153 00154 void registerType(QSClass *c); 00155 00156 void warn(const QString &msg, int l); 00157 void requestPackage(const QString &package, QString &err); 00158 00159 void setTimeoutTriggerEnabled(bool enable); 00160 QSTimeoutTrigger *timeoutTrigger() const { 00161 return timer; 00162 } 00163 00164 signals: 00168 void warning(const QString &msg, int l); 00175 void packageRequest(const QString &package, QString &err); 00176 00177 public: 00178 // ### ugly 00179 QSEngineImp *imp() const { 00180 return rep; 00181 } 00182 00183 private: 00184 QSEngineImp *rep; 00185 // not implemented 00186 QSEngine(const QSEngine &); 00187 QSEngine operator=(const QSEngine &); 00188 QSTimeoutTrigger *timer; 00189 00190 #ifdef QSDEBUGGER 00191 friend class Debugger; 00192 #endif 00193 }; 00194 00195 inline void QSEngine::setTimeoutTriggerEnabled(bool enable) 00196 { 00197 if (enable && !timer) { 00198 timer = new QSTimeoutTrigger; 00199 } else if (!enable && timer) { 00200 delete timer; 00201 timer = 0; 00202 } 00203 } 00204 00205 #endif