Project: titanium
Issue TIMOB-18517: Windows: Investigate cross-platform require implementation in GlobalObject
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: {code:cpp} JSValue Titanium_property = get_context().get_global_object().GetProperty("Titanium"); JSObject Titanium = static_cast(Titanium_property); JSValue FS_property = Titanium.GetProperty("Filesystem"); JSObject FS = static_cast(FS_property); JSValue File_property = FS.GetProperty("File"); JSObject File = static_cast(File_property); auto file = File.CallAsConstructor(path); JSValue resolve_property = file.GetProperty("resolve"); JSObject resolve = static_cast(resolve_property); return resolve(); {code} 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)?
Story points: 21