Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
8922bba
deps: update npm to 5.5.1
MylesBorins Oct 27, 2017
0ea8ff3
deps: backport 4ca695819 from npm upstream
MylesBorins Oct 27, 2017
237067d
deps: manually add 9.x support to npm
MylesBorins Oct 26, 2017
4fdd76d
http2: fix stream reading resumption
apapirovski Oct 29, 2017
ef238fb
v8: migrate setFlagsFromString to internal/errors
jasnell Oct 26, 2017
07d71c9
async_hooks: enable runtime checks by default
AndreasMadsen Oct 19, 2017
decb9e7
doc: add license information for remark-cli
MylesBorins Oct 31, 2017
ed92e0c
doc: add Gibson Fahnestock to Release team
gibfahn Oct 30, 2017
45873d2
module: revert #3384 DEP0019 EOL
MylesBorins Oct 31, 2017
daa286a
2017-10-31, Version 8.9.0 'Carbon' (LTS) Release
gibfahn Oct 31, 2017
fa9990f
2017-10-31, Version 9.0.0 (Current)
jasnell Sep 1, 2017
a933179
implement intialize(), tear_down(), process_events() for shared lib API
justus-hildebrand Dec 13, 2017
1906ddd
forgot to remove the node_lib include
justus-hildebrand Dec 18, 2017
f685a03
update ReadMe
justus-hildebrand Dec 18, 2017
8b01e1e
Update README.md
justus-hildebrand Dec 18, 2017
819c0f6
added nodelib interface v0.3
Dec 18, 2017
0280f31
Build on Travis (#6)
cmfcmf Dec 18, 2017
42a0104
revert changes made to node.cc and node.h
justus-hildebrand Jan 4, 2018
f4a5f64
Merge branch 'node_lib' of github.com:hpicgs/node into node_lib
justus-hildebrand Jan 4, 2018
d88e1d5
WIP: added more calling convenience
Jan 4, 2018
c9949a5
Renamed nodelib to node_lib
Jan 4, 2018
02493bb
Added Linux build commands to README
luminosuslight Jan 4, 2018
aa2c043
implement Terminate(), RequestTerminate(), RunEventLoop()
justus-hildebrand Jan 5, 2018
6ed7163
Short comments on what the Start() funcs do
justus-hildebrand Jan 5, 2018
2fae0db
Implemented Initialize(), Run() and Evaluate()
cmfcmf Jan 7, 2018
c01f4e5
Replace argc agrv in Initialize() with std::string
luminosuslight Jan 8, 2018
6acebd9
wip
msoechting Jan 8, 2018
4ad8cce
Cleaned code style (no indent for namespaces, left-lean asteriks, uni…
luminosuslight Jan 9, 2018
cc91ae3
Refactored cmd arg generation
luminosuslight Jan 9, 2018
4812646
Fixed cmd args
luminosuslight Jan 9, 2018
9a264ce
Moved code from Initialize() to new functions
luminosuslight Jan 9, 2018
ef6b4e5
Removed unused v8 argc argv
luminosuslight Jan 10, 2018
53f74b8
Implement remaining Call() methods
cmfcmf Jan 10, 2018
d5bb393
Re-add missing node.h include
cmfcmf Jan 14, 2018
d7d4b2b
Make RegisterModule work. Sadly, we can't use std::function|s, becaus…
cmfcmf Jan 14, 2018
f3e7a6d
fix issues from comments on PR #16
justus-hildebrand Jan 15, 2018
7a59273
Fix pointer to stack variable in register module
luminosuslight Jan 15, 2018
9175443
Use UV_RUN_NOWAIT, @justus-hildebrand
cmfcmf Jan 16, 2018
75f39b0
Merge branch 'interface-implementation' of github.com:hpicgs/node int…
cmfcmf Jan 16, 2018
674c0ee
add comments and TODOs for investigation
justus-hildebrand Jan 17, 2018
4e32b91
Implement `Deinitialize()` and `StopEventLoop()`
Jan 19, 2018
734d0d6
Don't read from stdin
cmfcmf Jan 19, 2018
0c575d5
Merge pull request #16 from hpicgs/interface-implementation
Jan 22, 2018
b945ac7
WIP usage
msoechting Jan 22, 2018
78329e0
Update usage documentation
msoechting Jan 22, 2018
6ea63e2
added code docu
Jan 22, 2018
a323279
refactored internals
Jan 24, 2018
6126411
Option to auto-call process.binding() when calling RegisterModule() (…
justus-hildebrand Jan 24, 2018
0ee4348
Rename getters to match style guide
cmfcmf Jan 29, 2018
200c1a9
added error handling via MaybeLocal (#40)
Jan 29, 2018
ee01950
Add support for cmd args (#39)
luminosuslight Jan 29, 2018
d7c8a33
Merge branch 'node_lib' into expose_internals
cmfcmf Jan 29, 2018
22a3107
Update README.md
EmberFlare Jan 29, 2018
5e7adc7
Merge branch 'node_lib' into expose_internals
EmberFlare Jan 29, 2018
e582066
early check for uv_loop_alive(), small refactoring
justus-hildebrand Jan 29, 2018
25211e6
Merge pull request #41 from hpicgs/expose_internals
Jan 30, 2018
6854d8f
changed the way internals are exposed.
Jan 30, 2018
807709d
included feedback from PR
Jan 30, 2018
c51f3f6
Fix method names
luminosuslight Jan 30, 2018
c5c73ff
fix nits
justus-hildebrand Jan 30, 2018
2bb42fb
Merge branch 'node_lib' into tick-event-loop-early-exit
justus-hildebrand Jan 30, 2018
ecee92a
Merge pull request #46 from hpicgs/tick-event-loop-early-exit
luminosuslight Jan 30, 2018
588ab28
moved 'EventLoopIsRunning' back to node::lib
Jan 30, 2018
b607c9f
Merge branch 'node_lib' into expose_internals
justus-hildebrand Jan 30, 2018
5539564
Merge pull request #47 from hpicgs/expose_internals
Jan 31, 2018
40baf2c
Merge branch 'node_lib' into lib-usage-documentation
EmberFlare Jan 31, 2018
e693ecf
added code docu
Jan 22, 2018
0ed0c77
included feedback from PR
Jan 30, 2018
2e6b1ff
fixed merge problems, added more docu for new methods
Jan 31, 2018
c913d75
Merge remote-tracking branch 'origin/interface_docu' into interface_docu
Jan 31, 2018
9c6bf17
Merge pull request #37 from hpicgs/interface_docu
EmberFlare Jan 31, 2018
cac4d43
Merge branch 'node_lib' into lib-usage-documentation
EmberFlare Jan 31, 2018
fd520a7
Merge pull request #35 from hpicgs/lib-usage-documentation
EmberFlare Jan 31, 2018
fe6a38a
Start fixing code style
luminosuslight Feb 1, 2018
334c3a6
Fix more code style, left leaning asterisks
luminosuslight Feb 1, 2018
f45be81
Fix C style cast
luminosuslight Feb 1, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Start fixing code style
  • Loading branch information
luminosuslight committed Feb 1, 2018
commit fe6a38ac492411fd513dbe5fa5717a4901f2c6c4
136 changes: 71 additions & 65 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5012,32 +5012,31 @@ class CmdArgs {
* @param arguments the arguments for the program
*/
CmdArgs(const std::string& program_name, const std::vector<std::string>& arguments)
: argc(0)
, argv(nullptr)
{
: argc(0),
argv(nullptr) {
size_t total_size = 0;
total_size += program_name.size() + 1;
for (const auto& argument: arguments) {
total_size += argument.size() + 1;
}

std::vector<std::size_t> offsets;
argument_data.reserve(total_size);
offsets.push_back(argument_data.size());
argument_data += program_name;
argument_data += char(0x0);
argument_data_.reserve(total_size);
offsets.push_back(argument_data_.size());
argument_data_ += program_name;
argument_data_ += char(0x0);
for (const auto& argument: arguments) {
offsets.push_back(argument_data.size());
argument_data += argument;
argument_data += char(0x0);
offsets.push_back(argument_data_.size());
argument_data_ += argument;
argument_data_ += char(0x0);
}

argument_pointers.resize(offsets.size());
for (std::size_t i=0; i<argument_pointers.size(); ++i) {
argument_pointers[i] = argument_data.data() + offsets[i];
argument_pointers_.resize(offsets.size());
for (std::size_t i=0; i<argument_pointers_.size(); ++i) {
argument_pointers_[i] = argument_data_.data() + offsets[i];
}
argc = argument_pointers.size();
argv = argument_pointers.data();
argc = argument_pointers_.size();
argv = argument_pointers_.data();
}

~CmdArgs() = default;
Expand All @@ -5056,11 +5055,11 @@ class CmdArgs {
/**
* @brief argument_data contains the program name and the arguments separated by null bytes
*/
std::string argument_data;
std::string argument_data_;
/**
* @brief argument_pointers contains pointers to the beginnings of the strings in argument_data
*/
std::vector<const char*> argument_pointers;
std::vector<const char*> argument_pointers_;
};

ArrayBufferAllocator* allocator;
Expand Down Expand Up @@ -5091,8 +5090,8 @@ namespace internal {
}

void _RegisterModuleCallback(v8::Local<v8::Object> exports,
v8::Local<v8::Value> module,
v8::Local<v8::Context> context,
v8::Local<v8::Value> /*module*/,
v8::Local<v8::Context> /*context*/,
void* priv) {
auto module_functions = static_cast<std::map<std::string, v8::FunctionCallback>*>(priv);
if (!module_functions) {
Expand All @@ -5102,13 +5101,12 @@ void _RegisterModuleCallback(v8::Local<v8::Object> exports,
for (std::pair<std::string, v8::FunctionCallback> element : *module_functions) {
NODE_SET_METHOD(exports, element.first.c_str(), element.second);
}

delete module_functions;
}

namespace deinitialize {

void deleteCmdArgs() {
void _DeleteCmdArgs() {
if (!cmd_args) {
return;
}
Expand All @@ -5129,14 +5127,14 @@ int _StopEnv() {
return exit_code;
}

void deleteIsolate() {
void _DeleteIsolate() {
Mutex::ScopedLock scoped_lock(node_isolate_mutex);
CHECK_EQ(node_isolate, _isolate);
node_isolate = nullptr;
_isolate->Dispose();
}

void deinitV8() {
void _DeinitV8() {
if (trace_enabled) {
v8_platform.StopTracingAgent();
}
Expand All @@ -5157,7 +5155,7 @@ void deinitV8() {

namespace initialize {

void initV8() {
void _InitV8() {
v8_platform.Initialize(v8_thread_pool_size, uv_default_loop());
// Enable tracing when argv has --trace-events-enabled.
if (trace_enabled) {
Expand All @@ -5170,7 +5168,7 @@ void initV8() {
v8_initialized = true;
}

void createIsolate() {
void _CreateIsolate() {
allocator = new ArrayBufferAllocator();
params.array_buffer_allocator = allocator;
#ifdef NODE_ENABLE_VTUNE_PROFILING
Expand Down Expand Up @@ -5201,7 +5199,7 @@ void createIsolate() {
}
}

void createInitialEnvironment() {
void _CreateInitialEnvironment() {
locker = new Locker(_isolate);
isolate_scope = new Isolate::Scope(_isolate);
static HandleScope handle_scope(_isolate); // TODO (jh): Once we write a Deinit(), we need to put this on the heap to call the deconstructor.
Expand All @@ -5218,7 +5216,7 @@ void createInitialEnvironment() {
uv_key_set(&thread_local_env, _environment);
}

void configureOpenSsl() {
void _ConfigureOpenSsl() {
#if HAVE_OPENSSL
{
std::string extra_ca_certs;
Expand All @@ -5238,34 +5236,34 @@ void configureOpenSsl() {

void _StartEnv(int argc,
const char* const* argv) {
std::cout << "Starting environment" << std::endl;
std::cout << "Starting environment" << std::endl;

int v8_argc = 0;
const char* const* v8_argv = nullptr;
_environment->Start(argc, argv, v8_argc, v8_argv, v8_is_profiling);
int v8_argc = 0;
const char* const* v8_argv = nullptr;
_environment->Start(argc, argv, v8_argc, v8_argv, v8_is_profiling);

const char* path = argc > 1 ? argv[1] : nullptr;
StartInspector(_environment, path, debug_options);
const char* path = argc > 1 ? argv[1] : nullptr;
StartInspector(_environment, path, debug_options);

if (debug_options.inspector_enabled() && !v8_platform.InspectorStarted(_environment)) {
return; // TODO (jh): Handle error
//return 12; // Signal internal error.
}
if (debug_options.inspector_enabled() && !v8_platform.InspectorStarted(_environment)) {
return; // TODO (jh): Handle error
//return 12; // Signal internal error.
}

_environment->set_abort_on_uncaught_exception(abort_on_uncaught_exception);
_environment->set_abort_on_uncaught_exception(abort_on_uncaught_exception);

if (no_force_async_hooks_checks) {
_environment->async_hooks()->no_force_checks();
}
if (no_force_async_hooks_checks) {
_environment->async_hooks()->no_force_checks();
}

{
Environment::AsyncCallbackScope callback_scope(_environment);
_environment->async_hooks()->push_async_ids(1, 0);
LoadEnvironment(_environment);
_environment->async_hooks()->pop_async_id(1);
}
{
Environment::AsyncCallbackScope callback_scope(_environment);
_environment->async_hooks()->push_async_ids(1, 0);
LoadEnvironment(_environment);
_environment->async_hooks()->pop_async_id(1);
}

_environment->set_trace_sync_io(trace_sync_io);
_environment->set_trace_sync_io(trace_sync_io);
}

} // namespace initialize
Expand All @@ -5292,17 +5290,17 @@ void Initialize(const std::string& program_name, const std::vector<std::string>&
const char** exec_argv = nullptr;
Init(&cmd_args->argc, cmd_args->argv, &exec_argc, &exec_argv);

initialize::configureOpenSsl();
initialize::_ConfigureOpenSsl();

initialize::initV8();
initialize::_InitV8();

//////////
// Start 2
//////////

initialize::createIsolate();
initialize::_CreateIsolate();

initialize::createInitialEnvironment();
initialize::_CreateInitialEnvironment();

//////////
// Start environment
Expand All @@ -5322,11 +5320,11 @@ int Deinitialize() {
__lsan_do_leak_check();
#endif

deinitialize::deleteIsolate();
deinitialize::_DeleteIsolate();

deinitialize::deinitV8();
deinitialize::_DeinitV8();

deinitialize::deleteCmdArgs();
deinitialize::_DeleteCmdArgs();

return exit_code;
}
Expand All @@ -5350,7 +5348,10 @@ v8::MaybeLocal<v8::Value> Evaluate(const std::string& java_script_code) {
try_catch.SetVerbose(false);

//ScriptOrigin origin(filename); // TODO jh: set reasonable ScriptOrigin. This is used for debugging
MaybeLocal<v8::Script> script = v8::Script::Compile(_environment->context(), v8::String::NewFromUtf8(_isolate, java_script_code.c_str())/*, origin*/);
MaybeLocal<v8::Script> script = v8::Script::Compile(_environment->context(),
v8::String::NewFromUtf8(_isolate,
java_script_code.c_str())
/*origin*/);
if (script.IsEmpty()) {
ReportException(_environment, try_catch);
return MaybeLocal<v8::Value>();
Expand Down Expand Up @@ -5383,15 +5384,18 @@ v8::MaybeLocal<v8::Object> GetRootObject() {
}


v8::MaybeLocal<v8::Value> Call(v8::Local<v8::Object> receiver, v8::Local<v8::Function> function, const std::vector<v8::Local<v8::Value>> & args) {
return function->Call(receiver, args.size(), const_cast<v8::Local<v8::Value>*>(&args[0]));
v8::MaybeLocal<v8::Value> Call(v8::Local<v8::Object> receiver, v8::Local<v8::Function> function,
const std::vector<v8::Local<v8::Value>> & args) {
return function->Call(receiver, args.size(), const_cast<v8::Local<v8::Value>*>(&args[0]));
}

v8::MaybeLocal<v8::Value> Call(v8::Local<v8::Object> receiver, v8::Local<v8::Function> function, std::initializer_list<v8::Local<v8::Value>> args) {
return Call(receiver, function, std::vector<v8::Local<v8::Value>>(args));
v8::MaybeLocal<v8::Value> Call(v8::Local<v8::Object> receiver, v8::Local<v8::Function> function,
std::initializer_list<v8::Local<v8::Value>> args) {
return Call(receiver, function, std::vector<v8::Local<v8::Value>>(args));
}

v8::MaybeLocal<v8::Value> Call(v8::Local<v8::Object> object, const std::string& function_name, const std::vector<v8::Local<v8::Value>>& args) {
v8::MaybeLocal<v8::Value> Call(v8::Local<v8::Object> object, const std::string& function_name,
const std::vector<v8::Local<v8::Value>>& args) {
MaybeLocal<v8::String> maybe_function_name = v8::String::NewFromUtf8(_isolate, function_name.c_str());
Local<v8::String> v8_function_name;

Expand All @@ -5414,8 +5418,10 @@ v8::MaybeLocal<v8::Value> Call(v8::Local<v8::Object> object, const std::string&
return Call(object, v8::Local<v8::Function>::Cast(value), args);
}

v8::MaybeLocal<v8::Value> Call(v8::Local<v8::Object> object, const std::string & function_name, std::initializer_list<v8::Local<v8::Value>> args) {
return Call(object, function_name, std::vector<v8::Local<v8::Value>>(args));
v8::MaybeLocal<v8::Value> Call(v8::Local<v8::Object> object,
const std::string & function_name,
std::initializer_list<v8::Local<v8::Value>> args) {
return Call(object, function_name, std::vector<v8::Local<v8::Value>>(args));
}

v8::MaybeLocal<v8::Object> IncludeModule(const std::string& module_name) {
Expand Down Expand Up @@ -5479,8 +5485,8 @@ void RegisterModule(const std::string & name, const addon_context_register_func
void RegisterModule(const std::string & name,
const std::map<std::string, v8::FunctionCallback> & module_functions,
const std::string & target) {
auto map_on_heap = new const std::map<std::string, v8::FunctionCallback>(module_functions);
RegisterModule(name, node::lib::_RegisterModuleCallback, const_cast<std::map<std::string, v8::FunctionCallback>*>(map_on_heap), target);
auto map_on_heap = new const std::map<std::string, v8::FunctionCallback>(module_functions);
RegisterModule(name, node::lib::_RegisterModuleCallback, const_cast<std::map<std::string, v8::FunctionCallback>*>(map_on_heap), target);
}

void StopEventLoop() {
Expand Down
Loading