FLEXProtocol.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. //
  2. // FLEXProtocol.h
  3. // FLEX
  4. //
  5. // Derived from MirrorKit.
  6. // Created by Tanner on 6/30/15.
  7. // Copyright (c) 2020 FLEX Team. 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 required methods of the protocol, if any. This includes property getters and setters.
  21. @property (nonatomic, readonly) NSArray<FLEXMethodDescription *> *requiredMethods;
  22. /// The optional methods of the protocol, if any. This includes property getters and setters.
  23. @property (nonatomic, readonly) NSArray<FLEXMethodDescription *> *optionalMethods;
  24. /// All protocols that this protocol conforms to, if any.
  25. @property (nonatomic, readonly) NSArray<FLEXProtocol *> *protocols;
  26. /// The full path of the image that contains this protocol definition,
  27. /// or \c nil if this protocol was probably defined at runtime.
  28. @property (nonatomic, readonly) NSString *imagePath;
  29. /// The properties in the protocol, if any. \c nil on iOS 10+
  30. @property (nonatomic, readonly) NSArray<FLEXProperty *> *properties API_DEPRECATED("Use the more specific accessors below", ios(2.0, 10.0));
  31. /// The required properties in the protocol, if any.
  32. @property (nonatomic, readonly) NSArray<FLEXProperty *> *requiredProperties API_AVAILABLE(ios(10.0));
  33. /// The optional properties in the protocol, if any.
  34. @property (nonatomic, readonly) NSArray<FLEXProperty *> *optionalProperties API_AVAILABLE(ios(10.0));
  35. /// For internal use
  36. @property (nonatomic) id tag;
  37. /// Not to be confused with \c -conformsToProtocol:, which refers to the current
  38. /// \c FLEXProtocol instance and not the underlying \c Protocol object.
  39. - (BOOL)conformsTo:(Protocol *)protocol;
  40. @end
  41. #pragma mark Method descriptions
  42. @interface FLEXMethodDescription : NSObject
  43. + (instancetype)description:(struct objc_method_description)description;
  44. + (instancetype)description:(struct objc_method_description)description instance:(BOOL)isInstance;
  45. /// The underlying method description data structure.
  46. @property (nonatomic, readonly) struct objc_method_description objc_description;
  47. /// The method's selector.
  48. @property (nonatomic, readonly) SEL selector;
  49. /// The method's type encoding.
  50. @property (nonatomic, readonly) NSString *typeEncoding;
  51. /// The method's return type.
  52. @property (nonatomic, readonly) FLEXTypeEncoding returnType;
  53. /// \c YES if this is an instance method, \c NO if it is a class method, or \c nil if unspecified
  54. @property (nonatomic, readonly) NSNumber *instance;
  55. @end