Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: simplify Javascript code embedding #27095

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 4 additions & 2 deletions common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@
'SuppressStartupBanner': 'true',
'WarnAsError': 'false',
'WarningLevel': 3, # /W3
'AdditionalOptions': [ '/std:c++17' ],

},
'VCLinkerTool': {
'conditions': [
Expand Down Expand Up @@ -334,7 +336,7 @@
}],
[ 'OS in "linux freebsd openbsd solaris android aix cloudabi"', {
'cflags': [ '-Wall', '-Wextra', '-Wno-unused-parameter', ],
'cflags_cc': [ '-fno-rtti', '-fno-exceptions', '-std=gnu++1y' ],
'cflags_cc': [ '-fno-rtti', '-fno-exceptions', '-std=gnu++1z' ],
'ldflags': [ '-rdynamic' ],
'target_conditions': [
# The 1990s toolchain on SmartOS can't handle thin archives.
Expand Down Expand Up @@ -461,7 +463,7 @@
['clang==1', {
'xcode_settings': {
'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0',
'CLANG_CXX_LANGUAGE_STANDARD': 'gnu++1y', # -std=gnu++1y
'CLANG_CXX_LANGUAGE_STANDARD': 'gnu++1z', # -std=gnu++1z
'CLANG_CXX_LIBRARY': 'libc++',
},
}],
Expand Down
16 changes: 8 additions & 8 deletions deps/acorn/acorn/dist/acorn.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions deps/gtest/gtest.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
'direct_dependent_settings': {
'include_dirs': ['include'],
},
'defines': [ 'GTEST_LANG_CXX11' ],
'include_dirs': ['.', 'include'],
'sources': [
'src/gtest-death-test.cc',
Expand Down
2 changes: 1 addition & 1 deletion deps/node-inspect/lib/internal/inspect_repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ function createRepl(inspector) {

[util.inspect.custom](depth, { stylize }) {
const { startTime, endTime } = this.data;
return stylize(`[Profile ${endTime - startTime}μs]`, 'special');
return stylize(`[Profile ${endTime - startTime}\u3bcss]`, 'special');
}

save(filename = 'node.cpuprofile') {
Expand Down
26 changes: 13 additions & 13 deletions lib/internal/cli_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ const HasOwnProperty = Function.call.bind(Object.prototype.hasOwnProperty);
// Refs: https://github.com/nodejs/node/issues/10673
const tableChars = {
/* eslint-disable node-core/non-ascii-character */
middleMiddle: '',
rowMiddle: '',
topRight: '',
topLeft: '',
leftMiddle: '',
topMiddle: '',
bottomRight: '',
bottomLeft: '',
bottomMiddle: '',
rightMiddle: '',
left: ' ',
right: ' ',
middle: ' ',
middleMiddle: '\u2500',
rowMiddle: '\u253c',
topRight: '\u2510',
topLeft: '\u250c',
leftMiddle: '\u251c',
topMiddle: '\u252c',
bottomRight: '\u2518',
bottomLeft: '\u2514',
bottomMiddle: '\u2534',
rightMiddle: '\u2524',
left: '\u2502 ',
right: ' \u2502',
middle: ' \u2502 ',
/* eslint-enable node-core/non-ascii-character */
};

Expand Down
27 changes: 2 additions & 25 deletions lib/internal/timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,6 @@
// Object maps are kept which contain linked lists keyed by their duration in
// milliseconds.
//
/* eslint-disable node-core/non-ascii-character */
//
// ╔════ > Object Map
// ║
// ╠══
// ║ lists: { '40': { }, '320': { etc } } (keys of millisecond duration)
// ╚══ ┌────┘
// │
// ╔══ │
// ║ TimersList { _idleNext: { }, _idlePrev: (self) }
// ║ ┌────────────────┘
// ║ ╔══ │ ^
// ║ ║ { _idleNext: { }, _idlePrev: { }, _onTimeout: (callback) }
// ║ ║ ┌───────────┘
// ║ ║ │ ^
// ║ ║ { _idleNext: { etc }, _idlePrev: { }, _onTimeout: (callback) }
// ╠══ ╠══
// ║ ║
// ║ ╚════ > Actual JavaScript timeouts
// ║
// ╚════ > Linked List
//
/* eslint-enable node-core/non-ascii-character */
//
// With this, virtually constant-time insertion (append), removal, and timeout
// is possible in the JavaScript layer. Any one list of timers is able to be
Expand All @@ -66,8 +43,8 @@
// always be due to timeout at a later time.
//
// Less-than constant time operations are thus contained in two places:
// The PriorityQueue an efficient binary heap implementation that does all
// operations in worst-case O(log n) time which manages the order of expiring
// The PriorityQueue - an efficient binary heap implementation that does all
// operations in worst-case O(log n) time - which manages the order of expiring
// Timeout lists and the object map lookup of a specific list by the duration of
// timers within (or creation of a new list). However, these operations combined
// have shown to be trivial in comparison to other timers architectures.
Expand Down
14 changes: 9 additions & 5 deletions node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@
'src/node_http2_state.h',
'src/node_i18n.h',
'src/node_internals.h',
'src/node_javascript.h',
'src/node_messaging.h',
'src/node_metadata.h',
'src/node_mutex.h',
Expand All @@ -538,7 +539,6 @@
'src/node_revert.h',
'src/node_root_certs.h',
'src/node_stat_watcher.h',
'src/node_union_bytes.h',
'src/node_url.h',
'src/node_version.h',
'src/node_v8_platform-inl.h',
Expand Down Expand Up @@ -791,6 +791,8 @@
'action_name': 'node_js2c',
'process_outputs_as_sources': 1,
'inputs': [
# Put the code first so it's a dependency and can be used for invocation.
'tools/js2c.py',
'<@(library_files)',
'config.gypi',
'tools/check_macros.py'
Expand All @@ -810,9 +812,8 @@
}]
],
'action': [
'python', 'tools/js2c.py',
'<@(_outputs)',
'<@(_inputs)',
'python', '<@(_inputs)',
'--target', '<@(_outputs)',
],
},
],
Expand Down Expand Up @@ -1030,7 +1031,10 @@
'<(SHARED_INTERMEDIATE_DIR)', # for node_natives.h
],

'defines': [ 'NODE_WANT_INTERNALS=1' ],
'defines': [
'NODE_WANT_INTERNALS=1',
'GTEST_LANG_CXX11'
],

'sources': [
'test/cctest/node_test_fixture.cc',
Expand Down
3 changes: 3 additions & 0 deletions node.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@
'<(_msvs_precompiled_header)',
'<(_msvs_precompiled_source)',
],
'include_dirs': [
'tools/msvs/pch',
],
}, { # POSIX
'defines': [ '__POSIX__' ],
}],
Expand Down
32 changes: 32 additions & 0 deletions src/node_javascript.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#pragma once

#include <map>
#include <string>

#if __has_include(<string_view>)
#include <string_view>
using std::string_view;
#else
#include <experimental/string_view>
using std::experimental::string_view;
#endif



namespace node {

namespace native_module {

using NativeModuleRecordMap = std::map<std::string, string_view>;

class JavascriptEmbeddedCode {
public:
JavascriptEmbeddedCode();
protected:
string_view config_;
NativeModuleRecordMap source_;
};

} // namespace native_module

} // namespace node
Loading