Re: Function object cannot be called with different context

2017-01-31 Thread Hannes Wallnöfer
Am 31.01.2017 um 11:39 schrieb Frantzius, Jörg : > > As the function object is dynamically created within some 3rd party > Javascript that I cannot modify, I’m not able to create a CompiledScript > instead. > Then your best bet is probably to evaluate the script containing the function for ea

Re: Function object cannot be called with different context

2017-01-31 Thread Frantzius , Jörg
Hi Hannes, thanks for the explanations! The Javascript function being a closure over the scope it was evaluated in is exactly what I did not understand yet. As the function object is dynamically created within some 3rd party Javascript that I cannot modify, I’m not able to create a CompiledScri

Re: Function object cannot be called with different context

2017-01-30 Thread Hannes Wallnöfer
There are a few problems with this code. The first is that a function declaration evaluates as undefined in Javascript, so your jsFunction variable is null. One way to work around this is to make the function an expression, e.g. by wrapping it in parentheses: engine.eval(„function test() { }“);

Function object cannot be called with different context

2017-01-30 Thread Frantzius , Jörg
Hi, in my code, I get hold of a function object from some 3rd party Javascript code, and I need to execute that function within a new context, i.e. make new ENGINE_SCOPE bindings available to it. ScriptObjectMirror.call() unfortunately does not allow to define a context to execute in, so I trie