Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2021-03-20BLI: improve support for generic algorithms with c++ containersJacques Lucke
Some generic algorithms from the standard library like `std::any_of` did not work with all container and iterator types. To improve the situation, this patch adds various type members to containers and iterators. Custom iterators for Set, Map and IndexRange now have an iterator category, which soe algorithms require. IndexRange could become a random access iterator, but adding all the missing methods can be done when it is necessary.
2020-12-16BLI: remove implicit casts between some span typesJacques Lucke
Casting pointers from one type to another does change the value of the pointer in some cases. Therefore, casting a span that contains pointers of one type to a span that contains pointers of another type, is not generally safe. In practice, this issue mainly comes up when dealing with classes that have a vtable. There are some special cases that are still allowed. For example, adding const to the pointer does not change the address. Also, casting to a void pointer is fine. In cases where implicit conversion is disabled, but one is sure that the cast is valid, an explicit call of `span.cast<NewType>()` can be used.
2020-09-07BLI: improve exception safety of VectorSetJacques Lucke
For more information see rB2aff45146f1464ba8899368ad004522cb6a1a98c.
2020-08-24BLI: improve exception safety of Set and MapJacques Lucke
For more information see rB2aff45146f1464ba8899368ad004522cb6a1a98c.
2020-08-24BLI: add Array.last methodJacques Lucke
This makes it consistent with Vector and Span.
2020-08-19BLI: improve exception safety of Vector, Array and StackJacques Lucke
Using C++ exceptions in Blender is difficult, due to the large number of C functions in the call stack. However, C++ data structures in blenlib should at least try to be exception safe, so that they can be used if someone wants to use exceptions in some isolated area. This patch improves the exception safety of the Vector, Array and Stack data structure. This is mainly achieved by reordering some lines and doing some explicit exception handling. I don't expect performance of common operations to be affected by this change. The three containers are supposed to provide at least the basic exception guarantee for most methods (except for e.g. `*_unchecked` methods). So, resources should not leak when the contained type throws an exception. I also added new unit tests that test the exception handling in various cases.
2020-08-14BLI: add reverse iterators, iterator constructor and Vector.insert/prependJacques Lucke
The new reverse iterators behave as the reverse iterators for contains from the standard library. Have a look at the tests to see how to use them. Using them will hopefully become easier with ranges in C++20. A Vector can now be constructed from two iterators, which is very common in the standard library. New Vector.insert methods allow adding elements in the middle of a vector. These methods should not be used often in practice, because they has a linear running time. New Vector.prepend methods allow adding elements to the beginning of a vector. These methods are O(n) as well.
2020-08-07Cleanup: use C++ style casts in various placesJacques Lucke
2020-08-07Code Style: use "#pragma once" in source directoryJacques Lucke
This replaces header include guards with `#pragma once`. A couple of include guards are not removed yet (e.g. `__RNA_TYPES_H__`), because they are used in other places. This patch has been generated by P1561 followed by `make format`. Differential Revision: https://developer.blender.org/D8466
2020-07-20BLI: add typedefs for containers that use raw allocatorsJacques Lucke
Those are useful when you have to create containers with static storage duration. If those would use Blender's guarded allocator, it would report memory leaks, that are not actually leaks.
2020-07-20BLI: add Vector/Array.fill methodsJacques Lucke
2020-07-20Refactor: Update integer type usageJacques Lucke
This updates the usage of integer types in code I wrote according to our new style guides. Major changes: * Use signed instead of unsigned integers in many places. * C++ containers in blenlib use `int64_t` for size and indices now (instead of `uint`). * Hash values for C++ containers are 64 bit wide now (instead of 32 bit). I do hope that I broke no builds, but it is quite likely that some compiler reports slightly different errors. Please let me know when there are any errors. If the fix is small, feel free to commit it yourself. I compiled successfully on linux with gcc and on windows.
2020-07-13BLI: fix constructor regression for Vector and ArrayJacques Lucke
This was introduced in rB403384998a6bb5f428e15ced5.
2020-07-08BLI: improve constructors and conversions to spanJacques Lucke
This allows us to avoid many calls to `as_span()` methods. I will remove those in the next commit. Furthermore, constructors of Vector and Array can convert from one type to another now. I tested these changes on Linux with gcc and on Windows.
2020-07-07BLI: simplify copy constructor of ArrayJacques Lucke
2020-07-06BLI: refactor how buffers for small object optimization are storedJacques Lucke
Previously, there was an error when operator-> was returning an invalid type. See error C2839.
2020-07-05Revert "BLI: refactor how buffers for small object optimization are stored"Jacques Lucke
This reverts commit 5d79f9f276b4b3e6289308c534c58e7ee3bb5e2d. This was introducing build errors in windows. Need a bit more time to check it.
2020-07-05BLI: refactor how buffers for small object optimization are storedJacques Lucke
2020-07-03Cleanup: bring operator overloads closer togetherJacques Lucke
2020-07-03Cleanup: Use trailing underscore for non-public data membersJacques Lucke
This makes the code conform better with our style guide.
2020-06-30BLI: add Array constructor that does not initialize non-trivial typesJacques Lucke
This should rarely be necessary, but I have a use case coming up soon.
2020-06-13Cleanup: spellingCampbell Barton
2020-06-09BLI: rename ArrayRef to SpanJacques Lucke
This also renames `MutableArrayRef` to `MutableSpan`. The name "Span" works better, because `std::span` will provide similar functionality in C++20. Furthermore, a shorter, more concise name for a common data structure is nice.
2020-06-09BLI: put C++ data structures in "blender" namespace instead of "BLI"Jacques Lucke
We plan to use the "blender" namespace in other modules as well.
2020-06-09BLI: generally improve C++ data structuresJacques Lucke
The main focus here was to improve the docs significantly. Furthermore, I reimplemented `Set`, `Map` and `VectorSet`. They are now (usually) faster, simpler and more customizable. I also rewrote `Stack` to make it more efficient by avoiding unnecessary copies. Thanks to everyone who helped with constructive feedback. Approved by brecht and sybren. Differential Revision: https://developer.blender.org/D7931
2020-05-04BLI: simplify memory management in OpenAddressingArrayJacques Lucke
2020-04-23BLI: various data structure improvementsJacques Lucke
* Rename template parameter N to InlineBufferCapacity * Expose InlineBufferCapacity parameter for Set and Map * Add some comments * Fixed an error that I introduced recently
2020-04-21BLI: Use .hh extension for C++ headers in blenlibJacques Lucke