了解Google V8的架构

时间:2010-06-27 23:55:11

标签: c# c++ v8

我不确定我是否了解V8的架构(是的,我已阅读其文档)。

在带有v8sharp包装器的C#中,我写了这样的东西,例如:

namespace App
{
    class Point
    {
        public Point() { }

        public Point(double x, double y) {
            this.X = x;
            this.Y = y;
        }

        public double X { get; set; }
        public double Y { get; set; }
    }
}

static class Program
{
    static void Main() {
        //registering with v8sharp
        V8Engine engine = V8Engine.Create();        
        engine.Register<App.Point>();

        //execute javascript
        object rtn = engine.Execute("new App.Point(10, 10);");
    }
}

如果没有这个包装器,我如何在标准C ++中编写相同的东西?

感谢。

1 个答案:

答案 0 :(得分:3)

如果你看一下:http://code.google.com/apis/v8/embed.html他们有一个与你的“访问动态变量”相同的样本