插件示例


¥Addon examples

以下是一些旨在帮助开发者入门的示例插件。这些示例使用 V8 API。请参阅在线 V8 参考手册 以获取有关各种 V8 调用的帮助,以及 V8 的 嵌入器指南 以获取对使用的几个概念(如句柄、作用域、函数模板等)的解释。

¥Following are some example addons intended to help developers get started. The examples use the V8 APIs. Refer to the online V8 reference for help with the various V8 calls, and V8's Embedder's Guide for an explanation of several concepts used such as handles, scopes, function templates, etc.

这些示例中的每一个都使用以下 binding.gyp 文件:

¥Each of these examples using the following binding.gyp file:

{
  "targets": [
    {
      "target_name": "addon",
      "sources": [ "addon.cc" ]
    }
  ]
} 

如果有多个 .cc 文件,只需将附加文件名添加到 sources 数组:

¥In cases where there is more than one .cc file, simply add the additional filename to the sources array:

"sources": ["addon.cc", "myexample.cc"] 

一旦 binding.gyp 文件准备就绪,就可以使用 node-gyp 配置和构建示例插件:

¥Once the binding.gyp file is ready, the example addons can be configured and built using node-gyp:

node-gyp configure build