Just had a thought, I assume I can just use (from shell.cc)
ExecuteScript("var print = function() {}"); or something like that?
or is it better to do something like:
noop_script = Script::Compile( "noop function", "function() {}" );
Handle<Value> noop_val = noop_script->Run();
context->Global()->Set( Str("print"), noop_val->ToFunction() );
I don't see how I could add it as a FunctionTemplate, before the global
context was created...
On Monday, April 23, 2012 8:15:35 PM UTC+8, Paul Harris wrote:
>
> Hi all,
>
> I have set up my own print function, like so:
> global->Set(v8::String::New("print"),
> v8::FunctionTemplate::New(Global_Print));
>
> Now I want to basically declare a noop print() so I can switch it off and
> thus speed up execution.
> The fastest way would be to do it directly in javascript, ie to declare
> function print() {}
> or, somehow rather, global.print = function() {}
>
> How do I do that in v8 ? How do I attach a function defined in javascript
> code?
>
> thanks,
> Paul
>
>
>
--
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users