• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

JavascriptNet/Javascript.Net: .Net bindings to the V8 JavaScript engine

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

JavascriptNet/Javascript.Net

开源软件地址:

https://github.com/JavascriptNet/Javascript.Net

开源编程语言:

C++ 63.6%

开源软件介绍:

Example

// Initialize a context
using (JavascriptContext context = new JavascriptContext()) {

    // Setting external parameters for the context
    context.SetParameter("console", new SystemConsole());
    context.SetParameter("message", "Hello World !");
    context.SetParameter("number", 1);

    // Script
    string script = @"
        var i;
        for (i = 0; i < 5; i++)
            console.Print(message + ' (' + i + ')');
        number += i;
    ";

    // Running the script
    context.Run(script);

    // Getting a parameter
    Console.WriteLine("number: " + context.GetParameter("number"));
}

See our wiki for more information.

Nuget

Old versions have been published as Noesis.JavaScript.

Publishing a newer version is a work in progress.

Redistribution

Noesis.Javascript.dll needs the Microsoft C Runtime Libraries.

If you don't include the correct version of the runtime libraries when you redistribute Noesis.Javascript.dll then you will get errors when loading the DLL on some users machines. (Many, but not all users will already have it.)

Targets: .NET Framework 4.5

Building from Source

Open the .sln file in Visual Studio, use Configuration Manager to switch to platform to x64, and build. I've been working using Visual Studio 2017, but 2015 will probably work too.

The following warnings are expected:

  • warning LNK4248: unresolved typeref token (0100003F) for 'v8.internal.Object'; image may not run

  • warning MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "C:\Users\oliver\Documents\GitHub\Javascript.Net\x64\Release\JavaScript.Net.dll", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.

Also note that when using the DLL built from source, you will need to add a Post Build Step to your consuming project, which copies the v8 DLLs and .bin files into your output directory. See Noesis.Javascript.Tests.csproj for an example, noting that it has some extra sections manually inserted to define V8Platform.

Updating v8

The log at https://docs.google.com/a/g7.org/document/d/1g8JFi8T_oAE_7uAri7Njtig7fKaPDfotU6huOa1alds/edit may help, if it is still being updated.

Running Tests

The unit tests are standard Visual Studio - run them using the GUI.

How it Works

Simple values and arrays are copied between the native memory space (where v8 resides) and the Common Language Runtime (CLR) (where .Net applications live). Complex .Net types (delegates, objects) are proxied. When calls are made into proxied types then the parameters are copied into the CLR and the call is executed. The results are copied back.

Internationalization

??? buildv8.bat turns off internationalization when invoking gyp to avoid the need to distribute the (large) ICU DLLs and data file.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap