V8引擎与GUI间的交互

搜遍互联网未果,Google开发网站又连不上去,又没能力去研究Chrome源码,但最终还是被我试出来了,仅两个静态函数就能解决。 

包装

//External::Wrap(console)//console is fltk::Browser*

Handle<ObjectTemplate> o= ObjectTemplate::New();
o->Set(String::New("browser"),External::Wrap(console));
o->Set(String::New("log"),FunctionTemplate::New(CWrapConsoleGridAppendRowFunction));

global->Set(String::New("console"),o);

拆包
//在CWrapConsoleGridAppendRowFunction函数中再解包出来
Local<Object> self = args.Holder();
Local<Value> browser = self->Get(String::New("browser"));
fltk::Browser* gridview = static_cast<fltk::Browser*> (External::Unwrap(browser));

实例

V8引擎与GUI间的交互

试玩此软体

你可能感兴趣的:(V8,fltk)