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:
authorHans Goudey <h.goudey@me.com>2022-10-05 21:44:02 +0300
committerHans Goudey <h.goudey@me.com>2022-10-05 21:48:01 +0300
commit548a2cbe06b23d90b0e09da49fc854178c270b8a (patch)
tree8706b5be97ace0ff0ca18d4109586ccb5cf0a666 /source/blender/blenloader
parent6306d747b770685f38f95bc57f8681335ddfa506 (diff)
Cleanup: Clang tidy
Also remove unnecessary struct keywords in C++ files.
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r--source/blender/blenloader/intern/blend_validate.cc2
-rw-r--r--source/blender/blenloader/intern/readblenentry.cc49
-rw-r--r--source/blender/blenloader/intern/readfile.cc116
-rw-r--r--source/blender/blenloader/intern/versioning_300.cc17
-rw-r--r--source/blender/blenloader/intern/versioning_common.cc4
-rw-r--r--source/blender/blenloader/intern/writefile.cc36
6 files changed, 110 insertions, 114 deletions
diff --git a/source/blender/blenloader/intern/blend_validate.cc b/source/blender/blenloader/intern/blend_validate.cc
index 96314ab4324..0f43b20c391 100644
--- a/source/blender/blenloader/intern/blend_validate.cc
+++ b/source/blender/blenloader/intern/blend_validate.cc
@@ -9,7 +9,7 @@
* \note Does not *fix* anything, only reports found errors.
*/
-#include <string.h> /* for #strrchr #strncmp #strstr */
+#include <cstring> /* for #strrchr #strncmp #strstr */
#include "BLI_utildefines.h"
diff --git a/source/blender/blenloader/intern/readblenentry.cc b/source/blender/blenloader/intern/readblenentry.cc
index 55d86371efe..55ac2d31277 100644
--- a/source/blender/blenloader/intern/readblenentry.cc
+++ b/source/blender/blenloader/intern/readblenentry.cc
@@ -6,12 +6,11 @@
* `.blend` file reading entry point.
*/
-#include <stddef.h>
-
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <cmath>
+#include <cstddef>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
#include "MEM_guardedalloc.h"
@@ -106,14 +105,14 @@ LinkNode *BLO_blendhandle_get_datablock_names(BlendHandle *bh,
int *r_tot_names)
{
FileData *fd = (FileData *)bh;
- LinkNode *names = NULL;
+ LinkNode *names = nullptr;
BHead *bhead;
int tot = 0;
for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) {
if (bhead->code == ofblocktype) {
const char *idname = blo_bhead_id_name(fd, bhead);
- if (use_assets_only && blo_bhead_id_asset_data_address(fd, bhead) == NULL) {
+ if (use_assets_only && blo_bhead_id_asset_data_address(fd, bhead) == nullptr) {
continue;
}
@@ -135,7 +134,7 @@ LinkNode *BLO_blendhandle_get_datablock_info(BlendHandle *bh,
int *r_tot_info_items)
{
FileData *fd = (FileData *)bh;
- LinkNode *infos = NULL;
+ LinkNode *infos = nullptr;
BHead *bhead;
int tot = 0;
@@ -147,7 +146,7 @@ LinkNode *BLO_blendhandle_get_datablock_info(BlendHandle *bh,
const char *name = blo_bhead_id_name(fd, bhead) + 2;
AssetMetaData *asset_meta_data = blo_bhead_id_asset_data_address(fd, bhead);
- const bool is_asset = asset_meta_data != NULL;
+ const bool is_asset = asset_meta_data != nullptr;
const bool skip_datablock = use_assets_only && !is_asset;
if (skip_datablock) {
continue;
@@ -187,7 +186,7 @@ LinkNode *BLO_blendhandle_get_datablock_info(BlendHandle *bh,
* bhead is consumed. the new bhead is returned by this function.
* \param result: the Preview Image where the preview rect will be stored.
* \param preview_from_file: The read PreviewImage where the bhead points to. The rects of this
- * \return PreviewImage or NULL when no preview Images have been found. Caller owns the returned
+ * \return PreviewImage or nullptr when no preview Images have been found. Caller owns the returned
*/
static BHead *blo_blendhandle_read_preview_rects(FileData *fd,
BHead *bhead,
@@ -206,10 +205,10 @@ static BHead *blo_blendhandle_read_preview_rects(FileData *fd,
else {
/* This should not be needed, but can happen in 'broken' .blend files,
* better handle this gracefully than crashing. */
- BLI_assert(preview_from_file->rect[preview_index] == NULL &&
+ BLI_assert(preview_from_file->rect[preview_index] == nullptr &&
preview_from_file->w[preview_index] == 0 &&
preview_from_file->h[preview_index] == 0);
- result->rect[preview_index] = NULL;
+ result->rect[preview_index] = nullptr;
result->w[preview_index] = result->h[preview_index] = 0;
}
BKE_previewimg_finish(result, preview_index);
@@ -232,7 +231,7 @@ PreviewImage *BLO_blendhandle_get_preview_for_id(BlendHandle *bh,
PreviewImage *preview_from_file = static_cast<PreviewImage *>(
BLO_library_read_struct(fd, bhead, "PreviewImage"));
- if (preview_from_file == NULL) {
+ if (preview_from_file == nullptr) {
break;
}
@@ -255,17 +254,17 @@ PreviewImage *BLO_blendhandle_get_preview_for_id(BlendHandle *bh,
}
}
- return NULL;
+ return nullptr;
}
LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *r_tot_prev)
{
FileData *fd = (FileData *)bh;
- LinkNode *previews = NULL;
+ LinkNode *previews = nullptr;
BHead *bhead;
int looking = 0;
- PreviewImage *prv = NULL;
- PreviewImage *new_prv = NULL;
+ PreviewImage *prv = nullptr;
+ PreviewImage *new_prv = nullptr;
int tot = 0;
for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) {
@@ -309,8 +308,8 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *r_
}
else {
looking = 0;
- new_prv = NULL;
- prv = NULL;
+ new_prv = nullptr;
+ prv = nullptr;
}
}
@@ -322,7 +321,7 @@ LinkNode *BLO_blendhandle_get_linkable_groups(BlendHandle *bh)
{
FileData *fd = (FileData *)bh;
GSet *gathered = BLI_gset_ptr_new("linkable_groups gh");
- LinkNode *names = NULL;
+ LinkNode *names = nullptr;
BHead *bhead;
for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) {
@@ -340,7 +339,7 @@ LinkNode *BLO_blendhandle_get_linkable_groups(BlendHandle *bh)
}
}
- BLI_gset_free(gathered, NULL);
+ BLI_gset_free(gathered, nullptr);
return names;
}
@@ -358,7 +357,7 @@ BlendFileData *BLO_read_from_file(const char *filepath,
eBLOReadSkip skip_flags,
BlendFileReadReport *reports)
{
- BlendFileData *bfd = NULL;
+ BlendFileData *bfd = nullptr;
FileData *fd;
fd = blo_filedata_from_file(filepath, reports);
@@ -376,7 +375,7 @@ BlendFileData *BLO_read_from_memory(const void *mem,
eBLOReadSkip skip_flags,
ReportList *reports)
{
- BlendFileData *bfd = NULL;
+ BlendFileData *bfd = nullptr;
FileData *fd;
BlendFileReadReport bf_reports{};
bf_reports.reports = reports;
@@ -397,7 +396,7 @@ BlendFileData *BLO_read_from_memfile(Main *oldmain,
const struct BlendFileReadParams *params,
ReportList *reports)
{
- BlendFileData *bfd = NULL;
+ BlendFileData *bfd = nullptr;
FileData *fd;
ListBase old_mainlist;
BlendFileReadReport bf_reports{};
diff --git a/source/blender/blenloader/intern/readfile.cc b/source/blender/blenloader/intern/readfile.cc
index a527c16fa6e..dd954f6e3e9 100644
--- a/source/blender/blenloader/intern/readfile.cc
+++ b/source/blender/blenloader/intern/readfile.cc
@@ -5,13 +5,14 @@
* \ingroup blenloader
*/
-#include <ctype.h> /* for isdigit. */
+#include <cctype> /* for isdigit. */
+#include <cerrno>
+#include <climits>
+#include <cstdarg> /* for va_start/end. */
+#include <cstddef> /* for offsetof. */
+#include <cstdlib> /* for atoi. */
+#include <ctime> /* for gmtime. */
#include <fcntl.h> /* for open flags (O_BINARY, O_RDONLY). */
-#include <limits.h>
-#include <stdarg.h> /* for va_start/end. */
-#include <stddef.h> /* for offsetof. */
-#include <stdlib.h> /* for atoi. */
-#include <time.h> /* for gmtime. */
#include "BLI_utildefines.h"
#ifndef WIN32
@@ -102,8 +103,6 @@
#include "readfile.h"
-#include <errno.h>
-
/* Make preferences read-only. */
#define U (*((const UserDef *)&U))
@@ -181,7 +180,7 @@ static void *read_struct(FileData *fd, BHead *bh, const char *blockname);
static BHead *find_bhead_from_code_name(FileData *fd, const short idcode, const char *name);
static BHead *find_bhead_from_idname(FileData *fd, const char *idname);
-typedef struct BHeadN {
+struct BHeadN {
struct BHeadN *next, *prev;
#ifdef USE_BHEAD_READ_ON_DEMAND
/** Use to read the data from the file directly into memory as needed. */
@@ -191,7 +190,7 @@ typedef struct BHeadN {
#endif
bool is_memchunk_identical;
struct BHead bhead;
-} BHeadN;
+};
#define BHEADN_FROM_BHEAD(bh) ((BHeadN *)POINTER_OFFSET(bh, -int(offsetof(BHeadN, bhead))))
@@ -230,14 +229,14 @@ static const char *library_parent_filepath(Library *lib)
/** \name OldNewMap API
* \{ */
-typedef struct OldNew {
+struct OldNew {
const void *oldp;
void *newp;
/* `nr` is "user count" for data, and ID code for libdata. */
int nr;
-} OldNew;
+};
-typedef struct OldNewMap {
+struct OldNewMap {
/* Array that stores the actual entries. */
OldNew *entries;
int nentries;
@@ -245,7 +244,7 @@ typedef struct OldNewMap {
int32_t *map;
int capacity_exp;
-} OldNewMap;
+};
#define ENTRIES_CAPACITY(onm) (1ll << (onm)->capacity_exp)
#define MAP_CAPACITY(onm) (1ll << ((onm)->capacity_exp + 1))
@@ -336,7 +335,7 @@ static void oldnewmap_init_data(OldNewMap *onm, const int capacity_exp)
oldnewmap_clear_map(onm);
}
-static OldNewMap *oldnewmap_new(void)
+static OldNewMap *oldnewmap_new()
{
OldNewMap *onm = static_cast<OldNewMap *>(MEM_mallocN(sizeof(*onm), "OldNewMap"));
@@ -677,19 +676,19 @@ static Main *blo_find_main(FileData *fd, const char *filepath, const char *relab
/** \name File Parsing
* \{ */
-typedef struct BlendDataReader {
+struct BlendDataReader {
FileData *fd;
-} BlendDataReader;
+};
-typedef struct BlendLibReader {
+struct BlendLibReader {
FileData *fd;
Main *main;
-} BlendLibReader;
+};
-typedef struct BlendExpander {
+struct BlendExpander {
FileData *fd;
Main *main;
-} BlendExpander;
+};
static void switch_endian_bh4(BHead4 *bhead)
{
@@ -1331,7 +1330,7 @@ FileData *blo_filedata_from_memory(const void *mem, int memsize, BlendFileReadRe
}
FileData *blo_filedata_from_memfile(MemFile *memfile,
- const struct BlendFileReadParams *params,
+ const BlendFileReadParams *params,
BlendFileReadReport *reports)
{
if (!memfile) {
@@ -1699,15 +1698,15 @@ void blo_make_old_idmap_from_main(FileData *fd, Main *bmain)
fd->old_idmap = BKE_main_idmap_create(bmain, false, nullptr, MAIN_IDMAP_TYPE_UUID);
}
-typedef struct BLOCacheStorage {
+struct BLOCacheStorage {
GHash *cache_map;
MemArena *memarena;
-} BLOCacheStorage;
+};
-typedef struct BLOCacheStorageValue {
+struct BLOCacheStorageValue {
void *cache_v;
uint new_usage_count;
-} BLOCacheStorageValue;
+};
/** Register a cache data entry to be preserved when reading some undo memfile. */
static void blo_cache_storage_entry_register(
@@ -1857,7 +1856,7 @@ void blo_cache_storage_end(FileData *fd)
/** \name DNA Struct Loading
* \{ */
-static void switch_endian_structs(const struct SDNA *filesdna, BHead *bhead)
+static void switch_endian_structs(const SDNA *filesdna, BHead *bhead)
{
int blocksize, nblocks;
char *data;
@@ -2318,10 +2317,10 @@ static void lib_link_scenes_check_set(Main *bmain)
* \{ */
/* how to handle user count on pointer restore */
-typedef enum ePointerUserMode {
+enum ePointerUserMode {
USER_IGNORE = 0, /* ignore user count */
USER_REAL = 1, /* ensure at least one real user (fake user ignored) */
-} ePointerUserMode;
+};
static void restore_pointer_user(ID *id, ID *newid, ePointerUserMode user)
{
@@ -2371,7 +2370,7 @@ static void *restore_pointer_by_name_main(Main *mainp, ID *id, ePointerUserMode
* this could be made an optional argument (falling back to a full lookup),
* however at the moment it's always available.
*/
-static void *restore_pointer_by_name(struct IDNameLib_Map *id_map, ID *id, ePointerUserMode user)
+static void *restore_pointer_by_name(IDNameLib_Map *id_map, ID *id, ePointerUserMode user)
{
#ifdef USE_GHASH_RESTORE_POINTER
if (id) {
@@ -2389,7 +2388,7 @@ static void *restore_pointer_by_name(struct IDNameLib_Map *id_map, ID *id, ePoin
#endif
}
-static void lib_link_seq_clipboard_pt_restore(ID *id, struct IDNameLib_Map *id_map)
+static void lib_link_seq_clipboard_pt_restore(ID *id, IDNameLib_Map *id_map)
{
if (id) {
/* clipboard must ensure this */
@@ -2399,7 +2398,7 @@ static void lib_link_seq_clipboard_pt_restore(ID *id, struct IDNameLib_Map *id_m
}
static bool lib_link_seq_clipboard_cb(Sequence *seq, void *arg_pt)
{
- struct IDNameLib_Map *id_map = static_cast<IDNameLib_Map *>(arg_pt);
+ IDNameLib_Map *id_map = static_cast<IDNameLib_Map *>(arg_pt);
lib_link_seq_clipboard_pt_restore((ID *)seq->scene, id_map);
lib_link_seq_clipboard_pt_restore((ID *)seq->scene_camera, id_map);
@@ -2409,7 +2408,7 @@ static bool lib_link_seq_clipboard_cb(Sequence *seq, void *arg_pt)
return true;
}
-static void lib_link_clipboard_restore(struct IDNameLib_Map *id_map)
+static void lib_link_clipboard_restore(IDNameLib_Map *id_map)
{
/* update IDs stored in sequencer clipboard */
SEQ_for_each_callback(&seqbase_clipboard, lib_link_seq_clipboard_cb, id_map);
@@ -2436,7 +2435,7 @@ static int lib_link_main_data_restore_cb(LibraryIDLinkCallbackData *cb_data)
}
}
- struct IDNameLib_Map *id_map = static_cast<IDNameLib_Map *>(cb_data->user_data);
+ IDNameLib_Map *id_map = static_cast<IDNameLib_Map *>(cb_data->user_data);
/* NOTE: Handling of user-count here is really bad, defining its own system...
* Will have to be refactored at some point, but that is not top priority task for now.
@@ -2447,7 +2446,7 @@ static int lib_link_main_data_restore_cb(LibraryIDLinkCallbackData *cb_data)
return IDWALK_RET_NOP;
}
-static void lib_link_main_data_restore(struct IDNameLib_Map *id_map, Main *newmain)
+static void lib_link_main_data_restore(IDNameLib_Map *id_map, Main *newmain)
{
ID *id;
FOREACH_MAIN_ID_BEGIN (newmain, id) {
@@ -2456,7 +2455,7 @@ static void lib_link_main_data_restore(struct IDNameLib_Map *id_map, Main *newma
FOREACH_MAIN_ID_END;
}
-static void lib_link_wm_xr_data_restore(struct IDNameLib_Map *id_map, wmXrData *xr_data)
+static void lib_link_wm_xr_data_restore(IDNameLib_Map *id_map, wmXrData *xr_data)
{
xr_data->session_settings.base_pose_object = static_cast<Object *>(restore_pointer_by_name(
id_map, (ID *)xr_data->session_settings.base_pose_object, USER_REAL));
@@ -2512,18 +2511,18 @@ static void lib_link_window_scene_data_restore(wmWindow *win, Scene *scene, View
}
}
-static void lib_link_restore_viewer_path(struct IDNameLib_Map *id_map, ViewerPath *viewer_path)
+static void lib_link_restore_viewer_path(IDNameLib_Map *id_map, ViewerPath *viewer_path)
{
LISTBASE_FOREACH (ViewerPathElem *, elem, &viewer_path->path) {
if (elem->type == VIEWER_PATH_ELEM_TYPE_ID) {
- auto typed_elem = reinterpret_cast<IDViewerPathElem *>(elem);
+ IDViewerPathElem *typed_elem = reinterpret_cast<IDViewerPathElem *>(elem);
typed_elem->id = static_cast<ID *>(
restore_pointer_by_name(id_map, (ID *)typed_elem->id, USER_IGNORE));
}
}
}
-static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map,
+static void lib_link_workspace_layout_restore(IDNameLib_Map *id_map,
Main *newmain,
WorkSpaceLayout *layout)
{
@@ -2764,8 +2763,7 @@ void blo_lib_link_restore(Main *oldmain,
Scene *curscene,
ViewLayer *cur_view_layer)
{
- struct IDNameLib_Map *id_map = BKE_main_idmap_create(
- newmain, true, oldmain, MAIN_IDMAP_TYPE_NAME);
+ IDNameLib_Map *id_map = BKE_main_idmap_create(newmain, true, oldmain, MAIN_IDMAP_TYPE_NAME);
LISTBASE_FOREACH (WorkSpace *, workspace, &newmain->workspaces) {
LISTBASE_FOREACH (WorkSpaceLayout *, layout, &workspace->layouts) {
@@ -4069,8 +4067,8 @@ struct BHeadSort {
static int verg_bheadsort(const void *v1, const void *v2)
{
- const struct BHeadSort *x1 = static_cast<const BHeadSort *>(v1),
- *x2 = static_cast<const BHeadSort *>(v2);
+ const BHeadSort *x1 = static_cast<const BHeadSort *>(v1),
+ *x2 = static_cast<const BHeadSort *>(v2);
if (x1->old > x2->old) {
return 1;
@@ -4084,7 +4082,7 @@ static int verg_bheadsort(const void *v1, const void *v2)
static void sort_bhead_old_map(FileData *fd)
{
BHead *bhead;
- struct BHeadSort *bhs;
+ BHeadSort *bhs;
int tot = 0;
for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) {
@@ -4097,14 +4095,14 @@ static void sort_bhead_old_map(FileData *fd)
}
bhs = fd->bheadmap = static_cast<BHeadSort *>(
- MEM_malloc_arrayN(tot, sizeof(struct BHeadSort), "BHeadSort"));
+ MEM_malloc_arrayN(tot, sizeof(BHeadSort), "BHeadSort"));
for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead), bhs++) {
bhs->bhead = bhead;
bhs->old = bhead->old;
}
- qsort(fd->bheadmap, tot, sizeof(struct BHeadSort), verg_bheadsort);
+ qsort(fd->bheadmap, tot, sizeof(BHeadSort), verg_bheadsort);
}
static BHead *find_previous_lib(FileData *fd, BHead *bhead)
@@ -4128,7 +4126,7 @@ static BHead *find_bhead(FileData *fd, void *old)
#if 0
BHead* bhead;
#endif
- struct BHeadSort *bhs, bhs_s;
+ BHeadSort *bhs, bhs_s;
if (!old) {
return nullptr;
@@ -4140,7 +4138,7 @@ static BHead *find_bhead(FileData *fd, void *old)
bhs_s.old = old;
bhs = static_cast<BHeadSort *>(
- bsearch(&bhs_s, fd->bheadmap, fd->tot_bheadmap, sizeof(struct BHeadSort), verg_bheadsort));
+ bsearch(&bhs_s, fd->bheadmap, fd->tot_bheadmap, sizeof(BHeadSort), verg_bheadsort));
if (bhs) {
return bhs->bhead;
@@ -4475,7 +4473,7 @@ ID *BLO_library_link_named_part(Main *mainl,
BlendHandle **bh,
const short idcode,
const char *name,
- const struct LibraryLink_Params *params)
+ const LibraryLink_Params *params)
{
FileData *fd = (FileData *)(*bh);
return link_named_part(mainl, fd, idcode, name, params->flag);
@@ -4515,8 +4513,8 @@ static Main *library_link_begin(Main *mainvar,
return mainl;
}
-void BLO_library_link_params_init(struct LibraryLink_Params *params,
- struct Main *bmain,
+void BLO_library_link_params_init(LibraryLink_Params *params,
+ Main *bmain,
const int flag,
const int id_tag_extra)
{
@@ -4526,14 +4524,14 @@ void BLO_library_link_params_init(struct LibraryLink_Params *params,
params->id_tag_extra = id_tag_extra;
}
-void BLO_library_link_params_init_with_context(struct LibraryLink_Params *params,
- struct Main *bmain,
+void BLO_library_link_params_init_with_context(LibraryLink_Params *params,
+ Main *bmain,
const int flag,
const int id_tag_extra,
/* Context arguments. */
- struct Scene *scene,
- struct ViewLayer *view_layer,
- const struct View3D *v3d)
+ Scene *scene,
+ ViewLayer *view_layer,
+ const View3D *v3d)
{
BLO_library_link_params_init(params, bmain, flag, id_tag_extra);
if (scene != nullptr) {
@@ -4545,7 +4543,7 @@ void BLO_library_link_params_init_with_context(struct LibraryLink_Params *params
Main *BLO_library_link_begin(BlendHandle **bh,
const char *filepath,
- const struct LibraryLink_Params *params)
+ const LibraryLink_Params *params)
{
FileData *fd = (FileData *)(*bh);
return library_link_begin(params->bmain, &fd, filepath, params->id_tag_extra);
@@ -4667,7 +4665,7 @@ static void library_link_end(Main *mainl, FileData **fd, const int flag)
}
}
-void BLO_library_link_end(Main *mainl, BlendHandle **bh, const struct LibraryLink_Params *params)
+void BLO_library_link_end(Main *mainl, BlendHandle **bh, const LibraryLink_Params *params)
{
FileData *fd = (FileData *)(*bh);
library_link_end(mainl, &fd, params->flag);
@@ -5056,7 +5054,7 @@ void BLO_read_list_cb(BlendDataReader *reader, ListBase *list, BlendReadListFn c
list->last = prev;
}
-void BLO_read_list(BlendDataReader *reader, struct ListBase *list)
+void BLO_read_list(BlendDataReader *reader, ListBase *list)
{
BLO_read_list_cb(reader, list, nullptr);
}
diff --git a/source/blender/blenloader/intern/versioning_300.cc b/source/blender/blenloader/intern/versioning_300.cc
index 8a6c73a7a5b..0584dd6b059 100644
--- a/source/blender/blenloader/intern/versioning_300.cc
+++ b/source/blender/blenloader/intern/versioning_300.cc
@@ -674,7 +674,7 @@ static void version_geometry_nodes_replace_transfer_attribute_node(bNodeTree *nt
{
using namespace blender;
/* Otherwise `ntree->typeInfo` is null. */
- ntreeSetTypes(NULL, ntree);
+ ntreeSetTypes(nullptr, ntree);
LISTBASE_FOREACH_MUTABLE (bNode *, node, &ntree->nodes) {
if (node->type != GEO_NODE_TRANSFER_ATTRIBUTE_DEPRECATED) {
continue;
@@ -685,7 +685,7 @@ static void version_geometry_nodes_replace_transfer_attribute_node(bNodeTree *nt
switch (storage->mode) {
case GEO_NODE_ATTRIBUTE_TRANSFER_NEAREST_FACE_INTERPOLATED: {
bNode *sample_nearest_surface = nodeAddStaticNode(
- NULL, ntree, GEO_NODE_SAMPLE_NEAREST_SURFACE);
+ nullptr, ntree, GEO_NODE_SAMPLE_NEAREST_SURFACE);
sample_nearest_surface->parent = node->parent;
sample_nearest_surface->custom1 = storage->data_type;
sample_nearest_surface->locx = node->locx;
@@ -711,7 +711,7 @@ static void version_geometry_nodes_replace_transfer_attribute_node(bNodeTree *nt
eAttrDomain(storage->domain);
/* Use a sample index node to retrieve the data with this node's index output. */
- bNode *sample_index = nodeAddStaticNode(NULL, ntree, GEO_NODE_SAMPLE_INDEX);
+ bNode *sample_index = nodeAddStaticNode(nullptr, ntree, GEO_NODE_SAMPLE_INDEX);
NodeGeometrySampleIndex *sample_storage = static_cast<NodeGeometrySampleIndex *>(
sample_index->storage);
sample_storage->data_type = storage->data_type;
@@ -727,7 +727,7 @@ static void version_geometry_nodes_replace_transfer_attribute_node(bNodeTree *nt
nodeFindSocket(sample_index, SOCK_IN, "Geometry"));
}
- bNode *sample_nearest = nodeAddStaticNode(NULL, ntree, GEO_NODE_SAMPLE_NEAREST);
+ bNode *sample_nearest = nodeAddStaticNode(nullptr, ntree, GEO_NODE_SAMPLE_NEAREST);
sample_nearest->parent = node->parent;
sample_nearest->custom1 = storage->data_type;
sample_nearest->custom2 = domain;
@@ -767,7 +767,7 @@ static void version_geometry_nodes_replace_transfer_attribute_node(bNodeTree *nt
break;
}
case GEO_NODE_ATTRIBUTE_TRANSFER_INDEX: {
- bNode *sample_index = nodeAddStaticNode(NULL, ntree, GEO_NODE_SAMPLE_INDEX);
+ bNode *sample_index = nodeAddStaticNode(nullptr, ntree, GEO_NODE_SAMPLE_INDEX);
NodeGeometrySampleIndex *sample_storage = static_cast<NodeGeometrySampleIndex *>(
sample_index->storage);
sample_storage->data_type = storage->data_type;
@@ -792,7 +792,7 @@ static void version_geometry_nodes_replace_transfer_attribute_node(bNodeTree *nt
if (!index_was_linked) {
/* Add an index input node, since the new node doesn't use an implicit input. */
- bNode *index = nodeAddStaticNode(NULL, ntree, GEO_NODE_INPUT_INDEX);
+ bNode *index = nodeAddStaticNode(nullptr, ntree, GEO_NODE_INPUT_INDEX);
index->parent = node->parent;
index->locx = node->locx - 25.0f;
index->locy = node->locy - 25.0f;
@@ -807,7 +807,7 @@ static void version_geometry_nodes_replace_transfer_attribute_node(bNodeTree *nt
}
/* The storage must be freed manually because the node type isn't defined anymore. */
MEM_freeN(node->storage);
- nodeRemoveNode(NULL, ntree, node, false);
+ nodeRemoveNode(nullptr, ntree, node, false);
}
}
@@ -2992,7 +2992,8 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain)
}
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
ToolSettings *tool_settings = scene->toolsettings;
- tool_settings->snap_flag_seq = tool_settings->snap_flag & ~(SCE_SNAP | SCE_SNAP_SEQ);
+ tool_settings->snap_flag_seq = tool_settings->snap_flag &
+ ~(short(SCE_SNAP) | short(SCE_SNAP_SEQ));
if (tool_settings->snap_flag & SCE_SNAP_SEQ) {
tool_settings->snap_flag_seq |= SCE_SNAP;
tool_settings->snap_flag &= ~SCE_SNAP_SEQ;
diff --git a/source/blender/blenloader/intern/versioning_common.cc b/source/blender/blenloader/intern/versioning_common.cc
index c87983f1287..56ada76eae6 100644
--- a/source/blender/blenloader/intern/versioning_common.cc
+++ b/source/blender/blenloader/intern/versioning_common.cc
@@ -249,7 +249,7 @@ void node_tree_relink_with_socket_id_map(bNodeTree &ntree,
bNodeSocket *new_socket = nodeFindSocket(&new_node, SOCK_IN, new_identifier->c_str());
link->tonode = &new_node;
link->tosock = new_socket;
- old_socket->link = NULL;
+ old_socket->link = nullptr;
}
}
if (link->fromnode == &old_node) {
@@ -258,7 +258,7 @@ void node_tree_relink_with_socket_id_map(bNodeTree &ntree,
bNodeSocket *new_socket = nodeFindSocket(&new_node, SOCK_OUT, new_identifier->c_str());
link->fromnode = &new_node;
link->fromsock = new_socket;
- old_socket->link = NULL;
+ old_socket->link = nullptr;
}
}
}
diff --git a/source/blender/blenloader/intern/writefile.cc b/source/blender/blenloader/intern/writefile.cc
index 4625a4471fe..42bc884098e 100644
--- a/source/blender/blenloader/intern/writefile.cc
+++ b/source/blender/blenloader/intern/writefile.cc
@@ -55,12 +55,13 @@
* - write #USER (#UserDef struct) if filename is `~/.config/blender/X.XX/config/startup.blend`.
*/
+#include <cerrno>
+#include <climits>
+#include <cmath>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
#include <fcntl.h>
-#include <limits.h>
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#ifdef WIN32
# include "BLI_winstuff.h"
@@ -116,8 +117,6 @@
#include "readfile.h"
-#include <errno.h>
-
#include <zstd.h>
/* Make preferences read-only. */
@@ -143,19 +142,18 @@ static CLG_LogRef LOG = {"blo.writefile"};
/** \name Internal Write Wrapper's (Abstracts Compression)
* \{ */
-typedef enum {
+enum eWriteWrapType {
WW_WRAP_NONE = 1,
WW_WRAP_ZSTD,
-} eWriteWrapType;
+};
-typedef struct ZstdFrame {
+struct ZstdFrame {
struct ZstdFrame *next, *prev;
uint32_t compressed_size;
uint32_t uncompressed_size;
-} ZstdFrame;
+};
-typedef struct WriteWrap WriteWrap;
struct WriteWrap {
/* callbacks */
bool (*open)(WriteWrap *ww, const char *filepath);
@@ -395,8 +393,8 @@ static void ww_handle_init(eWriteWrapType ww_type, WriteWrap *r_ww)
/** \name Write Data Type & Functions
* \{ */
-typedef struct {
- const struct SDNA *sdna;
+struct WriteData {
+ const SDNA *sdna;
struct {
/** Use for file and memory writing (size stored in max_size). */
@@ -429,11 +427,11 @@ typedef struct {
* Will be nullptr for UNDO.
*/
WriteWrap *ww;
-} WriteData;
+};
-typedef struct BlendWriter {
+struct BlendWriter {
WriteData *wd;
-} BlendWriter;
+};
static WriteData *writedata_new(WriteWrap *ww)
{
@@ -812,11 +810,11 @@ static void current_screen_compat(Main *mainvar,
nullptr;
}
-typedef struct RenderInfo {
+struct RenderInfo {
int sfra;
int efra;
char scene_name[MAX_ID_NAME - 2];
-} RenderInfo;
+};
/**
* This was originally added for the historic render-daemon feature,