Verify that LookupObject actually returns an object of the requested type.

This commit is contained in:
Dr. Chat 2015-11-12 19:02:32 -06:00
parent 7fc22f1987
commit 4dfe1addaa
1 changed files with 12 additions and 0 deletions

View File

@ -38,10 +38,22 @@ class ObjectTable {
template <typename T>
object_ref<T> LookupObject(X_HANDLE handle) {
auto object = LookupObject(handle, false);
if (object) {
assert_true(object->type() == T::kType);
}
auto result = object_ref<T>(reinterpret_cast<T*>(object));
return result;
}
// Generic lookup
template <>
object_ref<XObject> LookupObject<XObject>(X_HANDLE handle) {
auto object = LookupObject(handle, false);
auto result = object_ref<XObject>(reinterpret_cast<XObject*>(object));
return result;
}
X_STATUS AddNameMapping(const std::string& name, X_HANDLE handle);
void RemoveNameMapping(const std::string& name);
X_STATUS GetObjectByName(const std::string& name, X_HANDLE* out_handle);