Cleanup: Combine BKE_idprop C and C++ headers

In preparation for moving the whole BKE_idprop.h to C++.
To keep the git history intact we remove the newer smaller file.
This commit is contained in:
Hans Goudey
2024-03-26 12:51:05 -04:00
parent 881178895b
commit f41ab9abc1
14 changed files with 97 additions and 99 deletions

View File

@@ -8,7 +8,11 @@
* \ingroup bke
*/
#include <memory>
#include "BLI_compiler_attrs.h"
#include "BLI_span.hh"
#include "BLI_string_ref.hh"
#include "BLI_sys_types.h"
#ifdef __cplusplus
@@ -21,6 +25,10 @@ struct ID;
struct IDProperty;
struct IDPropertyUIData;
struct IDPropertyUIDataEnumItem;
namespace blender::io::serialize {
class ArrayValue;
class Value;
} // namespace blender::io::serialize
typedef union IDPropertyTemplate {
int i;
@@ -376,3 +384,80 @@ struct IDPropertyUIData *IDP_TryConvertUIData(struct IDPropertyUIData *src,
#ifdef __cplusplus
}
#endif
namespace blender::bke::idprop {
/**
* \brief Convert the given `properties` to `Value` objects for serialization.
*
* `IDP_ID` and `IDP_IDPARRAY` are not supported and will be ignored.
*
* UI data such as max/min will not be serialized.
*/
std::unique_ptr<blender::io::serialize::ArrayValue> convert_to_serialize_values(
const IDProperty *properties);
/**
* \brief Convert the given `value` to an `IDProperty`.
*/
IDProperty *convert_from_serialize_value(const blender::io::serialize::Value &value);
class IDPropertyDeleter {
public:
void operator()(IDProperty *id_prop)
{
IDP_FreeProperty(id_prop);
}
};
/** \brief Allocate a new IDProperty of type IDP_BOOLEAN, set its name and value. */
std::unique_ptr<IDProperty, IDPropertyDeleter> create_bool(StringRefNull prop_name, bool value);
/** \brief Allocate a new IDProperty of type IDP_INT, set its name and value. */
std::unique_ptr<IDProperty, IDPropertyDeleter> create(StringRefNull prop_name, int32_t value);
/** \brief Allocate a new IDProperty of type IDP_FLOAT, set its name and value. */
std::unique_ptr<IDProperty, IDPropertyDeleter> create(StringRefNull prop_name, float value);
/** \brief Allocate a new IDProperty of type IDP_DOUBLE, set its name and value. */
std::unique_ptr<IDProperty, IDPropertyDeleter> create(StringRefNull prop_name, double value);
/** \brief Allocate a new IDProperty of type IDP_STRING, set its name and value. */
std::unique_ptr<IDProperty, IDPropertyDeleter> create(StringRefNull prop_name,
const StringRefNull value);
/** \brief Allocate a new IDProperty of type IDP_ID, set its name and value. */
std::unique_ptr<IDProperty, IDPropertyDeleter> create(StringRefNull prop_name, ID *value);
/**
* \brief Allocate a new IDProperty of type IDP_ARRAY and sub-type IDP_INT.
*
* \param values: The values will be copied into the IDProperty.
*/
std::unique_ptr<IDProperty, IDPropertyDeleter> create(StringRefNull prop_name,
Span<int32_t> values);
/**
* \brief Allocate a new IDProperty of type IDP_ARRAY and sub-type IDP_FLOAT.
*
* \param values: The values will be copied into the IDProperty.
*/
std::unique_ptr<IDProperty, IDPropertyDeleter> create(StringRefNull prop_name, Span<float> values);
/**
* \brief Allocate a new IDProperty of type IDP_ARRAY and sub-type IDP_DOUBLE.
*
* \param values: The values will be copied into the IDProperty.
*/
std::unique_ptr<IDProperty, IDPropertyDeleter> create(StringRefNull prop_name,
Span<double> values);
/**
* \brief Allocate a new IDProperty of type IDP_GROUP.
*
* \param prop_name: The name of the newly created property.
*/
std::unique_ptr<IDProperty, IDPropertyDeleter> create_group(StringRefNull prop_name);
} // namespace blender::bke::idprop

View File

@@ -1,87 +0,0 @@
/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
#include "BKE_idprop.h"
#include "BLI_serialize.hh"
#include "BLI_span.hh"
namespace blender::bke::idprop {
/**
* \brief Convert the given `properties` to `Value` objects for serialization.
*
* `IDP_ID` and `IDP_IDPARRAY` are not supported and will be ignored.
*
* UI data such as max/min will not be serialized.
*/
std::unique_ptr<io::serialize::ArrayValue> convert_to_serialize_values(
const IDProperty *properties);
/**
* \brief Convert the given `value` to an `IDProperty`.
*/
IDProperty *convert_from_serialize_value(const blender::io::serialize::Value &value);
class IDPropertyDeleter {
public:
void operator()(IDProperty *id_prop)
{
IDP_FreeProperty(id_prop);
}
};
/** \brief Allocate a new IDProperty of type IDP_BOOLEAN, set its name and value. */
std::unique_ptr<IDProperty, IDPropertyDeleter> create_bool(StringRefNull prop_name, bool value);
/** \brief Allocate a new IDProperty of type IDP_INT, set its name and value. */
std::unique_ptr<IDProperty, IDPropertyDeleter> create(StringRefNull prop_name, int32_t value);
/** \brief Allocate a new IDProperty of type IDP_FLOAT, set its name and value. */
std::unique_ptr<IDProperty, IDPropertyDeleter> create(StringRefNull prop_name, float value);
/** \brief Allocate a new IDProperty of type IDP_DOUBLE, set its name and value. */
std::unique_ptr<IDProperty, IDPropertyDeleter> create(StringRefNull prop_name, double value);
/** \brief Allocate a new IDProperty of type IDP_STRING, set its name and value. */
std::unique_ptr<IDProperty, IDPropertyDeleter> create(StringRefNull prop_name,
const StringRefNull value);
/** \brief Allocate a new IDProperty of type IDP_ID, set its name and value. */
std::unique_ptr<IDProperty, IDPropertyDeleter> create(StringRefNull prop_name, ID *value);
/**
* \brief Allocate a new IDProperty of type IDP_ARRAY and sub-type IDP_INT.
*
* \param values: The values will be copied into the IDProperty.
*/
std::unique_ptr<IDProperty, IDPropertyDeleter> create(StringRefNull prop_name,
Span<int32_t> values);
/**
* \brief Allocate a new IDProperty of type IDP_ARRAY and sub-type IDP_FLOAT.
*
* \param values: The values will be copied into the IDProperty.
*/
std::unique_ptr<IDProperty, IDPropertyDeleter> create(StringRefNull prop_name, Span<float> values);
/**
* \brief Allocate a new IDProperty of type IDP_ARRAY and sub-type IDP_DOUBLE.
*
* \param values: The values will be copied into the IDProperty.
*/
std::unique_ptr<IDProperty, IDPropertyDeleter> create(StringRefNull prop_name,
Span<double> values);
/**
* \brief Allocate a new IDProperty of type IDP_GROUP.
*
* \param prop_name: The name of the newly created property.
*/
std::unique_ptr<IDProperty, IDPropertyDeleter> create_group(StringRefNull prop_name);
} // namespace blender::bke::idprop

View File

@@ -413,7 +413,6 @@ set(SRC
BKE_grease_pencil_vertex_groups.hh
BKE_icons.h
BKE_idprop.h
BKE_idprop.hh
BKE_idtype.hh
BKE_image.h
BKE_image_format.h

View File

@@ -19,7 +19,7 @@
#include "BKE_gpencil_modifier_legacy.h"
#include "BKE_grease_pencil.hh"
#include "BKE_grease_pencil_legacy_convert.hh"
#include "BKE_idprop.hh"
#include "BKE_idprop.h"
#include "BKE_lib_id.hh"
#include "BKE_lib_remap.hh"
#include "BKE_main.hh"

View File

@@ -6,7 +6,7 @@
#include "DNA_ID.h"
#include "BKE_idprop.hh"
#include "BKE_idprop.h"
namespace blender::bke::idprop {

View File

@@ -6,9 +6,10 @@
#include "DNA_ID.h"
#include "BKE_idprop.hh"
#include "BKE_idprop.h"
#include "BLI_listbase.h"
#include "BLI_serialize.hh"
namespace blender::bke::idprop {
using namespace blender::io::serialize;

View File

@@ -5,10 +5,11 @@
#include "testing/testing.h"
#include "BLI_listbase.h"
#include "BLI_serialize.hh"
#include "DNA_ID.h"
#include "BKE_idprop.hh"
#include "BKE_idprop.h"
namespace blender::bke::idprop::tests {

View File

@@ -33,7 +33,7 @@
#include "BKE_attribute.hh"
#include "BKE_customdata.hh"
#include "BKE_global.hh"
#include "BKE_idprop.hh"
#include "BKE_idprop.h"
#include "BKE_lib_id.hh"
#include "BKE_main.hh"
#include "BKE_main_namemap.hh"

View File

@@ -61,7 +61,6 @@
#include "BKE_cryptomatte.h"
#include "BKE_global.hh"
#include "BKE_idprop.h"
#include "BKE_idprop.hh"
#include "BKE_idtype.hh"
#include "BKE_image_format.h"
#include "BKE_lib_id.hh"

View File

@@ -53,7 +53,7 @@
#include "BKE_curve.hh"
#include "BKE_effect.h"
#include "BKE_grease_pencil.hh"
#include "BKE_idprop.hh"
#include "BKE_idprop.h"
#include "BKE_main.hh"
#include "BKE_material.h"
#include "BKE_mesh_legacy_convert.hh"

View File

@@ -30,7 +30,7 @@
#include "AS_asset_catalog.hh"
#include "BKE_appdir.hh"
#include "BKE_asset.hh"
#include "BKE_idprop.hh"
#include "BKE_idprop.h"
#include "CLG_log.h"

View File

@@ -48,7 +48,7 @@
#include "BKE_geometry_fields.hh"
#include "BKE_geometry_set_instances.hh"
#include "BKE_global.hh"
#include "BKE_idprop.hh"
#include "BKE_idprop.h"
#include "BKE_lib_id.hh"
#include "BKE_lib_query.hh"
#include "BKE_main.hh"

View File

@@ -9,7 +9,7 @@
#include "BLI_multi_value_map.hh"
#include "BLI_set.hh"
#include "BKE_idprop.hh"
#include "BKE_idprop.h"
#include "BKE_node.hh"
struct bNodeTree;

View File

@@ -20,7 +20,7 @@
#include "BKE_compute_contexts.hh"
#include "BKE_geometry_fields.hh"
#include "BKE_geometry_set.hh"
#include "BKE_idprop.hh"
#include "BKE_idprop.h"
#include "BKE_node_enum.hh"
#include "BKE_node_runtime.hh"
#include "BKE_node_socket_value.hh"