diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/doc_data.cpp | 65 | ||||
-rw-r--r-- | editor/editor_plugin.cpp | 2 |
2 files changed, 62 insertions, 5 deletions
diff --git a/editor/doc_data.cpp b/editor/doc_data.cpp index 6767159721..78c601d4bc 100644 --- a/editor/doc_data.cpp +++ b/editor/doc_data.cpp @@ -569,12 +569,15 @@ 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 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 + if (rt != Variant::NIL) { // Has operator. + // Skip String % operator as it's registered separately for each Variant arg type, + // we'll add it manually below. + if (i == Variant::STRING && Variant::Operator(j) == Variant::OP_MODULE) { + continue; + } MethodInfo mi; mi.name = "operator " + Variant::get_operator_name(Variant::Operator(j)); mi.return_val.type = rt; @@ -589,6 +592,21 @@ void DocData::generate(bool p_basic_types) { } } + if (i == Variant::STRING) { + // We skipped % operator above, and we register it manually once for Variant arg type here. + MethodInfo mi; + mi.name = "operator %"; + mi.return_val.type = Variant::STRING; + + PropertyInfo arg; + arg.name = "right"; + arg.type = Variant::NIL; + arg.usage = PROPERTY_USAGE_NIL_IS_VARIANT; + mi.arguments.push_back(arg); + + method_list.push_back(mi); + } + if (Variant::is_keyed(Variant::Type(i))) { MethodInfo mi; mi.name = "operator []"; @@ -718,6 +736,43 @@ void DocData::generate(bool p_basic_types) { } c.properties.push_back(pd); } + + List<StringName> builtin_funcs; + Variant::get_builtin_function_list(&builtin_funcs); + builtin_funcs.sort_custom<StringName::AlphCompare>(); + for (List<StringName>::Element *E = builtin_funcs.front(); E; E = E->next()) { + MethodDoc md; + md.name = E->get(); + //return + if (Variant::has_builtin_func_return_value(E->get())) { + PropertyInfo pi; + pi.type = Variant::get_builtin_func_return_type(E->get()); + if (pi.type == Variant::NIL) { + pi.usage = PROPERTY_USAGE_NIL_IS_VARIANT; + } + DocData::ArgumentDoc ad; + argument_doc_from_arginfo(ad, pi); + md.return_type = ad.type; + } + + if (Variant::is_builtin_func_vararg(E->get())) { + md.qualifiers = "vararg"; + } else { + for (int i = 0; i < Variant::get_builtin_func_argument_count(E->get()); i++) { + PropertyInfo pi; + pi.type = Variant::get_builtin_func_argument_type(E->get(), i); + pi.name = Variant::get_builtin_func_argument_name(E->get(), i); + if (pi.type == Variant::NIL) { + pi.usage = PROPERTY_USAGE_NIL_IS_VARIANT; + } + DocData::ArgumentDoc ad; + argument_doc_from_arginfo(ad, pi); + md.arguments.push_back(ad); + } + } + + c.methods.push_back(md); + } } // Built-in script reference. @@ -1147,7 +1202,7 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri qualifiers += " qualifiers=\"" + m.qualifiers.xml_escape() + "\""; } - _write_string(f, 2, "<method name=\"" + m.name + "\"" + qualifiers + ">"); + _write_string(f, 2, "<method name=\"" + m.name.xml_escape() + "\"" + qualifiers + ">"); if (m.return_type != "") { String enum_text; diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index e330713cfb..49d8e58955 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -866,6 +866,8 @@ void EditorPlugin::_bind_methods() { ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_canvas_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control"))); ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_canvas_force_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control"))); ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_spatial_gui_input", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera3D"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"))); + ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_spatial_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control"))); + ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_spatial_force_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control"))); ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::STRING, "get_plugin_name")); ClassDB::add_virtual_method(get_class_static(), MethodInfo(PropertyInfo(Variant::OBJECT, "icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "get_plugin_icon")); ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "has_main_screen")); |