[Bf-blender-cvs] [3cddf75818c] functions: use StringRef and ArrayRef in more places
Jacques Lucke
noreply at git.blender.org
Thu May 16 12:03:10 CEST 2019
Commit: 3cddf75818cd8e190e76529d3faddc9c5e89d7a4
Author: Jacques Lucke
Date: Thu May 16 12:02:57 2019 +0200
Branches: functions
https://developer.blender.org/rB3cddf75818cd8e190e76529d3faddc9c5e89d7a4
use StringRef and ArrayRef in more places
===================================================================
M source/blender/functions/backends/llvm/ir_for_tuple_call.cpp
M source/blender/functions/backends/tuple_call/execution_context.cpp
M source/blender/functions/backends/tuple_call/execution_context.hpp
M source/blender/functions/backends/tuple_call/tuple.hpp
M source/blender/functions/core/source_info.cpp
M source/blender/functions/core/source_info.hpp
M source/blender/functions/frontends/data_flow_nodes/builder.cpp
===================================================================
diff --git a/source/blender/functions/backends/llvm/ir_for_tuple_call.cpp b/source/blender/functions/backends/llvm/ir_for_tuple_call.cpp
index bdeba5ae98a..11b31c9dc1b 100644
--- a/source/blender/functions/backends/llvm/ir_for_tuple_call.cpp
+++ b/source/blender/functions/backends/llvm/ir_for_tuple_call.cpp
@@ -83,8 +83,8 @@ class TupleCallLLVM : public LLVMBuildIRBody {
llvm::Function *get_wrapper_function(CodeBuilder &builder,
CodeInterface &interface,
const BuildIRSettings &settings,
- SmallVector<LLVMTypeInfo *> input_type_infos,
- SmallVector<LLVMTypeInfo *> output_type_infos) const
+ ArrayRef<LLVMTypeInfo *> input_type_infos,
+ ArrayRef<LLVMTypeInfo *> output_type_infos) const
{
Function *fn = m_tuple_call->owner();
@@ -124,8 +124,8 @@ class TupleCallLLVM : public LLVMBuildIRBody {
void build_wrapper_function(const BuildIRSettings &settings,
llvm::Function *function,
- SmallVector<LLVMTypeInfo *> &input_type_infos,
- SmallVector<LLVMTypeInfo *> &output_type_infos,
+ ArrayRef<LLVMTypeInfo *> input_type_infos,
+ ArrayRef<LLVMTypeInfo *> output_type_infos,
llvm::Type *output_type) const
{
llvm::LLVMContext &context = function->getContext();
diff --git a/source/blender/functions/backends/tuple_call/execution_context.cpp b/source/blender/functions/backends/tuple_call/execution_context.cpp
index 2c8f630325f..57c7e628767 100644
--- a/source/blender/functions/backends/tuple_call/execution_context.cpp
+++ b/source/blender/functions/backends/tuple_call/execution_context.cpp
@@ -20,7 +20,7 @@ std::string SourceInfoStackFrame::to_string() const
}
}
-void SourceInfoStackFrame::handle_warning(std::string msg) const
+void SourceInfoStackFrame::handle_warning(StringRef msg) const
{
if (m_source != nullptr) {
m_source->handle_warning(msg);
@@ -32,13 +32,13 @@ std::string TextStackFrame::to_string() const
return std::string(m_text);
}
-void ExecutionContext::print_with_traceback(std::string msg)
+void ExecutionContext::print_with_traceback(StringRef msg)
{
m_stack.print_traceback();
std::cout << "-> " << msg << std::endl;
}
-void ExecutionContext::log_warning(std::string msg)
+void ExecutionContext::log_warning(StringRef msg)
{
for (StackFrame *frame : m_stack) {
frame->handle_warning(msg);
diff --git a/source/blender/functions/backends/tuple_call/execution_context.hpp b/source/blender/functions/backends/tuple_call/execution_context.hpp
index aab6c6d4488..4df493a772b 100644
--- a/source/blender/functions/backends/tuple_call/execution_context.hpp
+++ b/source/blender/functions/backends/tuple_call/execution_context.hpp
@@ -8,7 +8,7 @@ class StackFrame {
public:
virtual std::string to_string() const = 0;
- virtual void handle_warning(std::string UNUSED(msg)) const
+ virtual void handle_warning(StringRef UNUSED(msg)) const
{
}
};
@@ -28,7 +28,7 @@ class SourceInfoStackFrame : public StackFrame {
}
std::string to_string() const override;
- void handle_warning(std::string msg) const override;
+ void handle_warning(StringRef msg) const override;
};
class TextStackFrame : public StackFrame {
@@ -92,8 +92,8 @@ class ExecutionContext {
return m_stack;
}
- void print_with_traceback(std::string msg);
- void log_warning(std::string msg);
+ void print_with_traceback(StringRef msg);
+ void log_warning(StringRef msg);
};
} /* namespace FN */
diff --git a/source/blender/functions/backends/tuple_call/tuple.hpp b/source/blender/functions/backends/tuple_call/tuple.hpp
index e0ca2c91be7..42f4cc5edb3 100644
--- a/source/blender/functions/backends/tuple_call/tuple.hpp
+++ b/source/blender/functions/backends/tuple_call/tuple.hpp
@@ -13,7 +13,7 @@ class TupleMeta : public RefCountedBase {
uint m_size__data_and_init;
public:
- TupleMeta(const TypeVector &types = {}) : m_types(types)
+ TupleMeta(ArrayRef<SharedType> types = {}) : m_types(types.to_small_vector())
{
m_size__data = 0;
for (const SharedType &type : types) {
@@ -27,17 +27,17 @@ class TupleMeta : public RefCountedBase {
m_size__data_and_init = m_size__data + this->element_amount();
}
- const TypeVector &types() const
+ const ArrayRef<SharedType> types() const
{
return m_types;
}
- const SmallVector<CPPTypeInfo *> &type_infos() const
+ const ArrayRef<CPPTypeInfo *> type_infos() const
{
return m_type_info;
}
- const SmallVector<uint> &offsets() const
+ const ArrayRef<uint> offsets() const
{
return m_offsets;
}
diff --git a/source/blender/functions/core/source_info.cpp b/source/blender/functions/core/source_info.cpp
index 6a2d46c580c..1f777db993a 100644
--- a/source/blender/functions/core/source_info.cpp
+++ b/source/blender/functions/core/source_info.cpp
@@ -2,7 +2,7 @@
namespace FN {
-void SourceInfo::handle_warning(std::string UNUSED(msg)) const
+void SourceInfo::handle_warning(StringRef UNUSED(msg)) const
{
}
diff --git a/source/blender/functions/core/source_info.hpp b/source/blender/functions/core/source_info.hpp
index 1e716164e29..20a8d2f3401 100644
--- a/source/blender/functions/core/source_info.hpp
+++ b/source/blender/functions/core/source_info.hpp
@@ -11,7 +11,7 @@ class SourceInfo {
}
virtual std::string to_string() const = 0;
- virtual void handle_warning(std::string msg) const;
+ virtual void handle_warning(StringRef msg) const;
};
} /* namespace FN */
diff --git a/source/blender/functions/frontends/data_flow_nodes/builder.cpp b/source/blender/functions/frontends/data_flow_nodes/builder.cpp
index 4376b0ea20b..4d552a1be18 100644
--- a/source/blender/functions/frontends/data_flow_nodes/builder.cpp
+++ b/source/blender/functions/frontends/data_flow_nodes/builder.cpp
@@ -46,7 +46,7 @@ class NodeSource : public SourceInfo {
return ss.str();
}
- void handle_warning(std::string msg) const override
+ void handle_warning(StringRef msg) const override
{
#ifdef WITH_PYTHON
PyGILState_STATE gilstate;
@@ -57,7 +57,7 @@ class NodeSource : public SourceInfo {
PyObject *function = PyDict_GetItemString(globals, "report_warning");
PyObject *py_bnode = get_py_bnode(m_btree, m_bnode);
- PyObject *ret = PyObject_CallFunction(function, "Os", py_bnode, msg.c_str());
+ PyObject *ret = PyObject_CallFunction(function, "Os", py_bnode, msg.to_std_string().c_str());
Py_DECREF(ret);
PyGILState_Release(gilstate);
More information about the Bf-blender-cvs
mailing list