Verify that LookupObject actually returns an object of the requested type.
This commit is contained in:
parent
7fc22f1987
commit
4dfe1addaa
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue