FLEXProtocol.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 "FLEXRuntimeConstants.h"
  10. @class FLEXProperty, FLEXMethodDescription;
  11. #pragma mark FLEXProtocol
  12. @interface FLEXProtocol : NSObject
  13. /// Every protocol registered with the runtime.
  14. + (NSArray<FLEXProtocol *> *)allProtocols;
  15. + (instancetype)protocol:(Protocol *)protocol;
  16. /// The underlying protocol data structure.
  17. @property (nonatomic, readonly) Protocol *objc_protocol;
  18. /// The name of the protocol.
  19. @property (nonatomic, readonly) NSString *name;
  20. /// The properties in the protocol, if any.
  21. @property (nonatomic, readonly) NSArray<FLEXProperty *> *properties;
  22. /// The required methods of the protocol, if any. This includes property getters and setters.
  23. @property (nonatomic, readonly) NSArray<FLEXMethodDescription *> *requiredMethods;
  24. /// The optional methods of the protocol, if any. This includes property getters and setters.
  25. @property (nonatomic, readonly) NSArray<FLEXMethodDescription *> *optionalMethods;
  26. /// All protocols that this protocol conforms to, if any.
  27. @property (nonatomic, readonly) NSArray<FLEXProtocol *> *protocols;
  28. /// For internal use
  29. @property (nonatomic) id tag;
  30. /// Not to be confused with \c -conformsToProtocol:, which refers to the current
  31. /// \c FLEXProtocol instance and not the underlying \c Protocol object.
  32. - (BOOL)conformsTo:(Protocol *)protocol;
  33. @end
  34. #pragma mark Method descriptions
  35. @interface FLEXMethodDescription : NSObject
  36. + (instancetype)description:(struct objc_method_description)methodDescription;
  37. /// The underlying method description data structure.
  38. @property (nonatomic, readonly) struct objc_method_description objc_description;
  39. /// The method's selector.
  40. @property (nonatomic, readonly) SEL selector;
  41. /// The method's type encoding.
  42. @property (nonatomic, readonly) NSString *typeEncoding;
  43. /// The method's return type.
  44. @property (nonatomic, readonly) FLEXTypeEncoding returnType;
  45. @end