Cleanup: use full sentences for code-comments

Also correct references source files.
This commit is contained in:
Campbell Barton
2024-03-19 13:57:00 +11:00
parent 076b2ecf70
commit 8ac9b4ca46
6 changed files with 64 additions and 62 deletions
+6 -6
View File
@@ -69,14 +69,14 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine
siStartInfo.wShowWindow = SW_HIDE;
siStartInfo.dwFlags = STARTF_USESHOWWINDOW;
/* Get the path to the currently running executable (blender-launcher.exe) */
/* Get the path to the currently running executable (`blender-launcher.exe`). */
DWORD nSize = GetModuleFileName(NULL, path, MAX_PATH);
if (!nSize) {
return -1;
}
/* GetModuleFileName returns the number of characters written, but GetLastError needs to be
/* #GetModuleFileName returns the number of characters written, but GetLastError needs to be
* called to see if it ran out of space or not. However where would we be without exceptions
* to the rule: "If the buffer is too small to hold the module name, the function returns nSize.
* The last error code remains ERROR_SUCCESS." - source: MSDN. */
@@ -95,10 +95,10 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine
return -1;
}
int required_size_chars = lstrlenW(path) + /* Module name */
3 + /* 2 quotes + Space */
lstrlenW(pCmdLine) + /* Original command line */
1; /* Zero terminator */
int required_size_chars = lstrlenW(path) + /* Module name. */
3 + /* 2 quotes + Space. */
lstrlenW(pCmdLine) + /* Original command line. */
1; /* Zero terminator. */
size_t required_size_bytes = required_size_chars * sizeof(wchar_t);
wchar_t *buffer = (wchar_t *)malloc(required_size_bytes);
if (!buffer) {
+7 -7
View File
@@ -116,7 +116,7 @@
/** \name Local Application State
* \{ */
/* written to by 'creator_args.c' */
/* Written to by `creator_args.cc`. */
ApplicationState app_state = []() {
ApplicationState app_state{};
app_state.signal.use_crash_handler = true;
@@ -315,7 +315,7 @@ int main(int argc,
/* Win32 Unicode Arguments. */
{
/* NOTE: Can't use `guardedalloc` allocation here, as it's not yet initialized
* (it depends on the arguments passed in, which is what we're getting here!) */
* (it depends on the arguments passed in, which is what we're getting here!). */
wchar_t **argv_16 = CommandLineToArgvW(GetCommandLineW(), &argc);
argv = static_cast<char **>(malloc(argc * sizeof(char *)));
for (argv_num = 0; argv_num < argc; argv_num++) {
@@ -323,7 +323,7 @@ int main(int argc,
}
LocalFree(argv_16);
/* free on early-exit */
/* Free on early-exit. */
app_init_data.argv = argv;
app_init_data.argv_num = argv_num;
}
@@ -401,7 +401,7 @@ int main(int argc,
main_callback_setup();
#if defined(__APPLE__) && !defined(WITH_PYTHON_MODULE) && !defined(WITH_HEADLESS)
/* Patch to ignore argument finder gives us (PID?) */
/* Patch to ignore argument finder gives us (PID?). */
if (argc == 2 && STRPREFIX(argv[1], "-psn_")) {
static char firstfilebuf[512];
@@ -441,9 +441,9 @@ int main(int argc,
BKE_callback_global_init();
/* First test for background-mode (#Global.background) */
/* First test for background-mode (#Global.background). */
#ifndef WITH_PYTHON_MODULE
ba = BLI_args_create(argc, (const char **)argv); /* skip binary path */
ba = BLI_args_create(argc, (const char **)argv); /* Skip binary path. */
/* Ensure we free on early exit. */
app_init_data.ba = ba;
@@ -538,7 +538,7 @@ int main(int argc,
FRS_set_context(C);
#endif
/* OK we are ready for it */
/* OK we are ready for it. */
#ifndef WITH_PYTHON_MODULE
/* Handles #ARG_PASS_FINAL. */
BLI_args_parse(ba, ARG_PASS_FINAL, main_args_handle_load_file, C);
+29 -30
View File
@@ -71,7 +71,7 @@
# include "WM_types.hh"
# include "creator_intern.h" /* own include */
# include "creator_intern.h" /* Own include. */
/* -------------------------------------------------------------------- */
/** \name Build Defines
@@ -334,13 +334,13 @@ static int *parse_int_relative_clamp_n(
i++;
}
else {
goto fail; /* error message already set */
goto fail; /* Error message already set. */
}
if (str_end) { /* next */
if (str_end) { /* Next. */
str = str_end + 1;
}
else { /* finished */
else { /* Finished. */
break;
}
}
@@ -399,13 +399,13 @@ static int (*parse_int_range_relative_clamp_n(const char *str,
i++;
}
else {
goto fail; /* error message already set */
goto fail; /* Error message already set. */
}
if (str_end) { /* next */
if (str_end) { /* Next. */
str = str_end + 1;
}
else { /* finished */
else { /* Finished. */
break;
}
}
@@ -453,7 +453,7 @@ static void arg_py_context_backup(bContext *C, BlendePyContextStore *c_py, const
static void arg_py_context_restore(bContext *C, BlendePyContextStore *c_py)
{
/* script may load a file, check old data is valid before using */
/* Script may load a file, check old data is valid before using. */
if (c_py->has_win) {
if ((c_py->win == nullptr) || ((BLI_findindex(&G_MAIN->wm, c_py->wm) != -1) &&
(BLI_findindex(&c_py->wm->windows, c_py->win) != -1)))
@@ -467,7 +467,7 @@ static void arg_py_context_restore(bContext *C, BlendePyContextStore *c_py)
}
}
/* macro for context setup/reset */
/* Macro for context setup/reset. */
# define BPY_CTX_SETUP(_cmd) \
{ \
BlendePyContextStore py_c; \
@@ -706,7 +706,7 @@ static void print_help(bArgs *ba, bool all)
BLI_args_print_arg_doc(ba, "--help");
BLI_args_print_arg_doc(ba, "/?");
/* WIN32 only (ignored for non-win32) */
/* WIN32 only (ignored for non-WIN32). */
BLI_args_print_arg_doc(ba, "--register");
BLI_args_print_arg_doc(ba, "--register-allusers");
BLI_args_print_arg_doc(ba, "--unregister");
@@ -830,8 +830,8 @@ static int arg_handle_arguments_end(int /*argc*/, const char ** /*argv*/, void *
return -1;
}
/* only to give help message */
# ifdef WITH_PYTHON_SECURITY /* default */
/* Only to give help message. */
# ifdef WITH_PYTHON_SECURITY /* Default. */
# define PY_ENABLE_AUTO ""
# define PY_DISABLE_AUTO ", (default)"
# else
@@ -1090,7 +1090,7 @@ static const char arg_handle_debug_mode_set_doc[] =
"\t* Keeps Python's 'sys.stdin' rather than setting it to None";
static int arg_handle_debug_mode_set(int /*argc*/, const char ** /*argv*/, void *data)
{
G.debug |= G_DEBUG; /* std output printf's */
G.debug |= G_DEBUG;
printf("Blender %s\n", BKE_blender_version_string());
MEM_set_memory_debug();
# ifndef NDEBUG
@@ -1412,8 +1412,8 @@ static int arg_handle_env_system_set(int argc, const char **argv, void * /*data*
/* `--env-system-scripts` -> `BLENDER_SYSTEM_SCRIPTS` */
char env[64] = "BLENDER";
char *ch_dst = env + 7; /* skip BLENDER */
const char *ch_src = argv[0] + 5; /* skip --env */
char *ch_dst = env + 7; /* Skip `BLENDER`. */
const char *ch_src = argv[0] + 5; /* Skip `--env`. */
if (argc < 2) {
fprintf(stderr, "%s requires one argument\n", argv[0]);
@@ -1422,7 +1422,7 @@ static int arg_handle_env_system_set(int argc, const char **argv, void * /*data*
}
for (; *ch_src; ch_src++, ch_dst++) {
*ch_dst = (*ch_src == '-') ? '_' : (*ch_src) - 32; /* Inline #toupper() */
*ch_dst = (*ch_src == '-') ? '_' : (*ch_src) - 32; /* Inline #toupper(). */
}
*ch_dst = '\0';
@@ -1872,7 +1872,7 @@ static int arg_handle_render_frame(int argc, const char **argv, void *data)
RE_SetReports(re, &reports);
for (int i = 0; i < frames_range_len; i++) {
/* We could pass in frame ranges,
* but prefer having exact behavior as passing in multiple frames */
* but prefer having exact behavior as passing in multiple frames. */
if ((frame_range_arr[i][0] <= frame_range_arr[i][1]) == 0) {
fprintf(stderr, "\nWarning: negative range ignored '%s %s'.\n", arg_id, argv[1]);
}
@@ -2046,9 +2046,9 @@ static int arg_handle_python_file_run(int argc, const char **argv, void *data)
# ifdef WITH_PYTHON
bContext *C = static_cast<bContext *>(data);
/* workaround for scripts not getting a bpy.context.scene, causes internal errors elsewhere */
/* Workaround for scripts not getting a `bpy.context.scene`, causes internal errors elsewhere. */
if (argc > 1) {
/* Make the path absolute because its needed for relative linked blends to be found */
/* Make the path absolute because its needed for relative linked blends to be found. */
char filepath[FILE_MAX];
STRNCPY(filepath, argv[1]);
BLI_path_canonicalize_native(filepath, sizeof(filepath));
@@ -2079,10 +2079,10 @@ static int arg_handle_python_text_run(int argc, const char **argv, void *data)
# ifdef WITH_PYTHON
bContext *C = static_cast<bContext *>(data);
/* workaround for scripts not getting a bpy.context.scene, causes internal errors elsewhere */
/* Workaround for scripts not getting a `bpy.context.scene`, causes internal errors elsewhere. */
if (argc > 1) {
Main *bmain = CTX_data_main(C);
/* Make the path absolute because its needed for relative linked blends to be found */
/* Make the path absolute because its needed for relative linked blends to be found. */
Text *text = (Text *)BKE_libblock_find_name(bmain, ID_TXT, argv[1]);
bool ok;
@@ -2119,7 +2119,7 @@ static int arg_handle_python_expr_run(int argc, const char **argv, void *data)
# ifdef WITH_PYTHON
bContext *C = static_cast<bContext *>(data);
/* workaround for scripts not getting a bpy.context.scene, causes internal errors elsewhere */
/* Workaround for scripts not getting a `bpy.context.scene`, causes internal errors elsewhere. */
if (argc > 1) {
bool ok;
BPY_CTX_SETUP(ok = BPY_run_string_exec(C, nullptr, argv[1]));
@@ -2206,7 +2206,7 @@ static const char arg_handle_addons_set_doc[] =
"\tComma separated list (no spaces) of add-ons to enable in addition to any default add-ons.";
static int arg_handle_addons_set(int argc, const char **argv, void *data)
{
/* workaround for scripts not getting a bpy.context.scene, causes internal errors elsewhere */
/* Workaround for scripts not getting a `bpy.context.scene`, causes internal errors elsewhere. */
if (argc > 1) {
# ifdef WITH_PYTHON
const char script_str[] =
@@ -2237,12 +2237,12 @@ static int arg_handle_addons_set(int argc, const char **argv, void *data)
*/
static bool handle_load_file(bContext *C, const char *filepath_arg, const bool load_empty_file)
{
/* Make the path absolute because its needed for relative linked blends to be found */
/* Make the path absolute because its needed for relative linked blends to be found. */
char filepath[FILE_MAX];
STRNCPY(filepath, filepath_arg);
BLI_path_canonicalize_native(filepath, sizeof(filepath));
/* load the file */
/* Load the file. */
ReportList reports;
BKE_reports_init(&reports, RPT_PRINT);
WM_file_autoexec_init(filepath);
@@ -2256,13 +2256,12 @@ static bool handle_load_file(bContext *C, const char *filepath_arg, const bool l
}
}
else {
/* failed to load file, stop processing arguments if running in background mode */
/* Failed to load file, stop processing arguments if running in background mode. */
if (G.background) {
/* Set is_break if running in the background mode so
/* Set `is_break` if running in the background mode so
* blender will return non-zero exit code which then
* could be used in automated script to control how
* good or bad things are.
*/
* good or bad things are. */
G.is_break = true;
return false;
}
@@ -2394,7 +2393,7 @@ void main_args_setup(bContext *C, bArgs *ba, bool all)
* Also and commands that exit after usage. */
BLI_args_pass_set(ba, ARG_PASS_SETTINGS);
BLI_args_add(ba, "-h", "--help", CB(arg_handle_print_help), ba);
/* Windows only */
/* MS-Windows only. */
BLI_args_add(ba, "/?", nullptr, CB_EX(arg_handle_print_help, win32), ba);
BLI_args_add(ba, "-v", "--version", CB(arg_handle_print_version), nullptr);
+1 -1
View File
@@ -78,7 +78,7 @@ extern "C" __declspec(dllexport) void cpu_check_win32()
# endif
}
BOOL WINAPI DllMain(HINSTANCE /* hinstDLL */, DWORD fdwReason, LPVOID /* lpvReserved */)
BOOL WINAPI DllMain(HINSTANCE /*hinstDLL*/, DWORD fdwReason, LPVOID /*lpvReserved*/)
{
switch (fdwReason) {
case DLL_PROCESS_ATTACH:
+4 -4
View File
@@ -19,7 +19,7 @@ extern "C" {
#ifndef WITH_PYTHON_MODULE
/* creator_args.c */
/* `creator_args.cc` */
/**
* \param all: When enabled, all arguments are initialized
@@ -33,7 +33,7 @@ void main_args_setup(struct bContext *C, struct bArgs *ba, bool all);
*/
int main_args_handle_load_file(int argc, const char **argv, void *data);
/* creator_signals.c */
/* `creator_signals.cc` */
void main_signal_setup(void);
void main_signal_setup_background(void);
@@ -48,7 +48,7 @@ struct ApplicationState {
bool use_abort_handler;
} signal;
/* we may want to set different exit codes for other kinds of errors */
/* We may want to set different exit codes for other kinds of errors. */
struct {
unsigned char python;
} exit_code_on_error;
@@ -59,7 +59,7 @@ struct ApplicationState {
const char **argv;
} command;
};
extern struct ApplicationState app_state; /* creator.c */
extern struct ApplicationState app_state; /* `creator.cc` */
/**
* Passes for use by #main_args_setup.
+17 -14
View File
@@ -39,7 +39,7 @@
# include "BLI_utildefines.h"
# include BLI_SYSTEM_PID_H
# include "BKE_appdir.hh" /* BKE_tempdir_base */
# include "BKE_appdir.hh" /* #BKE_tempdir_base. */
# include "BKE_blender_version.h"
# include "BKE_global.hh"
# include "BKE_main.hh"
@@ -49,13 +49,15 @@
# include <csignal>
# ifdef WITH_PYTHON
# include "BPY_extern_python.h" /* BPY_python_backtrace */
# include "BPY_extern_python.h" /* #BPY_python_backtrace. */
# endif
# include "creator_intern.h" /* own include */
# include "creator_intern.h" /* Own include. */
/* set breakpoints here when running in debug mode, useful to catch floating point errors */
# if defined(__linux__) || defined(_WIN32) || defined(OSX_SSE_FPE)
/**
* Set breakpoints here when running in debug mode, useful to catch floating point errors.
*/
static void sig_handle_fpe(int /*sig*/)
{
fprintf(stderr, "debug: SIGFPE trapped\n");
@@ -65,7 +67,8 @@ static void sig_handle_fpe(int /*sig*/)
/* Handling `Ctrl-C` event in the console. */
static void sig_handle_blender_esc(int sig)
{
G.is_break = true; /* forces render loop to read queue, not sure if its needed */
/* Forces render loop to read queue, not sure if its needed. */
G.is_break = true;
if (sig == 2) {
static int count = 0;
@@ -119,7 +122,7 @@ static void sig_handle_crash(int signum)
build_hash);
# endif
/* open the crash log */
/* Open the crash log. */
errno = 0;
fp = BLI_fopen(filepath, "wb");
if (fp == nullptr) {
@@ -146,7 +149,7 @@ static void sig_handle_crash(int signum)
/* Delete content of temp dir! */
BKE_tempdir_session_purge();
/* really crash */
/* Really crash. */
signal(signum, SIG_DFL);
# ifndef WIN32
kill(getpid(), signum);
@@ -159,7 +162,7 @@ static void sig_handle_crash(int signum)
extern LONG WINAPI windows_exception_handler(EXCEPTION_POINTERS *ExceptionInfo)
{
/* If this is a stack overflow then we can't walk the stack, so just try to show
* where the error happened */
* where the error happened. */
if (ExceptionInfo->ExceptionRecord->ExceptionCode == EXCEPTION_STACK_OVERFLOW) {
HMODULE mod;
CHAR modulename[MAX_PATH];
@@ -193,7 +196,7 @@ void main_signal_setup()
# ifdef WIN32
SetUnhandledExceptionFilter(windows_exception_handler);
# else
/* after parsing args */
/* After parsing arguments. */
signal(SIGSEGV, sig_handle_crash);
# endif
}
@@ -222,8 +225,8 @@ void main_signal_setup_background()
void main_signal_setup_fpe()
{
# if defined(__linux__) || defined(_WIN32) || defined(OSX_SSE_FPE)
/* zealous but makes float issues a heck of a lot easier to find!
* set breakpoints on sig_handle_fpe */
/* Zealous but makes float issues a heck of a lot easier to find!
* Set breakpoints on #sig_handle_fpe. */
signal(SIGFPE, sig_handle_fpe);
# if defined(__linux__) && defined(__GNUC__) && defined(HAVE_FEENABLEEXCEPT)
@@ -231,14 +234,14 @@ void main_signal_setup_fpe()
# endif /* defined(__linux__) && defined(__GNUC__) */
# if defined(OSX_SSE_FPE)
/* OSX uses SSE for floating point by default, so here
* use SSE instructions to throw floating point exceptions */
* use SSE instructions to throw floating point exceptions. */
_MM_SET_EXCEPTION_MASK(_MM_MASK_MASK &
~(_MM_MASK_OVERFLOW | _MM_MASK_INVALID | _MM_MASK_DIV_ZERO));
# endif /* OSX_SSE_FPE */
# if defined(_WIN32) && defined(_MSC_VER)
/* enables all fp exceptions */
/* Enables all floating-point exceptions. */
_controlfp_s(nullptr, 0, _MCW_EM);
/* hide the ones we don't care about */
/* Hide the ones we don't care about. */
_controlfp_s(nullptr, _EM_DENORMAL | _EM_UNDERFLOW | _EM_INEXACT, _MCW_EM);
# endif /* _WIN32 && _MSC_VER */
# endif