[Bf-blender-cvs] [99922034fa7] nodes_playground: cleanup naming
Jacques Lucke
noreply at git.blender.org
Sun Jan 6 17:25:22 CET 2019
Commit: 99922034fa7a6d1112ca6bdbcc5da389cc9cc283
Author: Jacques Lucke
Date: Fri Jan 4 10:06:35 2019 +0100
Branches: nodes_playground
https://developer.blender.org/rB99922034fa7a6d1112ca6bdbcc5da389cc9cc283
cleanup naming
===================================================================
M source/blender/modifiers/CMakeLists.txt
R058 source/blender/modifiers/intern/HashSet.hpp source/blender/modifiers/intern/ArraySet.hpp
M source/blender/modifiers/intern/node_compiler.cpp
M source/blender/modifiers/intern/node_compiler.hpp
M source/blender/modifiers/intern/node_compiler_testing.cpp
===================================================================
diff --git a/source/blender/modifiers/CMakeLists.txt b/source/blender/modifiers/CMakeLists.txt
index a6ba8a9f93b..384633919bb 100644
--- a/source/blender/modifiers/CMakeLists.txt
+++ b/source/blender/modifiers/CMakeLists.txt
@@ -119,7 +119,7 @@ set(SRC
intern/node_compiler_testing.cpp
intern/node_compiler.cpp
intern/node_compiler.hpp
- intern/HashSet.hpp
+ intern/ArraySet.hpp
intern/HashMap.hpp
)
diff --git a/source/blender/modifiers/intern/HashSet.hpp b/source/blender/modifiers/intern/ArraySet.hpp
similarity index 58%
rename from source/blender/modifiers/intern/HashSet.hpp
rename to source/blender/modifiers/intern/ArraySet.hpp
index 8a1575f0358..e3455186a7e 100644
--- a/source/blender/modifiers/intern/HashSet.hpp
+++ b/source/blender/modifiers/intern/ArraySet.hpp
@@ -2,20 +2,24 @@
#include <vector>
template<typename T>
-class HashSet {
+class
+ArraySet {
private:
std::vector<T> entries;
public:
- HashSet() {};
- HashSet(std::vector<T> values)
+
+ ArraySet() {};
+
+ ArraySet(std::vector<T> values)
{
for (T value : values) {
this->add(value);
}
}
- HashSet(std::initializer_list<T> values)
+
+ ArraySet(std::initializer_list<T> values)
{
for (T value : values) {
this->add(value);
@@ -29,7 +33,7 @@ public:
}
}
- bool contains(T value)
+ bool contains(T value) const
{
for (T entry : this->entries) {
if (entry == value) return true;
@@ -37,8 +41,19 @@ public:
return false;
}
- const std::vector<T> &elements()
+ const std::vector<T> &elements() const
{
return this->entries;
}
+
+ T operator[](const int index) const
+ {
+ assert(index >= 0 && index < this->size());
+ return this->entries[index];
+ }
+
+ uint size() const
+ {
+ return this->entries.size();
+ }
};
\ No newline at end of file
diff --git a/source/blender/modifiers/intern/node_compiler.cpp b/source/blender/modifiers/intern/node_compiler.cpp
index b4eb317513b..77a1524d62b 100644
--- a/source/blender/modifiers/intern/node_compiler.cpp
+++ b/source/blender/modifiers/intern/node_compiler.cpp
@@ -51,17 +51,17 @@ std::string SimpleNode::debug_id() const
llvm::Function *Graph::generateFunction(
llvm::Module *module, std::string name,
- std::vector<AnySocket> &inputs, std::vector<AnySocket> &outputs)
+ SocketArraySet &inputs, SocketArraySet &outputs)
{
llvm::LLVMContext &context = module->getContext();
std::vector<llvm::Type *> input_types;
- for (AnySocket socket : inputs) {
+ for (AnySocket socket : inputs.elements()) {
input_types.push_back(socket.type());
}
std::vector<llvm::Type *> output_types;
- for (AnySocket socket : outputs) {
+ for (AnySocket socket : outputs.elements()) {
output_types.push_back(socket.type());
}
@@ -101,7 +101,7 @@ llvm::Function *Graph::generateFunction(
void Graph::generateCode(
llvm::IRBuilder<> *builder,
- std::vector<AnySocket> &inputs, std::vector<AnySocket> &outputs, std::vector<llvm::Value *> &input_values,
+ SocketArraySet &inputs, SocketArraySet &outputs, std::vector<llvm::Value *> &input_values,
llvm::IRBuilder<> **r_builder, std::vector<llvm::Value *> &r_output_values)
{
assert(inputs.size() == input_values.size());
@@ -111,7 +111,7 @@ void Graph::generateCode(
values.add(inputs[i], input_values[i]);
}
- for (AnySocket socket : outputs) {
+ for (AnySocket socket : outputs.elements()) {
llvm::IRBuilder<> *next_builder;
llvm::Value *value = this->generateCodeForSocket(socket, builder, values, &next_builder);
diff --git a/source/blender/modifiers/intern/node_compiler.hpp b/source/blender/modifiers/intern/node_compiler.hpp
index 54ee0c7e9ed..be67c8b47ab 100644
--- a/source/blender/modifiers/intern/node_compiler.hpp
+++ b/source/blender/modifiers/intern/node_compiler.hpp
@@ -8,7 +8,7 @@
#include <functional>
#include <unordered_set>
-#include "HashSet.hpp"
+#include "ArraySet.hpp"
#include "HashMap.hpp"
namespace LLVMNodeCompiler {
@@ -54,7 +54,8 @@ private:
uint _index;
};
-using SocketSet = HashSet<AnySocket>;
+using SocketArraySet = ArraySet<AnySocket>;
+using SocketSet = SocketArraySet;
template<typename TValue>
using SocketMap = HashMap<AnySocket, TValue>;
@@ -111,11 +112,11 @@ struct Graph {
llvm::Function *generateFunction(
llvm::Module *module, std::string name,
- std::vector<AnySocket> &inputs, std::vector<AnySocket> &outputs);
+ SocketArraySet &inputs, SocketArraySet &outputs);
void generateCode(
llvm::IRBuilder<> *builder,
- std::vector<AnySocket> &inputs, std::vector<AnySocket> &outputs, std::vector<llvm::Value *> &input_values,
+ SocketArraySet &inputs, SocketArraySet &outputs, std::vector<llvm::Value *> &input_values,
llvm::IRBuilder<> **r_builder, std::vector<llvm::Value *> &r_output_values);
AnySocket getOriginSocket(AnySocket socket) const;
diff --git a/source/blender/modifiers/intern/node_compiler_testing.cpp b/source/blender/modifiers/intern/node_compiler_testing.cpp
index 1b687ad69ef..54faa17edc9 100644
--- a/source/blender/modifiers/intern/node_compiler_testing.cpp
+++ b/source/blender/modifiers/intern/node_compiler_testing.cpp
@@ -95,8 +95,8 @@ void run_tests()
llvm::Module *module = new llvm::Module("test", context);
- std::vector<NC::AnySocket> inputs = { };
- std::vector<NC::AnySocket> outputs = { add3->Output(0), add1->Input(0) };
+ NC::SocketArraySet inputs = { in1->Output(0), in2->Output(0) };
+ NC::SocketArraySet outputs = { add3->Output(0), add1->Input(0) };
graph.generateFunction(module, "HelloWorld", inputs, outputs);
module->print(llvm::outs(), nullptr);
More information about the Bf-blender-cvs
mailing list