diff dw.h @ 2396:5bb3491ceba2

iOS: Get iOS basic funcionality working by creating dwmain() macros. This allows us to fork the main() entry point into the main thread to essentially just call UIApplicationMain() and a secondary thread to call the user's main() function. This is an experimental change... but required for iOS functionality... May be changed further going forward. Move more DW functions into thread safety since the user entry point is now a secondary thread.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 25 Mar 2021 20:39:52 +0000
parents e6449653a30b
children 4de830d3bf9e
line wrap: on
line diff
--- a/dw.h	Thu Mar 25 09:04:59 2021 +0000
+++ b/dw.h	Thu Mar 25 20:39:52 2021 +0000
@@ -1615,6 +1615,24 @@
 #define dw_container_get_start(a, b) dw_container_query_start(a, b)
 #define dw_container_get_next(a, b) dw_container_query_next(a, b)
 
+/* Entrypoint handling macros */
+#ifdef __IOS__
+#define dwmain(a, b) \
+_dwmain(a, b); \
+void _dw_main_thread(int argc, char **argv); \
+void _dw_main_launch(void **); \
+int main(a, b) { \
+    void **data = calloc(sizeof(void *), 3); \
+    data[0] = DW_POINTER(_dwmain); \
+    data[1] = DW_INT_TO_POINTER(argc); \
+    data[2] = DW_POINTER(argv); \
+    dw_thread_new(_dw_main_launch, data, 0); \
+    _dw_main_thread(argc, argv); } \
+int _dwmain(a, b)
+#else
+#define dwmain(a, b) main(a, b)
+#endif
+
 /* Public function prototypes */
 void API dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad);
 void API dw_box_pack_end(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad);