FLEXProtocol.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //
  2. // FLEXProtocol.h
  3. // FLEX
  4. //
  5. // Derived from MirrorKit.
  6. // Created by Tanner on 6/30/15.
  7. // Copyright (c) 2015 Tanner Bennett. All rights reserved.
  8. //
  9. #import <Foundation/Foundation.h>
  10. #import "FLEXRuntimeUtility.h"
  11. @class FLEXProperty, FLEXMethodDescription;
  12. #pragma mark FLEXProtocol
  13. @interface FLEXProtocol : NSObject
  14. /// Every protocol registered with the runtime.
  15. + (NSArray<FLEXProtocol *> *)allProtocols;
  16. + (instancetype)protocol:(Protocol *)protocol;
  17. /// The underlying protocol data structure.
  18. @property (nonatomic, readonly) Protocol *objc_protocol;
  19. /// The name of the protocol.
  20. @property (nonatomic, readonly) NSString *name;
  21. /// The properties in the protocol, if any.
  22. @property (nonatomic, readonly) NSArray<FLEXProperty *> *properties;
  23. /// The required methods of the protocol, if any. This includes property getters and setters.
  24. @property (nonatomic, readonly) NSArray<FLEXMethodDescription *> *requiredMethods;
  25. /// The optional methods of the protocol, if any. This includes property getters and setters.
  26. @property (nonatomic, readonly) NSArray<FLEXMethodDescription *> *optionalMethods;
  27. /// All protocols that this protocol conforms to, if any.
  28. @property (nonatomic, readonly) NSArray<FLEXProtocol *> *protocols;
  29. /// Not to be confused with \c -conformsToProtocol:, which refers to the current
  30. /// \c FLEXProtocol instance and not the underlying \c Protocol object.
  31. - (BOOL)conformsTo:(Protocol *)protocol;
  32. @end
  33. #pragma mark Method descriptions
  34. @interface FLEXMethodDescription : NSObject
  35. + (instancetype)description:(struct objc_method_description)methodDescription;
  36. /// The underlying method description data structure.
  37. @property (nonatomic, readonly) struct objc_method_description objc_description;
  38. /// The method's selector.
  39. @property (nonatomic, readonly) SEL selector;
  40. /// The method's type encoding.
  41. @property (nonatomic, readonly) NSString *typeEncoding;
  42. /// The method's return type.
  43. @property (nonatomic, readonly) FLEXTypeEncoding returnType;
  44. @end