[zion] Dynamically check Capability type.
Instead of passing an enum with the capability when creating it, relying on polymorphism and a template struct tag to determine the object type at runtime. This is cleaner and avoids errors where we pass the wrong capability type with the cap and do a bad cast at runtime.
This commit is contained in:
parent
b4902a79ef
commit
a47bac9966
13 changed files with 113 additions and 106 deletions
|
|
@ -6,8 +6,17 @@
|
|||
#include "object/thread.h"
|
||||
#include "usr/zcall_internal.h"
|
||||
|
||||
class Port;
|
||||
|
||||
template <>
|
||||
struct KernelObjectTag<Port> {
|
||||
static const uint64_t type = KernelObject::PORT;
|
||||
};
|
||||
|
||||
class Port : public KernelObject {
|
||||
public:
|
||||
uint64_t TypeTag() override { return KernelObject::PORT; }
|
||||
|
||||
Port();
|
||||
|
||||
z_err_t Write(const ZMessage& msg);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue