v / vlib / ios / ios_darwin.c.v
43 lines · 35 sloc · 1.21 KB · dc2f77557344cdeb714728c87c783bcf6f1b69ad
Raw
1module ios
2
3import macos
4
5#flag -framework UIKit
6#insert "@VEXEROOT/vlib/ios/uikit_bridge.h"
7
8fn C.ios_ui_application_main(argc int, argv &&char, principal voidptr, delegate voidptr) int
9fn C.ios_color_from_hex(hex u32) voidptr
10fn C.ios_color_from_hex_alpha(hex u32, alpha f64) voidptr
11fn C.ios_index_path_row(index_path voidptr) i64
12fn C.ios_index_path_for_row(row i64, section i64) voidptr
13
14// Start the UIKit application run loop.
15@[inline]
16pub fn application_main(argc int, argv &&char, delegate_class_name string) int {
17 return C.ios_ui_application_main(argc, argv, unsafe { nil },
18 macos.nsstring(delegate_class_name))
19}
20
21// Create a UIColor from a hex value (0xRRGGBB).
22@[inline]
23pub fn color(hex u32) macos.Id {
24 return C.ios_color_from_hex(hex)
25}
26
27// Create a UIColor from a hex value with alpha.
28@[inline]
29pub fn color_alpha(hex u32, alpha f64) macos.Id {
30 return C.ios_color_from_hex_alpha(hex, alpha)
31}
32
33// Get the row index from an NSIndexPath.
34@[inline]
35pub fn index_path_row(index_path macos.Id) int {
36 return int(C.ios_index_path_row(index_path))
37}
38
39// Create an NSIndexPath for a row in a section.
40@[inline]
41pub fn index_path(row int, section int) macos.Id {
42 return C.ios_index_path_for_row(i64(row), i64(section))
43}
44