当然,我针对的正是Google Chrome 用的那个 v8 引擎的 sample 文件夹下的 shell.cc
给它加个 system 函数会增加很多乐趣的~
放送代码:
- v8::Handle<v8::Value> System(const v8::Arguments& args)
- {
- if(args.Length()!=1)
- return v8::ThrowException(v8::String::New("Should give 1 argument"));
- if(!args[0]->IsString())
- return v8::ThrowException(v8::String::New("Argument should be string"));
- v8::String::Utf8Value str(args[0]);
- return v8::Int32::New(system(*str));
- }