mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
Currently the nm_modname does not match the file name of the resulting module. In fact, the nm_modname is pretty arbitrary. This seeks to introduce some consistency into the nm_modname property by having the name of the module appear in exactly one place: the "target_name" property of the gyp target that builds the module. PR-URL: https://github.com/nodejs/node/pull/15209 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
43 lines
980 B
C++
43 lines
980 B
C++
#include <assert.h>
|
|
#include <stdlib.h>
|
|
#include <node.h>
|
|
#include <v8.h>
|
|
|
|
using node::AtExit;
|
|
using v8::HandleScope;
|
|
using v8::Isolate;
|
|
using v8::Local;
|
|
using v8::Object;
|
|
|
|
static char cookie[] = "yum yum";
|
|
static int at_exit_cb1_called = 0;
|
|
static int at_exit_cb2_called = 0;
|
|
|
|
static void at_exit_cb1(void* arg) {
|
|
Isolate* isolate = static_cast<Isolate*>(arg);
|
|
HandleScope handle_scope(isolate);
|
|
Local<Object> obj = Object::New(isolate);
|
|
assert(!obj.IsEmpty()); // Assert VM is still alive.
|
|
assert(obj->IsObject());
|
|
at_exit_cb1_called++;
|
|
}
|
|
|
|
static void at_exit_cb2(void* arg) {
|
|
assert(arg == static_cast<void*>(cookie));
|
|
at_exit_cb2_called++;
|
|
}
|
|
|
|
static void sanity_check(void) {
|
|
assert(at_exit_cb1_called == 1);
|
|
assert(at_exit_cb2_called == 2);
|
|
}
|
|
|
|
void init(Local<Object> exports) {
|
|
AtExit(at_exit_cb1, exports->GetIsolate());
|
|
AtExit(at_exit_cb2, cookie);
|
|
AtExit(at_exit_cb2, cookie);
|
|
atexit(sanity_check);
|
|
}
|
|
|
|
NODE_MODULE(NODE_GYP_MODULE_NAME, init)
|