Re: [v8-users] Re: Using 'this' in scripts

2019-06-24 Thread Zoltan B
thanks, I'm struggling between function() { return ( "expression" ) } and running a script like: with(myContextProxy){ "expression" }. The latter allows me to handle this.x and x resolution separately as well but has other drawbacks (this is still not the object I want it to be so I cant put it

Re: [v8-users] Re: Using 'this' in scripts

2019-06-21 Thread J Decker
Sorry I did reflect that there's probably cases of simpler expessions. You could limit it to just no semicolons, and only allow commas, then you could just put it in a `()=>(/*expression without return*/)` but that doesn't let you pass a this. so you could make a `function() { return ` + (your ex

Re: [v8-users] Re: Using 'this' in scripts

2019-06-21 Thread J Decker
I run scripts to extend a 'this', but when that script runs, it just iniializes this.whatever and provides methods like this.handleMessage = function() {} If I want the object initilaized with the script to give me a value, I'd call a method on the this, but I don't know that the initialization co

Re: [v8-users] Re: Using 'this' in scripts

2019-06-21 Thread Zoltan B
Thank you! Also, In the case I'm running a Script (and not a function), if I write "myvariable" or "this.myvariable" then is there a way to distuingish between the two in the C++ side? Currently how I'm using it is like this: The context the script runs in has a global object with my template,

Re: [v8-users] Re: Using 'this' in scripts

2019-06-21 Thread Caitlin Potter
No, that method would still require a return statement. Getting rid of the return statement requirement would need a new API, or transforming the source program before using it. > On Jun 21, 2019, at 3:27 AM, Zoltan B wrote: > > Thanks for your answer! :) > > In the (1) solution of yours, is

Re: [v8-users] Re: Using 'this' in scripts

2019-06-21 Thread Zoltan B
Thanks for your answer! :) In the (1) solution of yours, is there a way to be able to create functions that behave like scripts? I mean, that if I write onclick="1+1", then if I parse and run "1+1" as a function it would return 2 without using the "return" keyword (e.g.: "return 1+1")? 2019. j

Re: [v8-users] Re: Using 'this' in scripts

2019-06-20 Thread Caitlin Potter
I don’t believe you can do exactly what you want here, as there are two parts: 1) getting `this` set properly. I believe you should be able to use `CompileFunctionInContext()` to this effect, which is used to provide implicit arguments to DOM onxxx=“script...” handlers. I believe you can then ma

[v8-users] Re: Using 'this' in scripts

2019-06-20 Thread Zoltan B
Any ideas? :) 2019. június 7., péntek 13:16:08 UTC+2 időpontban Zoltan B a következőt írta: > > Hi! > > Is there a way to provide value for the 'this' keyword, when I'm running a > v8 Script? > > An alternative would be to compile the code as a function instead, and > provide 'this' when calli