Project: titanium
Issue TIMOB-18879: Windows: Allow casting to a different native type
We should allow the ability to "upcast". We could simply hang a "JSObject Platform::Object::cast(std::string& type)" method that is on all native wrapped objects and would take the new type name. Then we'd have a giant generated if/else block where we test against the known set of type names and do the unwrapping/wrapping to "cast" it: {code} auto wrapped_object = unwrap(); auto new_type = js_context.CreateObject(JSExport::Class()); auto new_wrapper = new_type.GetPrivate(); new_wrapper->wrap(dynamic_cast(wrapped_object)); return new_type; {code}
Story points: 8