FPRProxy.m 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Copyright 2018 Google LLC
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import "FirebasePerformance/Tests/Unit/ISASwizzler/FPRProxy.h"
  17. @interface FPRProxy ()
  18. @property(nonatomic, strong) id delegateObject;
  19. @end
  20. @implementation FPRProxy
  21. - (instancetype)initWithDelegate:(id)delegate {
  22. _delegateObject = delegate;
  23. return self;
  24. }
  25. + (instancetype)proxyWithDelegate:(id)delegate {
  26. return [[FPRProxy alloc] initWithDelegate:delegate];
  27. }
  28. - (id)forwardingTargetForSelector:(SEL)selector {
  29. return _delegateObject;
  30. }
  31. - (void)forwardInvocation:(NSInvocation *)invocation {
  32. if (_delegateObject != nil) {
  33. [invocation setTarget:_delegateObject];
  34. [invocation invoke];
  35. }
  36. }
  37. - (NSMethodSignature *)methodSignatureForSelector:(SEL)selector {
  38. return [_delegateObject instanceMethodSignatureForSelector:selector];
  39. }
  40. - (BOOL)respondsToSelector:(SEL)aSelector {
  41. return [_delegateObject respondsToSelector:aSelector];
  42. }
  43. - (BOOL)isEqual:(id)object {
  44. return [_delegateObject isEqual:object];
  45. }
  46. - (NSUInteger)hash {
  47. return [_delegateObject hash];
  48. }
  49. - (Class)superclass {
  50. return [_delegateObject superclass];
  51. }
  52. - (Class)class {
  53. return [_delegateObject class];
  54. }
  55. - (BOOL)isKindOfClass:(Class)aClass {
  56. return [_delegateObject isKindOfClass:aClass];
  57. }
  58. - (BOOL)isMemberOfClass:(Class)aClass {
  59. return [_delegateObject isMemberOfClass:aClass];
  60. }
  61. - (BOOL)conformsToProtocol:(Protocol *)aProtocol {
  62. return [_delegateObject conformsToProtocol:aProtocol];
  63. }
  64. - (BOOL)isProxy {
  65. return YES;
  66. }
  67. - (NSString *)description {
  68. return [_delegateObject description];
  69. }
  70. - (NSString *)debugDescription {
  71. return [_delegateObject debugDescription];
  72. }
  73. @end