FLEXMethodBase.m 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //
  2. // FLEXMethodBase.m
  3. // FLEX
  4. //
  5. // Derived from MirrorKit.
  6. // Created by Tanner on 7/5/15.
  7. // Copyright (c) 2015 Tanner Bennett. All rights reserved.
  8. //
  9. #import "FLEXMethodBase.h"
  10. @implementation FLEXMethodBase
  11. #pragma mark Initializers
  12. + (instancetype)buildMethodNamed:(NSString *)name withTypes:(NSString *)typeEncoding implementation:(IMP)implementation {
  13. return [[self alloc] initWithSelector:sel_registerName(name.UTF8String) types:typeEncoding imp:implementation];
  14. }
  15. - (id)initWithSelector:(SEL)selector types:(NSString *)types imp:(IMP)imp {
  16. NSParameterAssert(selector); NSParameterAssert(types); NSParameterAssert(imp);
  17. self = [super init];
  18. if (self) {
  19. _selector = selector;
  20. _typeEncoding = types;
  21. _implementation = imp;
  22. _name = NSStringFromSelector(self.selector);
  23. }
  24. return self;
  25. }
  26. - (NSString *)selectorString {
  27. return _name;
  28. }
  29. #pragma mark Overrides
  30. - (NSString *)description {
  31. if (!_flex_description) {
  32. _flex_description = [NSString stringWithFormat:@"%@ '%@'", _name, _typeEncoding];
  33. }
  34. return _flex_description;
  35. }
  36. @end