Add CheckCast().

This commit is contained in:
Nikolay Igotti
2016-11-16 18:41:36 +03:00
parent 060163d1c4
commit cc1b2b9684
2 changed files with 9 additions and 0 deletions
+8
View File
@@ -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
+1
View File
@@ -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
}