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
00028 #ifndef _QORE_QOREOBJECT_H
00029
00030 #define _QORE_QOREOBJECT_H
00031
00032 class AutoVLock;
00033 class VRMutex;
00034 class BuiltinCopy;
00035 class BuiltinDeleteBlocker;
00036 class BuiltinNormalMethodVariantBase;
00037 class BuiltinCopyVariantBase;
00038 class QoreExternalMethodVariant;
00039 class QoreExternalStaticMethodVariant;
00040
00042
00055 class QoreObject : public AbstractQoreNode {
00056 friend struct qore_object_private;
00057 friend class qore_object_lock_handoff_manager;
00058
00059 private:
00061 struct qore_object_private *priv;
00062
00064 DLLLOCAL QoreObject(const QoreObject&);
00065
00067 DLLLOCAL QoreObject& operator=(const QoreObject&);
00068
00069 protected:
00071
00075 DLLEXPORT virtual bool derefImpl(ExceptionSink *xsink);
00076
00078
00080 DLLLOCAL virtual AbstractQoreNode *evalImpl(ExceptionSink *xsink) const;
00081
00083
00085 DLLLOCAL virtual AbstractQoreNode *evalImpl(bool &needs_deref, ExceptionSink *xsink) const;
00086
00088
00090 DLLLOCAL virtual int64 bigIntEvalImpl(ExceptionSink *xsink) const;
00091
00093
00095 DLLLOCAL virtual int integerEvalImpl(ExceptionSink *xsink) const;
00096
00098
00100 DLLLOCAL virtual bool boolEvalImpl(ExceptionSink *xsink) const;
00101
00103
00105 DLLLOCAL virtual double floatEvalImpl(ExceptionSink *xsink) const;
00106
00108 DLLLOCAL void customRefIntern() const;
00109
00111 DLLLOCAL virtual void customRef() const;
00112
00114 DLLLOCAL virtual void customDeref(ExceptionSink *xsink);
00115
00117 DLLLOCAL virtual ~QoreObject();
00118
00119 public:
00121
00125 DLLEXPORT QoreObject(const QoreClass *oc, QoreProgram *p);
00126
00128
00133 DLLEXPORT QoreObject(const QoreClass *oc, QoreProgram *p, AbstractPrivateData *data);
00134
00136
00142 DLLEXPORT virtual int getAsString(QoreString &str, int foff, ExceptionSink *xsink) const;
00143
00145
00152 DLLEXPORT virtual QoreString *getAsString(bool &del, int foff, ExceptionSink *xsink) const;
00153
00155 DLLEXPORT virtual AbstractQoreNode *realCopy() const;
00156
00158
00162 DLLEXPORT virtual bool is_equal_soft(const AbstractQoreNode *v, ExceptionSink *xsink) const;
00163
00165
00169 DLLEXPORT virtual bool is_equal_hard(const AbstractQoreNode *v, ExceptionSink *xsink) const;
00170
00172 DLLEXPORT virtual const char *getTypeName() const;
00173
00175 DLLLOCAL static const char *getStaticTypeName() {
00176 return "object";
00177 }
00178
00180
00183 DLLEXPORT bool validInstanceOf(qore_classid_t cid) const;
00184
00186
00191 DLLEXPORT void setValue(const char *key, AbstractQoreNode *val, ExceptionSink *xsink);
00192
00194
00197 DLLEXPORT QoreListNode *getMemberList(ExceptionSink *xsink) const;
00198
00200
00204 DLLEXPORT void deleteMemberValue(const QoreString *key, ExceptionSink *xsink);
00205
00207
00211 DLLEXPORT void deleteMemberValue(const char *key, ExceptionSink *xsink);
00212
00214
00218 DLLEXPORT void removeMember(const QoreString *key, ExceptionSink *xsink);
00219
00221
00225 DLLEXPORT void removeMember(const char *key, ExceptionSink *xsink);
00226
00228
00233 DLLEXPORT AbstractQoreNode *takeMember(const QoreString *key, ExceptionSink *xsink);
00234
00236
00241 DLLEXPORT AbstractQoreNode *takeMember(const char *key, ExceptionSink *xsink);
00242
00244
00247 DLLEXPORT int size(ExceptionSink *xsink) const;
00248
00250
00254 DLLEXPORT bool compareSoft(const QoreObject *obj, ExceptionSink *xsink) const;
00255
00257
00261 DLLEXPORT bool compareHard(const QoreObject *obj, ExceptionSink *xsink) const;
00262
00264
00269 DLLEXPORT AbstractQoreNode *getReferencedMemberNoMethod(const char *mem, ExceptionSink *xsink) const;
00270
00272
00278 DLLEXPORT int64 getMemberAsBigInt(const char *mem, bool &found, ExceptionSink *xsink) const;
00279
00281
00284 DLLEXPORT QoreHashNode *copyData(ExceptionSink *xsink) const;
00285
00287
00291 DLLEXPORT void mergeDataToHash(QoreHashNode *hash, ExceptionSink *xsink);
00292
00294
00298 DLLEXPORT void setPrivate(qore_classid_t key, AbstractPrivateData *pd);
00299
00301
00305 DLLEXPORT AbstractPrivateData *getReferencedPrivateData(qore_classid_t key, ExceptionSink *xsink) const;
00306
00308
00313 DLLEXPORT AbstractQoreNode *evalMethod(const QoreString *name, const QoreListNode *args, ExceptionSink *xsink);
00314
00316
00321 DLLEXPORT AbstractQoreNode *evalMethod(const char *name, const QoreListNode *args, ExceptionSink *xsink);
00322
00324
00329 DLLEXPORT AbstractQoreNode *evalMethod(const QoreMethod &method, const QoreListNode *args, ExceptionSink *xsink);
00330
00332
00335 DLLEXPORT void doDelete(ExceptionSink *xsink);
00336
00338
00342 DLLEXPORT const QoreClass *getClass(qore_classid_t cid) const;
00343
00345
00352 DLLEXPORT const QoreClass *getClass(qore_classid_t cid, bool &priv) const;
00353
00355
00358 DLLEXPORT const QoreClass *getClass() const;
00359
00361
00364 DLLEXPORT const char *getClassName() const;
00365
00367
00370 DLLEXPORT bool isValid() const;
00371
00373
00376 DLLEXPORT QoreProgram *getProgram() const;
00377
00379
00382 DLLEXPORT bool isSystemObject() const;
00383
00385
00390 DLLEXPORT void tRef() const;
00391
00393
00396 DLLEXPORT void tDeref();
00397
00399
00407 DLLEXPORT AbstractQoreNode *getMemberValueNoMethod(const QoreString *key, AutoVLock *vl, ExceptionSink *xsink) const;
00408
00410
00416 DLLEXPORT AbstractQoreNode *getMemberValueNoMethod(const char *key, AutoVLock *vl, ExceptionSink *xsink) const;
00417
00419
00421 DLLEXPORT void deleteBlockerRef() const;
00422
00424
00428 DLLEXPORT void externalDelete(qore_classid_t key, ExceptionSink *xsink);
00429
00431 DLLEXPORT AbstractQoreNode *evalMethodVariant(const QoreMethod &method, const QoreExternalMethodVariant *variant, const QoreListNode *args, ExceptionSink *xsink);
00432
00433 DLLLOCAL int getStatus() const;
00434
00436
00440 DLLLOCAL AbstractQoreNode *evalMember(const QoreString *member, ExceptionSink *xsink);
00441
00443
00447 DLLLOCAL void merge(const QoreHashNode *h, ExceptionSink *xsink);
00448
00450
00454 DLLLOCAL QoreHashNode *getRuntimeMemberHash(ExceptionSink *xsink) const;
00455
00456 DLLLOCAL class KeyNode *getReferencedPrivateDataNode(qore_classid_t key);
00457
00459
00463 DLLLOCAL AbstractPrivateData *getAndClearPrivateData(qore_classid_t key, ExceptionSink *xsink);
00464
00466
00472 DLLLOCAL AbstractQoreNode *evalBuiltinMethodWithPrivateData(const QoreMethod &method, const BuiltinNormalMethodVariantBase *meth, const QoreListNode *args, ExceptionSink *xsink);
00473
00475 DLLLOCAL void evalCopyMethodWithPrivateData(const QoreClass &thisclass, const BuiltinCopyVariantBase *meth, QoreObject *self, ExceptionSink *xsink);
00476
00478
00482 DLLLOCAL void addPrivateDataToString(QoreString *str, ExceptionSink *xsink) const;
00483
00485
00488 DLLLOCAL void obliterate(ExceptionSink *xsink);
00489
00491
00495 DLLLOCAL void defaultSystemDestructor(qore_classid_t classID, ExceptionSink *xsink);
00496
00498
00506 DLLLOCAL AbstractQoreNode **getMemberValuePtr(const QoreString *key, AutoVLock *vl, const QoreTypeInfo *&typeInfo, ExceptionSink *xsink) const;
00507
00509
00516 DLLLOCAL AbstractQoreNode **getMemberValuePtr(const char *key, AutoVLock *vl, const QoreTypeInfo *&typeInfo, ExceptionSink *xsink) const;
00517
00519
00526 DLLLOCAL AbstractQoreNode **getExistingValuePtr(const QoreString *mem, AutoVLock *vl, ExceptionSink *xsink) const;
00527
00529
00535 DLLLOCAL AbstractQoreNode **getExistingValuePtr(const char *mem, AutoVLock *vl, ExceptionSink *xsink) const;
00536
00537
00538 DLLLOCAL QoreHashNode *getSlice(const QoreListNode *value_list, ExceptionSink *xsink) const;
00539
00541 DLLLOCAL QoreObject(const QoreClass *oc, QoreProgram *p, QoreHashNode *d);
00542
00544 DLLLOCAL bool evalDeleteBlocker(qore_classid_t classid_for_method, BuiltinDeleteBlocker *meth);
00545
00547 DLLLOCAL bool hasMemberNotification() const;
00548
00550 DLLLOCAL void execMemberNotification(const char *member, ExceptionSink *xsink);
00551
00553 DLLLOCAL VRMutex *getClassSyncLock();
00554
00556 DLLLOCAL AbstractQoreNode **getMemberValuePtrForInitialization(const char *member);
00557 };
00558
00560 template <class T>
00561 class PrivateDataRefHolder : public ReferenceHolder<T> {
00562 public:
00563 DLLLOCAL PrivateDataRefHolder(const QoreObject *o, qore_classid_t cid, ExceptionSink *xsink) : ReferenceHolder<T>(reinterpret_cast<T *>(o->getReferencedPrivateData(cid, xsink)), xsink) {
00564 }
00565 };
00566
00567 #endif