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

Side by Side Diff: src/pdf/SkScoped.h

Issue 2278703002: SkPDF: Glyph validation change (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 3 nits Created 4 years, 3 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
« src/pdf/SkPDFFont.cpp ('K') | « src/pdf/SkPDFFont.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef SkScoped_DEFINED
9 #define SkScoped_DEFINED
10
11 /**
12 * sk_at_scope_end(stmt) evaluates stmt when the current scope ends.
13 *
14 * E.g.
15 *
16 * int x = 5;
17 * {
18 * sk_at_scope_end(x--);
19 * SkASSERT(x == 5);
20 * }
21 * SkASSERT(x == 4);
22 */
23 template <typename Fn>
24 class SkScoped {
bungeman-skia 2016/08/26 18:24:42 SkScopeExit
hal.canary 2016/08/26 19:22:37 Done.
25 public:
26 SkScoped(Fn f) : fFn(std::move(f)) {}
27 ~SkScoped() { fFn(); }
28
29 private:
30 Fn fFn;
31
32 SkScoped( const SkScoped& ) = delete;
33 SkScoped& operator=(const SkScoped& ) = delete;
34 SkScoped( SkScoped&&) = delete;
35 SkScoped& operator=( SkScoped&&) = delete;
36 };
37
38 template <typename Fn>
39 inline SkScoped<Fn> SkMakeScoped(Fn&& fn) {
bungeman-skia 2016/08/26 18:24:42 SkMakeScopeExit
hal.canary 2016/08/26 19:22:37 Done.
40 return {std::move(fn)};
41 }
42
43 #define sk_at_scope_end(stmt) \
bungeman-skia 2016/08/26 18:24:42 SK_AT_SCOPE_EXIT
44 SK_UNUSED auto&& SK_MACRO_APPEND_LINE(at_scope_exit_) = \
bungeman-skia 2016/08/26 18:24:42 You'll also need https://codereview.chromium.org/
45 SkMakeScoped([&]() { stmt; });
46
47 #endif // SkScoped_DEFINED
OLDNEW
« src/pdf/SkPDFFont.cpp ('K') | « src/pdf/SkPDFFont.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698