| 1 | #ifndef IOS_UIKIT_BRIDGE_H |
| 2 | #define IOS_UIKIT_BRIDGE_H |
| 3 | |
| 4 | #import <UIKit/UIKit.h> |
| 5 | |
| 6 | static inline int ios_ui_application_main(int argc, char** argv, void* principal, void* delegate) { |
| 7 | return UIApplicationMain(argc, argv, (__bridge NSString*)principal, (__bridge NSString*)delegate); |
| 8 | } |
| 9 | |
| 10 | static inline void* ios_color_from_hex(unsigned int hex) { |
| 11 | CGFloat r = ((hex >> 16) & 0xFF) / 255.0; |
| 12 | CGFloat g = ((hex >> 8) & 0xFF) / 255.0; |
| 13 | CGFloat b = (hex & 0xFF) / 255.0; |
| 14 | return (void*)[UIColor colorWithRed:r green:g blue:b alpha:1.0]; |
| 15 | } |
| 16 | |
| 17 | static inline void* ios_color_from_hex_alpha(unsigned int hex, double alpha) { |
| 18 | CGFloat r = ((hex >> 16) & 0xFF) / 255.0; |
| 19 | CGFloat g = ((hex >> 8) & 0xFF) / 255.0; |
| 20 | CGFloat b = (hex & 0xFF) / 255.0; |
| 21 | return (void*)[UIColor colorWithRed:r green:g blue:b alpha:alpha]; |
| 22 | } |
| 23 | |
| 24 | static inline long long ios_index_path_row(void* index_path) { |
| 25 | return [((NSIndexPath*)index_path) row]; |
| 26 | } |
| 27 | |
| 28 | static inline void* ios_index_path_for_row(long long row, long long section) { |
| 29 | return (void*)[NSIndexPath indexPathForRow:row inSection:section]; |
| 30 | } |
| 31 | |
| 32 | #endif |
| 33 | |