Eneboo - Documentación para desarrolladores
|
00001 /**************************************************************************** 00002 ** $Id: qsmember.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 QSMEMBER_H 00030 #define QSMEMBER_H 00031 00032 #include "qsglobal.h" 00033 #include "../kernel/dlldefs.h" 00034 #include <qstring.h> 00035 #include <qmap.h> 00036 00037 class QSObject; 00038 class QSList; 00039 class QSClass; 00040 class QSFunctionBodyNode; 00041 class QSEnv; 00042 00043 typedef QSObject(*QSMemberFunctionPointer)(QSObject *, const QSEnv *env); 00044 typedef QSObject(*QSFunctionPointer)(QSEnv *env); 00045 typedef void (*QSVoidFunctionPointer)(QSEnv *env); 00046 00047 class QUICKCORE_EXPORT QSMember 00048 { 00049 public: 00050 enum Type { Undefined, 00051 Variable, 00052 Object, 00053 Identifier, 00054 Class, 00055 Custom, 00056 NativeFunction, 00057 NativeMemberFunction, 00058 NativeVoidFunction, 00059 ScriptFunction 00060 }; 00061 00062 QSMember(Type t = Undefined, int a = AttributeNone) 00063 : typ(t), attrs(a), own(0), super_(0) { } 00064 00065 QSMember(Type t, int i, int a) 00066 : typ(t), attrs(a), own(0), idx(i), super_(0) { } 00067 00068 QSMember(QSFunctionPointer fptr, 00069 int a = AttributeNonWritable) 00070 : typ(NativeFunction), attrs(a | AttributeExecutable), own(0), 00071 nativeFunction(fptr), super_(0) { } 00072 00073 QSMember(QSMemberFunctionPointer fptr, int a = AttributeNonWritable) 00074 : typ(NativeMemberFunction), attrs(a | AttributeExecutable), 00075 own(0), nativeMemberFunction(fptr), super_(0) { } 00076 00077 QSMember(QSVoidFunctionPointer fptr, int a = AttributeNonWritable) 00078 : typ(NativeVoidFunction), attrs(a | AttributeExecutable), 00079 own(0), nativeVoidFunction(fptr), super_(0) { } 00080 00081 QSMember(QSFunctionBodyNode *f, int a = AttributeNonWritable) 00082 : typ(ScriptFunction), attrs(a | AttributeExecutable), own(0), 00083 scriptFunction(f), super_(0) { } 00084 00085 // ### AbanQ 00086 ~QSMember(); 00087 // ### AbanQ 00088 00089 Type type() const { 00090 return typ; 00091 } 00092 void setType(Type t) { 00093 typ = t; 00094 } 00095 QString typeName() const; 00096 00097 int attributes() const { 00098 return attrs; 00099 } 00100 bool hasAttribute(QSAttribute a) const { 00101 return attrs & a; 00102 } 00103 bool isStatic() const { 00104 return attrs & AttributeStatic; 00105 } 00106 00107 bool isDefined() const { 00108 return typ != Undefined; 00109 } 00110 00111 bool isExecutable() const { 00112 return attrs & AttributeExecutable; 00113 } 00114 bool isReadable() const { 00115 return !(attrs & AttributeNonReadable); 00116 } 00117 bool isWritable() const { 00118 return !(attrs & AttributeNonWritable); 00119 } 00120 bool isEnumberable() const { 00121 return attrs & AttributeEnumerable; 00122 } 00123 bool isPrivate() const { 00124 return attrs & AttributePrivate; 00125 } 00126 00127 bool isMemberOf(const QSClass *c) const { 00128 return c == own; 00129 } 00130 00131 void setExecutable(bool exec) { 00132 attrs = exec ? attrs | AttributeExecutable : attrs&~AttributeExecutable; 00133 } 00134 void setReadable(bool read) { 00135 attrs = read ? attrs&~AttributeNonReadable : 00136 attrs | AttributeNonReadable; 00137 } 00138 void setWritable(bool write) { 00139 attrs = write ? attrs&~AttributeNonWritable : 00140 attrs | AttributeNonWritable; 00141 } 00142 void setPrivate(bool priv) { 00143 attrs = priv ? attrs | AttributePrivate : 00144 attrs&~AttributePrivate; 00145 } 00146 void setStatic(bool stat) { 00147 attrs = stat ? attrs | AttributeStatic : 00148 attrs&~AttributeStatic; 00149 } 00150 00151 int index() const { 00152 return idx; 00153 } 00154 void setIndex(int i) { 00155 idx = i; 00156 } 00157 00158 QString name() const { 00159 return str; 00160 } 00161 void setName(const QString &n) { 00162 str = n; 00163 } 00164 00165 const QSClass *owner() const { 00166 return own; 00167 } 00168 void setOwner(const QSClass *cl) { 00169 own = cl; 00170 } 00171 00172 // ### AbanQ 00173 void setSuper(QSMember *super); 00174 QSMember *super() const { 00175 return super_; 00176 } 00177 00178 QSMember(const QSMember &other) 00179 : super_(0) { 00180 copy(other); 00181 } 00182 00183 QSMember &operator=(const QSMember &other) { 00184 copy(other); 00185 return *this; 00186 } 00187 // ### AbanQ 00188 00189 private: 00190 Type typ; 00191 int attrs; 00192 const QSClass *own; 00193 QString str; 00194 00195 // ### AbanQ 00196 QSMember *super_; 00197 00198 void copy(const QSMember &other) { 00199 typ = other.typ; 00200 attrs = other.attrs; 00201 own = other.own; 00202 str = other.str; 00203 setSuper(other.super_); 00204 idx = other.idx; 00205 scriptFunction = other.scriptFunction; 00206 nativeFunction = other.nativeFunction; 00207 nativeMemberFunction = other.nativeMemberFunction; 00208 nativeVoidFunction = other.nativeVoidFunction; 00209 obj = other.obj; 00210 } 00211 // ### AbanQ 00212 00213 public: 00214 // ### make private 00215 union { 00216 int idx; 00217 QSFunctionBodyNode *scriptFunction; 00218 QSFunctionPointer nativeFunction; 00219 QSMemberFunctionPointer nativeMemberFunction; 00220 QSVoidFunctionPointer nativeVoidFunction; 00221 QSObject *obj; 00222 }; 00223 }; 00224 00225 typedef QMap<QString, QSMember> QSMemberMap; 00226 00227 QString operator+(const QString &a, const QSMember &b); 00228 bool operator==(const QSMember &a, const QSMember &b); 00229 00230 #endif