Cleanup: Move BLO headers to C++

Except for BLO_readfile.h, which is still included by C files.

Pull Request: https://projects.blender.org/blender/blender/pulls/111610
This commit is contained in:
Hans Goudey 2023-08-28 15:01:05 +02:00 committed by Hans Goudey
parent 66c05fe368
commit 3db523ab3e
143 changed files with 301 additions and 356 deletions

View File

@ -60,7 +60,7 @@
#include "RNA_path.hh" #include "RNA_path.hh"
#include "RNA_prototypes.h" #include "RNA_prototypes.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#include "CLG_log.h" #include "CLG_log.h"

View File

@ -41,7 +41,7 @@
#include "DEG_depsgraph.h" #include "DEG_depsgraph.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#include "RNA_access.hh" #include "RNA_access.hh"
#include "RNA_path.hh" #include "RNA_path.hh"

View File

@ -57,7 +57,7 @@
#include "RNA_path.hh" #include "RNA_path.hh"
#include "RNA_prototypes.h" #include "RNA_prototypes.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#include "nla_private.h" #include "nla_private.h"

View File

@ -19,7 +19,7 @@
#include "GPU_batch.h" #include "GPU_batch.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
/* ******************************************************************** */ /* ******************************************************************** */
/* Animation Visualization */ /* Animation Visualization */

View File

@ -53,7 +53,7 @@
#include "BIK_api.h" #include "BIK_api.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#include "CLG_log.h" #include "CLG_log.h"

View File

@ -21,7 +21,7 @@
#include "BKE_icons.h" #include "BKE_icons.h"
#include "BKE_idprop.h" #include "BKE_idprop.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#include "MEM_guardedalloc.h" #include "MEM_guardedalloc.h"

View File

@ -13,7 +13,7 @@
#include "BKE_asset.h" #include "BKE_asset.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#include "DNA_asset_types.h" #include "DNA_asset_types.h"

View File

@ -38,7 +38,7 @@
#include "DEG_depsgraph_build.h" #include "DEG_depsgraph_build.h"
#include "BLO_readfile.h" #include "BLO_readfile.h"
#include "BLO_writefile.h" #include "BLO_writefile.hh"
#include "IMB_colormanagement.h" #include "IMB_colormanagement.h"

View File

@ -39,8 +39,8 @@
#include "BKE_undo_system.h" #include "BKE_undo_system.h"
#include "BLO_readfile.h" #include "BLO_readfile.h"
#include "BLO_undofile.h" #include "BLO_undofile.hh"
#include "BLO_writefile.h" #include "BLO_writefile.hh"
#include "DEG_depsgraph.h" #include "DEG_depsgraph.h"

View File

@ -59,7 +59,7 @@
#include "BKE_workspace.h" #include "BKE_workspace.h"
#include "BLO_readfile.h" #include "BLO_readfile.h"
#include "BLO_writefile.h" #include "BLO_writefile.hh"
#include "RNA_access.hh" #include "RNA_access.hh"

View File

@ -53,7 +53,7 @@
#include "BKE_blendfile_link_append.h" #include "BKE_blendfile_link_append.h"
#include "BLO_readfile.h" #include "BLO_readfile.h"
#include "BLO_writefile.h" #include "BLO_writefile.hh"
static CLG_LogRef LOG = {"bke.blendfile_link_append"}; static CLG_LogRef LOG = {"bke.blendfile_link_append"};

View File

@ -42,7 +42,7 @@
#include "RE_texture.h" /* RE_texture_evaluate */ #include "RE_texture.h" /* RE_texture_evaluate */
#include "BLO_read_write.h" #include "BLO_read_write.hh"
static void brush_init_data(ID *id) static void brush_init_data(ID *id)
{ {

View File

@ -37,7 +37,7 @@
#include "RE_engine.h" #include "RE_engine.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#include "MEM_guardedalloc.h" #include "MEM_guardedalloc.h"

View File

@ -47,7 +47,7 @@
#include "MEM_guardedalloc.h" #include "MEM_guardedalloc.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */
/** \name Camera Data-Block /** \name Camera Data-Block

View File

@ -48,7 +48,7 @@
#include "MEM_guardedalloc.h" #include "MEM_guardedalloc.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
static CLG_LogRef LOG = {"bke.collection"}; static CLG_LogRef LOG = {"bke.collection"};

View File

@ -28,7 +28,7 @@
#include "IMB_colormanagement.h" #include "IMB_colormanagement.h"
#include "IMB_imbuf_types.h" #include "IMB_imbuf_types.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
/* ********************************* color curve ********************* */ /* ********************************* color curve ********************* */

View File

@ -73,7 +73,7 @@
#include "DEG_depsgraph.h" #include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h" #include "DEG_depsgraph_query.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#include "CLG_log.h" #include "CLG_log.h"

View File

@ -56,7 +56,7 @@
#include "CLG_log.h" #include "CLG_log.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
using blender::float3; using blender::float3;
using blender::IndexRange; using blender::IndexRange;

View File

@ -21,7 +21,7 @@
#include "BKE_curve.h" #include "BKE_curve.h"
#include "BKE_curveprofile.h" #include "BKE_curveprofile.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
/** Number of points in high resolution table is dynamic up to a maximum. */ /** Number of points in high resolution table is dynamic up to a maximum. */
#define PROF_TABLE_MAX 512 #define PROF_TABLE_MAX 512

View File

@ -43,7 +43,7 @@
#include "DEG_depsgraph_query.h" #include "DEG_depsgraph_query.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
using blender::float3; using blender::float3;
using blender::IndexRange; using blender::IndexRange;

View File

@ -20,7 +20,7 @@
#include "BLI_multi_value_map.hh" #include "BLI_multi_value_map.hh"
#include "BLI_task.hh" #include "BLI_task.hh"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#include "DNA_curves_types.h" #include "DNA_curves_types.h"

View File

@ -52,7 +52,7 @@
#include "BKE_multires.hh" #include "BKE_multires.hh"
#include "BKE_subsurf.hh" #include "BKE_subsurf.hh"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#include "bmesh.h" #include "bmesh.h"

View File

@ -38,7 +38,7 @@
#include "BKE_object.h" #include "BKE_object.h"
#include "BKE_object_deform.h" #include "BKE_object_deform.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#include "data_transfer_intern.h" #include "data_transfer_intern.h"

View File

@ -36,7 +36,7 @@
#include "BKE_lib_query.h" #include "BKE_lib_query.h"
#include "BKE_nla.h" #include "BKE_nla.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#include "RNA_access.hh" #include "RNA_access.hh"
#include "RNA_path.hh" #include "RNA_path.hh"

View File

@ -55,7 +55,7 @@
#include "DEG_depsgraph_query.h" #include "DEG_depsgraph_query.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
static CLG_LogRef LOG = {"bke.gpencil"}; static CLG_LogRef LOG = {"bke.gpencil"};

View File

@ -49,7 +49,7 @@
#include "MOD_gpencil_legacy_lineart.h" #include "MOD_gpencil_legacy_lineart.h"
#include "MOD_gpencil_legacy_modifiertypes.h" #include "MOD_gpencil_legacy_modifiertypes.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#include "CLG_log.h" #include "CLG_log.h"

View File

@ -35,7 +35,7 @@
#include "BLI_vector_set.hh" #include "BLI_vector_set.hh"
#include "BLI_virtual_array.hh" #include "BLI_virtual_array.hh"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#include "BLT_translation.h" #include "BLT_translation.h"

View File

@ -47,7 +47,7 @@
#include "IMB_imbuf_types.h" #include "IMB_imbuf_types.h"
#include "IMB_thumbs.h" #include "IMB_thumbs.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#include "atomic_ops.h" #include "atomic_ops.h"

View File

@ -27,7 +27,7 @@
#include "MEM_guardedalloc.h" #include "MEM_guardedalloc.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#include "BLI_strict_flags.h" #include "BLI_strict_flags.h"

View File

@ -95,7 +95,7 @@
#include "DEG_depsgraph.h" #include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h" #include "DEG_depsgraph_query.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
/* for image user iteration */ /* for image user iteration */
#include "DNA_node_types.h" #include "DNA_node_types.h"

View File

@ -62,7 +62,7 @@
#include "SEQ_iterator.h" #include "SEQ_iterator.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#ifdef WIN32 #ifdef WIN32
# include "BLI_math_base.h" /* M_PI */ # include "BLI_math_base.h" /* M_PI */

View File

@ -51,7 +51,7 @@
#include "RNA_path.hh" #include "RNA_path.hh"
#include "RNA_prototypes.h" #include "RNA_prototypes.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
static void shapekey_copy_data(Main * /*bmain*/, ID *id_dst, const ID *id_src, const int /*flag*/) static void shapekey_copy_data(Main * /*bmain*/, ID *id_dst, const ID *id_src, const int /*flag*/)
{ {

View File

@ -46,7 +46,7 @@
#include "DEG_depsgraph_query.h" #include "DEG_depsgraph_query.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
static void lattice_init_data(ID *id) static void lattice_init_data(ID *id)
{ {

View File

@ -53,7 +53,7 @@
#include "MEM_guardedalloc.h" #include "MEM_guardedalloc.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
static CLG_LogRef LOG = {"bke.layercollection"}; static CLG_LogRef LOG = {"bke.layercollection"};

View File

@ -64,7 +64,7 @@
#include "RNA_access.hh" #include "RNA_access.hh"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#include "atomic_ops.h" #include "atomic_ops.h"

View File

@ -38,7 +38,7 @@
#include "DEG_depsgraph.h" #include "DEG_depsgraph.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
static void light_init_data(ID *id) static void light_init_data(ID *id)
{ {

View File

@ -26,7 +26,7 @@
#include "BLT_translation.h" #include "BLT_translation.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
static void lightprobe_init_data(ID *id) static void lightprobe_init_data(ID *id)
{ {

View File

@ -38,7 +38,7 @@
#include "BKE_node_tree_update.h" #include "BKE_node_tree_update.h"
#include "BKE_texture.h" #include "BKE_texture.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
static void linestyle_init_data(ID *id) static void linestyle_init_data(ID *id)
{ {

View File

@ -45,7 +45,7 @@
#include "DRW_engine.h" #include "DRW_engine.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
static CLG_LogRef LOG = {"bke.mask"}; static CLG_LogRef LOG = {"bke.mask"};

View File

@ -74,7 +74,7 @@
#include "NOD_shader.h" #include "NOD_shader.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
static CLG_LogRef LOG = {"bke.material"}; static CLG_LogRef LOG = {"bke.material"};

View File

@ -57,7 +57,7 @@
#include "DEG_depsgraph.h" #include "DEG_depsgraph.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
static void metaball_init_data(ID *id) static void metaball_init_data(ID *id)
{ {

View File

@ -65,7 +65,7 @@
#include "DEG_depsgraph.h" #include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h" #include "DEG_depsgraph_query.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
using blender::float3; using blender::float3;
using blender::MutableSpan; using blender::MutableSpan;

View File

@ -72,7 +72,7 @@
#include "MOD_modifiertypes.hh" #include "MOD_modifiertypes.hh"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#include "CLG_log.h" #include "CLG_log.h"

View File

@ -68,7 +68,7 @@
#include "GPU_texture.h" #include "GPU_texture.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#include "tracking_private.h" #include "tracking_private.h"

View File

@ -39,7 +39,7 @@
#include "BKE_nla.h" #include "BKE_nla.h"
#include "BKE_sound.h" #include "BKE_sound.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#include "RNA_access.hh" #include "RNA_access.hh"
#include "RNA_prototypes.h" #include "RNA_prototypes.h"

View File

@ -90,7 +90,7 @@
#include "DEG_depsgraph.h" #include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h" #include "DEG_depsgraph_build.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#include "PIL_time.h" #include "PIL_time.h"

View File

@ -14,7 +14,7 @@
#include "BLI_string.h" #include "BLI_string.h"
#include "BLI_vector.hh" #include "BLI_vector.hh"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#include "DNA_collection_types.h" #include "DNA_collection_types.h"
#include "DNA_material_types.h" #include "DNA_material_types.h"

View File

@ -136,7 +136,7 @@
#include "DRW_engine.h" #include "DRW_engine.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#include "BLO_readfile.h" #include "BLO_readfile.h"
#include "SEQ_sequencer.h" #include "SEQ_sequencer.h"

View File

@ -40,7 +40,7 @@
#include "IMB_imbuf.h" #include "IMB_imbuf.h"
#include "IMB_imbuf_types.h" #include "IMB_imbuf_types.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
int BKE_packedfile_seek(PackedFile *pf, int offset, int whence) int BKE_packedfile_seek(PackedFile *pf, int offset, int whence)
{ {

View File

@ -68,7 +68,7 @@
#include "RNA_enum_types.hh" #include "RNA_enum_types.hh"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#include "bmesh.h" #include "bmesh.h"

View File

@ -78,7 +78,7 @@
#include "RE_texture.h" #include "RE_texture.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#include "particle_private.h" #include "particle_private.h"

View File

@ -53,7 +53,7 @@
#include "BKE_scene.h" #include "BKE_scene.h"
#include "BKE_softbody.h" #include "BKE_softbody.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#include "BIK_api.h" #include "BIK_api.h"

View File

@ -42,7 +42,7 @@
#include "DEG_depsgraph_query.h" #include "DEG_depsgraph_query.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
using blender::float3; using blender::float3;
using blender::IndexRange; using blender::IndexRange;

View File

@ -105,7 +105,7 @@
#include "SEQ_iterator.h" #include "SEQ_iterator.h"
#include "SEQ_sequencer.h" #include "SEQ_sequencer.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#include "engines/eevee/eevee_lightcache.h" #include "engines/eevee/eevee_lightcache.h"

View File

@ -51,7 +51,7 @@
#include "BKE_viewer_path.h" #include "BKE_viewer_path.h"
#include "BKE_workspace.h" #include "BKE_workspace.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
/* TODO(@JulianEisel): For asset shelf region reading/writing. Region read/write should be done via /* TODO(@JulianEisel): For asset shelf region reading/writing. Region read/write should be done via
* a #ARegionType callback. */ * a #ARegionType callback. */

View File

@ -36,7 +36,7 @@
#include "FX_shader_types.h" #include "FX_shader_types.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
static ShaderFxTypeInfo *shader_fx_types[NUM_SHADER_FX_TYPES] = {nullptr}; static ShaderFxTypeInfo *shader_fx_types[NUM_SHADER_FX_TYPES] = {nullptr};

View File

@ -53,7 +53,7 @@
#include "DEG_depsgraph.h" #include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h" #include "DEG_depsgraph_query.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#include "SEQ_sequencer.h" #include "SEQ_sequencer.h"
#include "SEQ_sound.h" #include "SEQ_sound.h"

View File

@ -22,7 +22,7 @@
#include "BKE_main.h" #include "BKE_main.h"
#include "BKE_speaker.h" #include "BKE_speaker.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#include <cstring> #include <cstring>

View File

@ -41,7 +41,7 @@
#include "BKE_node.h" #include "BKE_node.h"
#include "BKE_text.h" #include "BKE_text.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#ifdef WITH_PYTHON #ifdef WITH_PYTHON
# include "BPY_extern.h" # include "BPY_extern.h"

View File

@ -61,7 +61,7 @@
#include "DRW_engine.h" #include "DRW_engine.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
static void texture_init_data(ID *id) static void texture_init_data(ID *id)
{ {

View File

@ -46,7 +46,7 @@
#include "BKE_vfont.h" #include "BKE_vfont.h"
#include "BKE_vfontdata.h" #include "BKE_vfontdata.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
static CLG_LogRef LOG = {"bke.data_transfer"}; static CLG_LogRef LOG = {"bke.data_transfer"};
static ThreadRWMutex vfont_rwlock = BLI_RWLOCK_INITIALIZER; static ThreadRWMutex vfont_rwlock = BLI_RWLOCK_INITIALIZER;

View File

@ -13,7 +13,7 @@
#include "MEM_guardedalloc.h" #include "MEM_guardedalloc.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
using blender::IndexRange; using blender::IndexRange;
using blender::StringRef; using blender::StringRef;

View File

@ -49,7 +49,7 @@
#include "DEG_depsgraph_query.h" #include "DEG_depsgraph_query.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#include "CLG_log.h" #include "CLG_log.h"

View File

@ -39,7 +39,7 @@
#include "MEM_guardedalloc.h" #include "MEM_guardedalloc.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */

View File

@ -40,7 +40,7 @@
#include "GPU_material.h" #include "GPU_material.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
/** Free (or release) any data used by this world (does not free the world itself). */ /** Free (or release) any data used by this world (does not free the world itself). */
static void world_free_data(ID *id) static void world_free_data(ID *id)

View File

@ -43,7 +43,7 @@
# define POISON_REDZONE_SIZE 0 # define POISON_REDZONE_SIZE 0
#endif #endif
/* NOTE: copied from BLO_blend_defs.h, don't use here because we're in BLI. */ /* NOTE: copied from BLO_blend_defs.hh, don't use here because we're in BLI. */
#ifdef __BIG_ENDIAN__ #ifdef __BIG_ENDIAN__
/* Big Endian */ /* Big Endian */
# define MAKE_ID(a, b, c, d) ((int)(a) << 24 | (int)(b) << 16 | (c) << 8 | (d)) # define MAKE_ID(a, b, c, d) ((int)(a) << 24 | (int)(b) << 16 | (c) << 8 | (d))

View File

@ -13,20 +13,12 @@
struct Main; struct Main;
struct ReportList; struct ReportList;
#ifdef __cplusplus
extern "C" {
#endif
/** /**
* Check (but do *not* fix) that all linked data-blocks are still valid * Check (but do *not* fix) that all linked data-blocks are still valid
* (i.e. pointing to the right library). * (i.e. pointing to the right library).
*/ */
bool BLO_main_validate_libraries(struct Main *bmain, struct ReportList *reports); bool BLO_main_validate_libraries(Main *bmain, ReportList *reports);
/** /**
* * Check (and fix if needed) that shape key's 'from' pointer is valid. * * Check (and fix if needed) that shape key's 'from' pointer is valid.
*/ */
bool BLO_main_validate_shapekeys(struct Main *bmain, struct ReportList *reports); bool BLO_main_validate_shapekeys(Main *bmain, ReportList *reports);
#ifdef __cplusplus
}
#endif

View File

@ -33,15 +33,10 @@
#include "DNA_windowmanager_types.h" /* for eReportType */ #include "DNA_windowmanager_types.h" /* for eReportType */
#ifdef __cplusplus struct BlendDataReader;
extern "C" {
#endif
typedef struct BlendDataReader BlendDataReader;
typedef struct BlendLibReader BlendLibReader;
typedef struct BlendWriter BlendWriter;
struct BlendFileReadReport; struct BlendFileReadReport;
struct BlendLibReader;
struct BlendWriter;
struct LibraryIDLinkCallbackData; struct LibraryIDLinkCallbackData;
struct Main; struct Main;
@ -142,20 +137,15 @@ void BLO_write_struct_array_at_address_by_id(
/** /**
* Write struct list. * Write struct list.
*/ */
void BLO_write_struct_list_by_name(BlendWriter *writer, void BLO_write_struct_list_by_name(BlendWriter *writer, const char *struct_name, ListBase *list);
const char *struct_name, void BLO_write_struct_list_by_id(BlendWriter *writer, int struct_id, ListBase *list);
struct ListBase *list);
void BLO_write_struct_list_by_id(BlendWriter *writer, int struct_id, struct ListBase *list);
#define BLO_write_struct_list(writer, struct_name, list_ptr) \ #define BLO_write_struct_list(writer, struct_name, list_ptr) \
BLO_write_struct_list_by_id(writer, BLO_get_struct_id(writer, struct_name), list_ptr) BLO_write_struct_list_by_id(writer, BLO_get_struct_id(writer, struct_name), list_ptr)
/** /**
* Write id struct. * Write id struct.
*/ */
void blo_write_id_struct(BlendWriter *writer, void blo_write_id_struct(BlendWriter *writer, int struct_id, const void *id_address, const ID *id);
int struct_id,
const void *id_address,
const struct ID *id);
#define BLO_write_id_struct(writer, struct_name, id_address, id) \ #define BLO_write_id_struct(writer, struct_name, id_address, id) \
blo_write_id_struct(writer, BLO_get_struct_id(writer, struct_name), id_address, id) blo_write_id_struct(writer, BLO_get_struct_id(writer, struct_name), id_address, id)
@ -167,13 +157,11 @@ void blo_write_id_struct(BlendWriter *writer,
* \note Once there is a better generic handling of embedded IDs, * \note Once there is a better generic handling of embedded IDs,
* this may go back to private code in `writefile.cc`. * this may go back to private code in `writefile.cc`.
*/ */
typedef struct BLO_Write_IDBuffer BLO_Write_IDBuffer; struct BLO_Write_IDBuffer;
BLO_Write_IDBuffer *BLO_write_allocate_id_buffer(void); BLO_Write_IDBuffer *BLO_write_allocate_id_buffer(void);
void BLO_write_init_id_buffer_from_id(BLO_Write_IDBuffer *id_buffer, void BLO_write_init_id_buffer_from_id(BLO_Write_IDBuffer *id_buffer, ID *id, const bool is_undo);
struct ID *id, ID *BLO_write_get_id_buffer_temp_id(BLO_Write_IDBuffer *id_buffer);
const bool is_undo);
struct ID *BLO_write_get_id_buffer_temp_id(BLO_Write_IDBuffer *id_buffer);
void BLO_write_destroy_id_buffer(BLO_Write_IDBuffer **id_buffer); void BLO_write_destroy_id_buffer(BLO_Write_IDBuffer **id_buffer);
/** /**
@ -242,8 +230,8 @@ typedef void (*BlendReadListFn)(BlendDataReader *reader, void *data);
* Updates the `list->first` and `list->last` pointers. * Updates the `list->first` and `list->last` pointers.
* When not NULL, calls the callback on every element. * When not NULL, calls the callback on every element.
*/ */
void BLO_read_list_cb(BlendDataReader *reader, struct ListBase *list, BlendReadListFn callback); void BLO_read_list_cb(BlendDataReader *reader, ListBase *list, BlendReadListFn callback);
void BLO_read_list(BlendDataReader *reader, struct ListBase *list); void BLO_read_list(BlendDataReader *reader, ListBase *list);
/* Update data pointers and correct byte-order if necessary. */ /* Update data pointers and correct byte-order if necessary. */
@ -261,8 +249,8 @@ int BLO_read_fileversion_get(BlendDataReader *reader);
bool BLO_read_requires_endian_switch(BlendDataReader *reader); bool BLO_read_requires_endian_switch(BlendDataReader *reader);
bool BLO_read_data_is_undo(BlendDataReader *reader); bool BLO_read_data_is_undo(BlendDataReader *reader);
void BLO_read_data_globmap_add(BlendDataReader *reader, void *oldaddr, void *newaddr); void BLO_read_data_globmap_add(BlendDataReader *reader, void *oldaddr, void *newaddr);
void BLO_read_glob_list(BlendDataReader *reader, struct ListBase *list); void BLO_read_glob_list(BlendDataReader *reader, ListBase *list);
struct BlendFileReadReport *BLO_read_data_reports(BlendDataReader *reader); BlendFileReadReport *BLO_read_data_reports(BlendDataReader *reader);
struct Library *BLO_read_data_current_library(BlendDataReader *reader); struct Library *BLO_read_data_current_library(BlendDataReader *reader);
/** \} */ /** \} */
@ -283,10 +271,10 @@ struct Library *BLO_read_data_current_library(BlendDataReader *reader);
* prevent linked data to point to local IDs. * prevent linked data to point to local IDs.
* \return the new address of the given ID pointer, or null if not found. * \return the new address of the given ID pointer, or null if not found.
*/ */
struct ID *BLO_read_get_new_id_address(BlendLibReader *reader, ID *BLO_read_get_new_id_address(BlendLibReader *reader,
struct ID *self_id, ID *self_id,
const bool do_linked_only, const bool do_linked_only,
struct ID *id) ATTR_NONNULL(2); ID *id) ATTR_NONNULL(2);
/** /**
* Search for the new address of the ID for the given `session_uuid`. * Search for the new address of the ID for the given `session_uuid`.
@ -299,14 +287,14 @@ struct ID *BLO_read_get_new_id_address(BlendLibReader *reader,
* coming from the previous, existing Main data, when it is preserved in newly read Main. * coming from the previous, existing Main data, when it is preserved in newly read Main.
* See e.g. the #scene_undo_preserve code-path. * See e.g. the #scene_undo_preserve code-path.
*/ */
struct ID *BLO_read_get_new_id_address_from_session_uuid(BlendLibReader *reader, uint session_uuid) ID *BLO_read_get_new_id_address_from_session_uuid(BlendLibReader *reader, uint session_uuid)
ATTR_NONNULL(1); ATTR_NONNULL(1);
/* Misc. */ /* Misc. */
bool BLO_read_lib_is_undo(BlendLibReader *reader); bool BLO_read_lib_is_undo(BlendLibReader *reader);
struct Main *BLO_read_lib_get_main(BlendLibReader *reader); Main *BLO_read_lib_get_main(BlendLibReader *reader);
struct BlendFileReadReport *BLO_read_lib_reports(BlendLibReader *reader); BlendFileReadReport *BLO_read_lib_reports(BlendLibReader *reader);
/** \} */ /** \} */
@ -321,13 +309,7 @@ struct BlendFileReadReport *BLO_read_lib_reports(BlendLibReader *reader);
* NOTE(@ideasman42) a kludge but better than doubling up on prints, * NOTE(@ideasman42) a kludge but better than doubling up on prints,
* we could alternatively have a versions of a report function which forces printing. * we could alternatively have a versions of a report function which forces printing.
*/ */
void BLO_reportf_wrap(struct BlendFileReadReport *reports, void BLO_reportf_wrap(BlendFileReadReport *reports, eReportType type, const char *format, ...)
eReportType type, ATTR_PRINTF_FORMAT(3, 4);
const char *format,
...) ATTR_PRINTF_FORMAT(3, 4);
/** \} */ /** \} */
#ifdef __cplusplus
}
#endif

View File

@ -10,11 +10,13 @@
*/ */
#include "BLI_filereader.h" #include "BLI_filereader.h"
#include "BLI_listbase.h"
struct GHash; struct GHash;
struct Main;
struct Scene; struct Scene;
typedef struct { struct MemFileChunk {
void *next, *prev; void *next, *prev;
const char *buf; const char *buf;
/** Size in bytes. */ /** Size in bytes. */
@ -28,14 +30,14 @@ typedef struct {
/** Session UUID of the ID being currently written (MAIN_ID_SESSION_UUID_UNSET when not writing /** Session UUID of the ID being currently written (MAIN_ID_SESSION_UUID_UNSET when not writing
* ID-related data). Used to find matching chunks in previous memundo step. */ * ID-related data). Used to find matching chunks in previous memundo step. */
uint id_session_uuid; uint id_session_uuid;
} MemFileChunk; };
typedef struct MemFile { struct MemFile {
ListBase chunks; ListBase chunks;
size_t size; size_t size;
} MemFile; };
typedef struct MemFileWriteData { struct MemFileWriteData {
MemFile *written_memfile; MemFile *written_memfile;
MemFile *reference_memfile; MemFile *reference_memfile;
@ -43,14 +45,14 @@ typedef struct MemFileWriteData {
MemFileChunk *reference_current_chunk; MemFileChunk *reference_current_chunk;
/** Maps an ID session uuid to its first reference MemFileChunk, if existing. */ /** Maps an ID session uuid to its first reference MemFileChunk, if existing. */
struct GHash *id_session_uuid_mapping; GHash *id_session_uuid_mapping;
} MemFileWriteData; };
typedef struct MemFileUndoData { struct MemFileUndoData {
char filepath[1024]; /* FILE_MAX */ char filepath[1024]; /* FILE_MAX */
MemFile memfile; MemFile memfile;
size_t undo_size; size_t undo_size;
} MemFileUndoData; };
/* FileReader-compatible wrapper for reading MemFiles */ /* FileReader-compatible wrapper for reading MemFiles */
typedef struct { typedef struct {
@ -62,10 +64,6 @@ typedef struct {
bool memchunk_identical; bool memchunk_identical;
} UndoReader; } UndoReader;
#ifdef __cplusplus
extern "C" {
#endif
/* Actually only used `writefile.cc`. */ /* Actually only used `writefile.cc`. */
void BLO_memfile_write_init(MemFileWriteData *mem_data, void BLO_memfile_write_init(MemFileWriteData *mem_data,
@ -95,18 +93,12 @@ extern void BLO_memfile_clear_future(MemFile *memfile);
/* Utilities. */ /* Utilities. */
extern struct Main *BLO_memfile_main_get(struct MemFile *memfile, extern Main *BLO_memfile_main_get(MemFile *memfile, Main *bmain, Scene **r_scene);
struct Main *bmain,
struct Scene **r_scene);
/** /**
* Saves .blend using undo buffer. * Saves .blend using undo buffer.
* *
* \return success. * \return success.
*/ */
extern bool BLO_memfile_write_file(struct MemFile *memfile, const char *filepath); extern bool BLO_memfile_write_file(MemFile *memfile, const char *filepath);
FileReader *BLO_memfile_new_filereader(MemFile *memfile, int undo_direction); FileReader *BLO_memfile_new_filereader(MemFile *memfile, int undo_direction);
#ifdef __cplusplus
}
#endif

View File

@ -49,14 +49,14 @@ set(SRC
intern/versioning_userdef.cc intern/versioning_userdef.cc
intern/writefile.cc intern/writefile.cc
BLO_blend_defs.h BLO_blend_defs.hh
BLO_blend_validate.h BLO_blend_validate.hh
BLO_read_write.h BLO_read_write.hh
BLO_readfile.h BLO_readfile.h
BLO_undofile.h BLO_undofile.hh
BLO_writefile.h BLO_writefile.hh
intern/readfile.h intern/readfile.hh
intern/versioning_common.h intern/versioning_common.hh
) )
set(LIB set(LIB

View File

@ -31,10 +31,10 @@
#include "BKE_main.h" #include "BKE_main.h"
#include "BKE_report.h" #include "BKE_report.h"
#include "BLO_blend_validate.h" #include "BLO_blend_validate.hh"
#include "BLO_readfile.h" #include "BLO_readfile.h"
#include "readfile.h" #include "readfile.hh"
bool BLO_main_validate_libraries(Main *bmain, ReportList *reports) bool BLO_main_validate_libraries(Main *bmain, ReportList *reports)
{ {

View File

@ -30,11 +30,11 @@
#include "BKE_idtype.h" #include "BKE_idtype.h"
#include "BKE_main.h" #include "BKE_main.h"
#include "BLO_blend_defs.h" #include "BLO_blend_defs.hh"
#include "BLO_readfile.h" #include "BLO_readfile.h"
#include "BLO_undofile.h" #include "BLO_undofile.hh"
#include "readfile.h" #include "readfile.hh"
#include "BLI_sys_types.h" /* Needed for `intptr_t`. */ #include "BLI_sys_types.h" /* Needed for `intptr_t`. */

View File

@ -93,11 +93,11 @@
#include "DEG_depsgraph.h" #include "DEG_depsgraph.h"
#include "BLO_blend_defs.h" #include "BLO_blend_defs.hh"
#include "BLO_blend_validate.h" #include "BLO_blend_validate.hh"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#include "BLO_readfile.h" #include "BLO_readfile.h"
#include "BLO_undofile.h" #include "BLO_undofile.hh"
#include "SEQ_clipboard.h" #include "SEQ_clipboard.h"
#include "SEQ_iterator.h" #include "SEQ_iterator.h"
@ -105,7 +105,7 @@
#include "SEQ_sequencer.h" #include "SEQ_sequencer.h"
#include "SEQ_utils.h" #include "SEQ_utils.h"
#include "readfile.h" #include "readfile.hh"
/* Make preferences read-only. */ /* Make preferences read-only. */
#define U (*((const UserDef *)&U)) #define U (*((const UserDef *)&U))

View File

@ -9,7 +9,7 @@
#pragma once #pragma once
#include <stdio.h> /* Include header using off_t before poisoning it below. */ #include <cstdio> /* Include header using off_t before poisoning it below. */
#ifdef WIN32 #ifdef WIN32
# include "BLI_winstuff.h" # include "BLI_winstuff.h"
@ -20,21 +20,23 @@
#include "DNA_space_types.h" #include "DNA_space_types.h"
#include "DNA_windowmanager_types.h" /* for eReportType */ #include "DNA_windowmanager_types.h" /* for eReportType */
#ifdef __cplusplus #include "BLO_readfile.h"
extern "C" {
#endif
struct BlendFileData;
struct BlendFileReadParams;
struct BlendFileReadReport;
struct BLOCacheStorage; struct BLOCacheStorage;
struct BHeadSort;
struct DNA_ReconstructInfo;
struct IDNameLib_Map; struct IDNameLib_Map;
struct Key; struct Key;
struct Main;
struct MemFile; struct MemFile;
struct Object; struct Object;
struct OldNewMap; struct OldNewMap;
struct ReportList; struct ReportList;
struct UserDef; struct UserDef;
typedef struct IDNameLib_Map IDNameLib_Map;
enum eFileDataFlag { enum eFileDataFlag {
FD_FLAGS_SWITCH_ENDIAN = 1 << 0, FD_FLAGS_SWITCH_ENDIAN = 1 << 0,
FD_FLAGS_FILE_POINTSIZE_IS_4 = 1 << 1, FD_FLAGS_FILE_POINTSIZE_IS_4 = 1 << 1,
@ -51,7 +53,7 @@ ENUM_OPERATORS(eFileDataFlag, FD_FLAGS_NOT_MY_LIBMAP)
# pragma GCC poison off_t # pragma GCC poison off_t
#endif #endif
typedef struct FileData { struct FileData {
/** Linked list of BHeadN's. */ /** Linked list of BHeadN's. */
ListBase bhead_list; ListBase bhead_list;
enum eFileDataFlag flags; enum eFileDataFlag flags;
@ -67,11 +69,11 @@ typedef struct FileData {
char relabase[FILE_MAX]; char relabase[FILE_MAX];
/** General reading variables. */ /** General reading variables. */
struct SDNA *filesdna; SDNA *filesdna;
const struct SDNA *memsdna; const SDNA *memsdna;
/** Array of #eSDNA_StructCompare. */ /** Array of #eSDNA_StructCompare. */
const char *compflags; const char *compflags;
struct DNA_ReconstructInfo *reconstruct_info; DNA_ReconstructInfo *reconstruct_info;
int fileversion; int fileversion;
/** Used to retrieve ID names from (bhead+1). */ /** Used to retrieve ID names from (bhead+1). */
@ -93,24 +95,24 @@ typedef struct FileData {
*/ */
int id_tag_extra; int id_tag_extra;
struct OldNewMap *datamap; OldNewMap *datamap;
struct OldNewMap *globmap; OldNewMap *globmap;
/** /**
* Store mapping from old ID pointers (the values they have in the .blend file) to new ones, * Store mapping from old ID pointers (the values they have in the .blend file) to new ones,
* typically from value in `bhead->old` to address in memory where the ID was read. * typically from value in `bhead->old` to address in memory where the ID was read.
* Used during library-linking process (see #lib_link_all). * Used during library-linking process (see #lib_link_all).
*/ */
struct OldNewMap *libmap; OldNewMap *libmap;
struct OldNewMap *packedmap; OldNewMap *packedmap;
struct BLOCacheStorage *cache_storage; BLOCacheStorage *cache_storage;
struct BHeadSort *bheadmap; BHeadSort *bheadmap;
int tot_bheadmap; int tot_bheadmap;
/** See: #USE_GHASH_BHEAD. */ /** See: #USE_GHASH_BHEAD. */
struct GHash *bhead_idname_hash; GHash *bhead_idname_hash;
ListBase *mainlist; ListBase *mainlist;
/** Used for undo. */ /** Used for undo. */
@ -118,7 +120,7 @@ typedef struct FileData {
/** /**
* IDMap using UUID's as keys of all the old IDs in the old bmain. Used during undo to find a * IDMap using UUID's as keys of all the old IDs in the old bmain. Used during undo to find a
* matching old data when reading a new ID. */ * matching old data when reading a new ID. */
struct IDNameLib_Map *old_idmap_uuid; IDNameLib_Map *old_idmap_uuid;
/** /**
* IDMap using uuids as keys of the IDs read (or moved) in the new main(s). * IDMap using uuids as keys of the IDs read (or moved) in the new main(s).
* *
@ -128,49 +130,46 @@ typedef struct FileData {
* *
* Also used to find current valid pointers (or none) of these 'no undo' IDs existing in * Also used to find current valid pointers (or none) of these 'no undo' IDs existing in
* read memfile. */ * read memfile. */
struct IDNameLib_Map *new_idmap_uuid; IDNameLib_Map *new_idmap_uuid;
struct BlendFileReadReport *reports; BlendFileReadReport *reports;
} FileData; };
#define SIZEOFBLENDERHEADER 12 #define SIZEOFBLENDERHEADER 12
/***/ /***/
struct Main;
void blo_join_main(ListBase *mainlist); void blo_join_main(ListBase *mainlist);
void blo_split_main(ListBase *mainlist, struct Main *main); void blo_split_main(ListBase *mainlist, Main *main);
struct BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath); BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath);
/** /**
* On each new library added, it now checks for the current #FileData and expands relativeness * On each new library added, it now checks for the current #FileData and expands relativeness
* *
* cannot be called with relative paths anymore! * cannot be called with relative paths anymore!
*/ */
FileData *blo_filedata_from_file(const char *filepath, struct BlendFileReadReport *reports); FileData *blo_filedata_from_file(const char *filepath, BlendFileReadReport *reports);
FileData *blo_filedata_from_memory(const void *mem, FileData *blo_filedata_from_memory(const void *mem, int memsize, BlendFileReadReport *reports);
int memsize, FileData *blo_filedata_from_memfile(MemFile *memfile,
struct BlendFileReadReport *reports); const BlendFileReadParams *params,
FileData *blo_filedata_from_memfile(struct MemFile *memfile, BlendFileReadReport *reports);
const struct BlendFileReadParams *params,
struct BlendFileReadReport *reports);
void blo_make_packed_pointer_map(FileData *fd, struct Main *oldmain); void blo_make_packed_pointer_map(FileData *fd, Main *oldmain);
/** /**
* Set old main packed data to zero if it has been restored * Set old main packed data to zero if it has been restored
* this works because freeing old main only happens after this call. * this works because freeing old main only happens after this call.
*/ */
void blo_end_packed_pointer_map(FileData *fd, struct Main *oldmain); void blo_end_packed_pointer_map(FileData *fd, Main *oldmain);
/** /**
* Build a #GSet of old main (we only care about local data here, * Build a #GSet of old main (we only care about local data here,
* so we can do that after #blo_split_main() call. * so we can do that after #blo_split_main() call.
*/ */
void blo_make_old_idmap_from_main(FileData *fd, struct Main *bmain); void blo_make_old_idmap_from_main(FileData *fd, Main *bmain);
BHead *blo_read_asset_data_block(FileData *fd, BHead *bhead, struct AssetMetaData **r_asset_data); BHead *blo_read_asset_data_block(FileData *fd, BHead *bhead, AssetMetaData **r_asset_data);
void blo_cache_storage_init(FileData *fd, struct Main *bmain); void blo_cache_storage_init(FileData *fd, Main *bmain);
void blo_cache_storage_old_bmain_clear(FileData *fd, struct Main *bmain_old); void blo_cache_storage_old_bmain_clear(FileData *fd, Main *bmain_old);
void blo_cache_storage_end(FileData *fd); void blo_cache_storage_end(FileData *fd);
void blo_filedata_free(FileData *fd); void blo_filedata_free(FileData *fd);
@ -186,7 +185,7 @@ const char *blo_bhead_id_name(const FileData *fd, const BHead *bhead);
/** /**
* Warning! Caller's responsibility to ensure given bhead **is** an ID one! * Warning! Caller's responsibility to ensure given bhead **is** an ID one!
*/ */
struct AssetMetaData *blo_bhead_id_asset_data_address(const FileData *fd, const BHead *bhead); AssetMetaData *blo_bhead_id_asset_data_address(const FileData *fd, const BHead *bhead);
/* do versions stuff */ /* do versions stuff */
@ -199,16 +198,13 @@ struct AssetMetaData *blo_bhead_id_asset_data_address(const FileData *fd, const
* *
* \attention ONLY USE THIS KIND OF VERSIONING WHEN `dna_rename_defs.h` ISN'T SUFFICIENT. * \attention ONLY USE THIS KIND OF VERSIONING WHEN `dna_rename_defs.h` ISN'T SUFFICIENT.
*/ */
void blo_do_versions_dna(struct SDNA *sdna, int versionfile, int subversionfile); void blo_do_versions_dna(SDNA *sdna, int versionfile, int subversionfile);
void blo_do_versions_oldnewmap_insert(struct OldNewMap *onm, void blo_do_versions_oldnewmap_insert(OldNewMap *onm, const void *oldaddr, void *newaddr, int nr);
const void *oldaddr,
void *newaddr,
int nr);
/** /**
* Only library data. * Only library data.
*/ */
void *blo_do_versions_newlibadr(struct FileData *fd, void *blo_do_versions_newlibadr(FileData *fd,
ID *self_id, ID *self_id,
const bool is_linked_only, const bool is_linked_only,
const void *adr); const void *adr);
@ -217,34 +213,34 @@ void *blo_do_versions_newlibadr(struct FileData *fd,
* \note this version patch is intended for versions < 2.52.2, * \note this version patch is intended for versions < 2.52.2,
* but was initially introduced in 2.27 already. * but was initially introduced in 2.27 already.
*/ */
void blo_do_version_old_trackto_to_constraints(struct Object *ob); void blo_do_version_old_trackto_to_constraints(Object *ob);
void blo_do_versions_key_uidgen(struct Key *key); void blo_do_versions_key_uidgen(Key *key);
/** /**
* Patching #UserDef struct and Themes. * Patching #UserDef struct and Themes.
*/ */
void blo_do_versions_userdef(struct UserDef *userdef); void blo_do_versions_userdef(UserDef *userdef);
void blo_do_versions_pre250(struct FileData *fd, struct Library *lib, struct Main *bmain); void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain);
void blo_do_versions_250(struct FileData *fd, struct Library *lib, struct Main *bmain); void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain);
void blo_do_versions_260(struct FileData *fd, struct Library *lib, struct Main *bmain); void blo_do_versions_260(FileData *fd, Library *lib, Main *bmain);
void blo_do_versions_270(struct FileData *fd, struct Library *lib, struct Main *bmain); void blo_do_versions_270(FileData *fd, Library *lib, Main *bmain);
void blo_do_versions_280(struct FileData *fd, struct Library *lib, struct Main *bmain); void blo_do_versions_280(FileData *fd, Library *lib, Main *bmain);
void blo_do_versions_290(struct FileData *fd, struct Library *lib, struct Main *bmain); void blo_do_versions_290(FileData *fd, Library *lib, Main *bmain);
void blo_do_versions_300(struct FileData *fd, struct Library *lib, struct Main *bmain); void blo_do_versions_300(FileData *fd, Library *lib, Main *bmain);
void blo_do_versions_400(struct FileData *fd, struct Library *lib, struct Main *bmain); void blo_do_versions_400(FileData *fd, Library *lib, Main *bmain);
void blo_do_versions_cycles(struct FileData *fd, struct Library *lib, struct Main *bmain); void blo_do_versions_cycles(FileData *fd, Library *lib, Main *bmain);
void do_versions_after_linking_250(struct Main *bmain); void do_versions_after_linking_250(Main *bmain);
void do_versions_after_linking_260(struct Main *bmain); void do_versions_after_linking_260(Main *bmain);
void do_versions_after_linking_270(struct Main *bmain); void do_versions_after_linking_270(Main *bmain);
void do_versions_after_linking_280(struct FileData *fd, struct Main *bmain); void do_versions_after_linking_280(FileData *fd, Main *bmain);
void do_versions_after_linking_290(struct FileData *fd, struct Main *bmain); void do_versions_after_linking_290(FileData *fd, Main *bmain);
void do_versions_after_linking_300(struct FileData *fd, struct Main *bmain); void do_versions_after_linking_300(FileData *fd, Main *bmain);
void do_versions_after_linking_400(struct FileData *fd, struct Main *bmain); void do_versions_after_linking_400(FileData *fd, Main *bmain);
void do_versions_after_linking_cycles(struct Main *bmain); void do_versions_after_linking_cycles(Main *bmain);
void do_versions_after_setup(struct Main *new_bmain, struct BlendFileReadReport *reports); void do_versions_after_setup(Main *new_bmain, BlendFileReadReport *reports);
/** /**
* Direct data-blocks with global linking. * Direct data-blocks with global linking.
@ -252,12 +248,8 @@ void do_versions_after_setup(struct Main *new_bmain, struct BlendFileReadReport
* \note This is rather unfortunate to have to expose this here, * \note This is rather unfortunate to have to expose this here,
* but better use that nasty hack in do_version than readfile itself. * but better use that nasty hack in do_version than readfile itself.
*/ */
void *blo_read_get_new_globaldata_address(struct FileData *fd, const void *adr); void *blo_read_get_new_globaldata_address(FileData *fd, const void *adr);
/* Mark the Main data as invalid (.blend file reading should be aborted ASAP, and the already read /* Mark the Main data as invalid (.blend file reading should be aborted ASAP, and the already read
* data should be discarded). Also add an error report to `fd` including given `message`. */ * data should be discarded). Also add an error report to `fd` including given `message`. */
void blo_readfile_invalidate(struct FileData *fd, struct Main *bmain, const char *message); void blo_readfile_invalidate(FileData *fd, Main *bmain, const char *message);
#ifdef __cplusplus
}
#endif

View File

@ -28,7 +28,7 @@
#include "BLI_ghash.h" #include "BLI_ghash.h"
#include "BLO_readfile.h" #include "BLO_readfile.h"
#include "BLO_undofile.h" #include "BLO_undofile.hh"
#include "BKE_lib_id.h" #include "BKE_lib_id.h"
#include "BKE_main.h" #include "BKE_main.h"

View File

@ -73,9 +73,9 @@
#include "BLO_readfile.h" #include "BLO_readfile.h"
#include "readfile.h" #include "readfile.hh"
#include "versioning_common.h" #include "versioning_common.hh"
#include <cerrno> #include <cerrno>

View File

@ -76,7 +76,7 @@
#include "BLO_readfile.h" #include "BLO_readfile.h"
#include "readfile.h" #include "readfile.hh"
/** Without empty statements, clang-format fails (tested with v12 & v15). */ /** Without empty statements, clang-format fails (tested with v12 & v15). */
#define CLANG_FORMAT_NOP_WORKAROUND ((void)0) #define CLANG_FORMAT_NOP_WORKAROUND ((void)0)

View File

@ -72,7 +72,7 @@
#include "NOD_composite.h" #include "NOD_composite.h"
#include "NOD_socket.hh" #include "NOD_socket.hh"
#include "readfile.h" #include "readfile.hh"
#include "MEM_guardedalloc.h" #include "MEM_guardedalloc.h"

View File

@ -101,11 +101,11 @@
#include "BLT_translation.h" #include "BLT_translation.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#include "BLO_readfile.h" #include "BLO_readfile.h"
#include "readfile.h" #include "readfile.hh"
#include "versioning_common.h" #include "versioning_common.hh"
#include "MEM_guardedalloc.h" #include "MEM_guardedalloc.h"

View File

@ -68,8 +68,8 @@
#include "SEQ_transform.h" #include "SEQ_transform.h"
#include "BLO_readfile.h" #include "BLO_readfile.h"
#include "readfile.h" #include "readfile.hh"
#include "versioning_common.h" #include "versioning_common.hh"
/* Make preferences read-only, use `versioning_userdef.cc`. */ /* Make preferences read-only, use `versioning_userdef.cc`. */
#define U (*((const UserDef *)&U)) #define U (*((const UserDef *)&U))

View File

@ -80,7 +80,7 @@
#include "BLO_readfile.h" #include "BLO_readfile.h"
#include "readfile.h" #include "readfile.hh"
#include "SEQ_channels.h" #include "SEQ_channels.h"
#include "SEQ_effects.h" #include "SEQ_effects.h"
@ -89,7 +89,7 @@
#include "SEQ_sequencer.h" #include "SEQ_sequencer.h"
#include "SEQ_time.h" #include "SEQ_time.h"
#include "versioning_common.h" #include "versioning_common.hh"
static CLG_LogRef LOG = {"blo.readfile.doversion"}; static CLG_LogRef LOG = {"blo.readfile.doversion"};

View File

@ -43,12 +43,12 @@
#include "BLT_translation.h" #include "BLT_translation.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#include "BLO_readfile.h" #include "BLO_readfile.h"
#include "readfile.h" #include "readfile.hh"
#include "versioning_common.h" #include "versioning_common.hh"
// static CLG_LogRef LOG = {"blo.readfile.doversion"}; // static CLG_LogRef LOG = {"blo.readfile.doversion"};

View File

@ -33,8 +33,8 @@
#include "MEM_guardedalloc.h" #include "MEM_guardedalloc.h"
#include "BLO_readfile.h" #include "BLO_readfile.h"
#include "readfile.h" #include "readfile.hh"
#include "versioning_common.h" #include "versioning_common.hh"
using blender::Map; using blender::Map;
using blender::StringRef; using blender::StringRef;
@ -185,17 +185,18 @@ void version_node_output_socket_name(bNodeTree *ntree,
bNodeSocket *version_node_add_socket_if_not_exist(bNodeTree *ntree, bNodeSocket *version_node_add_socket_if_not_exist(bNodeTree *ntree,
bNode *node, bNode *node,
eNodeSocketInOut in_out, int in_out,
int type, int type,
int subtype, int subtype,
const char *identifier, const char *identifier,
const char *name) const char *name)
{ {
bNodeSocket *sock = nodeFindSocket(node, in_out, identifier); bNodeSocket *sock = nodeFindSocket(node, eNodeSocketInOut(in_out), identifier);
if (sock != nullptr) { if (sock != nullptr) {
return sock; return sock;
} }
return nodeAddStaticSocket(ntree, node, in_out, type, subtype, identifier, name); return nodeAddStaticSocket(
ntree, node, eNodeSocketInOut(in_out), type, subtype, identifier, name);
} }
void version_node_id(bNodeTree *ntree, const int node_type, const char *new_name) void version_node_id(bNodeTree *ntree, const int node_type, const char *new_name)

View File

@ -8,13 +8,11 @@
#pragma once #pragma once
#ifdef __cplusplus #include "BLI_function_ref.hh"
# include "BLI_function_ref.hh" #include "BLI_map.hh"
# include "BLI_map.hh"
using blender::FunctionRef;
#endif
struct ARegion; struct ARegion;
struct bNode;
struct bNodeSocket; struct bNodeSocket;
struct bNodeTree; struct bNodeTree;
struct ID; struct ID;
@ -23,19 +21,17 @@ struct ListBase;
struct Main; struct Main;
struct ViewLayer; struct ViewLayer;
#ifdef __cplusplus using blender::FunctionRef;
extern "C" {
#endif
/** /**
* Check if a region of type \a region_type exists in \a regionbase. Otherwise add it after the * Check if a region of type \a region_type exists in \a regionbase. Otherwise add it after the
* first region of type \a link_after_region_type. * first region of type \a link_after_region_type.
* \returns null if a region of the given type already existed, otherwise the newly added region. * \returns null if a region of the given type already existed, otherwise the newly added region.
*/ */
struct ARegion *do_versions_add_region_if_not_found(struct ListBase *regionbase, ARegion *do_versions_add_region_if_not_found(ListBase *regionbase,
int region_type, int region_type,
const char *allocname, const char *allocname,
int link_after_region_type); int link_after_region_type);
/** /**
* Check if a region of type \a region_type exists in \a regionbase. Otherwise add it after the * Check if a region of type \a region_type exists in \a regionbase. Otherwise add it after the
* first region of type \a link_after_region_type. * first region of type \a link_after_region_type.
@ -53,17 +49,17 @@ ARegion *do_versions_ensure_region(ListBase *regionbase,
*/ */
ID *do_versions_rename_id(Main *bmain, short id_type, const char *name_src, const char *name_dst); ID *do_versions_rename_id(Main *bmain, short id_type, const char *name_src, const char *name_dst);
bool version_node_socket_is_used(struct bNodeSocket *sock); bool version_node_socket_is_used(bNodeSocket *sock);
void version_node_socket_name(struct bNodeTree *ntree, void version_node_socket_name(bNodeTree *ntree,
int node_type, int node_type,
const char *old_name, const char *old_name,
const char *new_name); const char *new_name);
void version_node_input_socket_name(struct bNodeTree *ntree, void version_node_input_socket_name(bNodeTree *ntree,
int node_type, int node_type,
const char *old_name, const char *old_name,
const char *new_name); const char *new_name);
void version_node_output_socket_name(struct bNodeTree *ntree, void version_node_output_socket_name(bNodeTree *ntree,
int node_type, int node_type,
const char *old_name, const char *old_name,
const char *new_name); const char *new_name);
@ -96,20 +92,20 @@ void version_node_socket_index_animdata(
/** /**
* Replace the ID name of all nodes in the tree with the given type with the new name. * Replace the ID name of all nodes in the tree with the given type with the new name.
*/ */
void version_node_id(struct bNodeTree *ntree, int node_type, const char *new_name); void version_node_id(bNodeTree *ntree, int node_type, const char *new_name);
/** /**
* Convert `SocketName.001` unique name format to `SocketName_001`. Previously both were used. * Convert `SocketName.001` unique name format to `SocketName_001`. Previously both were used.
*/ */
void version_node_socket_id_delim(bNodeSocket *socket); void version_node_socket_id_delim(bNodeSocket *socket);
struct bNodeSocket *version_node_add_socket_if_not_exist(struct bNodeTree *ntree, bNodeSocket *version_node_add_socket_if_not_exist(bNodeTree *ntree,
struct bNode *node, bNode *node,
eNodeSocketInOut in_out, int in_out,
int type, int type,
int subtype, int subtype,
const char *identifier, const char *identifier,
const char *name); const char *name);
/** /**
* The versioning code generally expects `SOCK_IS_LINKED` to be set correctly. This function * The versioning code generally expects `SOCK_IS_LINKED` to be set correctly. This function
@ -124,29 +120,20 @@ void add_realize_instances_before_socket(bNodeTree *ntree,
bNode *node, bNode *node,
bNodeSocket *geometry_socket); bNodeSocket *geometry_socket);
float *version_cycles_node_socket_float_value(struct bNodeSocket *socket); float *version_cycles_node_socket_float_value(bNodeSocket *socket);
float *version_cycles_node_socket_rgba_value(struct bNodeSocket *socket); float *version_cycles_node_socket_rgba_value(bNodeSocket *socket);
float *version_cycles_node_socket_vector_value(struct bNodeSocket *socket); float *version_cycles_node_socket_vector_value(bNodeSocket *socket);
struct IDProperty *version_cycles_properties_from_ID(struct ID *id); IDProperty *version_cycles_properties_from_ID(ID *id);
struct IDProperty *version_cycles_properties_from_view_layer(struct ViewLayer *view_layer); IDProperty *version_cycles_properties_from_view_layer(ViewLayer *view_layer);
struct IDProperty *version_cycles_visibility_properties_from_ID(ID *id); IDProperty *version_cycles_visibility_properties_from_ID(ID *id);
float version_cycles_property_float(struct IDProperty *idprop, float version_cycles_property_float(IDProperty *idprop, const char *name, float default_value);
const char *name, int version_cycles_property_int(IDProperty *idprop, const char *name, int default_value);
float default_value); void version_cycles_property_int_set(IDProperty *idprop, const char *name, int value);
int version_cycles_property_int(struct IDProperty *idprop, const char *name, int default_value); bool version_cycles_property_boolean(IDProperty *idprop, const char *name, bool default_value);
void version_cycles_property_int_set(struct IDProperty *idprop, const char *name, int value); void version_cycles_property_boolean_set(IDProperty *idprop, const char *name, bool value);
bool version_cycles_property_boolean(struct IDProperty *idprop,
const char *name,
bool default_value);
void version_cycles_property_boolean_set(struct IDProperty *idprop, const char *name, bool value);
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
void node_tree_relink_with_socket_id_map(bNodeTree &ntree, void node_tree_relink_with_socket_id_map(bNodeTree &ntree,
bNode &old_node, bNode &old_node,
bNode &new_node, bNode &new_node,
@ -157,4 +144,3 @@ void version_update_node_input(
const char *socket_identifier, const char *socket_identifier,
FunctionRef<void(bNode *, bNodeSocket *)> update_input, FunctionRef<void(bNode *, bNodeSocket *)> update_input,
FunctionRef<void(bNode *, bNodeSocket *, bNode *, bNodeSocket *)> update_input_link); FunctionRef<void(bNode *, bNodeSocket *, bNode *, bNodeSocket *)> update_input_link);
#endif

View File

@ -65,7 +65,7 @@
#include "BLT_translation.h" #include "BLT_translation.h"
#include "versioning_common.h" #include "versioning_common.hh"
/* Make preferences read-only, use `versioning_userdef.cc`. */ /* Make preferences read-only, use `versioning_userdef.cc`. */
#define U (*((const UserDef *)&U)) #define U (*((const UserDef *)&U))

View File

@ -15,7 +15,7 @@
#include "DNA_listBase.h" #include "DNA_listBase.h"
#include "BLO_readfile.h" #include "BLO_readfile.h"
#include "readfile.h" #include "readfile.hh"
void blo_do_versions_dna(SDNA *sdna, const int versionfile, const int subversionfile) void blo_do_versions_dna(SDNA *sdna, const int versionfile, const int subversionfile)
{ {

View File

@ -72,7 +72,7 @@
#include "BLO_readfile.h" #include "BLO_readfile.h"
#include "readfile.h" #include "readfile.hh"
#include "PIL_time.h" #include "PIL_time.h"

View File

@ -42,7 +42,7 @@
#include "MEM_guardedalloc.h" #include "MEM_guardedalloc.h"
#include "readfile.h" /* Own include. */ #include "readfile.hh" /* Own include. */
#include "WM_types.hh" #include "WM_types.hh"
#include "wm_event_types.hh" #include "wm_event_types.hh"

View File

@ -21,7 +21,7 @@
* *
* data-blocks: (also see struct #BHead). * data-blocks: (also see struct #BHead).
* <pre> * <pre>
* `bh.code` `char[4]` see `BLO_blend_defs.h` for a list of known types. * `bh.code` `char[4]` see `BLO_blend_defs.hh` for a list of known types.
* `bh.len` `int32` length data after #BHead in bytes. * `bh.len` `int32` length data after #BHead in bytes.
* `bh.old` `void *` old pointer (the address at the time of writing the file). * `bh.old` `void *` old pointer (the address at the time of writing the file).
* `bh.SDNAnr` `int32` struct index of structs stored in #DNA1 data. * `bh.SDNAnr` `int32` struct index of structs stored in #DNA1 data.
@ -112,14 +112,14 @@
#include "BKE_report.h" #include "BKE_report.h"
#include "BKE_workspace.h" #include "BKE_workspace.h"
#include "BLO_blend_defs.h" #include "BLO_blend_defs.hh"
#include "BLO_blend_validate.h" #include "BLO_blend_validate.hh"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#include "BLO_readfile.h" #include "BLO_readfile.h"
#include "BLO_undofile.h" #include "BLO_undofile.hh"
#include "BLO_writefile.h" #include "BLO_writefile.hh"
#include "readfile.h" #include "readfile.hh"
#include <zstd.h> #include <zstd.h>

View File

@ -34,7 +34,7 @@
#include "WM_api.hh" #include "WM_api.hh"
#include "WM_types.hh" #include "WM_types.hh"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#include "wm_window.hh" #include "wm_window.hh"

View File

@ -8,7 +8,7 @@
#include "BLI_listbase.h" #include "BLI_listbase.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#include "DNA_defs.h" #include "DNA_defs.h"
#include "DNA_screen_types.h" #include "DNA_screen_types.h"

View File

@ -14,7 +14,7 @@
#include "DNA_screen_types.h" #include "DNA_screen_types.h"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#include "BLI_listbase.h" #include "BLI_listbase.h"
#include "BLI_string.h" #include "BLI_string.h"

View File

@ -44,7 +44,7 @@
#include "ED_space_api.hh" #include "ED_space_api.hh"
#include "ED_time_scrub_ui.hh" #include "ED_time_scrub_ui.hh"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#include "GPU_matrix.h" #include "GPU_matrix.h"

View File

@ -39,7 +39,7 @@
#include "UI_interface.hh" #include "UI_interface.hh"
#include "UI_resources.hh" #include "UI_resources.hh"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#include "buttons_intern.h" /* own include */ #include "buttons_intern.h" /* own include */

View File

@ -50,7 +50,7 @@
#include "UI_resources.hh" #include "UI_resources.hh"
#include "UI_view2d.hh" #include "UI_view2d.hh"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#include "RNA_access.hh" #include "RNA_access.hh"

View File

@ -30,7 +30,7 @@
#include "UI_resources.hh" #include "UI_resources.hh"
#include "UI_view2d.hh" #include "UI_view2d.hh"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#include "console_intern.hh" /* own include */ #include "console_intern.hh" /* own include */

View File

@ -44,7 +44,7 @@
#include "UI_resources.hh" #include "UI_resources.hh"
#include "UI_view2d.hh" #include "UI_view2d.hh"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#include "GPU_framebuffer.h" #include "GPU_framebuffer.h"
#include "file_indexer.hh" #include "file_indexer.hh"

View File

@ -47,7 +47,7 @@
#include "UI_resources.hh" #include "UI_resources.hh"
#include "UI_view2d.hh" #include "UI_view2d.hh"
#include "BLO_read_write.h" #include "BLO_read_write.hh"
#include "graph_intern.h" /* own include */ #include "graph_intern.h" /* own include */

Some files were not shown because too many files have changed in this diff Show More