meso: use macro to refactor auto obj declaration

This commit is contained in:
TuxSH 2018-11-11 15:59:27 +01:00 committed by Michael Scire
parent 86c43331eb
commit eb7e4153d1
11 changed files with 31 additions and 121 deletions

View File

@ -12,47 +12,29 @@ virtual ushort GetClassToken() const\
return KAutoObject::GenerateClassToken<K##DerivedId >();\
}\
#define MESOSPHERE_AUTO_OBJECT_FW_DECL(BaseId)\
class K##BaseId;\
void intrusive_ptr_add_ref(K##BaseId *obj);\
void intrusive_ptr_release(K##BaseId *obj);
#define MESOSPHERE_AUTO_OBJECT_DEFINE_INCREF(BaseId)\
inline void intrusive_ptr_add_ref(K##BaseId *obj) { intrusive_ptr_add_ref((KAutoObject *)obj); }\
inline void intrusive_ptr_release(K##BaseId *obj) { intrusive_ptr_release((KAutoObject *)obj); }
namespace mesosphere
{
// Foward declarations for intrusive_ptr
class KProcess;
class KResourceLimit;
class KThread;
class KEvent;
class KReadableEvent;
class KWritableEvent;
class KInterruptEvent;
class KBaseSession;
class KBaseClientSession;
class KBaseServerSession;
void intrusive_ptr_add_ref(KProcess *obj);
void intrusive_ptr_release(KProcess *obj);
void intrusive_ptr_add_ref(KResourceLimit *obj);
void intrusive_ptr_release(KResourceLimit *obj);
void intrusive_ptr_add_ref(KEvent *obj);
void intrusive_ptr_release(KEvent *obj);
void intrusive_ptr_add_ref(KReadableEvent *obj);
void intrusive_ptr_release(KReadableEvent *obj);
void intrusive_ptr_add_ref(KWritableEvent *obj);
void intrusive_ptr_release(KWritableEvent *obj);
void intrusive_ptr_add_ref(KInterruptEvent *obj);
void intrusive_ptr_release(KInterruptEvent *obj);
void intrusive_ptr_add_ref(KBaseSession *obj);
void intrusive_ptr_release(KBaseSession *obj);
void intrusive_ptr_add_ref(KBaseClientSession *obj);
void intrusive_ptr_release(KBaseClientSession *obj);
void intrusive_ptr_add_ref(KBaseClientSession *obj);
void intrusive_ptr_release(KBaseServerSession *obj);
MESOSPHERE_AUTO_OBJECT_FW_DECL(Process);
MESOSPHERE_AUTO_OBJECT_FW_DECL(ResourceLimit);
MESOSPHERE_AUTO_OBJECT_FW_DECL(Thread);
MESOSPHERE_AUTO_OBJECT_FW_DECL(Event);
MESOSPHERE_AUTO_OBJECT_FW_DECL(ReadableEvent);
MESOSPHERE_AUTO_OBJECT_FW_DECL(WritableEvent);
MESOSPHERE_AUTO_OBJECT_FW_DECL(InterruptEvent);
MESOSPHERE_AUTO_OBJECT_FW_DECL(BaseSession);
MESOSPHERE_AUTO_OBJECT_FW_DECL(BaseClientSession);
MESOSPHERE_AUTO_OBJECT_FW_DECL(BaseServerSession);
class KAutoObject {
public:

View File

@ -23,4 +23,6 @@ class KSynchronizationObject : public KAutoObject {
KLinkedList<KThread *> waiters{};
};
MESOSPHERE_AUTO_OBJECT_DEFINE_INCREF(SynchronizationObject);
}

View File

@ -5,10 +5,7 @@
namespace mesosphere
{
class KThread;
class KEvent;
class KTransferMemory;
class KSession;
class KResourceLimit final :
public KAutoObject,
@ -71,13 +68,6 @@ class KResourceLimit final :
mutable KConditionVariable condvar{};
};
inline void intrusive_ptr_add_ref(KResourceLimit *obj)
{
intrusive_ptr_add_ref((KAutoObject *)obj);
}
MESOSPHERE_AUTO_OBJECT_DEFINE_INCREF(ResourceLimit);
inline void intrusive_ptr_release(KResourceLimit *obj)
{
intrusive_ptr_add_ref((KAutoObject *)obj);
}
}

View File

@ -32,14 +32,6 @@ class KBaseClientSession : public KAutoObject, public IClient<KBaseSession, KBas
KClientPort *parentPort = nullptr;
};
inline void intrusive_ptr_add_ref(KBaseClientSession *obj)
{
intrusive_ptr_add_ref((KAutoObject *)obj);
}
inline void intrusive_ptr_release(KBaseClientSession *obj)
{
intrusive_ptr_release((KAutoObject *)obj);
}
MESOSPHERE_AUTO_OBJECT_DEFINE_INCREF(BaseClientSession);
}

View File

@ -45,14 +45,6 @@ class KBaseServerSession :
KBaseServerSession() = default;
};
inline void intrusive_ptr_add_ref(KBaseServerSession *obj)
{
intrusive_ptr_add_ref((KAutoObject *)obj);
}
inline void intrusive_ptr_release(KBaseServerSession *obj)
{
intrusive_ptr_release((KAutoObject *)obj);
}
MESOSPHERE_AUTO_OBJECT_DEFINE_INCREF(BaseServerSession);
}

View File

@ -26,14 +26,6 @@ class KBaseSession : public KAutoObject, public IClientServerParent<KBaseSession
KBaseSession() = default;
};
inline void intrusive_ptr_add_ref(KBaseSession *obj)
{
intrusive_ptr_add_ref((KAutoObject *)obj);
}
inline void intrusive_ptr_release(KBaseSession *obj)
{
intrusive_ptr_release((KAutoObject *)obj);
}
MESOSPHERE_AUTO_OBJECT_DEFINE_INCREF(BaseSession);
}

View File

@ -29,14 +29,6 @@ class KEvent final :
private:
};
inline void intrusive_ptr_add_ref(KEvent *obj)
{
intrusive_ptr_add_ref((KAutoObject *)obj);
}
inline void intrusive_ptr_release(KEvent *obj)
{
intrusive_ptr_release((KAutoObject *)obj);
}
MESOSPHERE_AUTO_OBJECT_DEFINE_INCREF(Event);
}

View File

@ -33,14 +33,6 @@ class KProcess final : public KAutoObject {
KHandleTable handleTable{};
};
inline void intrusive_ptr_add_ref(KProcess *obj)
{
intrusive_ptr_add_ref((KAutoObject *)obj);
}
inline void intrusive_ptr_release(KProcess *obj)
{
intrusive_ptr_release((KAutoObject *)obj);
}
MESOSPHERE_AUTO_OBJECT_DEFINE_INCREF(Process);
}

View File

@ -29,14 +29,6 @@ class KReadableEvent : public KSynchronizationObject, public IClient<KEvent, KRe
bool isSignaled = false;
};
inline void intrusive_ptr_add_ref(KReadableEvent *obj)
{
intrusive_ptr_add_ref((KAutoObject *)obj);
}
inline void intrusive_ptr_release(KReadableEvent *obj)
{
intrusive_ptr_release((KAutoObject *)obj);
}
MESOSPHERE_AUTO_OBJECT_DEFINE_INCREF(ReadableEvent);
}

View File

@ -28,14 +28,6 @@ class KWritableEvent final : public KAutoObject, public IServer<KEvent, KReadabl
SharedPtr<KReadableEvent> client{};
};
inline void intrusive_ptr_add_ref(KWritableEvent *obj)
{
intrusive_ptr_add_ref((KAutoObject *)obj);
}
inline void intrusive_ptr_release(KWritableEvent *obj)
{
intrusive_ptr_release((KAutoObject *)obj);
}
MESOSPHERE_AUTO_OBJECT_DEFINE_INCREF(WritableEvent);
}

View File

@ -309,14 +309,6 @@ private:
u64 lastScheduledTime = 0;
};
inline void intrusive_ptr_add_ref(KThread *obj)
{
intrusive_ptr_add_ref((KAutoObject *)obj);
}
inline void intrusive_ptr_release(KThread *obj)
{
intrusive_ptr_release((KAutoObject *)obj);
}
MESOSPHERE_AUTO_OBJECT_DEFINE_INCREF(Thread);
}