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
3 # found in the LICENSE file.
5 """Presubmit script for ui.
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
8 for more details about the presubmit API built into depot_tools.
11 INCLUDE_CPP_FILES_ONLY
= (
15 def CheckScopedPtr(input_api
, output_api
,
16 white_list
=INCLUDE_CPP_FILES_ONLY
, black_list
=None):
17 black_list
= tuple(black_list
or input_api
.DEFAULT_BLACK_LIST
)
18 source_file_filter
= lambda x
: input_api
.FilterSourceFile(x
,
22 for f
in input_api
.AffectedSourceFiles(source_file_filter
):
23 for line_number
, line
in f
.ChangedContents():
26 if input_api
.re
.search(r
'\bscoped_ptr<.*?>\(\)', line
):
27 errors
.append(output_api
.PresubmitError(
28 '%s:%d uses scoped_ptr<T>(). Use nullptr instead.' %
29 (f
.LocalPath(), line_number
)))
33 def CheckChange(input_api
, output_api
):
35 results
+= CheckScopedPtr(input_api
, output_api
)
39 def CheckChangeOnUpload(input_api
, output_api
):
40 return CheckChange(input_api
, output_api
)
43 def CheckChangeOnCommit(input_api
, output_api
):
44 return CheckChange(input_api
, output_api
)