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 addVirtualPrivateData(AbstractPrivateData *apd);
00061 DLLLOCAL void doPrivateException(const char *mem, ExceptionSink *xsink) const;
00062
00063 DLLLOCAL bool checkExternalPrivateAccess(const char *mem) const;
00064
00065 DLLLOCAL bool checkExternalPrivateAccess(const char *mem, ExceptionSink *xsink) const;
00066
00068 DLLLOCAL QoreObject(const QoreObject&);
00069
00071 DLLLOCAL QoreObject& operator=(const QoreObject&);
00072
00073 protected:
00075
00079 DLLEXPORT virtual bool derefImpl(ExceptionSink *xsink);
00080
00082
00084 DLLLOCAL virtual AbstractQoreNode *evalImpl(ExceptionSink *xsink) const;
00085
00087
00089 DLLLOCAL virtual AbstractQoreNode *evalImpl(bool &needs_deref, ExceptionSink *xsink) const;
00090
00092
00094 DLLLOCAL virtual int64 bigIntEvalImpl(ExceptionSink *xsink) const;
00095
00097
00099 DLLLOCAL virtual int integerEvalImpl(ExceptionSink *xsink) const;
00100
00102
00104 DLLLOCAL virtual bool boolEvalImpl(ExceptionSink *xsink) const;
00105
00107
00109 DLLLOCAL virtual double floatEvalImpl(ExceptionSink *xsink) const;
00110
00112 DLLLOCAL void customRefIntern() const;
00113
00115 DLLLOCAL virtual void customRef() const;
00116
00118 DLLLOCAL virtual void customDeref(ExceptionSink *xsink);
00119
00121 DLLLOCAL virtual ~QoreObject();
00122
00123 public:
00125
00129 DLLEXPORT QoreObject(const QoreClass *oc, QoreProgram *p);
00130
00132
00137 DLLEXPORT QoreObject(const QoreClass *oc, QoreProgram *p, AbstractPrivateData *data);
00138
00140
00146 DLLEXPORT virtual int getAsString(QoreString &str, int foff, ExceptionSink *xsink) const;
00147
00149
00156 DLLEXPORT virtual QoreString *getAsString(bool &del, int foff, ExceptionSink *xsink) const;
00157
00159 DLLEXPORT virtual AbstractQoreNode *realCopy() const;
00160
00162
00166 DLLEXPORT virtual bool is_equal_soft(const AbstractQoreNode *v, ExceptionSink *xsink) const;
00167
00169
00173 DLLEXPORT virtual bool is_equal_hard(const AbstractQoreNode *v, ExceptionSink *xsink) const;
00174
00176 DLLEXPORT virtual const char *getTypeName() const;
00177
00179 DLLLOCAL static const char *getStaticTypeName() {
00180 return "object";
00181 }
00182
00184
00187 DLLEXPORT bool validInstanceOf(qore_classid_t cid) const;
00188
00190
00195 DLLEXPORT void setValue(const char *key, AbstractQoreNode *val, ExceptionSink *xsink);
00196
00198
00201 DLLEXPORT QoreListNode *getMemberList(ExceptionSink *xsink) const;
00202
00204
00208 DLLEXPORT void deleteMemberValue(const QoreString *key, ExceptionSink *xsink);
00209
00211
00215 DLLEXPORT void deleteMemberValue(const char *key, ExceptionSink *xsink);
00216
00218
00222 DLLEXPORT void removeMember(const QoreString *key, ExceptionSink *xsink);
00223
00225
00229 DLLEXPORT void removeMember(const char *key, ExceptionSink *xsink);
00230
00232
00235 DLLEXPORT int size(ExceptionSink *xsink) const;
00236
00238
00242 DLLEXPORT bool compareSoft(const QoreObject *obj, ExceptionSink *xsink) const;
00243
00245
00249 DLLEXPORT bool compareHard(const QoreObject *obj, ExceptionSink *xsink) const;
00250
00252
00257 DLLEXPORT AbstractQoreNode *getReferencedMemberNoMethod(const char *mem, ExceptionSink *xsink) const;
00258
00260
00266 DLLEXPORT int64 getMemberAsBigInt(const char *mem, bool &found, ExceptionSink *xsink) const;
00267
00269
00272 DLLEXPORT QoreHashNode *copyData(ExceptionSink *xsink) const;
00273
00275
00279 DLLEXPORT void mergeDataToHash(QoreHashNode *hash, ExceptionSink *xsink);
00280
00282
00286 DLLEXPORT void setPrivate(qore_classid_t key, AbstractPrivateData *pd);
00287
00289
00293 DLLEXPORT AbstractPrivateData *getReferencedPrivateData(qore_classid_t key, ExceptionSink *xsink) const;
00294
00296
00301 DLLEXPORT AbstractQoreNode *evalMethod(const QoreString *name, const QoreListNode *args, ExceptionSink *xsink);
00302
00304
00309 DLLEXPORT AbstractQoreNode *evalMethod(const char *name, const QoreListNode *args, ExceptionSink *xsink);
00310
00312
00317 DLLEXPORT AbstractQoreNode *evalMethod(const QoreMethod &method, const QoreListNode *args, ExceptionSink *xsink);
00318
00320
00323 DLLEXPORT void doDelete(ExceptionSink *xsink);
00324
00326
00330 DLLEXPORT const QoreClass *getClass(qore_classid_t cid) const;
00331
00333
00336 DLLEXPORT const QoreClass *getClass() const;
00337
00339
00342 DLLEXPORT const char *getClassName() const;
00343
00345
00348 DLLEXPORT bool isValid() const;
00349
00351
00354 DLLEXPORT QoreProgram *getProgram() const;
00355
00357
00360 DLLEXPORT bool isSystemObject() const;
00361
00363
00368 DLLEXPORT void tRef() const;
00369
00371
00374 DLLEXPORT void tDeref();
00375
00377
00385 DLLEXPORT AbstractQoreNode *getMemberValueNoMethod(const QoreString *key, AutoVLock *vl, ExceptionSink *xsink) const;
00386
00388
00394 DLLEXPORT AbstractQoreNode *getMemberValueNoMethod(const char *key, AutoVLock *vl, ExceptionSink *xsink) const;
00395
00397
00399 DLLEXPORT void deleteBlockerRef() const;
00400
00402
00406 DLLEXPORT void externalDelete(qore_classid_t key, ExceptionSink *xsink);
00407
00408 DLLLOCAL int getStatus() const;
00409
00411
00415 DLLLOCAL AbstractQoreNode *evalMember(const QoreString *member, ExceptionSink *xsink);
00416
00418
00422 DLLLOCAL void merge(const QoreHashNode *h, ExceptionSink *xsink);
00423
00425
00429 DLLLOCAL QoreHashNode *getRuntimeMemberHash(ExceptionSink *xsink) const;
00430
00431 DLLLOCAL class KeyNode *getReferencedPrivateDataNode(qore_classid_t key);
00432
00434
00438 DLLLOCAL AbstractPrivateData *getAndClearPrivateData(qore_classid_t key, ExceptionSink *xsink);
00439
00441
00447 DLLLOCAL AbstractQoreNode *evalBuiltinMethodWithPrivateData(const QoreMethod &method, BuiltinMethod *meth, const QoreListNode *args, ExceptionSink *xsink);
00448
00450
00455 DLLLOCAL AbstractQoreNode *evalBuiltinMethodWithPrivateData(BuiltinMethod *meth, const QoreListNode *args, ExceptionSink *xsink);
00456
00458 DLLLOCAL void evalCopyMethodWithPrivateData(const QoreClass &thisclass, BuiltinMethod *meth, QoreObject *self, bool new_calling_convention, ExceptionSink *xsink);
00459
00461
00465 DLLLOCAL void addPrivateDataToString(QoreString *str, ExceptionSink *xsink) const;
00466
00468
00471 DLLLOCAL void obliterate(ExceptionSink *xsink);
00472
00474
00478 DLLLOCAL void defaultSystemDestructor(qore_classid_t classID, ExceptionSink *xsink);
00479
00481
00488 DLLLOCAL AbstractQoreNode **getMemberValuePtr(const QoreString *key, AutoVLock *vl, ExceptionSink *xsink) const;
00489
00491
00497 DLLLOCAL AbstractQoreNode **getMemberValuePtr(const char *key, AutoVLock *vl, ExceptionSink *xsink) const;
00498
00500
00507 DLLLOCAL AbstractQoreNode **getExistingValuePtr(const QoreString *mem, AutoVLock *vl, ExceptionSink *xsink) const;
00508
00510
00516 DLLLOCAL AbstractQoreNode **getExistingValuePtr(const char *mem, AutoVLock *vl, ExceptionSink *xsink) const;
00517
00518
00519 DLLLOCAL QoreHashNode *getSlice(const QoreListNode *value_list, ExceptionSink *xsink) const;
00520
00522 DLLLOCAL QoreObject(const QoreClass *oc, QoreProgram *p, QoreHashNode *d);
00523
00525 DLLLOCAL bool evalDeleteBlocker(BuiltinMethod *meth);
00526
00528 DLLLOCAL bool hasMemberNotification() const;
00529
00531 DLLLOCAL void execMemberNotification(const char *member, ExceptionSink *xsink);
00532
00534 DLLLOCAL VRMutex *getClassSyncLock();
00535 };
00536
00538 template <class T>
00539 class PrivateDataRefHolder : public ReferenceHolder<T> {
00540 public:
00541 DLLLOCAL PrivateDataRefHolder(const QoreObject *o, qore_classid_t cid, ExceptionSink *xsink) : ReferenceHolder<T>(reinterpret_cast<T *>(o->getReferencedPrivateData(cid, xsink)), xsink) {
00542 }
00543 };
00544
00545
00546 #endif