Add CheckCast().
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "Assert.h"
|
||||
#include "Exceptions.h"
|
||||
#include "Memory.h"
|
||||
|
||||
void FreeObject(ContainerHeader* header) {
|
||||
@@ -105,6 +106,13 @@ int IsInstance(const ObjHeader* obj, const TypeInfo* type_info) {
|
||||
return obj_type_info != nullptr;
|
||||
}
|
||||
|
||||
void CheckInstance(const ObjHeader* obj, const TypeInfo* type_info) {
|
||||
if (IsInstance(obj, type_info)) {
|
||||
return;
|
||||
}
|
||||
ThrowClassCastException();
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -267,6 +267,7 @@ void* AllocInstance(const TypeInfo* type_info, PlacementHint hint);
|
||||
void* AllocArrayInstance(
|
||||
const TypeInfo* type_info, PlacementHint hint, uint32_t elements);
|
||||
int IsInstance(const ObjHeader* obj, const TypeInfo* type_info);
|
||||
void CheckCast(const ObjHeader* obj, const TypeInfo* type_info);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user