|
321 | 321 | 'runtime/string',
|
322 | 322 | 'runtime/threadsafe_fn',
|
323 | 323 | 'runtime/vlog',
|
| 324 | + 'runtime/v8_persistent', |
324 | 325 | 'whitespace/blank_line',
|
325 | 326 | 'whitespace/braces',
|
326 | 327 | 'whitespace/comma',
|
|
627 | 628 |
|
628 | 629 | _NULL_TOKEN_PATTERN = re.compile(r'\bNULL\b')
|
629 | 630 |
|
| 631 | +_V8_PERSISTENT_PATTERN = re.compile(r'\bv8::Persistent\b') |
| 632 | + |
630 | 633 | _RIGHT_LEANING_POINTER_PATTERN = re.compile(r'[^=|(,\s><);&?:}]'
|
631 | 634 | r'(?<!(sizeof|return))'
|
632 | 635 | r'\s\*[a-zA-Z_][0-9a-zA-Z_]*')
|
@@ -4547,6 +4550,28 @@ def CheckNullTokens(filename, clean_lines, linenum, error):
|
4547 | 4550 | error(filename, linenum, 'readability/null_usage', 2,
|
4548 | 4551 | 'Use nullptr instead of NULL')
|
4549 | 4552 |
|
| 4553 | +def CheckV8PersistentTokens(filename, clean_lines, linenum, error): |
| 4554 | + """Check v8::Persistent usage. |
| 4555 | +
|
| 4556 | + Args: |
| 4557 | + filename: The name of the current file. |
| 4558 | + clean_lines: A CleansedLines instance containing the file. |
| 4559 | + linenum: The number of the line to check. |
| 4560 | + error: The function to call with any errors found. |
| 4561 | + """ |
| 4562 | + line = clean_lines.elided[linenum] |
| 4563 | + |
| 4564 | + # Avoid preprocessor lines |
| 4565 | + if Match(r'^\s*#', line): |
| 4566 | + return |
| 4567 | + |
| 4568 | + if line.find('/*') >= 0 or line.find('*/') >= 0: |
| 4569 | + return |
| 4570 | + |
| 4571 | + for match in _V8_PERSISTENT_PATTERN.finditer(line): |
| 4572 | + error(filename, linenum, 'runtime/v8_persistent', 2, |
| 4573 | + 'Use v8::Global instead of v8::Persistent') |
| 4574 | + |
4550 | 4575 | def CheckLeftLeaningPointer(filename, clean_lines, linenum, error):
|
4551 | 4576 | """Check for left-leaning pointer placement.
|
4552 | 4577 |
|
@@ -4723,6 +4748,7 @@ def CheckStyle(filename, clean_lines, linenum, file_extension, nesting_state,
|
4723 | 4748 | CheckCheck(filename, clean_lines, linenum, error)
|
4724 | 4749 | CheckAltTokens(filename, clean_lines, linenum, error)
|
4725 | 4750 | CheckNullTokens(filename, clean_lines, linenum, error)
|
| 4751 | + CheckV8PersistentTokens(filename, clean_lines, linenum, error) |
4726 | 4752 | CheckLeftLeaningPointer(filename, clean_lines, linenum, error)
|
4727 | 4753 | classinfo = nesting_state.InnermostClass()
|
4728 | 4754 | if classinfo:
|
|
0 commit comments