diff --git a/core/variant/variant.h b/core/variant/variant.h index 8bb28b24061..ee08373b275 100644 --- a/core/variant/variant.h +++ b/core/variant/variant.h @@ -467,7 +467,7 @@ public: return res; } - Variant::Type get_operator_return_type(Operator p_operator, Type p_type_a, Type p_type_b); + static Variant::Type get_operator_return_type(Operator p_operator, Type p_type_a, Type p_type_b); typedef void (*ValidatedOperatorEvaluator)(const Variant *left, const Variant *right, Variant *r_ret); static ValidatedOperatorEvaluator get_validated_operator_evaluator(Operator p_operator, Type p_type_a, Type p_type_b); #ifdef PTRCALL_ENABLED diff --git a/core/variant/variant_op.cpp b/core/variant/variant_op.cpp index 4704deac205..8e55c1d6cd1 100644 --- a/core/variant/variant_op.cpp +++ b/core/variant/variant_op.cpp @@ -2145,8 +2145,8 @@ static const char *_op_names[Variant::OP_MAX] = { "-", "*", "/", - "- (negation)", - "+ (positive)", + "-", + "+", "%", "<<", ">>", diff --git a/editor/doc_data.cpp b/editor/doc_data.cpp index 5cede65fa6a..67671597217 100644 --- a/editor/doc_data.cpp +++ b/editor/doc_data.cpp @@ -569,11 +569,61 @@ void DocData::generate(bool p_basic_types) { method_list.sort(); Variant::get_constructor_list(Variant::Type(i), &method_list); + for (int j = 0; j < Variant::OP_AND; j++) { //showing above 'and' is pretty confusing and there are a lot of variations + + for (int k = 0; k < Variant::VARIANT_MAX; k++) { + Variant::Type rt = Variant::get_operator_return_type(Variant::Operator(j), Variant::Type(i), Variant::Type(k)); + if (rt != Variant::NIL) { + //has operator + MethodInfo mi; + mi.name = "operator " + Variant::get_operator_name(Variant::Operator(j)); + mi.return_val.type = rt; + if (k != Variant::NIL) { + PropertyInfo arg; + arg.name = "right"; + arg.type = Variant::Type(k); + mi.arguments.push_back(arg); + } + method_list.push_back(mi); + } + } + } + + if (Variant::is_keyed(Variant::Type(i))) { + MethodInfo mi; + mi.name = "operator []"; + mi.return_val.type = Variant::NIL; + mi.return_val.usage = PROPERTY_USAGE_NIL_IS_VARIANT; + + PropertyInfo arg; + arg.name = "key"; + arg.type = Variant::NIL; + arg.usage = PROPERTY_USAGE_NIL_IS_VARIANT; + mi.arguments.push_back(arg); + + method_list.push_back(mi); + } else if (Variant::has_indexing(Variant::Type(i))) { + MethodInfo mi; + mi.name = "operator []"; + mi.return_val.type = Variant::get_indexed_element_type(Variant::Type(i)); + PropertyInfo arg; + arg.name = "index"; + arg.type = Variant::INT; + mi.arguments.push_back(arg); + + method_list.push_back(mi); + } + for (List::Element *E = method_list.front(); E; E = E->next()) { MethodInfo &mi = E->get(); MethodDoc method; method.name = mi.name; + if (method.name == cname) { + method.qualifiers = "constructor"; + } else if (method.name.begins_with("operator")) { + method.qualifiers = "operator"; + } for (int j = 0; j < mi.arguments.size(); j++) { PropertyInfo arginfo = mi.arguments[j];