00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef _QORE_QOREOBJECT_H
00028
00029 #define _QORE_QOREOBJECT_H
00030
00031 class AutoVLock;
00032 class VRMutex;
00033 class BuiltinMethod;
00034
00036
00049 class QoreObject : public AbstractQoreNode {
00050 friend struct qore_object_private;
00051 friend class qore_object_lock_handoff_manager;
00052
00053 private:
00055 struct qore_object_private *priv;
00056
00057
00058 DLLLOCAL void doDeleteIntern(ExceptionSink *xsink);
00059 DLLLOCAL void cleanup(ExceptionSink *xsink, QoreHashNode *td);
00060 DLLLOCAL void doPrivateException(const char *mem, ExceptionSink *xsink) const;
00061
00062 DLLLOCAL bool checkExternalPrivateAccess(const char *mem) const;
00063
00064 DLLLOCAL bool checkExternalPrivateAccess(const char *mem, ExceptionSink *xsink) const;
00065
00067 DLLLOCAL QoreObject(const QoreObject&);
00068
00070 DLLLOCAL QoreObject& operator=(const QoreObject&);
00071
00072 protected:
00074
00078 DLLEXPORT virtual bool derefImpl(ExceptionSink *xsink);
00079
00081
00083 DLLLOCAL virtual AbstractQoreNode *evalImpl(ExceptionSink *xsink) const;
00084
00086
00088 DLLLOCAL virtual AbstractQoreNode *evalImpl(bool &needs_deref, ExceptionSink *xsink) const;
00089
00091
00093 DLLLOCAL virtual int64 bigIntEvalImpl(ExceptionSink *xsink) const;
00094
00096
00098 DLLLOCAL virtual int integerEvalImpl(ExceptionSink *xsink) const;
00099
00101
00103 DLLLOCAL virtual bool boolEvalImpl(ExceptionSink *xsink) const;
00104
00106
00108 DLLLOCAL virtual double floatEvalImpl(ExceptionSink *xsink) const;
00109
00111 DLLLOCAL void customRefIntern() const;
00112
00114 DLLLOCAL virtual void customRef() const;
00115
00117 DLLLOCAL virtual void customDeref(ExceptionSink *xsink);
00118
00120 DLLLOCAL virtual ~QoreObject();
00121
00122 public:
00124
00128 DLLEXPORT QoreObject(const QoreClass *oc, QoreProgram *p);
00129
00131
00136 DLLEXPORT QoreObject(const QoreClass *oc, QoreProgram *p, AbstractPrivateData *data);
00137
00139
00145 DLLEXPORT virtual int getAsString(QoreString &str, int foff, ExceptionSink *xsink) const;
00146
00148
00155 DLLEXPORT virtual QoreString *getAsString(bool &del, int foff, ExceptionSink *xsink) const;
00156
00158 DLLEXPORT virtual AbstractQoreNode *realCopy() const;
00159
00161
00165 DLLEXPORT virtual bool is_equal_soft(const AbstractQoreNode *v, ExceptionSink *xsink) const;
00166
00168
00172 DLLEXPORT virtual bool is_equal_hard(const AbstractQoreNode *v, ExceptionSink *xsink) const;
00173
00175 DLLEXPORT virtual const char *getTypeName() const;
00176
00178 DLLLOCAL static const char *getStaticTypeName() {
00179 return "object";
00180 }
00181
00183
00186 DLLEXPORT bool validInstanceOf(qore_classid_t cid) const;
00187
00189
00194 DLLEXPORT void setValue(const char *key, AbstractQoreNode *val, ExceptionSink *xsink);
00195
00197
00200 DLLEXPORT QoreListNode *getMemberList(ExceptionSink *xsink) const;
00201
00203
00207 DLLEXPORT void deleteMemberValue(const QoreString *key, ExceptionSink *xsink);
00208
00210
00214 DLLEXPORT void deleteMemberValue(const char *key, ExceptionSink *xsink);
00215
00217
00221 DLLEXPORT void removeMember(const QoreString *key, ExceptionSink *xsink);
00222
00224
00228 DLLEXPORT void removeMember(const char *key, ExceptionSink *xsink);
00229
00231
00234 DLLEXPORT int size(ExceptionSink *xsink) const;
00235
00237
00241 DLLEXPORT bool compareSoft(const QoreObject *obj, ExceptionSink *xsink) const;
00242
00244
00248 DLLEXPORT bool compareHard(const QoreObject *obj, ExceptionSink *xsink) const;
00249
00251
00256 DLLEXPORT AbstractQoreNode *getReferencedMemberNoMethod(const char *mem, ExceptionSink *xsink) const;
00257
00259
00265 DLLEXPORT int64 getMemberAsBigInt(const char *mem, bool &found, ExceptionSink *xsink) const;
00266
00268
00271 DLLEXPORT QoreHashNode *copyData(ExceptionSink *xsink) const;
00272
00274
00278 DLLEXPORT void mergeDataToHash(QoreHashNode *hash, ExceptionSink *xsink);
00279
00281
00285 DLLEXPORT void setPrivate(qore_classid_t key, AbstractPrivateData *pd);
00286
00288
00292 DLLEXPORT AbstractPrivateData *getReferencedPrivateData(qore_classid_t key, ExceptionSink *xsink) const;
00293
00295
00300 DLLEXPORT AbstractQoreNode *evalMethod(const QoreString *name, const QoreListNode *args, ExceptionSink *xsink);
00301
00303
00308 DLLEXPORT AbstractQoreNode *evalMethod(const char *name, const QoreListNode *args, ExceptionSink *xsink);
00309
00311
00316 DLLEXPORT AbstractQoreNode *evalMethod(const QoreMethod &method, const QoreListNode *args, ExceptionSink *xsink);
00317
00319
00322 DLLEXPORT void doDelete(ExceptionSink *xsink);
00323
00325
00329 DLLEXPORT const QoreClass *getClass(qore_classid_t cid) const;
00330
00332
00335 DLLEXPORT const QoreClass *getClass() const;
00336
00338
00341 DLLEXPORT const char *getClassName() const;
00342
00344
00347 DLLEXPORT bool isValid() const;
00348
00350
00353 DLLEXPORT QoreProgram *getProgram() const;
00354
00356
00359 DLLEXPORT bool isSystemObject() const;
00360
00362
00367 DLLEXPORT void tRef() const;
00368
00370
00373 DLLEXPORT void tDeref();
00374
00376
00384 DLLEXPORT AbstractQoreNode *getMemberValueNoMethod(const QoreString *key, AutoVLock *vl, ExceptionSink *xsink) const;
00385
00387
00393 DLLEXPORT AbstractQoreNode *getMemberValueNoMethod(const char *key, AutoVLock *vl, ExceptionSink *xsink) const;
00394
00396
00398 DLLEXPORT void deleteBlockerRef() const;
00399
00401
00405 DLLEXPORT void externalDelete(qore_classid_t key, ExceptionSink *xsink);
00406
00407 DLLLOCAL int getStatus() const;
00408
00410
00414 DLLLOCAL AbstractQoreNode *evalMember(const QoreString *member, ExceptionSink *xsink);
00415
00417
00421 DLLLOCAL void merge(const QoreHashNode *h, ExceptionSink *xsink);
00422
00424
00428 DLLLOCAL QoreHashNode *getRuntimeMemberHash(ExceptionSink *xsink) const;
00429
00430 DLLLOCAL class KeyNode *getReferencedPrivateDataNode(qore_classid_t key);
00431
00433
00437 DLLLOCAL AbstractPrivateData *getAndClearPrivateData(qore_classid_t key, ExceptionSink *xsink);
00438
00440
00446 DLLLOCAL AbstractQoreNode *evalBuiltinMethodWithPrivateData(const QoreMethod &method, BuiltinMethod *meth, const QoreListNode *args, ExceptionSink *xsink);
00447
00449
00454 DLLLOCAL AbstractQoreNode *evalBuiltinMethodWithPrivateData(BuiltinMethod *meth, const QoreListNode *args, ExceptionSink *xsink);
00455
00457 DLLLOCAL void evalCopyMethodWithPrivateData(const QoreClass &thisclass, BuiltinMethod *meth, QoreObject *self, bool new_calling_convention, ExceptionSink *xsink);
00458
00460
00464 DLLLOCAL void addPrivateDataToString(QoreString *str, ExceptionSink *xsink) const;
00465
00467
00470 DLLLOCAL void obliterate(ExceptionSink *xsink);
00471
00473
00477 DLLLOCAL void defaultSystemDestructor(qore_classid_t classID, ExceptionSink *xsink);
00478
00480
00487 DLLLOCAL AbstractQoreNode **getMemberValuePtr(const QoreString *key, AutoVLock *vl, ExceptionSink *xsink) const;
00488
00490
00496 DLLLOCAL AbstractQoreNode **getMemberValuePtr(const char *key, AutoVLock *vl, ExceptionSink *xsink) const;
00497
00499
00506 DLLLOCAL AbstractQoreNode **getExistingValuePtr(const QoreString *mem, AutoVLock *vl, ExceptionSink *xsink) const;
00507
00509
00515 DLLLOCAL AbstractQoreNode **getExistingValuePtr(const char *mem, AutoVLock *vl, ExceptionSink *xsink) const;
00516
00517
00518 DLLLOCAL QoreHashNode *getSlice(const QoreListNode *value_list, ExceptionSink *xsink) const;
00519
00521 DLLLOCAL QoreObject(const QoreClass *oc, QoreProgram *p, QoreHashNode *d);
00522
00524 DLLLOCAL bool evalDeleteBlocker(BuiltinMethod *meth);
00525
00527 DLLLOCAL bool hasMemberNotification() const;
00528
00530 DLLLOCAL void execMemberNotification(const char *member, ExceptionSink *xsink);
00531
00533 DLLLOCAL VRMutex *getClassSyncLock();
00534 };
00535
00537 template <class T>
00538 class PrivateDataRefHolder : public ReferenceHolder<T> {
00539 public:
00540 DLLLOCAL PrivateDataRefHolder(const QoreObject *o, qore_classid_t cid, ExceptionSink *xsink) : ReferenceHolder<T>(reinterpret_cast<T *>(o->getReferencedPrivateData(cid, xsink)), xsink) {
00541 }
00542 };
00543
00544
00545 #endif