[Bf-blender-cvs] [01d09210ffb] functions: use shared list in tuple

Jacques Lucke noreply at git.blender.org
Fri Mar 8 15:15:30 CET 2019


Commit: 01d09210ffba2ff10a620581f1823d2708e44548
Author: Jacques Lucke
Date:   Fri Mar 8 14:54:36 2019 +0100
Branches: functions
https://developer.blender.org/rB01d09210ffba2ff10a620581f1823d2708e44548

use shared list in tuple

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

M	source/blender/functions/c_wrapper.cpp
M	source/blender/functions/functions/lists.cpp
M	source/blender/functions/types/numeric_lists.hpp

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

diff --git a/source/blender/functions/c_wrapper.cpp b/source/blender/functions/c_wrapper.cpp
index a253ae1e2d0..df5cee0def5 100644
--- a/source/blender/functions/c_wrapper.cpp
+++ b/source/blender/functions/c_wrapper.cpp
@@ -28,15 +28,15 @@ static void playground()
 	Tuple fn_in(fn->signature().input_types());
 	Tuple fn_out(fn->signature().output_types());
 
-	auto *list = new FloatList();
+	auto list = SharedFloatList::New();
 	list->new_user();
-	fn_in.set<FloatList *>(0, list);
+	fn_in.copy_in<SharedFloatList>(0, list);
 	fn_in.set<float>(1, 42.0f);
 
 	std::cout << "Size before: " << list->size() << std::endl;
 	fn->body<TupleCallBody>()->call(fn_in, fn_out);
 
-	auto *new_list = fn_out.get<FloatList *>(0);
+	auto new_list = fn_out.copy_out<SharedFloatList>(0);
 	std::cout << "Size Old after: " << list->size() << std::endl;
 	std::cout << "Size New after: " << new_list->size() << std::endl;
 }
diff --git a/source/blender/functions/functions/lists.cpp b/source/blender/functions/functions/lists.cpp
index 36b6856360f..a6c3e7756e3 100644
--- a/source/blender/functions/functions/lists.cpp
+++ b/source/blender/functions/functions/lists.cpp
@@ -11,13 +11,13 @@ namespace FN { namespace Functions {
 	class AppendFloat : public TupleCallBody {
 		void call(const Tuple &fn_in, Tuple &fn_out) const override
 		{
-			auto *list = fn_in.get<FloatList *>(0);
+			auto list = fn_in.copy_out<SharedFloatList>(0);
 			float value = fn_in.get<float>(1);
 
-			list = list->get_mutable(false);
+			auto mutable_list = list->get_mutable(false);
 
-			list->append(value);
-			fn_out.set<FloatList *>(0, list);
+			mutable_list->append(value);
+			fn_out.copy_in<SharedFloatList>(0, SharedFloatList::FromPointer(mutable_list));
 		}
 	};
 
diff --git a/source/blender/functions/types/numeric_lists.hpp b/source/blender/functions/types/numeric_lists.hpp
index eaaf315d3b9..0ba1f085ff7 100644
--- a/source/blender/functions/types/numeric_lists.hpp
+++ b/source/blender/functions/types/numeric_lists.hpp
@@ -5,7 +5,7 @@
 
 namespace FN { namespace Types {
 
-	using FloatList = List<float>;
+	using SharedFloatList = SharedList<float>;
 
 	SharedType &get_float_list_type();



More information about the Bf-blender-cvs mailing list