插件示例
【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