[TIMOB-18879] Windows: Allow casting to a different native type
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2015-05-19T14:42:50.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 4.1.0 |
Components | Windows |
Labels | n/a |
Reporter | Christopher Williams |
Assignee | Christopher Williams |
Created | 2015-05-07T21:56:01.000+0000 |
Updated | 2017-03-14T20:14:52.000+0000 |
Description
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:
auto wrapped_object = unwrap();
auto new_type = js_context.CreateObject(JSExport<Titanium::Windows::UI::Xaml::Controls::Page>::Class());
auto new_wrapper = new_type.GetPrivate<Titanium::Windows::UI::Xaml::Controls::Page>();
new_wrapper->wrap(dynamic_cast<Windows::UI::Xaml::Controls::Page>(wrapped_object));
return new_type;
Closing ticket as fixed.