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

Side by Side Diff: base/mac/scoped_objc_class_swizzler.h

Issue 345243007: Add ScopedObjCClassSwizzler in base/mac, absorbs objc_method_swizzle and ScopedClassSwizzler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Inlude in shiny new gn base_unittests target Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « base/base.gypi ('k') | base/mac/scoped_objc_class_swizzler.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 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.
4
5 #ifndef BASE_MAC_SCOPED_OBJC_CLASS_SWIZZLER_H_
6 #define BASE_MAC_SCOPED_OBJC_CLASS_SWIZZLER_H_
7
8 #import <objc/runtime.h>
9
10 #include "base/base_export.h"
11 #include "base/macros.h"
12
13 namespace base {
14 namespace mac {
15
16 // Within a given scope, swaps method implementations of a class interface, or
17 // between two class interfaces. The argument and return types must match.
18 class BASE_EXPORT ScopedObjCClassSwizzler {
19 public:
20 // Given two classes that each respond to |selector|, swap the implementations
21 // of those methods.
22 ScopedObjCClassSwizzler(Class target, Class source, SEL selector);
23
24 // Given two selectors on the same class interface, |target| (e.g. via
25 // inheritance or categories), swap the implementations of methods |original|
26 // and |alternate|.
27 ScopedObjCClassSwizzler(Class target, SEL original, SEL alternate);
28
29 ~ScopedObjCClassSwizzler();
30
31 // Return a callable function pointer for the replaced method. To call this
32 // from the replacing function, the first two arguments should be |self| and
33 // |_cmd|. These are followed by the (variadic) method arguments.
34 IMP GetOriginalImplementation();
35
36 private:
37 // Delegated constructor.
38 void Init(Class target, Class source, SEL original, SEL alternate);
39
40 Method old_selector_impl_;
41 Method new_selector_impl_;
42
43 DISALLOW_COPY_AND_ASSIGN(ScopedObjCClassSwizzler);
44 };
45
46 } // namespace mac
47 } // namespace base
48
49 #endif // BASE_MAC_SCOPED_OBJC_CLASS_SWIZZLER_H_
OLDNEW
« no previous file with comments | « base/base.gypi ('k') | base/mac/scoped_objc_class_swizzler.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698