00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _QORE_QORETYPE_H
00025
00026 #define _QORE_QORETYPE_H
00027
00028 #include <qore/common.h>
00029 #include <qore/node_types.h>
00030
00031 #include <map>
00032
00033
00034 DLLEXPORT extern QoreListNode *emptyList;
00035 DLLEXPORT extern QoreHashNode *emptyHash;
00036 DLLEXPORT extern QoreStringNode *NullString;
00037 DLLEXPORT extern DateTimeNode *ZeroDate;
00038 DLLEXPORT extern QoreBigIntNode *Zero;
00039
00040 DLLEXPORT extern QoreString NothingTypeString, NullTypeString, TrueString,
00041 FalseString, EmptyHashString, EmptyListString;
00042
00043 class QoreTypeInfo;
00044 DLLEXPORT extern const QoreTypeInfo *anyTypeInfo,
00045 *bigIntTypeInfo,
00046 *floatTypeInfo,
00047 *boolTypeInfo,
00048 *stringTypeInfo,
00049 *binaryTypeInfo,
00050 *dateTypeInfo,
00051 *objectTypeInfo,
00052 *hashTypeInfo,
00053 *listTypeInfo,
00054 *nothingTypeInfo,
00055 *nullTypeInfo,
00056 *runTimeClosureTypeInfo,
00057 *callReferenceTypeInfo,
00058 *referenceTypeInfo,
00059 *userReferenceTypeInfo,
00060 *codeTypeInfo,
00061 *softBigIntTypeInfo,
00062 *softFloatTypeInfo,
00063 *softBoolTypeInfo,
00064 *softStringTypeInfo,
00065 *somethingTypeInfo,
00066 *dataTypeInfo;
00067
00068 DLLEXPORT qore_type_t get_next_type_id();
00069
00070 DLLEXPORT bool compareHard(const AbstractQoreNode *l, const AbstractQoreNode *r, ExceptionSink *xsink);
00071 DLLEXPORT bool compareSoft(const AbstractQoreNode *l, const AbstractQoreNode *r, ExceptionSink *xsink);
00072
00073 static inline AbstractQoreNode *boolean_false() {
00074 return &False;
00075 }
00076
00077 static inline AbstractQoreNode *boolean_true() {
00078 return &True;
00079 }
00080
00081 static inline QoreBigIntNode *zero() {
00082 Zero->ref();
00083 return Zero;
00084 }
00085
00086 static inline QoreFloatNode *zero_float() {
00087 return new QoreFloatNode(0.0);
00088 }
00089
00090 static inline DateTimeNode *zero_date() {
00091 ZeroDate->ref();
00092 return ZeroDate;
00093 }
00094
00095 static inline class QoreStringNode *null_string() {
00096 NullString->ref();
00097 return NullString;
00098 }
00099
00100 static inline QoreListNode *empty_list() {
00101 emptyList->ref();
00102 return emptyList;
00103 }
00104
00105 static inline QoreHashNode *empty_hash() {
00106 emptyHash->ref();
00107 return emptyHash;
00108 }
00109
00111 enum qore_type_result_e {
00112 QTI_IGNORE = -2,
00113 QTI_UNASSIGNED = -1,
00114
00115 QTI_NOT_EQUAL = 0,
00116 QTI_AMBIGUOUS = 1,
00117 QTI_IDENT = 2
00118 };
00119
00121 class ExternalTypeInfo;
00122
00124
00126 class QoreTypeInfoHelper {
00127 friend class ExternalTypeInfo;
00128
00129 protected:
00130 ExternalTypeInfo *typeInfo;
00131
00132 DLLLOCAL QoreTypeInfoHelper(ExternalTypeInfo *n_typeInfo) : typeInfo(n_typeInfo) {
00133 }
00134
00136 DLLEXPORT virtual bool acceptInputImpl(AbstractQoreNode *&n, ExceptionSink *xsink) const;
00137
00138 public:
00140 DLLEXPORT QoreTypeInfoHelper(const char *n_tname);
00142 DLLEXPORT QoreTypeInfoHelper(qore_type_t id, const char *n_tname);
00144 DLLEXPORT virtual ~QoreTypeInfoHelper();
00146 DLLEXPORT const QoreTypeInfo *getTypeInfo() const;
00148 DLLEXPORT void assign(qore_type_t id);
00150 DLLEXPORT void addAcceptsType(const QoreTypeInfo *n_typeInfo);
00152 DLLEXPORT void setInt();
00154 DLLEXPORT void setInexactReturn();
00156 DLLEXPORT void setInputFilter();
00158 DLLEXPORT void setIntMatch();
00159
00160 DLLEXPORT int doAcceptError(bool priv_error, bool obj, int param_num, const char *param_name, AbstractQoreNode *n, ExceptionSink *xsink) const;
00161 };
00162
00164 class AbstractQoreClassTypeInfoHelper : public QoreTypeInfoHelper {
00165 protected:
00166 QoreClass *qc;
00167
00168 public:
00170 DLLEXPORT AbstractQoreClassTypeInfoHelper(const char *name, int n_domain = QDOM_DEFAULT);
00172 DLLEXPORT ~AbstractQoreClassTypeInfoHelper();
00174 DLLEXPORT QoreClass *getClass();
00176 DLLEXPORT bool hasClass() const;
00177 };
00178
00179 DLLEXPORT int testObjectClassAccess(const QoreObject *obj, const QoreClass *classtoaccess);
00180
00181 DLLEXPORT const QoreClass *typeInfoGetUniqueReturnClass(const QoreTypeInfo *typeInfo);
00182 DLLEXPORT bool typeInfoHasType(const QoreTypeInfo *typeInfo);
00183 DLLEXPORT const char *typeInfoGetName(const QoreTypeInfo *typeInfo);
00184 DLLEXPORT qore_type_result_e typeInfoAcceptsType(const QoreTypeInfo *typeInfo, const QoreTypeInfo *otherTypeInfo);
00185 DLLEXPORT qore_type_result_e typeInfoReturnsType(const QoreTypeInfo *typeInfo, const QoreTypeInfo *otherTypeInfo);
00186
00187
00188 #endif // _QORE_QORETYPE_H