[Bf-blender-cvs] [d79805e1db4] functions: cleanup classes that are used in a composition

Jacques Lucke noreply at git.blender.org
Sun Mar 24 17:29:14 CET 2019


Commit: d79805e1db46eb285bbc07e3e1e39c2a2efaa967
Author: Jacques Lucke
Date:   Sun Mar 24 17:29:06 2019 +0100
Branches: functions
https://developer.blender.org/rBd79805e1db46eb285bbc07e3e1e39c2a2efaa967

cleanup classes that are used in a composition

===================================================================

M	source/blender/blenlib/BLI_composition.hpp
M	source/blender/functions/backends/dependencies/dependencies.cpp
M	source/blender/functions/backends/dependencies/dependencies.hpp
M	source/blender/functions/backends/llvm/build_ir_body.cpp
M	source/blender/functions/backends/llvm/build_ir_body.hpp
M	source/blender/functions/backends/llvm/compiled_body.cpp
M	source/blender/functions/backends/llvm/compiled_body.hpp
M	source/blender/functions/backends/llvm/llvm_types.cpp
M	source/blender/functions/backends/llvm/llvm_types.hpp
M	source/blender/functions/backends/tuple_call/cpp_types.cpp
M	source/blender/functions/backends/tuple_call/cpp_types.hpp
M	source/blender/functions/backends/tuple_call/tuple_call.cpp
M	source/blender/functions/backends/tuple_call/tuple_call.hpp

===================================================================

diff --git a/source/blender/blenlib/BLI_composition.hpp b/source/blender/blenlib/BLI_composition.hpp
index b5f21330813..60d42360cf6 100644
--- a/source/blender/blenlib/BLI_composition.hpp
+++ b/source/blender/blenlib/BLI_composition.hpp
@@ -60,4 +60,14 @@ namespace BLI {
 		BLI::SmallMap<uint64_t, Entry> m_elements;
 	};
 
-} /* namespace BLI */
\ No newline at end of file
+} /* namespace BLI */
+
+#define BLI_COMPOSITION_DECLARATION(Type) \
+	static const char *identifier_in_composition(); \
+	static void free_self(void *value);
+
+#define BLI_COMPOSITION_IMPLEMENTATION(Type) \
+	const char *Type::identifier_in_composition() \
+	{ return STRINGIFY(Type); } \
+	void Type::free_self(void *value) \
+	{ delete (Type *)value; }
diff --git a/source/blender/functions/backends/dependencies/dependencies.cpp b/source/blender/functions/backends/dependencies/dependencies.cpp
index 582c4f6304c..1097400da89 100644
--- a/source/blender/functions/backends/dependencies/dependencies.cpp
+++ b/source/blender/functions/backends/dependencies/dependencies.cpp
@@ -5,17 +5,7 @@
 
 namespace FN {
 
-	const char *DependenciesBody::identifier_in_composition()
-	{
-		return "Dependencies";
-	}
-
-	void DependenciesBody::free_self(void *value)
-	{
-		DependenciesBody *v = (DependenciesBody *)value;
-		delete v;
-	}
-
+	BLI_COMPOSITION_IMPLEMENTATION(DependenciesBody);
 
 	void Dependencies::add_object_transform_dependency(struct Object *object)
 	{
diff --git a/source/blender/functions/backends/dependencies/dependencies.hpp b/source/blender/functions/backends/dependencies/dependencies.hpp
index 0dacf8e45d5..220aa05b98a 100644
--- a/source/blender/functions/backends/dependencies/dependencies.hpp
+++ b/source/blender/functions/backends/dependencies/dependencies.hpp
@@ -26,8 +26,7 @@ namespace FN {
 
 	class DependenciesBody : public FunctionBody {
 	public:
-		static const char *identifier_in_composition();
-		static void free_self(void *value);
+		BLI_COMPOSITION_DECLARATION(DependenciesBody);
 
 		virtual ~DependenciesBody() {}
 		virtual void dependencies(Dependencies &deps) const = 0;
diff --git a/source/blender/functions/backends/llvm/build_ir_body.cpp b/source/blender/functions/backends/llvm/build_ir_body.cpp
index ecc690ea282..26c2d890f1f 100644
--- a/source/blender/functions/backends/llvm/build_ir_body.cpp
+++ b/source/blender/functions/backends/llvm/build_ir_body.cpp
@@ -2,15 +2,6 @@
 
 namespace FN {
 
-	const char *LLVMBuildIRBody::identifier_in_composition()
-	{
-		return "LLVM Gen Body";
-	}
-
-	void LLVMBuildIRBody::free_self(void *value)
-	{
-		LLVMBuildIRBody *v = (LLVMBuildIRBody *)value;
-		delete v;
-	}
+	BLI_COMPOSITION_IMPLEMENTATION(LLVMBuildIRBody);
 
 } /* namespace FN */
\ No newline at end of file
diff --git a/source/blender/functions/backends/llvm/build_ir_body.hpp b/source/blender/functions/backends/llvm/build_ir_body.hpp
index 262ac5ce3a5..62e07912558 100644
--- a/source/blender/functions/backends/llvm/build_ir_body.hpp
+++ b/source/blender/functions/backends/llvm/build_ir_body.hpp
@@ -10,8 +10,7 @@ namespace FN {
 
 	class LLVMBuildIRBody : public FunctionBody {
 	public:
-		static const char *identifier_in_composition();
-		static void free_self(void *value);
+		BLI_COMPOSITION_DECLARATION(LLVMBuildIRBody);
 
 		virtual ~LLVMBuildIRBody() {};
 
diff --git a/source/blender/functions/backends/llvm/compiled_body.cpp b/source/blender/functions/backends/llvm/compiled_body.cpp
index 6f6a9c96a66..614b5f5a51a 100644
--- a/source/blender/functions/backends/llvm/compiled_body.cpp
+++ b/source/blender/functions/backends/llvm/compiled_body.cpp
@@ -6,16 +6,7 @@
 
 namespace FN {
 
-	const char *LLVMCompiledBody::identifier_in_composition()
-	{
-		return "Compiled LLVM Body";
-	}
-
-	void LLVMCompiledBody::free_self(void *value)
-	{
-		LLVMCompiledBody *v = (LLVMCompiledBody *)value;
-		delete v;
-	}
+	BLI_COMPOSITION_IMPLEMENTATION(LLVMCompiledBody);
 
 	void LLVMCompiledBody::build_ir(
 		llvm::IRBuilder<> &builder,
diff --git a/source/blender/functions/backends/llvm/compiled_body.hpp b/source/blender/functions/backends/llvm/compiled_body.hpp
index ca00bc61bda..0a531bd5e07 100644
--- a/source/blender/functions/backends/llvm/compiled_body.hpp
+++ b/source/blender/functions/backends/llvm/compiled_body.hpp
@@ -19,8 +19,7 @@ namespace FN {
 		LLVMCompiledBody() = default;
 
 	public:
-		static const char *identifier_in_composition();
-		static void free_self(void *value);
+		BLI_COMPOSITION_DECLARATION(LLVMCompiledBody);
 
 		LLVMCompiledBody(std::unique_ptr<CompiledLLVM> compiled)
 			: m_compiled(std::move(compiled)) {}
diff --git a/source/blender/functions/backends/llvm/llvm_types.cpp b/source/blender/functions/backends/llvm/llvm_types.cpp
index 2916217ac6b..68c311befe9 100644
--- a/source/blender/functions/backends/llvm/llvm_types.cpp
+++ b/source/blender/functions/backends/llvm/llvm_types.cpp
@@ -5,16 +5,7 @@ namespace FN {
 
 	/******************** LLVMTypeInfo ********************/
 
-	const char *LLVMTypeInfo::identifier_in_composition()
-	{
-		return "LLVM Type Info";
-	}
-
-	void LLVMTypeInfo::free_self(void *value)
-	{
-		LLVMTypeInfo *value_ = (LLVMTypeInfo *)value;
-		delete value_;
-	}
+	BLI_COMPOSITION_IMPLEMENTATION(LLVMTypeInfo);
 
 	llvm::Type *LLVMTypeInfo::get_type(
 		llvm::LLVMContext &context) const
diff --git a/source/blender/functions/backends/llvm/llvm_types.hpp b/source/blender/functions/backends/llvm/llvm_types.hpp
index 6eb6e62655b..ed2a1be4eb9 100644
--- a/source/blender/functions/backends/llvm/llvm_types.hpp
+++ b/source/blender/functions/backends/llvm/llvm_types.hpp
@@ -11,8 +11,7 @@ namespace FN {
 
 	class LLVMTypeInfo {
 	public:
-		static const char *identifier_in_composition();
-		static void free_self(void *value);
+		BLI_COMPOSITION_DECLARATION(LLVMTypeInfo);
 
 		virtual ~LLVMTypeInfo() {}
 
diff --git a/source/blender/functions/backends/tuple_call/cpp_types.cpp b/source/blender/functions/backends/tuple_call/cpp_types.cpp
index 4e2a69ad711..eb99c5d3eb0 100644
--- a/source/blender/functions/backends/tuple_call/cpp_types.cpp
+++ b/source/blender/functions/backends/tuple_call/cpp_types.cpp
@@ -2,15 +2,6 @@
 
 namespace FN {
 
-	const char *CPPTypeInfo::identifier_in_composition()
-	{
-		return "C++ Type Info";
-	}
-
-	void CPPTypeInfo::free_self(void *value)
-	{
-		CPPTypeInfo *value_ = (CPPTypeInfo *)value;
-		delete value_;
-	}
+	BLI_COMPOSITION_IMPLEMENTATION(CPPTypeInfo);
 
 } /* namespace FN */
\ No newline at end of file
diff --git a/source/blender/functions/backends/tuple_call/cpp_types.hpp b/source/blender/functions/backends/tuple_call/cpp_types.hpp
index 8af9fb20933..8c91acc4ee8 100644
--- a/source/blender/functions/backends/tuple_call/cpp_types.hpp
+++ b/source/blender/functions/backends/tuple_call/cpp_types.hpp
@@ -6,8 +6,7 @@ namespace FN {
 
 	class CPPTypeInfo {
 	public:
-		static const char *identifier_in_composition();
-		static void free_self(void *value);
+		BLI_COMPOSITION_DECLARATION(CPPTypeInfo);
 
 		virtual ~CPPTypeInfo() {}
 
diff --git a/source/blender/functions/backends/tuple_call/tuple_call.cpp b/source/blender/functions/backends/tuple_call/tuple_call.cpp
index 0ce79b1590b..25ea86be90b 100644
--- a/source/blender/functions/backends/tuple_call/tuple_call.cpp
+++ b/source/blender/functions/backends/tuple_call/tuple_call.cpp
@@ -2,16 +2,7 @@
 
 namespace FN {
 
-	const char *TupleCallBody::identifier_in_composition()
-	{
-		return "Tuple Call Body";
-	}
-
-	void TupleCallBody::free_self(void *value)
-	{
-		TupleCallBody *v = (TupleCallBody *)value;
-		delete v;
-	}
+	BLI_COMPOSITION_IMPLEMENTATION(TupleCallBody);
 
 	void TupleCallBody::init_defaults(Tuple &fn_in) const
 	{
diff --git a/source/blender/functions/backends/tuple_call/tuple_call.hpp b/source/blender/functions/backends/tuple_call/tuple_call.hpp
index ecffd787010..c72521e64b9 100644
--- a/source/blender/functions/backends/tuple_call/tuple_call.hpp
+++ b/source/blender/functions/backends/tuple_call/tuple_call.hpp
@@ -16,8 +16,7 @@ namespace FN {
 			: FunctionBody() {}
 
 	public:
-		static const char *identifier_in_composition();
-		static void free_self(void *value);
+		BLI_COMPOSITION_DECLARATION(TupleCallBody);
 
 		virtual ~TupleCallBody() {};



More information about the Bf-blender-cvs mailing list