[Bf-blender-cvs] [296fd08875d] functions: support for storing operation hash per function

Jacques Lucke noreply at git.blender.org
Sat Jan 18 20:18:05 CET 2020


Commit: 296fd08875dc71b8236af9090d47f2d2a00e92c8
Author: Jacques Lucke
Date:   Sat Jan 18 19:59:40 2020 +0100
Branches: functions
https://developer.blender.org/rB296fd08875dc71b8236af9090d47f2d2a00e92c8

support for storing operation hash per function

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

M	source/blender/functions/FN_multi_function.h

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

diff --git a/source/blender/functions/FN_multi_function.h b/source/blender/functions/FN_multi_function.h
index fa6ade0320e..b837d86056c 100644
--- a/source/blender/functions/FN_multi_function.h
+++ b/source/blender/functions/FN_multi_function.h
@@ -1,6 +1,8 @@
 #ifndef __FN_MULTI_FUNCTION_H__
 #define __FN_MULTI_FUNCTION_H__
 
+#include <typeinfo>
+
 #include "FN_generic_array_ref.h"
 #include "FN_generic_vector_array.h"
 #include "FN_generic_virtual_list_ref.h"
@@ -22,6 +24,7 @@ struct MFSignatureData {
   Vector<BLI::class_id_t> used_element_contexts;
   Vector<BLI::class_id_t> used_global_contexts;
   Vector<uint> param_data_indices;
+  Optional<uint32_t> operation_hash;
 
   uint data_index(uint param_index) const
   {
@@ -148,6 +151,21 @@ class MFSignatureBuilder {
         break;
     }
   }
+
+  /* Operation Hash */
+
+  void operation_hash(uint32_t hash)
+  {
+    m_data.operation_hash.set(hash);
+  }
+
+  void constant_operation_hash()
+  {
+    const std::type_info &type_info = typeid(*this);
+    uintptr_t ptr = (uintptr_t)&type_info;
+    uint32_t hash = (ptr * 56247945663) ^ (ptr >> 32);
+    this->operation_hash(hash);
+  }
 };
 
 class MFParams;
@@ -202,6 +220,11 @@ class MultiFunction {
     return m_signature_data.used_global_contexts.contains(id);
   }
 
+  Optional<uint32_t> operation_hash() const
+  {
+    return m_signature_data.operation_hash;
+  }
+
  protected:
   MFSignatureBuilder get_builder(StringRef function_name)
   {



More information about the Bf-blender-cvs mailing list