#include #include "malunal/types/object.h" const uuid_t UUID_OBJECT_T = { .tl = 0xB84510EE, .tm = 0xBCDB, .thv = 0x4B26, .csr = 0x9E, .csl = 0xEF, .nbs = { 0xBB, 0x5A, 0xDB, 0x6C, 0x9C, 0x3A } }; error_t object_query_interface( object_iptr_t obj, uuid_iptr_t iid, rtti_intf_mptr_t intf ) { if (obj == null) return (error_t) { .domain = &ERROR_DOMAIN_OBJECT_T, .code = OBJECT_ERROR_NULL_OBJECT }; if (intf == null) return (error_t) { .domain = &ERROR_DOMAIN_OBJECT_T, .code = OBJECT_ERROR_NULL_OUTPUT }; malunal_size_t index; rtti_intf_mptr_t entry; for (index = 0; index < obj->rtti->nIntfs; index++) { entry = &obj->rtti->pIntfs[index]; if (uuid_equals(iid, entry->iid)) { intf->iid = entry->iid; intf->vtable = entry->vtable; return NO_ERROR; } } intf->iid = null; intf->vtable = null; return (error_t) { .domain = &ERROR_DOMAIN_OBJECT_T, .code = OBJECT_ERROR_NOT_MY_INTERFACE }; } error_t object_query_property( object_iptr_t obj, malunal_cstr_t name, rtti_prop_mptr_t prop ) { if (obj == null) return (error_t) { .domain = &ERROR_DOMAIN_OBJECT_T, .code = OBJECT_ERROR_NOT_MY_INTERFACE }; if (prop == null) return (error_t) { .domain = &ERROR_DOMAIN_OBJECT_T, .code = OBJECT_ERROR_NULL_OUTPUT }; malunal_size_t index; rtti_prop_mptr_t entry; for (index = 0; index < obj->rtti->nProps; index++) { entry = &obj->rtti->pProps[index]; if (strcmp(name, entry->name) == 0) { prop->name = entry->name; prop->rtti = entry->rtti; return NO_ERROR; } } prop->name = null; prop->rtti = null; return (error_t) { .domain = &ERROR_DOMAIN_OBJECT_T, .code = OBJECT_ERROR_NOT_MY_PROPERTY }; }