Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-18517] Windows: Investigate cross-platform require implementation in GlobalObject

GitHub Issuen/a
TypeStory
PriorityMedium
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
ComponentsWindows
Labelsn/a
ReporterGary Mathews
AssigneeUnknown
Created2015-02-05T15:25:24.000+0000
Updated2018-02-28T19:54:48.000+0000

Description

From https://github.com/appcelerator/titanium_mobile_windows/pull/110#discussion_r24169482 It looks to me like we could implement GlobalObject and require entirely cross-platform, but it'd have to defer to using Ti.Filesystem API. Right now that requires us to jump into JS to do so:
JSValue Titanium_property = get_context().get_global_object().GetProperty("Titanium");
JSObject Titanium = static_cast<JSObject>(Titanium_property);

JSValue FS_property = Titanium.GetProperty("Filesystem");
JSObject FS = static_cast<JSObject>(FS_property);

JSValue File_property = FS.GetProperty("File");
JSObject File = static_cast<JSObject>(File_property);

auto file = File.CallAsConstructor(path);

JSValue resolve_property = file.GetProperty("resolve");
JSObject resolve = static_cast<JSObject>(resolve_property);

return resolve();
We were reluctant to do so out of concern for performance/memory overhead of accessing the JS objects/properties/functions and then calling them (and marshaling the values back and forth between c++ types and JSValues). What is the actual performance overhead involved here? Is it small enough that a cross-platform implementation is of high importance? Is there a way we can use pure C++ and still do this cross-platform (i.e. can we still get a reference/defer to the platform specific implementation of File when we need to)?

Comments

No comments

JSON Source