From 8a8dbd76b165db2b94c1625873da9e13bf24c2b9 Mon Sep 17 00:00:00 2001 From: George Marques Date: Tue, 12 Jan 2021 14:12:40 -0300 Subject: [PATCH] Add GDNative JSON generator for the builtin API Which can be used by language bindings to generate code statically. This is generated as a different file from the class API because it has different requirements (the builtin types have constructors and don't have signals), so bindings can better make use of each JSON file without extra parsing. This also cleans up a bit the old API generator, mainly initializing structs and renaming "instanciable" to the more correct "instantiable". The argument description in help text was updated to better reflect how it should be used. The argument is mandatory. --- main/main.cpp | 115 ++--- .../gdnative/nativescript/api_generator.cpp | 412 +++++++++++++++++- modules/gdnative/nativescript/api_generator.h | 1 + .../gdnative/nativescript/nativescript.cpp | 9 + 4 files changed, 462 insertions(+), 75 deletions(-) diff --git a/main/main.cpp b/main/main.cpp index f4548291003..a9354b80119 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -265,27 +265,27 @@ void Main::print_help(const char *p_binary) { OS::get_singleton()->print("\n"); OS::get_singleton()->print("General options:\n"); - OS::get_singleton()->print(" -h, --help Display this help message.\n"); - OS::get_singleton()->print(" --version Display the version string.\n"); - OS::get_singleton()->print(" -v, --verbose Use verbose stdout mode.\n"); - OS::get_singleton()->print(" --quiet Quiet mode, silences stdout messages. Errors are still displayed.\n"); + OS::get_singleton()->print(" -h, --help Display this help message.\n"); + OS::get_singleton()->print(" --version Display the version string.\n"); + OS::get_singleton()->print(" -v, --verbose Use verbose stdout mode.\n"); + OS::get_singleton()->print(" --quiet Quiet mode, silences stdout messages. Errors are still displayed.\n"); OS::get_singleton()->print("\n"); OS::get_singleton()->print("Run options:\n"); #ifdef TOOLS_ENABLED - OS::get_singleton()->print(" -e, --editor Start the editor instead of running the scene.\n"); - OS::get_singleton()->print(" -p, --project-manager Start the project manager, even if a project is auto-detected.\n"); + OS::get_singleton()->print(" -e, --editor Start the editor instead of running the scene.\n"); + OS::get_singleton()->print(" -p, --project-manager Start the project manager, even if a project is auto-detected.\n"); #endif - OS::get_singleton()->print(" -q, --quit Quit after the first iteration.\n"); - OS::get_singleton()->print(" -l, --language Use a specific locale ( being a two-letter code).\n"); - OS::get_singleton()->print(" --path Path to a project ( must contain a 'project.godot' file).\n"); - OS::get_singleton()->print(" -u, --upwards Scan folders upwards for project.godot file.\n"); - OS::get_singleton()->print(" --main-pack Path to a pack (.pck) file to load.\n"); - OS::get_singleton()->print(" --render-thread Render thread mode ('unsafe', 'safe', 'separate').\n"); - OS::get_singleton()->print(" --remote-fs
Remote filesystem ([:] address).\n"); - OS::get_singleton()->print(" --remote-fs-password Password for remote filesystem.\n"); + OS::get_singleton()->print(" -q, --quit Quit after the first iteration.\n"); + OS::get_singleton()->print(" -l, --language Use a specific locale ( being a two-letter code).\n"); + OS::get_singleton()->print(" --path Path to a project ( must contain a 'project.godot' file).\n"); + OS::get_singleton()->print(" -u, --upwards Scan folders upwards for project.godot file.\n"); + OS::get_singleton()->print(" --main-pack Path to a pack (.pck) file to load.\n"); + OS::get_singleton()->print(" --render-thread Render thread mode ('unsafe', 'safe', 'separate').\n"); + OS::get_singleton()->print(" --remote-fs
Remote filesystem ([:] address).\n"); + OS::get_singleton()->print(" --remote-fs-password Password for remote filesystem.\n"); - OS::get_singleton()->print(" --audio-driver Audio driver ["); + OS::get_singleton()->print(" --audio-driver Audio driver ["); for (int i = 0; i < AudioDriverManager::get_driver_count(); i++) { if (i > 0) { OS::get_singleton()->print(", "); @@ -294,7 +294,7 @@ void Main::print_help(const char *p_binary) { } OS::get_singleton()->print("].\n"); - OS::get_singleton()->print(" --display-driver Display driver (and rendering driver) ["); + OS::get_singleton()->print(" --display-driver Display driver (and rendering driver) ["); for (int i = 0; i < DisplayServer::get_create_function_count(); i++) { if (i > 0) { OS::get_singleton()->print(", "); @@ -311,26 +311,26 @@ void Main::print_help(const char *p_binary) { } OS::get_singleton()->print("].\n"); - OS::get_singleton()->print(" --rendering-driver Rendering driver (depends on display driver).\n"); + OS::get_singleton()->print(" --rendering-driver Rendering driver (depends on display driver).\n"); - OS::get_singleton()->print(" --text-driver Text driver (Fonts, BiDi, shaping)\n"); + OS::get_singleton()->print(" --text-driver Text driver (Fonts, BiDi, shaping)\n"); OS::get_singleton()->print("\n"); #ifndef SERVER_ENABLED OS::get_singleton()->print("Display options:\n"); - OS::get_singleton()->print(" -f, --fullscreen Request fullscreen mode.\n"); - OS::get_singleton()->print(" -m, --maximized Request a maximized window.\n"); - OS::get_singleton()->print(" -w, --windowed Request windowed mode.\n"); - OS::get_singleton()->print(" -t, --always-on-top Request an always-on-top window.\n"); - OS::get_singleton()->print(" --resolution x Request window resolution.\n"); - OS::get_singleton()->print(" --position , Request window position.\n"); - OS::get_singleton()->print(" --low-dpi Force low-DPI mode (macOS and Windows only).\n"); - OS::get_singleton()->print(" --no-window Disable window creation (Windows only). Useful together with --script.\n"); - OS::get_singleton()->print(" --enable-vsync-via-compositor When vsync is enabled, vsync via the OS' window compositor (Windows only).\n"); - OS::get_singleton()->print(" --disable-vsync-via-compositor Disable vsync via the OS' window compositor (Windows only).\n"); - OS::get_singleton()->print(" --single-window Use a single window (no separate subwindows).\n"); - OS::get_singleton()->print(" --tablet-driver Tablet input driver ("); + OS::get_singleton()->print(" -f, --fullscreen Request fullscreen mode.\n"); + OS::get_singleton()->print(" -m, --maximized Request a maximized window.\n"); + OS::get_singleton()->print(" -w, --windowed Request windowed mode.\n"); + OS::get_singleton()->print(" -t, --always-on-top Request an always-on-top window.\n"); + OS::get_singleton()->print(" --resolution x Request window resolution.\n"); + OS::get_singleton()->print(" --position , Request window position.\n"); + OS::get_singleton()->print(" --low-dpi Force low-DPI mode (macOS and Windows only).\n"); + OS::get_singleton()->print(" --no-window Disable window creation (Windows only). Useful together with --script.\n"); + OS::get_singleton()->print(" --enable-vsync-via-compositor When vsync is enabled, vsync via the OS' window compositor (Windows only).\n"); + OS::get_singleton()->print(" --disable-vsync-via-compositor Disable vsync via the OS' window compositor (Windows only).\n"); + OS::get_singleton()->print(" --single-window Use a single window (no separate subwindows).\n"); + OS::get_singleton()->print(" --tablet-driver Tablet input driver ("); for (int i = 0; i < OS::get_singleton()->get_tablet_driver_count(); i++) { if (i != 0) OS::get_singleton()->print(", "); @@ -341,43 +341,44 @@ void Main::print_help(const char *p_binary) { #endif OS::get_singleton()->print("Debug options:\n"); - OS::get_singleton()->print(" -d, --debug Debug (local stdout debugger).\n"); - OS::get_singleton()->print(" -b, --breakpoints Breakpoint list as source::line comma-separated pairs, no spaces (use %%20 instead).\n"); - OS::get_singleton()->print(" --profiling Enable profiling in the script debugger.\n"); - OS::get_singleton()->print(" --vk-layers Enable Vulkan Validation layers for debugging.\n"); + OS::get_singleton()->print(" -d, --debug Debug (local stdout debugger).\n"); + OS::get_singleton()->print(" -b, --breakpoints Breakpoint list as source::line comma-separated pairs, no spaces (use %%20 instead).\n"); + OS::get_singleton()->print(" --profiling Enable profiling in the script debugger.\n"); + OS::get_singleton()->print(" --vk-layers Enable Vulkan Validation layers for debugging.\n"); #if DEBUG_ENABLED - OS::get_singleton()->print(" --gpu-abort Abort on GPU errors (usually validation layer errors), may help see the problem if your system freezes.\n"); + OS::get_singleton()->print(" --gpu-abort Abort on GPU errors (usually validation layer errors), may help see the problem if your system freezes.\n"); #endif - OS::get_singleton()->print(" --remote-debug Remote debug (://[:], e.g. tcp://127.0.0.1:6007).\n"); + OS::get_singleton()->print(" --remote-debug Remote debug (://[:], e.g. tcp://127.0.0.1:6007).\n"); #if defined(DEBUG_ENABLED) && !defined(SERVER_ENABLED) - OS::get_singleton()->print(" --debug-collisions Show collision shapes when running the scene.\n"); - OS::get_singleton()->print(" --debug-navigation Show navigation polygons when running the scene.\n"); + OS::get_singleton()->print(" --debug-collisions Show collision shapes when running the scene.\n"); + OS::get_singleton()->print(" --debug-navigation Show navigation polygons when running the scene.\n"); #endif - OS::get_singleton()->print(" --frame-delay Simulate high CPU load (delay each frame by milliseconds).\n"); - OS::get_singleton()->print(" --time-scale Force time scale (higher values are faster, 1.0 is normal speed).\n"); - OS::get_singleton()->print(" --disable-render-loop Disable render loop so rendering only occurs when called explicitly from script.\n"); - OS::get_singleton()->print(" --disable-crash-handler Disable crash handler when supported by the platform code.\n"); - OS::get_singleton()->print(" --fixed-fps Force a fixed number of frames per second. This setting disables real-time synchronization.\n"); - OS::get_singleton()->print(" --print-fps Print the frames per second to the stdout.\n"); - OS::get_singleton()->print(" --profile-gpu Show a simple profile of the tasks that took more time during frame rendering.\n"); + OS::get_singleton()->print(" --frame-delay Simulate high CPU load (delay each frame by milliseconds).\n"); + OS::get_singleton()->print(" --time-scale Force time scale (higher values are faster, 1.0 is normal speed).\n"); + OS::get_singleton()->print(" --disable-render-loop Disable render loop so rendering only occurs when called explicitly from script.\n"); + OS::get_singleton()->print(" --disable-crash-handler Disable crash handler when supported by the platform code.\n"); + OS::get_singleton()->print(" --fixed-fps Force a fixed number of frames per second. This setting disables real-time synchronization.\n"); + OS::get_singleton()->print(" --print-fps Print the frames per second to the stdout.\n"); + OS::get_singleton()->print(" --profile-gpu Show a simple profile of the tasks that took more time during frame rendering.\n"); OS::get_singleton()->print("\n"); OS::get_singleton()->print("Standalone tools:\n"); - OS::get_singleton()->print(" -s, --script