diff --git a/intern/guardedalloc/intern/mallocn_guarded_impl.cc b/intern/guardedalloc/intern/mallocn_guarded_impl.cc index 2aaea362764..89a7c1887ee 100644 --- a/intern/guardedalloc/intern/mallocn_guarded_impl.cc +++ b/intern/guardedalloc/intern/mallocn_guarded_impl.cc @@ -107,6 +107,8 @@ typedef struct localListBase { void *first, *last; } localListBase; +namespace { + /* NOTE(@hos): keep this struct aligned (e.g., IRIX/GCC). */ typedef struct MemHead { int tag1; @@ -137,6 +139,8 @@ static_assert(MEM_MIN_CPP_ALIGNMENT <= sizeof(MemHead), "Bad size of MemHead"); typedef MemHead MemHeadAligned; +} // namespace + /* #MemHead::flag. */ enum MemHeadFlag { /** diff --git a/intern/guardedalloc/intern/mallocn_lockfree_impl.cc b/intern/guardedalloc/intern/mallocn_lockfree_impl.cc index 8d0ae31df98..f6a47242052 100644 --- a/intern/guardedalloc/intern/mallocn_lockfree_impl.cc +++ b/intern/guardedalloc/intern/mallocn_lockfree_impl.cc @@ -31,6 +31,8 @@ using namespace mem_guarded::internal; +namespace { + typedef struct MemHead { /* Length of allocated memory block. */ size_t len; @@ -45,6 +47,8 @@ typedef struct MemHeadAligned { static_assert(MEM_MIN_CPP_ALIGNMENT <= alignof(MemHeadAligned), "Bad alignment of MemHeadAligned"); static_assert(MEM_MIN_CPP_ALIGNMENT <= sizeof(MemHeadAligned), "Bad size of MemHeadAligned"); +} // namespace + static bool malloc_debug_memset = false; static void (*error_callback)(const char *) = nullptr; diff --git a/source/blender/blenkernel/intern/movieclip.cc b/source/blender/blenkernel/intern/movieclip.cc index 561e5c1a3cd..c35aa55ee73 100644 --- a/source/blender/blenkernel/intern/movieclip.cc +++ b/source/blender/blenkernel/intern/movieclip.cc @@ -465,11 +465,15 @@ static void get_proxy_filepath(const MovieClip *clip, #ifdef WITH_OPENEXR +namespace { + struct MultilayerConvertContext { float *combined_pass; int num_combined_channels; }; +} // namespace + static void *movieclip_convert_multilayer_add_view(void * /*ctx_v*/, const char * /*view_name*/) { return nullptr; diff --git a/source/blender/blenkernel/intern/studiolight.cc b/source/blender/blenkernel/intern/studiolight.cc index d61345334a2..f672674dfd6 100644 --- a/source/blender/blenkernel/intern/studiolight.cc +++ b/source/blender/blenkernel/intern/studiolight.cc @@ -274,6 +274,8 @@ static void direction_to_equirect(float r[2], const float dir[3]) r[1] = (acosf(dir[2] / 1.0) - M_PI) / -M_PI; } +namespace { + struct MultilayerConvertContext { int num_diffuse_channels; float *diffuse_pass; @@ -281,6 +283,8 @@ struct MultilayerConvertContext { float *specular_pass; }; +} // namespace + static void *studiolight_multilayer_addview(void * /*base*/, const char * /*view_name*/) { return nullptr; diff --git a/source/blender/blenlib/intern/polyfill_2d.cc b/source/blender/blenlib/intern/polyfill_2d.cc index baf7d191c76..28c4f6b7311 100644 --- a/source/blender/blenlib/intern/polyfill_2d.cc +++ b/source/blender/blenlib/intern/polyfill_2d.cc @@ -65,6 +65,8 @@ # include "BLI_time_utildefines.h" #endif +namespace { + using eSign = int8_t; #ifdef USE_KDTREE @@ -147,6 +149,8 @@ struct PolyFill { #endif }; +} // namespace + /* Based on LIBGDX 2013-11-28, APACHE 2.0 licensed. */ static void pf_coord_sign_calc(const PolyFill *pf, PolyIndex *pi); diff --git a/source/blender/blenlib/intern/scanfill.cc b/source/blender/blenlib/intern/scanfill.cc index 09aadd7b22b..5e3acc8d352 100644 --- a/source/blender/blenlib/intern/scanfill.cc +++ b/source/blender/blenlib/intern/scanfill.cc @@ -34,6 +34,8 @@ #include "BLI_strict_flags.h" /* IWYU pragma: keep. Keep last. */ +namespace { + /* local types */ struct PolyFill { uint edges, verts; @@ -47,6 +49,8 @@ struct ScanFillVertLink { ScanFillEdge *edge_first, *edge_last; }; +} // namespace + /* Local functions. */ #define SF_EPSILON 0.00003f diff --git a/source/blender/bmesh/operators/bmo_join_triangles.cc b/source/blender/bmesh/operators/bmo_join_triangles.cc index 20a9370d233..2272e93ca7e 100644 --- a/source/blender/bmesh/operators/bmo_join_triangles.cc +++ b/source/blender/bmesh/operators/bmo_join_triangles.cc @@ -268,6 +268,9 @@ static void bm_edge_to_quad_verts(const BMEdge *e, const BMVert *r_v_quad[4]) * \{ */ /** Cache custom-data delimiters. */ + +namespace { + struct DelimitData_CD { int cd_type; int cd_size; @@ -291,6 +294,8 @@ struct DelimitData { int cdata_len; }; +} // namespace + /** Determines if the loop custom-data is contiguous. */ static bool bm_edge_is_contiguous_loop_cd_all(const BMEdge *e, const DelimitData_CD *delimit_data) { diff --git a/source/blender/bmesh/tools/bmesh_decimate_dissolve.cc b/source/blender/bmesh/tools/bmesh_decimate_dissolve.cc index 0b27cc18806..0daf9788cf5 100644 --- a/source/blender/bmesh/tools/bmesh_decimate_dissolve.cc +++ b/source/blender/bmesh/tools/bmesh_decimate_dissolve.cc @@ -25,7 +25,16 @@ #define COST_INVALID FLT_MAX -struct DelimitData; +namespace { + +struct DelimitData { + int cd_loop_type; + int cd_loop_size; + int cd_loop_offset; + int cd_loop_offset_end; +}; + +} // namespace static bool bm_edge_is_delimiter(const BMEdge *e, const BMO_Delimit delimit, @@ -64,13 +73,6 @@ static float bm_vert_edge_face_angle(BMVert *v, #undef ANGLE_TO_UNIT } -struct DelimitData { - int cd_loop_type; - int cd_loop_size; - int cd_loop_offset; - int cd_loop_offset_end; -}; - static bool bm_edge_is_contiguous_loop_cd_all(const BMEdge *e, const DelimitData *delimit_data) { int cd_loop_offset; diff --git a/source/blender/editors/curve/editcurve_undo.cc b/source/blender/editors/curve/editcurve_undo.cc index 82e651f0666..f1446a47284 100644 --- a/source/blender/editors/curve/editcurve_undo.cc +++ b/source/blender/editors/curve/editcurve_undo.cc @@ -46,6 +46,8 @@ static CLG_LogRef LOG = {"ed.undo.curve"}; /** \name Undo Conversion * \{ */ +namespace { + struct UndoCurve { ListBase nubase; int actvert; @@ -72,6 +74,8 @@ struct UndoCurve { size_t undo_size; }; +} // namespace + static void undocurve_to_editcurve(Main *bmain, UndoCurve *ucu, Curve *cu, short *r_shapenr) { ListBase *undobase = &ucu->nubase; diff --git a/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.cc b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.cc index 1dfeb665cfa..96ed75def3c 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.cc +++ b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.cc @@ -992,6 +992,8 @@ static int gizmo_cage2d_test_select(bContext *C, wmGizmo *gz, const int mval[2]) return -1; } +namespace { + struct RectTransformInteraction { float orig_mouse[2]; float orig_matrix_offset[4][4]; @@ -1000,6 +1002,8 @@ struct RectTransformInteraction { bool use_temp_uniform; }; +} // namespace + static int gizmo_cage2d_transform_flag_get(const wmGizmo *gz) { RectTransformInteraction *data = static_cast(gz->interaction_data); diff --git a/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.cc b/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.cc index 0637cc0a53c..da9c224fee2 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.cc +++ b/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.cc @@ -429,12 +429,16 @@ static int gizmo_cage3d_get_cursor(wmGizmo *gz) return WM_CURSOR_DEFAULT; } +namespace { + struct RectTransformInteraction { float orig_mouse[3]; float orig_matrix_offset[4][4]; float orig_matrix_final_no_offset[4][4]; }; +} // namespace + static void gizmo_cage3d_setup(wmGizmo *gz) { gz->flag |= /* WM_GIZMO_DRAW_MODAL | */ /* TODO */ diff --git a/source/blender/editors/interface/view2d/view2d_gizmo_navigate.cc b/source/blender/editors/interface/view2d/view2d_gizmo_navigate.cc index 2be4e27209a..8bb2f339597 100644 --- a/source/blender/editors/interface/view2d/view2d_gizmo_navigate.cc +++ b/source/blender/editors/interface/view2d/view2d_gizmo_navigate.cc @@ -39,6 +39,8 @@ /* How much mini buttons offset from the primary. */ #define GIZMO_MINI_OFFSET_FAC 0.38f +namespace { + enum { GZ_INDEX_MOVE = 0, GZ_INDEX_ZOOM = 1, @@ -52,6 +54,16 @@ struct NavigateGizmoInfo { uint icon; }; +struct NavigateWidgetGroup { + wmGizmo *gz_array[GZ_INDEX_TOTAL]; + /* Store the view state to check for changes. */ + struct { + rcti rect_visible; + } state; +}; + +} // namespace + static NavigateGizmoInfo g_navigate_params_for_space_image[GZ_INDEX_TOTAL] = { { "IMAGE_OT_view_pan", @@ -104,14 +116,6 @@ static NavigateGizmoInfo *navigate_params_from_space_type(short space_type) } } -struct NavigateWidgetGroup { - wmGizmo *gz_array[GZ_INDEX_TOTAL]; - /* Store the view state to check for changes. */ - struct { - rcti rect_visible; - } state; -}; - static bool WIDGETGROUP_navigate_poll(const bContext *C, wmGizmoGroupType * /*gzgt*/) { if ((U.uiflag & USER_SHOW_GIZMO_NAVIGATE) == 0) { diff --git a/source/blender/editors/sculpt_paint/paint_curve_undo.cc b/source/blender/editors/sculpt_paint/paint_curve_undo.cc index 2d4aa036256..3213a191e95 100644 --- a/source/blender/editors/sculpt_paint/paint_curve_undo.cc +++ b/source/blender/editors/sculpt_paint/paint_curve_undo.cc @@ -31,12 +31,16 @@ /** \name Undo Conversion * \{ */ +namespace { + struct UndoCurve { PaintCurvePoint *points; /* points of curve */ int tot_points; int add_index; }; +} // namespace + static void undocurve_from_paintcurve(UndoCurve *uc, const PaintCurve *pc) { BLI_assert(BLI_array_is_zeroed(uc, 1)); diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.cc b/source/blender/editors/sculpt_paint/sculpt_uv.cc index b771bcbfe05..2252774ff2e 100644 --- a/source/blender/editors/sculpt_paint/sculpt_uv.cc +++ b/source/blender/editors/sculpt_paint/sculpt_uv.cc @@ -46,6 +46,8 @@ #include "UI_view2d.hh" +namespace { + enum eBrushUVSculptTool { UV_SCULPT_BRUSH_TYPE_GRAB = 0, UV_SCULPT_BRUSH_TYPE_RELAX = 1, @@ -145,6 +147,8 @@ struct UvSculptData { float uv_base_offset[2]; }; +} // namespace + static void apply_sculpt_data_constraints(UvSculptData *sculptdata, float uv[2]) { if (!sculptdata->constrain_to_bounds) { diff --git a/source/blender/editors/space_clip/clip_ops.cc b/source/blender/editors/space_clip/clip_ops.cc index 9e31f88772e..99f965ee6ee 100644 --- a/source/blender/editors/space_clip/clip_ops.cc +++ b/source/blender/editors/space_clip/clip_ops.cc @@ -363,6 +363,8 @@ void CLIP_OT_reload(wmOperatorType *ot) /** \name View Pan Operator * \{ */ +namespace { + struct ViewPanData { float x, y; float xof, yof, xorig, yorig; @@ -371,6 +373,8 @@ struct ViewPanData { float *vec; }; +} // namespace + static void view_pan_init(bContext *C, wmOperator *op, const wmEvent *event) { wmWindow *win = CTX_wm_window(C); @@ -536,6 +540,8 @@ void CLIP_OT_view_pan(wmOperatorType *ot) /** \name View Zoom Operator * \{ */ +namespace { + struct ViewZoomData { float x, y; float zoom; @@ -546,6 +552,8 @@ struct ViewZoomData { bool own_cursor; }; +} // namespace + static void view_zoom_init(bContext *C, wmOperator *op, const wmEvent *event) { wmWindow *win = CTX_wm_window(C); diff --git a/source/blender/editors/space_image/image_buttons.cc b/source/blender/editors/space_image/image_buttons.cc index 4b0c8a7b7f0..c4aa6ab034a 100644 --- a/source/blender/editors/space_image/image_buttons.cc +++ b/source/blender/editors/space_image/image_buttons.cc @@ -698,7 +698,6 @@ static void uiblock_layer_pass_buttons(uiLayout *layout, } } -/* Prevent naming collision. */ namespace { struct RNAUpdateCb { diff --git a/source/blender/editors/space_image/image_ops.cc b/source/blender/editors/space_image/image_ops.cc index 2d22b0d51b0..63b3f805766 100644 --- a/source/blender/editors/space_image/image_ops.cc +++ b/source/blender/editors/space_image/image_ops.cc @@ -357,6 +357,8 @@ static bool space_image_main_area_not_uv_brush_poll(bContext *C) /** \name View Pan Operator * \{ */ +namespace { + struct ViewPanData { float x, y; float xof, yof; @@ -364,6 +366,8 @@ struct ViewPanData { bool own_cursor; }; +} // namespace + static void image_view_pan_init(bContext *C, wmOperator *op, const wmEvent *event) { wmWindow *win = CTX_wm_window(C); @@ -504,6 +508,8 @@ void IMAGE_OT_view_pan(wmOperatorType *ot) /** \name View Zoom Operator * \{ */ +namespace { + struct ViewZoomData { float origx, origy; float zoom; @@ -520,6 +526,8 @@ struct ViewZoomData { ARegion *region; }; +} // namespace + static void image_view_zoom_init(bContext *C, wmOperator *op, const wmEvent *event) { wmWindow *win = CTX_wm_window(C); diff --git a/source/blender/editors/space_view3d/view3d_gizmo_navigate.cc b/source/blender/editors/space_view3d/view3d_gizmo_navigate.cc index af1526cc565..33e600d830d 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_navigate.cc +++ b/source/blender/editors/space_view3d/view3d_gizmo_navigate.cc @@ -42,6 +42,8 @@ /* Margin around the smaller buttons. */ #define GIZMO_MINI_OFFSET 2.0f +namespace { + enum { GZ_INDEX_MOVE = 0, GZ_INDEX_ROTATE = 1, @@ -68,6 +70,22 @@ struct NavigateGizmoInfo { void (*op_prop_fn)(PointerRNA *ptr); }; +struct NavigateWidgetGroup { + wmGizmo *gz_array[GZ_INDEX_TOTAL]; + /* Store the view state to check for changes. */ + struct { + rcti rect_visible; + struct { + char is_persp; + bool is_camera; + char viewlock; + char cameralock; + } rv3d; + } state; +}; + +} // namespace + static void navigate_context_toggle_camera_lock_init(PointerRNA *ptr) { RNA_string_set(ptr, "data_path", "space_data.lock_camera"); @@ -130,20 +148,6 @@ static NavigateGizmoInfo g_navigate_params[GZ_INDEX_TOTAL] = { }, }; -struct NavigateWidgetGroup { - wmGizmo *gz_array[GZ_INDEX_TOTAL]; - /* Store the view state to check for changes. */ - struct { - rcti rect_visible; - struct { - char is_persp; - bool is_camera; - char viewlock; - char cameralock; - } rv3d; - } state; -}; - static bool WIDGETGROUP_navigate_poll(const bContext *C, wmGizmoGroupType * /*gzgt*/) { View3D *v3d = CTX_wm_view3d(C); diff --git a/source/blender/editors/transform/transform_convert_sequencer.cc b/source/blender/editors/transform/transform_convert_sequencer.cc index 5b2983923a1..2bc2f59255a 100644 --- a/source/blender/editors/transform/transform_convert_sequencer.cc +++ b/source/blender/editors/transform/transform_convert_sequencer.cc @@ -40,6 +40,8 @@ namespace blender::ed::transform { #define STRIP_EDGE_PAN_DELAY 1.0f #define STRIP_EDGE_PAN_ZOOM_INFLUENCE 0.5f +namespace { + /** Used for sequencer transform. */ struct TransDataSeq { Strip *strip; @@ -68,6 +70,8 @@ struct TransSeq { VectorSet time_dependent_strips; }; +} // namespace + /* -------------------------------------------------------------------- */ /** \name Sequencer Transform Creation * \{ */ diff --git a/source/blender/editors/transform/transform_convert_sequencer_image.cc b/source/blender/editors/transform/transform_convert_sequencer_image.cc index 29f8c22ad0c..c2f74645a87 100644 --- a/source/blender/editors/transform/transform_convert_sequencer_image.cc +++ b/source/blender/editors/transform/transform_convert_sequencer_image.cc @@ -31,6 +31,8 @@ namespace blender::ed::transform { +namespace { + /** Used for sequencer transform. */ struct TransDataSeq { Strip *strip; @@ -40,6 +42,8 @@ struct TransDataSeq { float orig_rotation; }; +} // namespace + static TransData *SeqToTransData(const Scene *scene, Strip *strip, TransData *td, diff --git a/source/blender/editors/uvedit/uvedit_path.cc b/source/blender/editors/uvedit/uvedit_path.cc index e690e409567..c91640c8f10 100644 --- a/source/blender/editors/uvedit/uvedit_path.cc +++ b/source/blender/editors/uvedit/uvedit_path.cc @@ -55,6 +55,8 @@ using blender::Vector; /** \name Path Select Struct & Properties * \{ */ +namespace { + struct PathSelectParams { /** ensure the active element is the last selected item (handy for picking) */ bool track_active; @@ -70,6 +72,8 @@ struct UserData_UV { BMUVOffsets offsets; }; +} // namespace + static void path_select_properties(wmOperatorType *ot) { RNA_def_boolean(ot->srna, diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.cc b/source/blender/editors/uvedit/uvedit_smart_stitch.cc index 3d818d28a5a..d025586227f 100644 --- a/source/blender/editors/uvedit/uvedit_smart_stitch.cc +++ b/source/blender/editors/uvedit/uvedit_smart_stitch.cc @@ -60,6 +60,8 @@ using blender::Vector; /* ********************** smart stitch operator *********************** */ +namespace { + /* object that stores display data for previewing before confirming stitching */ struct StitchPreviewer { /* here we'll store the preview triangle indices of the mesh */ @@ -231,6 +233,8 @@ struct StitchStateInit { UvElementID *to_select; }; +} // namespace + /* constructor */ static StitchPreviewer *stitch_preview_init() { diff --git a/source/blender/modifiers/intern/MOD_laplaciandeform.cc b/source/blender/modifiers/intern/MOD_laplaciandeform.cc index 7056d7e99aa..0616f9c5b33 100644 --- a/source/blender/modifiers/intern/MOD_laplaciandeform.cc +++ b/source/blender/modifiers/intern/MOD_laplaciandeform.cc @@ -49,7 +49,6 @@ enum { LAPDEFORM_SYSTEM_CHANGE_NOT_VALID_GROUP, }; -/* Prevent naming collision. */ namespace { struct LaplacianSystem { diff --git a/source/blender/modifiers/intern/MOD_laplaciansmooth.cc b/source/blender/modifiers/intern/MOD_laplaciansmooth.cc index 4090b3989a6..a4b8a9799e3 100644 --- a/source/blender/modifiers/intern/MOD_laplaciansmooth.cc +++ b/source/blender/modifiers/intern/MOD_laplaciansmooth.cc @@ -31,7 +31,6 @@ #include "eigen_capi.h" -/* Prevent naming collision. */ namespace { struct LaplacianSystem {