diff options
author | Jacques Lucke <jacques@blender.org> | 2020-08-21 13:45:33 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-08-21 13:45:41 +0300 |
commit | 933f0caec65fdbbfbee9ca5f4f2a0b207b619a05 (patch) | |
tree | e3f745c69ec8285a9f9fb2a38b498a4a091549d0 /source/blender/blenloader/intern/writefile.c | |
parent | 27f0a19bdc09c785d4ef5f7ac2bcd97018bed489 (diff) |
Blenloader: move IDProperty read/write code to blenkernel
This is part of T76372.
Diffstat (limited to 'source/blender/blenloader/intern/writefile.c')
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 112 |
1 files changed, 19 insertions, 93 deletions
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index ed4f997a856..74829c3ae32 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -164,6 +164,7 @@ #include "BKE_fcurve_driver.h" #include "BKE_global.h" // for G #include "BKE_gpencil_modifier.h" +#include "BKE_idprop.h" #include "BKE_idtype.h" #include "BKE_layer.h" #include "BKE_lib_id.h" @@ -656,86 +657,11 @@ static void writelist_id(WriteData *wd, int filecode, const char *structname, co * These functions are used by blender's .blend system for file saving/loading. * \{ */ -void IDP_WriteProperty_OnlyData(const IDProperty *prop, BlendWriter *writer); -void IDP_WriteProperty(const IDProperty *prop, BlendWriter *writer); - -static void IDP_WriteArray(const IDProperty *prop, BlendWriter *writer) -{ - /*REMEMBER to set totalen to len in the linking code!!*/ - if (prop->data.pointer) { - BLO_write_raw(writer, MEM_allocN_len(prop->data.pointer), prop->data.pointer); - - if (prop->subtype == IDP_GROUP) { - IDProperty **array = prop->data.pointer; - int a; - - for (a = 0; a < prop->len; a++) { - IDP_WriteProperty(array[a], writer); - } - } - } -} - -static void IDP_WriteIDPArray(const IDProperty *prop, BlendWriter *writer) -{ - /*REMEMBER to set totalen to len in the linking code!!*/ - if (prop->data.pointer) { - const IDProperty *array = prop->data.pointer; - int a; - - BLO_write_struct_array(writer, IDProperty, prop->len, array); - - for (a = 0; a < prop->len; a++) { - IDP_WriteProperty_OnlyData(&array[a], writer); - } - } -} - -static void IDP_WriteString(const IDProperty *prop, BlendWriter *writer) -{ - /*REMEMBER to set totalen to len in the linking code!!*/ - BLO_write_raw(writer, prop->len, prop->data.pointer); -} - -static void IDP_WriteGroup(const IDProperty *prop, BlendWriter *writer) -{ - IDProperty *loop; - - for (loop = prop->data.group.first; loop; loop = loop->next) { - IDP_WriteProperty(loop, writer); - } -} - -/* Functions to read/write ID Properties */ -void IDP_WriteProperty_OnlyData(const IDProperty *prop, BlendWriter *writer) -{ - switch (prop->type) { - case IDP_GROUP: - IDP_WriteGroup(prop, writer); - break; - case IDP_STRING: - IDP_WriteString(prop, writer); - break; - case IDP_ARRAY: - IDP_WriteArray(prop, writer); - break; - case IDP_IDPARRAY: - IDP_WriteIDPArray(prop, writer); - break; - } -} - -void IDP_WriteProperty(const IDProperty *prop, BlendWriter *writer) -{ - BLO_write_struct(writer, IDProperty, prop); - IDP_WriteProperty_OnlyData(prop, writer); -} - static void write_iddata(BlendWriter *writer, ID *id) { /* ID_WM's id->properties are considered runtime only, and never written in .blend file. */ if (id->properties && !ELEM(GS(id->name), ID_WM)) { - IDP_WriteProperty(id->properties, writer); + IDP_BlendWrite(writer, id->properties); } if (id->override_library) { @@ -825,7 +751,7 @@ static void write_fmodifiers(BlendWriter *writer, ListBase *fmodifiers) /* Write ID Properties -- and copy this comment EXACTLY for easy finding * of library blocks that implement this.*/ - IDP_WriteProperty(data->prop, writer); + IDP_BlendWrite(writer, data->prop); break; } @@ -1017,7 +943,7 @@ static void write_node_socket(BlendWriter *writer, bNodeSocket *sock) BLO_write_struct(writer, bNodeSocket, sock); if (sock->prop) { - IDP_WriteProperty(sock->prop, writer); + IDP_BlendWrite(writer, sock->prop); } write_node_socket_default_value(writer, sock); @@ -1028,7 +954,7 @@ static void write_node_socket_interface(BlendWriter *writer, bNodeSocket *sock) BLO_write_struct(writer, bNodeSocket, sock); if (sock->prop) { - IDP_WriteProperty(sock->prop, writer); + IDP_BlendWrite(writer, sock->prop); } write_node_socket_default_value(writer, sock); @@ -1050,7 +976,7 @@ static void write_nodetree_nolib(BlendWriter *writer, bNodeTree *ntree) BLO_write_struct(writer, bNode, node); if (node->prop) { - IDP_WriteProperty(node->prop, writer); + IDP_BlendWrite(writer, node->prop); } for (sock = node->inputs.first; sock; sock = sock->next) { @@ -1229,7 +1155,7 @@ static void write_keymapitem(BlendWriter *writer, const wmKeyMapItem *kmi) { BLO_write_struct(writer, wmKeyMapItem, kmi); if (kmi->properties) { - IDP_WriteProperty(kmi->properties, writer); + IDP_BlendWrite(writer, kmi->properties); } } @@ -1262,7 +1188,7 @@ static void write_userdef(BlendWriter *writer, const UserDef *userdef) LISTBASE_FOREACH (const wmKeyConfigPref *, kpt, &userdef->user_keyconfig_prefs) { BLO_write_struct(writer, wmKeyConfigPref, kpt); if (kpt->prop) { - IDP_WriteProperty(kpt->prop, writer); + IDP_BlendWrite(writer, kpt->prop); } } @@ -1273,7 +1199,7 @@ static void write_userdef(BlendWriter *writer, const UserDef *userdef) const bUserMenuItem_Op *umi_op = (const bUserMenuItem_Op *)umi; BLO_write_struct(writer, bUserMenuItem_Op, umi_op); if (umi_op->prop) { - IDP_WriteProperty(umi_op->prop, writer); + IDP_BlendWrite(writer, umi_op->prop); } } else if (umi->type == USER_MENU_TYPE_MENU) { @@ -1293,7 +1219,7 @@ static void write_userdef(BlendWriter *writer, const UserDef *userdef) LISTBASE_FOREACH (const bAddon *, bext, &userdef->addons) { BLO_write_struct(writer, bAddon, bext); if (bext->prop) { - IDP_WriteProperty(bext->prop, writer); + IDP_BlendWrite(writer, bext->prop); } } @@ -1550,7 +1476,7 @@ static void write_constraints(BlendWriter *writer, ListBase *conlist) /* Write ID Properties -- and copy this comment EXACTLY for easy finding * of library blocks that implement this.*/ - IDP_WriteProperty(data->prop, writer); + IDP_BlendWrite(writer, data->prop); break; } @@ -1598,7 +1524,7 @@ static void write_pose(BlendWriter *writer, bPose *pose, bArmature *arm) /* Write ID Properties -- and copy this comment EXACTLY for easy finding * of library blocks that implement this.*/ if (chan->prop) { - IDP_WriteProperty(chan->prop, writer); + IDP_BlendWrite(writer, chan->prop); } write_constraints(writer, &chan->constraints); @@ -2453,7 +2379,7 @@ static void write_view_settings(BlendWriter *writer, ColorManagedViewSettings *v static void write_view3dshading(BlendWriter *writer, View3DShading *shading) { if (shading->prop) { - IDP_WriteProperty(shading->prop, writer); + IDP_BlendWrite(writer, shading->prop); } } @@ -2480,7 +2406,7 @@ static void write_view_layer(BlendWriter *writer, ViewLayer *view_layer) BLO_write_struct_list(writer, Base, &view_layer->object_bases); if (view_layer->id_properties) { - IDP_WriteProperty(view_layer->id_properties, writer); + IDP_BlendWrite(writer, view_layer->id_properties); } LISTBASE_FOREACH (FreestyleModuleConfig *, fmc, &view_layer->freestyle_config.modules) { @@ -2675,7 +2601,7 @@ static void write_scene(BlendWriter *writer, Scene *sce, const void *id_address) } if (seq->prop) { - IDP_WriteProperty(seq->prop, writer); + IDP_BlendWrite(writer, seq->prop); } write_sequence_modifiers(writer, &seq->modifiers); @@ -2698,7 +2624,7 @@ static void write_scene(BlendWriter *writer, Scene *sce, const void *id_address) } } if (sce->r.ffcodecdata.properties) { - IDP_WriteProperty(sce->r.ffcodecdata.properties, writer); + IDP_BlendWrite(writer, sce->r.ffcodecdata.properties); } /* writing dynamic list of TimeMarkers to the blend file */ @@ -2842,7 +2768,7 @@ static void write_uilist(BlendWriter *writer, uiList *ui_list) BLO_write_struct(writer, uiList, ui_list); if (ui_list->properties) { - IDP_WriteProperty(ui_list->properties, writer); + IDP_BlendWrite(writer, ui_list->properties); } } @@ -3103,7 +3029,7 @@ static void write_bone(BlendWriter *writer, Bone *bone) /* Write ID Properties -- and copy this comment EXACTLY for easy finding * of library blocks that implement this.*/ if (bone->prop) { - IDP_WriteProperty(bone->prop, writer); + IDP_BlendWrite(writer, bone->prop); } /* Write Children */ @@ -3741,7 +3667,7 @@ static void write_workspace(BlendWriter *writer, WorkSpace *workspace, const voi BLO_write_struct_list(writer, bToolRef, &workspace->tools); LISTBASE_FOREACH (bToolRef *, tref, &workspace->tools) { if (tref->properties) { - IDP_WriteProperty(tref->properties, writer); + IDP_BlendWrite(writer, tref->properties); } } } |