Thanks again Stephan.

I was wondering if I could handle scripts like 'var x = eval('a' +
'b');', where the result of eval is to be assigned to x. Following
your suggestion, I verified this can be done by returning the args
received to keep the script running (i.e. complete the assignment to
x).

I'm now trying to see if there is any way to distinguish the type of
eval operation based on the args, i.e. if it's an eval on an
expression (which is evaluated) or a set of one ore more statements
(which are executed).

Thank you for your help!

Ravi


On Apr 17, 9:22 am, Stephan Beal <[email protected]> wrote:
> On Sun, Apr 17, 2011 at 2:51 PM, Chinnu <[email protected]> wrote:
> > One final question - now that I've captured the string being passed to
> > eval, what would be the right Handle<Value> to return from the
> > function template to keep the script running in V8.
>
> From what i understand, as long as you return any non-empty handle, v8 is
> happy. e.g. return v8::Undefined() if you don't care about the return value.
> That's semantically equivalent to returning void in C/C++.
>
> > Should I get the
> > inbuilt eval function handle and pass this arg to that function.
>
> i don't think that will work in your case because you're overriding "eval".
> That means that fetching the global eval using the code i showed before
> would return your copy of eval, which (when you forward the argument to it)
> would result in an endless loop.
>
> If your version of evai has a different name, you can forward all of the
> Arguments values to the global eval using something like:
>
> // Copy Arguments data to an array:
> std::vector< Handle<Value> > vec( static_cast<size_t>( args.Length() ),
> v8::Undefined() );
> for( int i = 0; i < args.Length(); ++i ) vec[i] = args[i];
>
> // Pass them on to the "real" eval() function:
> theRealEvalFunctionHandle->Call( args.This(), &vec[0], args.Length() );
>
> --
> ----- stephan bealhttp://wanderinghorse.net/home/stephan/

-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users

Reply via email to