WebKit之V8编写简单demon

## 测试  testv8.cxx

[cpp]  view plain  copy
  1. // testv8.cpp : Defines the entry point for the console application.  
  2. //  
  3. #include <v8.h>  
  4.   
  5. using namespace v8;  
  6.   
  7. int main(int argc, char* argv[]) {  
  8.   
  9.     // Create a stack-allocated handle scope.  
  10.     HandleScope handle_scope;  
  11.   
  12.     // Create a new context.  
  13.     Persistent<Context> context = Context::New();  
  14.   
  15.     // Enter the created context for compiling and  
  16.     // running the hello world script.   
  17.     Context::Scope context_scope(context);  
  18.   
  19.     // Create a string containing the JavaScript source code.  
  20.     Handle<String> source = String::New("var x='xyziamheres2///sdfsdf123'; x.match(/\\d{3,3}/);");  
  21.   
  22.     // Compile the source code.  
  23.     Handle<Script> script = Script::Compile(source);  
  24.   
  25.     // Run the script to get the result.  
  26.     Handle<Value> result = script->Run();  
  27.   
  28.     // Dispose the persistent context.  
  29.     context.Dispose();  
  30.   
  31.     // Convert the result to an ASCII string and print it.  
  32.     String::AsciiValue ascii(result);  
  33.     printf("%s\n", *ascii);  
  34.     return 0;  
  35. }  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值