[Bf-blender-cvs] [dbd5c545107] functions: debug print for functions

Jacques Lucke noreply at git.blender.org
Wed Feb 20 17:21:34 CET 2019


Commit: dbd5c545107a79f44b3e45f69caafb87cd695b5e
Author: Jacques Lucke
Date:   Wed Feb 20 16:21:40 2019 +0100
Branches: functions
https://developer.blender.org/rBdbd5c545107a79f44b3e45f69caafb87cd695b5e

debug print for functions

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

M	source/blender/functions/FN_functions.h
M	source/blender/functions/c_wrapper.cpp
M	source/blender/functions/core/core.cpp
M	source/blender/functions/core/core.hpp
M	source/blender/modifiers/intern/MOD_functiondeform.c

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

diff --git a/source/blender/functions/FN_functions.h b/source/blender/functions/FN_functions.h
index 843c9649a33..30b5fa5ad60 100644
--- a/source/blender/functions/FN_functions.h
+++ b/source/blender/functions/FN_functions.h
@@ -25,6 +25,8 @@ uint FN_output_amount(FnFunction fn);
 bool FN_input_has_type(FnFunction fn, uint index, FnType type);
 bool FN_output_has_type(FnFunction fn, uint index, FnType type);
 
+void FN_function_print(FnFunction fn);
+
 FnTuple FN_tuple_for_input(FnFunction fn);
 FnTuple FN_tuple_for_output(FnFunction fn);
 
diff --git a/source/blender/functions/c_wrapper.cpp b/source/blender/functions/c_wrapper.cpp
index 8803b14a223..0af4a389c81 100644
--- a/source/blender/functions/c_wrapper.cpp
+++ b/source/blender/functions/c_wrapper.cpp
@@ -83,6 +83,12 @@ bool FN_output_has_type(FnFunction fn, uint index, FnType type)
 	return type1 == type2;
 }
 
+void FN_function_print(FnFunction fn)
+{
+	FN::Function *function = unwrap(fn)->ptr();
+	function->print();
+}
+
 
 FnTuple FN_tuple_for_input(FnFunction fn)
 {
diff --git a/source/blender/functions/core/core.cpp b/source/blender/functions/core/core.cpp
index 5d86cfa1aed..d4f36aa59e8 100644
--- a/source/blender/functions/core/core.cpp
+++ b/source/blender/functions/core/core.cpp
@@ -29,4 +29,35 @@ namespace FN {
 			&& SmallTypeVector::all_equal(this->output_types(), outputs));
 	}
 
+
+	/* Printing
+	 ***************************************/
+
+	void Parameter::print() const
+	{
+		std::cout << this->type()->name() << " - " << this->name();
+	}
+
+	void Signature::print(std::string indent) const
+	{
+		std::cout << indent << "Inputs:" << std::endl;
+		for (InputParameter &param : this->inputs()) {
+			std::cout << indent << "  ";
+			param.print();
+			std::cout << std::endl;
+		}
+		std::cout << indent << "Outputs:" << std::endl;
+		for (OutputParameter &param : this->outputs()) {
+			std::cout << indent << "  ";
+			param.print();
+			std::cout << std::endl;
+		}
+	}
+
+	void Function::print() const
+	{
+		std::cout << "Function: " << this->name() << std::endl;
+		this->signature().print("  ");
+	}
+
 } /* namespace FN */
\ No newline at end of file
diff --git a/source/blender/functions/core/core.hpp b/source/blender/functions/core/core.hpp
index 0c8cde14605..7a4e16c0cd7 100644
--- a/source/blender/functions/core/core.hpp
+++ b/source/blender/functions/core/core.hpp
@@ -64,6 +64,8 @@ namespace FN {
 			return m_type;
 		}
 
+		void print() const;
+
 	private:
 		const std::string m_name;
 		const SharedType m_type;
@@ -109,6 +111,8 @@ namespace FN {
 			const SmallTypeVector &inputs,
 			const SmallTypeVector &outputs) const;
 
+		void print(std::string indent = "") const;
+
 	private:
 		const InputParameters m_inputs;
 		const OutputParameters m_outputs;
@@ -147,6 +151,8 @@ namespace FN {
 			m_bodies.add(body);
 		}
 
+		void print() const;
+
 	private:
 		const std::string m_name;
 		const Signature m_signature;
diff --git a/source/blender/modifiers/intern/MOD_functiondeform.c b/source/blender/modifiers/intern/MOD_functiondeform.c
index ef38cefd22d..6f12bf47470 100644
--- a/source/blender/modifiers/intern/MOD_functiondeform.c
+++ b/source/blender/modifiers/intern/MOD_functiondeform.c
@@ -65,7 +65,7 @@ static bool is_deform_function(FnFunction fn)
 	FnType fvec3_ty = FN_type_get_fvec3();
 
 	FnType inputs[] = { fvec3_ty, float_ty, NULL };
-	FnType outputs[] = { float_ty, NULL };
+	FnType outputs[] = { fvec3_ty, NULL };
 
 	bool match = FN_function_has_signature(fn, inputs, outputs);
 
@@ -84,6 +84,7 @@ static void do_deformation(
 	if (fn == NULL) {
 		return;
 	}
+	FN_function_print(fn);
 	if (!is_deform_function(fn)) {
 		return;
 	}



More information about the Bf-blender-cvs mailing list