Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2020-10-28 04:58:27 +0300
committerCampbell Barton <ideasman42@gmail.com>2020-10-28 06:04:44 +0300
commitc518cd73cdba971f27943f491cdb3525ddcf3176 (patch)
tree7786d751831c30d64056bd8fa4c4f2f5bd1dd4fd /source/creator
parent6ac46c9708f46f9dd83dd36008d6f7c9569b74eb (diff)
Cleanup: use enum for command line argument passes
Diffstat (limited to 'source/creator')
-rw-r--r--source/creator/creator.c11
-rw-r--r--source/creator/creator_args.c23
-rw-r--r--source/creator/creator_intern.h15
3 files changed, 32 insertions, 17 deletions
diff --git a/source/creator/creator.c b/source/creator/creator.c
index f9aea0af301..eba6c7c292f 100644
--- a/source/creator/creator.c
+++ b/source/creator/creator.c
@@ -404,7 +404,7 @@ int main(int argc,
MEM_use_memleak_detection(false);
/* Parse environment handling arguments. */
- BLI_argsParse(ba, 0, NULL, NULL);
+ BLI_argsParse(ba, ARG_PASS_ENVIRONMENT, NULL, NULL);
#else
/* Using preferences or user startup makes no sense for #WITH_PYTHON_MODULE. */
@@ -419,7 +419,7 @@ int main(int argc,
#ifndef WITH_PYTHON_MODULE
/* First test for background-mode (#Global.background) */
- BLI_argsParse(ba, 1, NULL, NULL);
+ BLI_argsParse(ba, ARG_PASS_SETTINGS, NULL, NULL);
main_signal_setup();
#endif
@@ -459,14 +459,14 @@ int main(int argc,
if (G.background == 0) {
#ifndef WITH_PYTHON_MODULE
- BLI_argsParse(ba, 2, NULL, NULL);
- BLI_argsParse(ba, 3, NULL, NULL);
+ BLI_argsParse(ba, ARG_PASS_SETTINGS_GUI, NULL, NULL);
+ BLI_argsParse(ba, ARG_PASS_SETTINGS_FORCE, NULL, NULL);
#endif
WM_init(C, argc, (const char **)argv);
}
else {
#ifndef WITH_PYTHON_MODULE
- BLI_argsParse(ba, 3, NULL, NULL);
+ BLI_argsParse(ba, ARG_PASS_SETTINGS_FORCE, NULL, NULL);
#endif
WM_init(C, argc, (const char **)argv);
@@ -488,6 +488,7 @@ int main(int argc,
/* OK we are ready for it */
#ifndef WITH_PYTHON_MODULE
+ /* Handles #ARG_PASS_FINAL. */
main_args_setup_post(C, ba);
#endif
diff --git a/source/creator/creator_args.c b/source/creator/creator_args.c
index d1f83b323a4..ef1c8e935c3 100644
--- a/source/creator/creator_args.c
+++ b/source/creator/creator_args.c
@@ -2057,12 +2057,12 @@ void main_args_setup(bContext *C, bArgs *ba)
BLI_argsPassSet(ba, -1);
BLI_argsAdd(ba, "--", NULL, CB(arg_handle_arguments_end), NULL);
- /* Pass 0: Environment Setup
+ /* Pass: Environment Setup
*
* It's important these run before any initialization is done, since they set up
* the environment used to access data-files, which are be used when initializing
* sub-systems such as color management. */
- BLI_argsPassSet(ba, 0);
+ BLI_argsPassSet(ba, ARG_PASS_ENVIRONMENT);
BLI_argsAdd(ba, NULL, "--python-use-system-env", CB(arg_handle_python_use_system_env_set), NULL);
/* Note that we could add used environment variables too. */
@@ -2071,10 +2071,10 @@ void main_args_setup(bContext *C, bArgs *ba)
BLI_argsAdd(ba, NULL, "--env-system-scripts", CB_EX(arg_handle_env_system_set, scripts), NULL);
BLI_argsAdd(ba, NULL, "--env-system-python", CB_EX(arg_handle_env_system_set, python), NULL);
- /* Pass 1: Background Mode & Settings
+ /* Pass: Background Mode & Settings
*
* Also and commands that exit after usage. */
- BLI_argsPassSet(ba, 1);
+ BLI_argsPassSet(ba, ARG_PASS_SETTINGS);
BLI_argsAdd(ba, "-h", "--help", CB(arg_handle_print_help), ba);
/* Windows only */
BLI_argsAdd(ba, "/?", NULL, CB_EX(arg_handle_print_help, win32), ba);
@@ -2105,7 +2105,6 @@ void main_args_setup(bContext *C, bArgs *ba)
# ifdef WITH_FFMPEG
BLI_argsAdd(ba,
-
NULL,
"--debug-ffmpeg",
CB_EX(arg_handle_debug_mode_generic_set, ffmpeg),
@@ -2242,8 +2241,8 @@ void main_args_setup(bContext *C, bArgs *ba)
BLI_argsAdd(ba, NULL, "--factory-startup", CB(arg_handle_factory_startup_set), NULL);
BLI_argsAdd(ba, NULL, "--enable-event-simulate", CB(arg_handle_enable_event_simulate), NULL);
- /* Pass 2: Custom Window Stuff. */
- BLI_argsPassSet(ba, 2);
+ /* Pass: Custom Window Stuff. */
+ BLI_argsPassSet(ba, ARG_PASS_SETTINGS_GUI);
BLI_argsAdd(ba, "-p", "--window-geometry", CB(arg_handle_window_geometry), NULL);
BLI_argsAdd(ba, "-w", "--window-border", CB(arg_handle_with_borders), NULL);
BLI_argsAdd(ba, "-W", "--window-fullscreen", CB(arg_handle_without_borders), NULL);
@@ -2254,13 +2253,13 @@ void main_args_setup(bContext *C, bArgs *ba)
BLI_argsAdd(ba, "-r", NULL, CB_EX(arg_handle_register_extension, silent), ba);
BLI_argsAdd(ba, NULL, "--no-native-pixels", CB(arg_handle_native_pixels_set), ba);
- /* Pass 3: Disabling Things & Forcing Settings. */
- BLI_argsPassSet(ba, 3);
+ /* Pass: Disabling Things & Forcing Settings. */
+ BLI_argsPassSet(ba, ARG_PASS_SETTINGS_FORCE);
BLI_argsAddCase(ba, "-noaudio", 1, NULL, 0, CB(arg_handle_audio_disable), NULL);
BLI_argsAddCase(ba, "-setaudio", 1, NULL, 0, CB(arg_handle_audio_set), NULL);
- /* Pass 4: Processing Arguments. */
- BLI_argsPassSet(ba, 4);
+ /* Pass: Processing Arguments. */
+ BLI_argsPassSet(ba, ARG_PASS_FINAL);
BLI_argsAdd(ba, "-f", "--render-frame", CB(arg_handle_render_frame), C);
BLI_argsAdd(ba, "-a", "--render-anim", CB(arg_handle_render_animation), C);
BLI_argsAdd(ba, "-S", "--scene", CB(arg_handle_scene_set), C);
@@ -2289,7 +2288,7 @@ void main_args_setup(bContext *C, bArgs *ba)
*/
void main_args_setup_post(bContext *C, bArgs *ba)
{
- BLI_argsParse(ba, 4, arg_handle_load_file, C);
+ BLI_argsParse(ba, ARG_PASS_FINAL, arg_handle_load_file, C);
}
/** \} */
diff --git a/source/creator/creator_intern.h b/source/creator/creator_intern.h
index 7ff3247e17e..fe8f8c4e20e 100644
--- a/source/creator/creator_intern.h
+++ b/source/creator/creator_intern.h
@@ -52,6 +52,21 @@ struct ApplicationState {
};
extern struct ApplicationState app_state; /* creator.c */
+/**
+ * Passes for use by #main_args_setup.
+ * Keep in order of execution.
+ */
+enum {
+ ARG_PASS_ENVIRONMENT = 0,
+ ARG_PASS_SETTINGS = 1,
+ /** Windowing & graphical settings, ignored in background mode. */
+ ARG_PASS_SETTINGS_GUI = 2,
+ ARG_PASS_SETTINGS_FORCE = 3,
+
+ /** Actions & fall back to loading blend file. */
+ ARG_PASS_FINAL = 4,
+};
+
/* for the callbacks: */
#ifndef WITH_PYTHON_MODULE
# define BLEND_VERSION_FMT "Blender %d.%02d.%d"