[Bf-blender-cvs] [e865bc730d7] functions: check function signature with c wrapper

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


Commit: e865bc730d7eca0f8bbb3d6ddc7664010f60042d
Author: Jacques Lucke
Date:   Wed Feb 20 15:48:22 2019 +0100
Branches: functions
https://developer.blender.org/rBe865bc730d7eca0f8bbb3d6ddc7664010f60042d

check function signature with c wrapper

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

M	source/blender/functions/FN_functions.h
M	source/blender/functions/c_wrapper.cpp

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

diff --git a/source/blender/functions/FN_functions.h b/source/blender/functions/FN_functions.h
index 1221ca789fb..e677ad9ac50 100644
--- a/source/blender/functions/FN_functions.h
+++ b/source/blender/functions/FN_functions.h
@@ -19,6 +19,12 @@ FnCallable FN_function_get_callable(FnFunction fn);
 void FN_function_call(FnCallable call, FnTuple fn_in, FnTuple fn_out);
 void FN_function_free(FnFunction fn);
 
+uint FN_input_amount(FnFunction fn);
+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);
+
 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 50b6b7fffea..91ce024f3b7 100644
--- a/source/blender/functions/c_wrapper.cpp
+++ b/source/blender/functions/c_wrapper.cpp
@@ -18,7 +18,6 @@ WRAPPERS(BLI::RefCounted<FN::Type> *, FnType);
 WRAPPERS(FN::Tuple *, FnTuple);
 WRAPPERS(const FN::TupleCallBody *, FnCallable);
 
-void FN_test_inferencer(void);
 
 void FN_initialize()
 {
@@ -40,6 +39,31 @@ void FN_function_free(FnFunction fn)
 	unwrap(fn)->decref();
 }
 
+uint FN_input_amount(FnFunction fn)
+{
+	return unwrap(fn)->ptr()->signature().inputs().size();
+}
+
+uint FN_output_amount(FnFunction fn)
+{
+	return unwrap(fn)->ptr()->signature().outputs().size();
+}
+
+bool FN_input_has_type(FnFunction fn, uint index, FnType type)
+{
+	FN::Type *type1 = unwrap(fn)->ptr()->signature().inputs()[index].type().refcounter()->ptr();
+	FN::Type *type2 = unwrap(type)->ptr();
+	return type1 == type2;
+}
+
+bool FN_output_has_type(FnFunction fn, uint index, FnType type)
+{
+	FN::Type *type1 = unwrap(fn)->ptr()->signature().outputs()[index].type().refcounter()->ptr();
+	FN::Type *type2 = unwrap(type)->ptr();
+	return type1 == type2;
+}
+
+
 FnTuple FN_tuple_for_input(FnFunction fn)
 {
 	auto tuple = new FN::Tuple(unwrap(fn)->ptr()->signature().input_types());



More information about the Bf-blender-cvs mailing list