I'm not a C++ programmer, so please forgive me if this is a stupid question.
Suppose that I want to change a particular behavior in V8. Of course I can change it inside deps/v8
and then build Node.js from source. But I'm searching if there is an easier way.
Can I write a C++ addon to override what I want in V8?
For example, could I create an empty addon:
namespace MY_EMPTY_ADDON
{
void init(v8::Local<v8::Object> exports, v8::Local<v8::Object> module)
{
// empty
}
NODE_MODULE(MY_EMPTY_ADDON, init)
}
Then, at the same file add some thing like this:
namespace v8
{
namespace internal
{
// here I do my changes
}
}
Could this work?
No. C++ does not allow monkey-patching in the way JavaScript does. You cannot override another module's/library's functions from the outside.