Commit: ac02c2daf22f1a9a742e786bc8e201eed79f3b20
Author: Jacques Lucke
Date:   Sun Mar 10 10:44:20 2019 +0100
Branches: functions
https://developer.blender.org/rBac02c2daf22f1a9a742e786bc8e201eed79f3b20

cleanup C wrapper

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

M       source/blender/blenkernel/intern/fcurve.c
M       source/blender/functions/FN-C.h
M       source/blender/functions/c_wrapper.cpp
M       source/blender/modifiers/intern/MOD_displace.c
M       source/blender/modifiers/intern/MOD_functiondeform.c

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

diff --git a/source/blender/blenkernel/intern/fcurve.c 
b/source/blender/blenkernel/intern/fcurve.c
index 6eeba6c9efd..3cc2e3e5247 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -1621,12 +1621,13 @@ static float dvar_eval_function(ChannelDriver 
*UNUSED(driver), DriverVar *dvar)
                return 0.0f;
        }
 
-       FnTuple fn_in = FN_tuple_for_input(fn);
-       FnTuple fn_out = FN_tuple_for_output(fn);
+       FnTupleCallBody body = FN_tuple_call_get(fn);
+
+       FnTuple fn_in = FN_tuple_for_input(body);
+       FnTuple fn_out = FN_tuple_for_output(body);
        FN_tuple_set_int32(fn_in, 0, (int64_t)dvar);
-       FnTupleCallBody callable = FN_function_get_callable(fn);
 
-       FN_function_call(callable, fn_in, fn_out);
+       FN_tuple_call_invoke(body, fn_in, fn_out);
        float result = FN_tuple_get_float(fn_out, 0);
 
        FN_tuple_free(fn_in);
diff --git a/source/blender/functions/FN-C.h b/source/blender/functions/FN-C.h
index b34ea72914f..8e33109b5d4 100644
--- a/source/blender/functions/FN-C.h
+++ b/source/blender/functions/FN-C.h
@@ -15,8 +15,8 @@ typedef struct OpaqueFnType *FnType;
 typedef struct OpaqueFnTuple *FnTuple;
 typedef struct OpaqueFnTupleCallBody *FnTupleCallBody;
 
-FnTupleCallBody FN_function_get_callable(FnFunction fn);
-void FN_function_call(FnTupleCallBody call, FnTuple fn_in, FnTuple fn_out);
+/************** Core *************/
+
 void FN_function_free(FnFunction fn);
 
 bool FN_function_has_signature(FnFunction, FnType *inputs, FnType *outputs);
@@ -27,17 +27,8 @@ 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);
-
-void FN_tuple_free(FnTuple tuple);
 
-void FN_tuple_set_float(FnTuple tuple, uint index, float value);
-void FN_tuple_set_int32(FnTuple tuple, uint index, int32_t value);
-void FN_tuple_set_float_vector_3(FnTuple tuple, uint index, float vector[3]);
-float FN_tuple_get_float(FnTuple tuple, uint index);
-int32_t FN_tuple_get_int32(FnTuple tuple, uint index);
-void FN_tuple_get_float_vector_3(FnTuple tuple, uint index, float dst[3]);
+/************** Types *************/
 
 const char *FN_type_name(FnType type);
 void FN_type_free(FnType type);
@@ -50,15 +41,39 @@ FnType FN_type_borrow_float(void);
 FnType FN_type_borrow_int32(void);
 FnType FN_type_borrow_fvec3(void);
 
-FnFunction FN_tree_to_function(bNodeTree *bnodetree);
-FnFunction FN_function_get_with_signature(
-       bNodeTree *btree, FnType *inputs, FnType *outputs);
+
+/*************** Tuple Call ****************/
+
+FnTupleCallBody FN_tuple_call_get(FnFunction fn);
+void FN_tuple_call_invoke(FnTupleCallBody body, FnTuple fn_in, FnTuple fn_out);
+FnTuple FN_tuple_for_input(FnTupleCallBody body);
+FnTuple FN_tuple_for_output(FnTupleCallBody body);
+
+void FN_tuple_free(FnTuple tuple);
+
+void FN_tuple_set_float(FnTuple tuple, uint index, float value);
+void FN_tuple_set_int32(FnTuple tuple, uint index, int32_t value);
+void FN_tuple_set_float_vector_3(FnTuple tuple, uint index, float vector[3]);
+float FN_tuple_get_float(FnTuple tuple, uint index);
+int32_t FN_tuple_get_int32(FnTuple tuple, uint index);
+void FN_tuple_get_float_vector_3(FnTuple tuple, uint index, float dst[3]);
+
+
+/*************** Dependencies ****************/
 
 struct DepsNodeHandle;
 void FN_function_update_dependencies(
        FnFunction fn,
        struct DepsNodeHandle *deps_node);
 
+
+/************ Data Flow Nodes ****************/
+
+FnFunction FN_tree_to_function(bNodeTree *bnodetree);
+FnFunction FN_function_get_with_signature(
+       bNodeTree *btree, FnType *inputs, FnType *outputs);
+
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/source/blender/functions/c_wrapper.cpp 
b/source/blender/functions/c_wrapper.cpp
index 15a2a942f8f..687d7867993 100644
--- a/source/blender/functions/c_wrapper.cpp
+++ b/source/blender/functions/c_wrapper.cpp
@@ -19,7 +19,7 @@ using namespace FN::DataFlowNodes;
 WRAPPERS(Function *, FnFunction);
 WRAPPERS(Type *, FnType);
 WRAPPERS(Tuple *, FnTuple);
-WRAPPERS(const TupleCallBody *, FnTupleCallBody);
+WRAPPERS(TupleCallBody *, FnTupleCallBody);
 
 static void playground()
 {
@@ -50,7 +50,7 @@ void FN_initialize()
        playground();
 }
 
-void FN_function_call(FnTupleCallBody fn_call, FnTuple fn_in, FnTuple fn_out)
+void FN_tuple_call_invoke(FnTupleCallBody fn_call, FnTuple fn_in, FnTuple 
fn_out)
 {
        Tuple &fn_in_ = *unwrap(fn_in);
        Tuple &fn_out_ = *unwrap(fn_out);
@@ -60,7 +60,7 @@ void FN_function_call(FnTupleCallBody fn_call, FnTuple fn_in, 
FnTuple fn_out)
        BLI_assert(fn_out_.all_initialized());
 }
 
-FnTupleCallBody FN_function_get_callable(FnFunction fn)
+FnTupleCallBody FN_tuple_call_get(FnFunction fn)
 {
        return wrap(unwrap(fn)->body<TupleCallBody>());
 }
@@ -121,15 +121,15 @@ void FN_function_print(FnFunction fn)
 }
 
 
-FnTuple FN_tuple_for_input(FnFunction fn)
+FnTuple FN_tuple_for_input(FnTupleCallBody body)
 {
-       auto tuple = new Tuple(unwrap(fn)->signature().input_types());
+       auto tuple = new Tuple(unwrap(body)->meta_in());
        return wrap(tuple);
 }
 
-FnTuple FN_tuple_for_output(FnFunction fn)
+FnTuple FN_tuple_for_output(FnTupleCallBody body)
 {
-       auto tuple = new Tuple(unwrap(fn)->signature().output_types());
+       auto tuple = new Tuple(unwrap(body)->meta_out());
        return wrap(tuple);
 }
 
diff --git a/source/blender/modifiers/intern/MOD_displace.c 
b/source/blender/modifiers/intern/MOD_displace.c
index 44589cfb7dc..0df669a8f6d 100644
--- a/source/blender/modifiers/intern/MOD_displace.c
+++ b/source/blender/modifiers/intern/MOD_displace.c
@@ -220,13 +220,17 @@ static void displaceModifier_do_task(
        float local_vec[3];
 
        if (data->calc_weight_func) {
-               FnTuple fn_in = FN_tuple_for_input(data->calc_weight_func);
-               FnTuple fn_out = FN_tuple_for_output(data->calc_weight_func);
+               FnTupleCallBody body = 
FN_tuple_call_get(data->calc_weight_func);
+               FnTuple fn_in = FN_tuple_for_input(body);
+               FnTuple fn_out = FN_tuple_for_output(body);
+
                FN_tuple_set_float_vector_3(fn_in, 0, vertexCos[iter]);
                FN_tuple_set_int32(fn_in, 1, iter);
-               FnTupleCallBody callable = 
FN_function_get_callable(data->calc_weight_func);
-               FN_function_call(callable, fn_in, fn_out);
+
+               FN_tuple_call_invoke(body, fn_in, fn_out);
+
                weight = FN_tuple_get_float(fn_out, 0);
+
                FN_tuple_free(fn_in);
                FN_tuple_free(fn_out);
        }
diff --git a/source/blender/modifiers/intern/MOD_functiondeform.c 
b/source/blender/modifiers/intern/MOD_functiondeform.c
index 0aeb072185e..832e2e74689 100644
--- a/source/blender/modifiers/intern/MOD_functiondeform.c
+++ b/source/blender/modifiers/intern/MOD_functiondeform.c
@@ -77,11 +77,11 @@ static void do_deformation(
                return;
        }
 
-       FnTupleCallBody fn_call = FN_function_get_callable(fn);
-       BLI_assert(fn_call);
+       FnTupleCallBody body = FN_tuple_call_get(fn);
+       BLI_assert(body);
 
-       FnTuple fn_in = FN_tuple_for_input(fn);
-       FnTuple fn_out = FN_tuple_for_output(fn);
+       FnTuple fn_in = FN_tuple_for_input(body);
+       FnTuple fn_out = FN_tuple_for_output(body);
 
        clock_t start = clock();
 
@@ -89,7 +89,9 @@ static void do_deformation(
                FN_tuple_set_float_vector_3(fn_in, 0, vertexCos[i]);
                FN_tuple_set_int32(fn_in, 1, i);
                FN_tuple_set_float(fn_in, 2, fdmd->control1);
-               FN_function_call(fn_call, fn_in, fn_out);
+
+               FN_tuple_call_invoke(body, fn_in, fn_out);
+
                FN_tuple_get_float_vector_3(fn_out, 0, vertexCos[i]);
        }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to