Repository: godotengine/godot
File: modules/visual_script/visual_script_nodes.cpp (C++)

Code before:
	}
};

VisualScriptNodeInstance *VisualScriptOperator::instantiate(VisualScriptInstance *p_instance) {
	VisualScriptNodeInstanceOperator *instance = memnew(VisualScriptNodeInstanceOperator);
	instance->unary = get_input_value_port_count() == 1;
	instance->op = op;
	return instance;
}

VisualScriptOperator::VisualScriptOperator() {
	op = Variant::OP_ADD;
	typed = Variant::NIL;
}

template <Variant::Operator OP>
static Ref<VisualScriptNode> create_op_node(const String &p_name) {
	Ref<VisualScriptOperator> node;
	node.instantiate();
	node->set_operator(OP);
	return node;
}

//////////////////////////////////////////
////////////////OPERATOR//////////////////
//////////////////////////////////////////

int VisualScriptSelect::get_output_sequence_port_count() const {
	return 0;
}

bool VisualScriptSelect::has_input_sequence_port() const {
	return false;
}

int VisualScriptSelect::get_input_value_port_count() const {
	return 3;
}

int VisualScriptSelect::get_output_value_port_count() const {
	return 1;
}

String VisualScriptSelect::get_output_sequence_port_text(int p_port) const {
	return String();
}

PropertyInfo VisualScriptSelect::get_input_value_port_info(int p_idx) const {
	if (p_idx == 0) {
		return PropertyInfo(Variant::BOOL, "cond");
	} else if (p_idx == 1) {

Review comment (suggestion):
I don't have a strong opinion, but yes if you think it's best to use the `Variant` names in the error that should be fine.

Code after:
	ADD_PROPERTY(PropertyInfo(Variant::INT, "type", PROPERTY_HINT_ENUM, argt), "set_typed", "get_typed");
}

class VisualScriptNodeInstanceOperator : public VisualScriptNodeInstance {
public:
	bool unary;
	Variant::Operator op;

	//virtual int get_working_memory_size() const { return 0; }

	virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) {
		bool valid;
		if (unary) {
			Variant::evaluate(op, *p_inputs[0], Variant(), *p_outputs[0], valid);
		} else {
			Variant::evaluate(op, *p_inputs[0], *p_inputs[1], *p_outputs[0], valid);
		}

		if (!valid) {
			r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
			if (p_outputs[0]->get_type() == Variant::STRING) {
				r_error_str = *p_outputs[0];
			} else {
				if (unary) {
					r_error_str = String(Variant::get_operator_name(op)) + RTR(": Invalid argument of type: ") + Variant::get_type_name(p_inputs[0]->get_type());
				} else {
					r_error_str = String(Variant::get_operator_name(op)) + RTR(": Invalid arguments: ") + "A: " + Variant::get_type_name(p_inputs[0]->get_type()) + "  B: " + Variant::get_type_name(p_inputs[1]->get_type());
				}
			}
		}

		return 0;
	}
};

VisualScriptNodeInstance *VisualScriptOperator::instantiate(VisualScriptInstance *p_instance) {
	VisualScriptNodeInstanceOperator *instance = memnew(VisualScriptNodeInstanceOperator);
	instance->unary = get_input_value_port_count() == 1;
	instance->op = op;
	return instance;
}

VisualScriptOperator::VisualScriptOperator() {
	op = Variant::OP_ADD;
	typed = Variant::NIL;
}

template <Variant::Operator OP>
static Ref<VisualScriptNode> create_op_node(const String &p_name) {
	Ref<VisualScriptOperator> node;
	node.instantiate();