node.js Internals: How can I find out where `process.binding('eval')` gets defined?

我们两清 提交于 2020-03-01 04:03:52

问题


  • How can I find out where in the C++ source code of node.js the JavaScript object gets defined which I can access through process.binding('eval')? - I already found out that it's in /src/node_script.cc in this special case, but: How can I know where I can find that module just when I just take a look on the /src/ directory overview? I don't want to step through all the files in /src/ in order to look for a module.
  • Where can I find some deep going information about the internals of process.binding()s?

Thanks.


回答1:


I was looking for the same myself today. I cannot guarantee that there isn't more to it, but this is what I discovered.

src/node_extensions.h contains a list of built-in modules, defined like:

ITEM(node_module_name)

where module_name is the name of the module (obviously)

You can find out which file defines that module by searching for which file has a line that starts with

NODE_MODULE(node_module_name, 

So, to find the file that defines the 'evals' module for process.bindings:

$ grep "NODE_MODULE(node_evals" src/*.cc
src/node_script.cc:NODE_MODULE(node_evals, node::InitEvals)


来源:https://stackoverflow.com/questions/12138851/node-js-internals-how-can-i-find-out-where-process-bindingeval-gets-defin

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!