OLD | NEW |
(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, replace the selector |selector| on |target| with that |
| 17 // from |source|. |
| 18 class BASE_EXPORT ScopedObjCClassSwizzler { |
| 19 public: |
| 20 ScopedObjCClassSwizzler(Class target, Class source, SEL selector); |
| 21 ~ScopedObjCClassSwizzler(); |
| 22 |
| 23 // Return a callable function pointer for the replaced method. To call this |
| 24 // from the replacing function, the first two arguments should be |self| and |
| 25 // |_cmd|. These are followed by the (variadic) method arguments. |
| 26 IMP GetOriginalImplementation(); |
| 27 |
| 28 private: |
| 29 Method old_selector_impl_; |
| 30 Method new_selector_impl_; |
| 31 |
| 32 DISALLOW_COPY_AND_ASSIGN(ScopedObjCClassSwizzler); |
| 33 }; |
| 34 |
| 35 } // namespace mac |
| 36 } // namespace base |
| 37 |
| 38 #endif // BASE_MAC_SCOPED_OBJC_CLASS_SWIZZLER_H_ |
OLD | NEW |