Closed tryone144 closed 4 months ago
What do you think about changing these methods to instance-methods of Window? This would need a way to check between browser and worker context to select the proper function.
I don't think there's any difference between atob
and btoa
functions in different scopes.
Alternatively, we could introduce a teavm_globals prefix to access the global scope in the @JSBody annotations if needed
No, I don't see any need in this. TeaVM runtime has two distinct cases of accessing "global" scope: top-level runtime declarations and global declarations. @JSBody
is not meant to access any of runtime functions (though there's a hack with hard-coded name prefix to do this, but it's a non-documented feature and a subject of change), so there's no need to introduce similar special. I think these window.
prefixes were introduced here long ago, when TeaVM could not handle such cases properly.
I don't think there's any difference between
atob
andbtoa
functions in different scopes.
As far as I am aware, these are identical. The differentiation would only be needed if we were to access these as instance methods of a Window object retrieved via current()
or worker()
. Judging by the other global methods, keeping these static
is consistent.
I think these
window.
prefixes were introduced here long ago, when TeaVM could not handle such cases properly.
If the identifiers in @JSBody
are not subject to name mangling, this should be fine.
This removes the hardcoded
window
access in some globally available objects/function if they are also available in the WebWorker context (which has nowindow
butself
).What do you think about changing these methods to instance-methods of
Window
? This would need a way to check between browser and worker context to select the proper function. Alternatively, we could introduce ateavm_globals
prefix to access the global scope in the@JSBody
annotations if needed (like the runtime templates utilize).