Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(402)

Side by Side Diff: ui/PRESUBMIT.py

Issue 1868363002: Replace scoped_ptr with std::unique_ptr in //ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptrcc
Patch Set: scopedptrui: rebase-make_scoped_ptr Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Presubmit script for ui. 5 """Presubmit script for ui.
6 6
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
8 for more details about the presubmit API built into depot_tools. 8 for more details about the presubmit API built into depot_tools.
9 """ 9 """
10 10
11 INCLUDE_CPP_FILES_ONLY = ( 11 INCLUDE_CPP_FILES_ONLY = (
12 r'.*\.(cc|h|mm)$', 12 r'.*\.(cc|h|mm)$',
13 ) 13 )
14 14
15 def CheckScopedPtr(input_api, output_api, 15 def CheckUniquePtr(input_api, output_api,
16 white_list=INCLUDE_CPP_FILES_ONLY, black_list=None): 16 white_list=INCLUDE_CPP_FILES_ONLY, black_list=None):
17 black_list = tuple(black_list or input_api.DEFAULT_BLACK_LIST) 17 black_list = tuple(black_list or input_api.DEFAULT_BLACK_LIST)
18 source_file_filter = lambda x: input_api.FilterSourceFile(x, 18 source_file_filter = lambda x: input_api.FilterSourceFile(x,
19 white_list, 19 white_list,
20 black_list) 20 black_list)
21 errors = [] 21 errors = []
22 for f in input_api.AffectedSourceFiles(source_file_filter): 22 for f in input_api.AffectedSourceFiles(source_file_filter):
23 for line_number, line in f.ChangedContents(): 23 for line_number, line in f.ChangedContents():
24 # Disallow: 24 # Disallow:
25 # return scoped_ptr<T>(foo); 25 # return std::unique_ptr<T>(foo);
26 # bar = scoped_ptr<T>(foo); 26 # bar = std::unique_ptr<T>(foo);
27 # But allow: 27 # But allow:
28 # return scoped_ptr<T[]>(foo); 28 # return std::unique_ptr<T[]>(foo);
29 # bar = scoped_ptr<T[]>(foo); 29 # bar = std::unique_ptr<T[]>(foo);
30 if input_api.re.search( 30 if input_api.re.search(
31 r'(=|\breturn)\s*scoped_ptr<[^\[\]>]+>\([^)]+\)', line): 31 r'(=|\breturn)\s*std::unique_ptr<[^\[\]>]+>\([^)]+\)', line):
32 errors.append(output_api.PresubmitError( 32 errors.append(output_api.PresubmitError(
33 ('%s:%d uses explicit scoped_ptr constructor. ' + 33 ('%s:%d uses explicit std::unique_ptr constructor. ' +
34 'Use make_scoped_ptr() instead.') % (f.LocalPath(), line_number))) 34 'Use base::WrapUnique() instead.') % (f.LocalPath(), line_number)))
35 # TODO(sky): this incorrectly catches templates. Fix and reenable. 35 # TODO(sky): this incorrectly catches templates. Fix and reenable.
36 # Disallow: 36 # Disallow:
37 # scoped_ptr<T>() 37 # std::unique_ptr<T>()
38 # if input_api.re.search(r'\bscoped_ptr<.*?>\(\)', line): 38 # if input_api.re.search(r'\bstd::unique_ptr<.*?>\(\)', line):
39 # errors.append(output_api.PresubmitError( 39 # errors.append(output_api.PresubmitError(
40 # '%s:%d uses scoped_ptr<T>(). Use nullptr instead.' % 40 # '%s:%d uses std::unique_ptr<T>(). Use nullptr instead.' %
41 # (f.LocalPath(), line_number))) 41 # (f.LocalPath(), line_number)))
42 return errors 42 return errors
43 43
44 44
45 def CheckChange(input_api, output_api): 45 def CheckChange(input_api, output_api):
46 results = [] 46 results = []
47 results += CheckScopedPtr(input_api, output_api) 47 results += CheckUniquePtr(input_api, output_api)
48 return results 48 return results
49 49
50 50
51 def CheckChangeOnUpload(input_api, output_api): 51 def CheckChangeOnUpload(input_api, output_api):
52 return CheckChange(input_api, output_api) 52 return CheckChange(input_api, output_api)
53 53
54 54
55 def CheckChangeOnCommit(input_api, output_api): 55 def CheckChangeOnCommit(input_api, output_api):
56 return CheckChange(input_api, output_api) 56 return CheckChange(input_api, output_api)
OLDNEW
« no previous file with comments | « extensions/common/features/json_feature_provider_source.cc ('k') | ui/accelerated_widget_mac/io_surface_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698