Functions: minor improvements

This commit is contained in:
Jacques Lucke 2020-07-12 12:38:03 +02:00
parent 404486e66c
commit 838b1742fb
4 changed files with 21 additions and 6 deletions

View File

@ -73,6 +73,11 @@ class MultiFunction {
return false;
}
uint param_amount() const
{
return signature_.param_types.size();
}
IndexRange param_indices() const
{
return signature_.param_types.index_range();

View File

@ -144,6 +144,11 @@ class MFParamType {
return ELEM(interface_type_, Output, Mutable);
}
bool is_output() const
{
return interface_type_ == Output;
}
friend bool operator==(const MFParamType &a, const MFParamType &b);
friend bool operator!=(const MFParamType &a, const MFParamType &b);
};

View File

@ -344,6 +344,11 @@ class GVSpan : public VSpanBase<void> {
return GVSpan::FromSingle(type, value, UINT32_MAX);
}
static GVSpan FromDefault(const CPPType &type)
{
return GVSpan::FromSingleWithMaxSize(type, type.default_value());
}
static GVSpan FromFullPointerArray(const CPPType &type, const void *const *values, uint size)
{
GVSpan ref;

View File

@ -106,30 +106,30 @@ MFNetworkEvaluator::MFNetworkEvaluator(Vector<const MFOutputSocket *> inputs,
BLI_assert(outputs_.size() > 0);
MFSignatureBuilder signature = this->get_builder("Function Tree");
for (auto socket : inputs_) {
for (const MFOutputSocket *socket : inputs_) {
BLI_assert(socket->node().is_dummy());
MFDataType type = socket->data_type();
switch (type.category()) {
case MFDataType::Single:
signature.single_input("Input", type.single_type());
signature.single_input(socket->name(), type.single_type());
break;
case MFDataType::Vector:
signature.vector_input("Input", type.vector_base_type());
signature.vector_input(socket->name(), type.vector_base_type());
break;
}
}
for (auto socket : outputs_) {
for (const MFInputSocket *socket : outputs_) {
BLI_assert(socket->node().is_dummy());
MFDataType type = socket->data_type();
switch (type.category()) {
case MFDataType::Single:
signature.single_output("Output", type.single_type());
signature.single_output(socket->name(), type.single_type());
break;
case MFDataType::Vector:
signature.vector_output("Output", type.vector_base_type());
signature.vector_output(socket->name(), type.vector_base_type());
break;
}
}