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_COMMON_H
00025
00026 #define _QORE_COMMON_H
00027
00032 #include <string.h>
00033 #include <strings.h>
00034 #include <stdarg.h>
00035
00036 #include <string>
00037 #include <functional>
00038 #include <list>
00039 #include <set>
00040 #include <vector>
00041 #include <algorithm>
00042 #include <set>
00043
00045 typedef signed short qore_type_t;
00046
00048 typedef unsigned long qore_size_t;
00049
00051 typedef long qore_offset_t;
00052
00054 typedef unsigned qore_classid_t;
00055
00057 typedef std::set<int> int_set_t;
00058
00060 enum qore_license_t { QL_GPL = 0,
00061 QL_LGPL = 1
00062 };
00063
00064 #ifdef _MSC_VER
00065 #ifdef BUILDING_DLL
00066 #define DLLEXPORT __declspec(dllexport)
00067 #else
00068 #define DLLEXPORT __declspec(dllimport)
00069 #endif
00070 #define DLLLOCAL
00071 #else
00072 #ifdef HAVE_GCC_VISIBILITY
00073 #define DLLEXPORT __attribute__ ((visibility("default")))
00074 #define DLLLOCAL __attribute__ ((visibility("hidden")))
00075 #else
00076 #define DLLEXPORT
00077 #define DLLLOCAL
00078 #endif
00079 #endif
00080
00081 #define _Q_MAKE_STRING(x) #x
00082 #define MAKE_STRING_FROM_SYMBOL(x) _Q_MAKE_STRING(x)
00083
00084 class AbstractQoreNode;
00085 class QoreListNode;
00086 class ExceptionSink;
00087 class QoreObject;
00088 class AbstractPrivateData;
00089 class QoreMethod;
00090 class QoreBuiltinMethod;
00091 class QoreClass;
00092 class QoreTypeInfo;
00093
00095 template <typename T> struct free_ptr : std::unary_function <T*, void> {
00096 void operator()(T *ptr) {
00097 free(ptr);
00098 }
00099 };
00100
00102 template <typename T> struct simple_delete {
00103 void operator()(T *ptr) {
00104 delete ptr;
00105 }
00106 };
00107
00109 template <typename T> struct simple_deref {
00110 void operator()(T *ptr) {
00111 ptr->deref();
00112 }
00113 void operator()(T *ptr, ExceptionSink *xsink) {
00114 ptr->deref(xsink);
00115 }
00116 };
00117
00119 class ltstr {
00120 public:
00121 bool operator()(const char* s1, const char* s2) const {
00122 return strcmp(s1, s2) < 0;
00123 }
00124 };
00125
00127 class ltcstrcase {
00128 public:
00129 bool operator()(const char* s1, const char* s2) const {
00130 return strcasecmp(s1, s2) < 0;
00131 }
00132 };
00133
00135 class ltstrcase {
00136 public:
00137 bool operator()(std::string s1, std::string s2) const {
00138 return strcasecmp(s1.c_str(), s2.c_str()) < 0;
00139 }
00140 };
00141
00143 class ltchar {
00144 public:
00145 bool operator()(const char s1, const char s2) const {
00146 return s1 < s2;
00147 }
00148 };
00149
00151 class cstr_vector_t : public std::vector<char *> {
00152 public:
00153 DLLLOCAL ~cstr_vector_t() {
00154 std::for_each(begin(), end(), free_ptr<char>());
00155 }
00156 };
00157
00159 typedef std::vector<const QoreTypeInfo *> type_vec_t;
00160
00162 typedef std::vector<AbstractQoreNode *> arg_vec_t;
00163
00164 typedef long long int64;
00165
00167
00171 typedef AbstractQoreNode *(*q_func_t)(const QoreListNode *args, ExceptionSink *xsink);
00172
00174
00180 typedef AbstractQoreNode *(*q_method_t)(QoreObject *self, AbstractPrivateData *private_data, const QoreListNode *args, ExceptionSink *xsink);
00181
00183
00190 typedef AbstractQoreNode *(*q_method2_t)(const QoreMethod &method, QoreObject *self, AbstractPrivateData *private_data, const QoreListNode *args, ExceptionSink *xsink);
00191
00193
00202 typedef AbstractQoreNode *(*q_method3_t)(const QoreMethod &method, const type_vec_t &typeList, const void *ptr, QoreObject *self, AbstractPrivateData *private_data, const QoreListNode *args, ExceptionSink *xsink);
00203
00205
00210 typedef AbstractQoreNode *(*q_static_method2_t)(const QoreMethod &method, const QoreListNode *args, ExceptionSink *xsink);
00211
00213
00220 typedef AbstractQoreNode *(*q_static_method3_t)(const QoreMethod &method, const type_vec_t &typeList, const void *ptr, const QoreListNode *args, ExceptionSink *xsink);
00221
00223
00227 typedef void (*q_constructor_t)(QoreObject *self, const QoreListNode *args, ExceptionSink *xsink);
00228
00230
00235 typedef void (*q_constructor2_t)(const QoreClass &thisclass, QoreObject *self, const QoreListNode *args, ExceptionSink *xsink);
00236
00238
00245 typedef void (*q_constructor3_t)(const QoreClass &thisclass, const type_vec_t &typeList, const void *ptr, QoreObject *self, const QoreListNode *args, ExceptionSink *xsink);
00246
00248
00255 typedef void (*q_system_constructor_t)(QoreObject *self, int code, va_list args);
00256
00258
00265 typedef void (*q_system_constructor2_t)(const QoreClass &thisclass, QoreObject *self, int code, va_list args);
00266
00268
00273 typedef void (*q_destructor_t)(QoreObject *self, AbstractPrivateData *private_data, ExceptionSink *xsink);
00274
00276
00282 typedef void (*q_destructor2_t)(const QoreClass &thisclass, QoreObject *self, AbstractPrivateData *private_data, ExceptionSink *xsink);
00283
00285
00292 typedef void (*q_destructor3_t)(const QoreClass &thisclass, const void *ptr, QoreObject *self, AbstractPrivateData *private_data, ExceptionSink *xsink);
00293
00295
00301 typedef void (*q_copy_t)(QoreObject *self, QoreObject *old, AbstractPrivateData *private_data, ExceptionSink *xsink);
00302
00304
00311 typedef void (*q_copy2_t)(const QoreClass &thisclass, QoreObject *self, QoreObject *old, AbstractPrivateData *private_data, ExceptionSink *xsink);
00312
00314
00322 typedef void (*q_copy3_t)(const QoreClass &thisclass, const void *ptr, QoreObject *self, QoreObject *old, AbstractPrivateData *private_data, ExceptionSink *xsink);
00323
00325
00330 typedef bool (*q_delete_blocker_t)(QoreObject *self, AbstractPrivateData *private_data);
00331
00332 DLLEXPORT long long q_atoll(const char *str);
00333
00334 #endif // _QORE_COMMON_H