diff --git a/src/node_object_wrap.h b/src/node_object_wrap.h index 9dce684892a2d8..cb13d84388bcc6 100644 --- a/src/node_object_wrap.h +++ b/src/node_object_wrap.h @@ -65,6 +65,7 @@ class ObjectWrap { } + // NOLINTNEXTLINE(runtime/v8_persistent) inline v8::Persistent& persistent() { return handle_; } @@ -122,6 +123,7 @@ class ObjectWrap { delete wrap; } + // NOLINTNEXTLINE(runtime/v8_persistent) v8::Persistent handle_; }; diff --git a/tools/cpplint.py b/tools/cpplint.py index 40564789549aba..4ea91c0dc04a54 100755 --- a/tools/cpplint.py +++ b/tools/cpplint.py @@ -321,6 +321,7 @@ 'runtime/string', 'runtime/threadsafe_fn', 'runtime/vlog', + 'runtime/v8_persistent', 'whitespace/blank_line', 'whitespace/braces', 'whitespace/comma', @@ -627,6 +628,8 @@ _NULL_TOKEN_PATTERN = re.compile(r'\bNULL\b') +_V8_PERSISTENT_PATTERN = re.compile(r'\bv8::Persistent\b') + _RIGHT_LEANING_POINTER_PATTERN = re.compile(r'[^=|(,\s><);&?:}]' r'(?= 0 or line.find('*/') >= 0: + return + + for match in _V8_PERSISTENT_PATTERN.finditer(line): + error(filename, linenum, 'runtime/v8_persistent', 2, + 'Use v8::Global instead of v8::Persistent') + def CheckLeftLeaningPointer(filename, clean_lines, linenum, error): """Check for left-leaning pointer placement. @@ -4723,6 +4748,7 @@ def CheckStyle(filename, clean_lines, linenum, file_extension, nesting_state, CheckCheck(filename, clean_lines, linenum, error) CheckAltTokens(filename, clean_lines, linenum, error) CheckNullTokens(filename, clean_lines, linenum, error) + CheckV8PersistentTokens(filename, clean_lines, linenum, error) CheckLeftLeaningPointer(filename, clean_lines, linenum, error) classinfo = nesting_state.InnermostClass() if classinfo: