Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-18879] Windows: Allow casting to a different native type

GitHub Issuen/a
TypeImprovement
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2015-05-19T14:42:50.000+0000
Affected Version/sn/a
Fix Version/sRelease 4.1.0
ComponentsWindows
Labelsn/a
ReporterChristopher Williams
AssigneeChristopher Williams
Created2015-05-07T21:56:01.000+0000
Updated2017-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;

Comments

  1. Lee Morris 2017-03-14

    Closing ticket as fixed.

JSON Source