AUI Framework  master
Cross-platform module-based framework for developing C++20 desktop applications
Entry.h
1/*
2 * AUI Framework - Declarative UI toolkit for modern C++20
3 * Copyright (C) 2020-2024 Alex2772 and Contributors
4 *
5 * SPDX-License-Identifier: MPL-2.0
6 *
7 * This Source Code Form is subject to the terms of the Mozilla Public
8 * License, v. 2.0. If a copy of the MPL was not distributed with this
9 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 */
11
12#pragma once
13
14#include <AUI/api.h>
15#include <AUI/Util/ACommandLineArgs.h>
16
36#if defined(WIN32)
37#include <windows.h>
38
39// fake the main function when tests module compiling
40#ifdef AUI_TESTS_MODULE
41#define AUI_ENTRY \
42 AUI_EXPORT int aui_entry(const AStringVector& args); \
43 AUI_EXPORT int aui_main(int argc, char** argv, int(*aui_entry)(const AStringVector&)); \
44 int fake_main(int argc, char** argv) { \
45 return aui_main(argc, argv, aui_entry);\
46 } \
47AUI_EXPORT int aui_entry(const AStringVector& args)
48#else
49 #define AUI_ENTRY \
50 AUI_EXPORT int aui_entry(const AStringVector& args); \
51 AUI_EXPORT int aui_main(int argc, char** argv, int(*aui_entry)(const AStringVector&)); \
52 int main(int argc, char** argv) { \
53 return aui_main(argc, argv, aui_entry);\
54 } \
55 int __stdcall WinMain( \
56 HINSTANCE hInstance, \
57 HINSTANCE hPrevInstance, \
58 LPSTR lpCmdLine, \
59 int nShowCmd \
60) { \
61 return main(0, nullptr); \
62} \
63AUI_EXPORT int aui_entry(const AStringVector& args)
64#endif
65#elif AUI_PLATFORM_ANDROID
66
67#include <jni.h>
68
69#define AUI_ENTRY \
70 AUI_EXPORT int aui_entry(const AStringVector& args); \
71 AUI_EXPORT int aui_main(JavaVM* vm, int(*aui_entry)(const AStringVector&)); \
72extern "C" \
73JNIEXPORT jint JNICALL \
74JNI_OnLoad(JavaVM* vm, void* reserved) { \
75 aui_main(vm, aui_entry); \
76 return JNI_VERSION_1_2; \
77 } \
78 AUI_EXPORT int aui_entry(const AStringVector& args)
79
80#else
81
82// fake the main function when tests module compiling
83#ifdef AUI_TESTS_MODULE
84#define AUI_ENTRY \
85 AUI_EXPORT int aui_entry(const AStringVector& args); \
86 AUI_EXPORT int aui_main(int argc, char** argv, int(*aui_entry)(const AStringVector&)); \
87 int fake_main(int argc, char** argv) { \
88 return aui_main(argc, argv, aui_entry);\
89 } \
90 AUI_EXPORT int aui_entry(const AStringVector& args)
91#else
92#define AUI_ENTRY \
93 AUI_EXPORT int aui_entry(const AStringVector& args); \
94 AUI_EXPORT int aui_main(int argc, char** argv, int(*aui_entry)(const AStringVector&)); \
95 int main(int argc, char** argv) { \
96 return aui_main(argc, argv, aui_entry);\
97 } \
98 AUI_EXPORT int aui_entry(const AStringVector& args)
99#endif
100
101#endif
102
103namespace aui {
108 API_AUI_CORE const ACommandLineArgs& args() noexcept;
109}
Simple command line arguments parser.
Definition: ACommandLineArgs.h:22
API_AUI_CORE const ACommandLineArgs & args() noexcept
Definition: OSAndroid.cpp:29