acadia/zion/capability/capability.cpp

53 lines
1.2 KiB
C++
Raw Normal View History

2023-06-06 16:24:03 -07:00
#include "capability/capability.h"
#include "object/process.h"
#include "object/thread.h"
2023-06-06 16:24:03 -07:00
template <>
RefPtr<Process> Capability::obj<Process>() {
2023-06-06 16:24:03 -07:00
if (type_ != PROCESS) {
panic("Accessing %u cap as object.", type_);
}
return StaticCastRefPtr<Process>(obj_);
2023-06-06 16:24:03 -07:00
}
template <>
RefPtr<Thread> Capability::obj<Thread>() {
2023-06-06 16:24:03 -07:00
if (type_ != THREAD) {
panic("Accessing %u cap as object.", type_);
}
return StaticCastRefPtr<Thread>(obj_);
}
template <>
RefPtr<AddressSpace> Capability::obj<AddressSpace>() {
if (type_ != ADDRESS_SPACE) {
panic("Accessing %u cap as object.", type_);
}
return StaticCastRefPtr<AddressSpace>(obj_);
}
template <>
RefPtr<MemoryObject> Capability::obj<MemoryObject>() {
if (type_ != MEMORY_OBJECT) {
panic("Accessing %u cap as object.", type_);
}
return StaticCastRefPtr<MemoryObject>(obj_);
2023-06-06 16:24:03 -07:00
}
template <>
RefPtr<Channel> Capability::obj<Channel>() {
if (type_ != CHANNEL) {
panic("Accessing %u cap as object.", type_);
}
return StaticCastRefPtr<Channel>(obj_);
}
template <>
RefPtr<Port> Capability::obj<Port>() {
if (type_ != PORT) {
panic("Accessing %u cap as object.", type_);
}
return StaticCastRefPtr<Port>(obj_);
}