AUI Framework  master
Cross-platform base for C++ UI apps
Loading...
Searching...
No Matches
Entry.h
    1/*
    2 * AUI Framework - Declarative UI toolkit for modern C++20
    3 * Copyright (C) 2020-2025 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
   56
   57#if defined(WIN32)
   58#include <windows.h>
   59
   60// fake the main function when tests module compiling
   61#ifdef AUI_TESTS_MODULE
   62#define AUI_ENTRY \
   63    AUI_EXPORT int aui_entry(const AStringVector& args); \
   64    AUI_EXPORT int aui_main(int argc, char** argv, int(*aui_entry)(const AStringVector&)); \
   65    int fake_main(int argc, char** argv) {                               \
   66        return aui_main(argc, argv, aui_entry);\
   67    }             \
   68AUI_EXPORT int aui_entry(const AStringVector& args)
   69#else
   70    #define AUI_ENTRY \
   71    AUI_EXPORT int aui_entry(const AStringVector& args); \
   72    AUI_EXPORT int aui_main(int argc, char** argv, int(*aui_entry)(const AStringVector&)); \
   73    int main(int argc, char** argv) {                               \
   74        return aui_main(argc, argv, aui_entry);\
   75    } \
   76    int __stdcall WinMain( \
   77        HINSTANCE hInstance, \
   78        HINSTANCE hPrevInstance, \
   79        LPSTR     lpCmdLine, \
   80        int       nShowCmd \
   81) { \
   82    return main(0, nullptr); \
   83} \
   84AUI_EXPORT int aui_entry(const AStringVector& args)
   85#endif
   86#elif AUI_PLATFORM_ANDROID
   87
   88#include <jni.h>
   89
   90#define AUI_ENTRY \
   91    AUI_EXPORT int aui_entry(const AStringVector& args); \
   92    AUI_EXPORT int aui_main(JavaVM* vm, int(*aui_entry)(const AStringVector&)); \
   93extern "C" \
   94JNIEXPORT jint JNICALL \
   95JNI_OnLoad(JavaVM* vm, void* reserved) { \
   96        aui_main(vm, aui_entry); \
   97        return JNI_VERSION_1_2;  \
   98    } \
   99    AUI_EXPORT int aui_entry(const AStringVector& args)
  100
  101#else
  102
  103// fake the main function when tests module compiling
  104#ifdef AUI_TESTS_MODULE
  105#define AUI_ENTRY \
  106    AUI_EXPORT int aui_entry(const AStringVector& args); \
  107    AUI_EXPORT int aui_main(int argc, char** argv, int(*aui_entry)(const AStringVector&)); \
  108    int fake_main(int argc, char** argv) {                               \
  109        return aui_main(argc, argv, aui_entry);\
  110    } \
  111    AUI_EXPORT int aui_entry(const AStringVector& args)
  112#else
  113#define AUI_ENTRY \
  114    AUI_EXPORT int aui_entry(const AStringVector& args); \
  115    AUI_EXPORT int aui_main(int argc, char** argv, int(*aui_entry)(const AStringVector&)); \
  116    int main(int argc, char** argv) {                               \
  117        return aui_main(argc, argv, aui_entry);\
  118    } \
  119    AUI_EXPORT int aui_entry(const AStringVector& args)
  120#endif
  121
  122#endif
  123
  124namespace aui {
  129    API_AUI_CORE const ACommandLineArgs& args() noexcept;
  130}
Simple command line arguments parser.
Definition ACommandLineArgs.h:22
API_AUI_CORE const ACommandLineArgs & args() noexcept