Eneboo - Documentación para desarrolladores
src/qsa/src/editor/qsacompletion.h
Ir a la documentación de este archivo.
00001 /****************************************************************************
00002 ** $Id: qsacompletion.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 QSACOMPLETION_H
00030 #define QSACOMPLETION_H
00031 
00032 #include "quickobjects.h"
00033 
00034 #include <private/qcom_p.h>
00035 #include <private/qucom_p.h>
00036 #include <private/qucomextra_p.h>
00037 
00038 #include <completion.h>
00039 
00040 class QSInterpreter;
00041 class QuickInterpreter;
00042 class QSEnv;
00043 
00044 struct QSCompletionObject {
00045   // this should be an anonymous union, but doesn't work as you
00046   // can't have objects with a constructor in an union
00047   QSObject qsobj;
00048   const QMetaObject *meta;
00049   QPtrVector<QObject> qobj;
00050 
00051   enum Type { TQSObject, TQMetaObject, TQObject, TNull } type;
00052 
00053   QSCompletionObject(const QSObject &o)
00054     : qsobj(o), type(TQSObject) {}
00055   QSCompletionObject(const QMetaObject *m)
00056     : meta(m), type(TQMetaObject) {}
00057   QSCompletionObject(const QPtrVector<QObject> &o)
00058     : qobj(o), type(TQObject) {}
00059   QSCompletionObject()
00060     : type(TNull) {}
00061 
00062   QSCompletionObject &operator=(const QSObject &o) {
00063     qsobj = o;
00064     type = TQSObject;
00065     return *this;
00066   }
00067   QSCompletionObject &operator=(const QMetaObject *m) {
00068     meta = m;
00069     type = TQMetaObject;
00070     return *this;
00071   }
00072   QSCompletionObject &operator=(const QPtrVector<QObject> &o) {
00073     qobj = o;
00074     type = TQObject;
00075     return *this;
00076   }
00077 
00078   void resolve();
00079   bool isNull() const;
00080 };
00081 
00082 class QSACompletion : public EditorCompletion
00083 {
00084   Q_OBJECT
00085 
00086 public:
00087   QSACompletion(Editor *e);
00088 
00089   bool doObjectCompletion(const QString &object);
00090   QValueList<QStringList> functionParameters(const QString &func, QChar &, QString &prefix, QString &postfix);
00091   void setContext(QObject *this_);
00092 
00093   void setInterpreter(QSInterpreter *ip) {
00094     qsInterp = ip;
00095   }
00096 
00097 private:
00098   QString functionCode() const;
00099 
00100   QValueList<QPair<QString, QString> > parseAssignments(const QString &code) const;
00101   QString resolveValue(const QString &value, const QValueList<QPair<QString, QString> > &assignments) const;
00102   QString resolveFullyQualifiedValue(const QString &value, const QValueList<QPair<QString, QString> > &assignments) const;
00103 
00104   QSCompletionObject queryObject(const QString &object);
00105   QSCompletionObject queryCompletionObject(QSCompletionObject &ctx, const QString &property) const;
00106   QSObject queryQSObject(QSObject &ctx, const QString &property) const;
00107   QSObject queryQSObject(const QMetaObject *meta, const QString &property, bool includeSuperClass) const;
00108   QSObject queryQSObject(const QPtrVector<QObject> &objects, const QString &property) const;
00109   const QMetaObject *queryQMetaObject(const QMetaObject *meta, const QString &property, bool includeSuperClass) const;
00110   const QMetaObject *queryQMetaObject(const QPtrVector<QObject> &objects, const QString &property) const;
00111   QPtrVector<QObject> queryQObject(const QPtrVector<QObject> &objects, const QString &property) const;
00112 
00113   void completeQSObject(QSObject &obj, QValueList<CompletionEntry> &res, bool assumedStatic);
00114   enum QSMetaObjectCompletionFlags { IncludeSuperClass = 1, IsUnnamed = 2 };
00115   void completeQMetaObject(const QMetaObject *meta,
00116                            const QString &object,
00117                            QValueList<CompletionEntry> &res,
00118                            int flags,
00119                            QSObject &obj);
00120   void completeQObject(const QPtrVector<QObject> &objects,
00121                        const QString &object,
00122                        QValueList<CompletionEntry> &res);
00123 
00124   QString cppClassForScript(const QString &className) const;
00125   const QMetaObject *locateMetaObject(const QString &className) const;
00126 
00127 private:
00128   QSEnv *env() const;
00129   QuickInterpreter *interpreter() const;
00130 
00131   QPtrVector<QObject>* interfaceObjects(const QSObject &o) const;
00132   QSObject vTypeToQSType(const QString &type) const;
00133   QSObject uTypeToQSType(QUType *t, const char *extra) const;
00134 
00135   QObject *thisObject;
00136   QuickInterpreter *interp;
00137   QSInterpreter *qsInterp;
00138 };
00139 
00140 #endif
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'