[Bf-blender-cvs] [4457268059c] functions: add some comments

Jacques Lucke noreply at git.blender.org
Wed Aug 7 12:00:28 CEST 2019


Commit: 4457268059c4e50297232e635d35e987f08b1252
Author: Jacques Lucke
Date:   Wed Aug 7 11:14:14 2019 +0200
Branches: functions
https://developer.blender.org/rB4457268059c4e50297232e635d35e987f08b1252

add some comments

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

M	source/blender/blenlib/BLI_array_allocator.hpp
M	source/blender/blenlib/BLI_array_ref.hpp

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

diff --git a/source/blender/blenlib/BLI_array_allocator.hpp b/source/blender/blenlib/BLI_array_allocator.hpp
index a2aa570ed45..dc19caa4f12 100644
--- a/source/blender/blenlib/BLI_array_allocator.hpp
+++ b/source/blender/blenlib/BLI_array_allocator.hpp
@@ -150,6 +150,10 @@ class ArrayAllocator {
     return ScopedAllocation<T>(*this, this->allocate<T>(), sizeof(T));
   }
 
+  /**
+   * This is a simple vector that has been allocated using an array allocator. The maximum size of
+   * the vector is determined by the allocator.
+   */
   template<typename T> class VectorAdapter {
    private:
     ScopedAllocation<T> m_ptr;
@@ -174,6 +178,9 @@ class ArrayAllocator {
     }
   };
 
+  /**
+   * This is a simple fixed size array that has been allocated using an array allocator.
+   */
   template<typename T> class Array {
    private:
     ScopedAllocation<T> m_ptr;
diff --git a/source/blender/blenlib/BLI_array_ref.hpp b/source/blender/blenlib/BLI_array_ref.hpp
index c48120f3b0e..e02be9109dd 100644
--- a/source/blender/blenlib/BLI_array_ref.hpp
+++ b/source/blender/blenlib/BLI_array_ref.hpp
@@ -256,12 +256,21 @@ template<typename T> class ArrayRef {
     return fallback;
   }
 
+  /**
+   * Get a new array ref to the same underlying memory buffer. No conversions are done.
+   * Asserts when the sizes of the types don't match.
+   */
   template<typename NewT> ArrayRef<NewT> cast() const
   {
+    /* Can be adjusted to allow different type sizes when necessary. */
     BLI_STATIC_ASSERT(sizeof(T) == sizeof(NewT), "");
     return ArrayRef<NewT>((NewT *)m_start, m_size);
   }
 
+  /**
+   * A debug utility to print the content of the array ref. Every element will be printed on a
+   * separate line using the given callback.
+   */
   template<typename PrintLineF> void print_as_lines(StringRef name, PrintLineF print_line) const
   {
     std::cout << "ArrayRef: " << name << " \tSize:" << m_size << '\n';
@@ -273,6 +282,9 @@ template<typename T> class ArrayRef {
   }
 };
 
+/**
+ * Shorthand to make use of automatic template parameter deduction.
+ */
 template<typename T> ArrayRef<T> ref_c_array(T *array, uint size)
 {
   return ArrayRef<T>(array, size);



More information about the Bf-blender-cvs mailing list