diff options
author | Sergey Sharybin <sergey@blender.org> | 2022-03-25 12:57:13 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey@blender.org> | 2022-03-25 12:57:13 +0300 |
commit | 484af996aa75750c8b419a25b68c9eb8d7efcf19 (patch) | |
tree | 4e82ec9dead85650ddfae3718a369ea8cd9d54c0 /source/blender/makesdna | |
parent | 8c44793228750537c08ea7b19fc18df0138f9501 (diff) |
Revert "Implement C++ methods for DNA structures"
This reverts commit 8c44793228750537c08ea7b19fc18df0138f9501.
Apparently, this generated a lot of warnings in GCC.
Didn't find a quick solution and is it not something I want to be
trading between (more quiet Clang in an expense of less quiet GCC).
Will re-iterate on the patch are re-commit it.
Diffstat (limited to 'source/blender/makesdna')
-rw-r--r-- | source/blender/makesdna/DNA_defs.h | 81 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_object_types.h | 2 | ||||
-rw-r--r-- | source/blender/makesdna/intern/dna_utils.c | 12 | ||||
-rw-r--r-- | source/blender/makesdna/intern/makesdna.c | 12 |
4 files changed, 0 insertions, 107 deletions
diff --git a/source/blender/makesdna/DNA_defs.h b/source/blender/makesdna/DNA_defs.h index 283eacf1a16..b4230209dd5 100644 --- a/source/blender/makesdna/DNA_defs.h +++ b/source/blender/makesdna/DNA_defs.h @@ -46,84 +46,3 @@ /* non-id name variables should use this length */ #define MAX_NAME 64 - -/* #DNA_DEFINE_CXX_METHODS is used to define C++ methods which are needed for proper/safe resource - * management, making unsafe (from an ownership perspective: i.e. pointers which sometimes needs to - * be set to nullptr on copy, sometimes needs to be dupalloc-ed) operations explicit, and taking - * care of compiler specific warnings when dealing with members marked with DNA_DEPRECATED. - * - * The `class_name` argument is to match the structure name the macro is used from. - * - * Typical usage example: - * - * typedef struct Object { - * DNA_DEFINE_CXX_METHODS(Object) - * } Object; - */ -#ifndef __cplusplus -# define DNA_DEFINE_CXX_METHODS(class_name) -#else - -/* Forward-declared here since there is no simple header file to be pulled for this functionality. - * Avoids pulling `string.h` from this header to get access to #memcpy. */ -extern "C" void _DNA_internal_memcpy(void *dst, const void *src, size_t size); - -namespace blender::dna::internal { - -template<class T> class ShallowDataConstRef { - public: - constexpr explicit ShallowDataConstRef(const T &ref) : ref_(ref) - { - } - - inline const T *get_pointer() const - { - return &ref_; - } - - private: - const T &ref_; -}; - -} // namespace blender::dna::internal - -# define DNA_DEFINE_CXX_METHODS(class_name) \ - class_name() = default; \ - ~class_name() = default; \ - /* Delete copy and assignment, which are not safe for resource ownership. */ \ - class_name(const class_name &other) = delete; \ - class_name(class_name &&other) noexcept = delete; \ - class_name &operator=(const class_name &other) = delete; \ - class_name &operator=(class_name &&other) = delete; \ - /* Support for shallow copy. */ \ - class_name(const blender::dna::internal::ShallowDataConstRef<class_name> ref) \ - { \ - _DNA_internal_memcpy(this, ref.get_pointer(), sizeof(class_name)); \ - } \ - class_name &operator=(const blender::dna::internal::ShallowDataConstRef<class_name> ref) \ - { \ - if (this != ref.get_pointer()) { \ - _DNA_internal_memcpy(this, ref.get_pointer(), sizeof(class_name)); \ - } \ - return *this; \ - } - -namespace blender::dna { - -/* Creates shallow copy of the given object. - * The entire object is copied as-is using memory copy. - * - * Typical usage: - * Object temp_object = blender::dna::shallow_copy(*input_object); - * - * From the implementation detail go via copy constructor/assign operator defined in the structure. - */ -template<class T> -[[nodiscard]] inline internal::ShallowDataConstRef<T> shallow_copy(const T &other) -{ - return internal::ShallowDataConstRef(other); -} - -} // namespace blender::dna - -#endif diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index c3708e25ee7..9e0bf7dcc5a 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -233,8 +233,6 @@ enum eObjectLineArt_Flags { }; typedef struct Object { - DNA_DEFINE_CXX_METHODS(Object) - ID id; /** Animation data (must be immediately after id for utilities to use it). */ struct AnimData *adt; diff --git a/source/blender/makesdna/intern/dna_utils.c b/source/blender/makesdna/intern/dna_utils.c index 560b91b925e..8c86ef69ebd 100644 --- a/source/blender/makesdna/intern/dna_utils.c +++ b/source/blender/makesdna/intern/dna_utils.c @@ -308,15 +308,3 @@ const char *DNA_struct_rename_legacy_hack_alias_from_static(const char *name) } /** \} */ - -/* -------------------------------------------------------------------- */ -/** \name Internal helpers for C++ - * \{ */ - -void _DNA_internal_memcpy(void *dst, const void *src, size_t size); -void _DNA_internal_memcpy(void *dst, const void *src, const size_t size) -{ - memcpy(dst, src, size); -} - -/** \} */ diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c index 12ec7262906..0d2f265a9b5 100644 --- a/source/blender/makesdna/intern/makesdna.c +++ b/source/blender/makesdna/intern/makesdna.c @@ -620,7 +620,6 @@ static int preprocess_include(char *maindata, const int maindata_len) int newlen = 0; comment = 0; a = maindata_len; - bool skip_until_closing_brace = false; while (a--) { if (cp[0] == '/' && cp[1] == '*') { @@ -647,17 +646,6 @@ static int preprocess_include(char *maindata, const int maindata_len) a -= 13; cp += 13; } - else if (match_identifier(cp, "DNA_DEFINE_CXX_METHODS")) { - /* single values are skipped already, so decrement 1 less */ - a -= 21; - cp += 21; - skip_until_closing_brace = true; - } - else if (skip_until_closing_brace) { - if (cp[0] == ')') { - skip_until_closing_brace = false; - } - } else { md[0] = cp[0]; md++; |