summaryrefslogtreecommitdiff
path: root/editor/doc_tools.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/doc_tools.cpp')
-rw-r--r--editor/doc_tools.cpp150
1 files changed, 71 insertions, 79 deletions
diff --git a/editor/doc_tools.cpp b/editor/doc_tools.cpp
index befafec6cb..c752d0d4fd 100644
--- a/editor/doc_tools.cpp
+++ b/editor/doc_tools.cpp
@@ -266,20 +266,20 @@ void DocTools::generate(bool p_basic_types) {
}
List<PropertyInfo>::Element *EO = own_properties.front();
- for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) {
+ for (const PropertyInfo &E : properties) {
bool inherited = EO == nullptr;
- if (EO && EO->get() == E->get()) {
+ if (EO && EO->get() == E) {
inherited = false;
EO = EO->next();
}
- if (E->get().usage & PROPERTY_USAGE_GROUP || E->get().usage & PROPERTY_USAGE_SUBGROUP || E->get().usage & PROPERTY_USAGE_CATEGORY || E->get().usage & PROPERTY_USAGE_INTERNAL) {
+ if (E.usage & PROPERTY_USAGE_GROUP || E.usage & PROPERTY_USAGE_SUBGROUP || E.usage & PROPERTY_USAGE_CATEGORY || E.usage & PROPERTY_USAGE_INTERNAL) {
continue;
}
DocData::PropertyDoc prop;
- prop.name = E->get().name;
+ prop.name = E.name;
prop.overridden = inherited;
@@ -288,20 +288,20 @@ void DocTools::generate(bool p_basic_types) {
if (name == "ProjectSettings") {
// Special case for project settings, so that settings are not taken from the current project's settings
- if (E->get().name == "script" || !ProjectSettings::get_singleton()->is_builtin_setting(E->get().name)) {
+ if (E.name == "script" || !ProjectSettings::get_singleton()->is_builtin_setting(E.name)) {
continue;
}
- if (E->get().usage & PROPERTY_USAGE_EDITOR) {
- if (!ProjectSettings::get_singleton()->get_ignore_value_in_docs(E->get().name)) {
- default_value = ProjectSettings::get_singleton()->property_get_revert(E->get().name);
+ if (E.usage & PROPERTY_USAGE_EDITOR) {
+ if (!ProjectSettings::get_singleton()->get_ignore_value_in_docs(E.name)) {
+ default_value = ProjectSettings::get_singleton()->property_get_revert(E.name);
default_value_valid = true;
}
}
} else {
- default_value = get_documentation_default_value(name, E->get().name, default_value_valid);
+ default_value = get_documentation_default_value(name, E.name, default_value_valid);
if (inherited) {
bool base_default_value_valid = false;
- Variant base_default_value = get_documentation_default_value(ClassDB::get_parent_class(name), E->get().name, base_default_value_valid);
+ Variant base_default_value = get_documentation_default_value(ClassDB::get_parent_class(name), E.name, base_default_value_valid);
if (!default_value_valid || !base_default_value_valid || default_value == base_default_value) {
continue;
}
@@ -309,13 +309,13 @@ void DocTools::generate(bool p_basic_types) {
}
//used to track uninitialized values using valgrind
- //print_line("getting default value for " + String(name) + "." + String(E->get().name));
+ //print_line("getting default value for " + String(name) + "." + String(E.name));
if (default_value_valid && default_value.get_type() != Variant::OBJECT) {
prop.default_value = default_value.get_construct_string().replace("\n", "");
}
- StringName setter = ClassDB::get_property_setter(name, E->get().name);
- StringName getter = ClassDB::get_property_getter(name, E->get().name);
+ StringName setter = ClassDB::get_property_setter(name, E.name);
+ StringName getter = ClassDB::get_property_getter(name, E.name);
prop.setter = setter;
prop.getter = getter;
@@ -353,10 +353,10 @@ void DocTools::generate(bool p_basic_types) {
}
if (!found_type) {
- if (E->get().type == Variant::OBJECT && E->get().hint == PROPERTY_HINT_RESOURCE_TYPE) {
- prop.type = E->get().hint_string;
+ if (E.type == Variant::OBJECT && E.hint == PROPERTY_HINT_RESOURCE_TYPE) {
+ prop.type = E.hint_string;
} else {
- prop.type = Variant::get_type_name(E->get().type);
+ prop.type = Variant::get_type_name(E.type);
}
}
@@ -367,62 +367,62 @@ void DocTools::generate(bool p_basic_types) {
ClassDB::get_method_list(name, &method_list, true);
method_list.sort();
- for (List<MethodInfo>::Element *E = method_list.front(); E; E = E->next()) {
- if (E->get().name == "" || (E->get().name[0] == '_' && !(E->get().flags & METHOD_FLAG_VIRTUAL))) {
+ for (const MethodInfo &E : method_list) {
+ if (E.name == "" || (E.name[0] == '_' && !(E.flags & METHOD_FLAG_VIRTUAL))) {
continue; //hidden, don't count
}
- if (skip_setter_getter_methods && setters_getters.has(E->get().name)) {
+ if (skip_setter_getter_methods && setters_getters.has(E.name)) {
// Don't skip parametric setters and getters, i.e. method which require
// one or more parameters to define what property should be set or retrieved.
// E.g. CPUParticles3D::set_param(Parameter param, float value).
- if (E->get().arguments.size() == 0 /* getter */ || (E->get().arguments.size() == 1 && E->get().return_val.type == Variant::NIL /* setter */)) {
+ if (E.arguments.size() == 0 /* getter */ || (E.arguments.size() == 1 && E.return_val.type == Variant::NIL /* setter */)) {
continue;
}
}
DocData::MethodDoc method;
- method.name = E->get().name;
+ method.name = E.name;
- if (E->get().flags & METHOD_FLAG_VIRTUAL) {
+ if (E.flags & METHOD_FLAG_VIRTUAL) {
method.qualifiers = "virtual";
}
- if (E->get().flags & METHOD_FLAG_CONST) {
+ if (E.flags & METHOD_FLAG_CONST) {
if (method.qualifiers != "") {
method.qualifiers += " ";
}
method.qualifiers += "const";
}
- if (E->get().flags & METHOD_FLAG_VARARG) {
+ if (E.flags & METHOD_FLAG_VARARG) {
if (method.qualifiers != "") {
method.qualifiers += " ";
}
method.qualifiers += "vararg";
}
- if (E->get().flags & METHOD_FLAG_STATIC) {
+ if (E.flags & METHOD_FLAG_STATIC) {
if (method.qualifiers != "") {
method.qualifiers += " ";
}
method.qualifiers += "static";
}
- for (int i = -1; i < E->get().arguments.size(); i++) {
+ for (int i = -1; i < E.arguments.size(); i++) {
if (i == -1) {
#ifdef DEBUG_METHODS_ENABLED
- DocData::return_doc_from_retinfo(method, E->get().return_val);
+ DocData::return_doc_from_retinfo(method, E.return_val);
#endif
} else {
- const PropertyInfo &arginfo = E->get().arguments[i];
+ const PropertyInfo &arginfo = E.arguments[i];
DocData::ArgumentDoc argument;
DocData::argument_doc_from_arginfo(argument, arginfo);
- int darg_idx = i - (E->get().arguments.size() - E->get().default_arguments.size());
+ int darg_idx = i - (E.arguments.size() - E.default_arguments.size());
if (darg_idx >= 0) {
- Variant default_arg = E->get().default_arguments[darg_idx];
+ Variant default_arg = E.default_arguments[darg_idx];
argument.default_value = default_arg.get_construct_string();
}
@@ -455,12 +455,12 @@ void DocTools::generate(bool p_basic_types) {
List<String> constant_list;
ClassDB::get_integer_constant_list(name, &constant_list, true);
- for (List<String>::Element *E = constant_list.front(); E; E = E->next()) {
+ for (const String &E : constant_list) {
DocData::ConstantDoc constant;
- constant.name = E->get();
- constant.value = itos(ClassDB::get_integer_constant(name, E->get()));
+ constant.name = E;
+ constant.value = itos(ClassDB::get_integer_constant(name, E));
constant.is_value_valid = true;
- constant.enumeration = ClassDB::get_integer_constant_enum(name, E->get());
+ constant.enumeration = ClassDB::get_integer_constant_enum(name, E);
c.constants.push_back(constant);
}
@@ -469,53 +469,53 @@ void DocTools::generate(bool p_basic_types) {
{
List<StringName> l;
Theme::get_default()->get_constant_list(cname, &l);
- for (List<StringName>::Element *E = l.front(); E; E = E->next()) {
+ for (const StringName &E : l) {
DocData::PropertyDoc pd;
- pd.name = E->get();
+ pd.name = E;
pd.type = "int";
- pd.default_value = itos(Theme::get_default()->get_constant(E->get(), cname));
+ pd.default_value = itos(Theme::get_default()->get_constant(E, cname));
c.theme_properties.push_back(pd);
}
l.clear();
Theme::get_default()->get_color_list(cname, &l);
- for (List<StringName>::Element *E = l.front(); E; E = E->next()) {
+ for (const StringName &E : l) {
DocData::PropertyDoc pd;
- pd.name = E->get();
+ pd.name = E;
pd.type = "Color";
- pd.default_value = Variant(Theme::get_default()->get_color(E->get(), cname)).get_construct_string();
+ pd.default_value = Variant(Theme::get_default()->get_color(E, cname)).get_construct_string();
c.theme_properties.push_back(pd);
}
l.clear();
Theme::get_default()->get_icon_list(cname, &l);
- for (List<StringName>::Element *E = l.front(); E; E = E->next()) {
+ for (const StringName &E : l) {
DocData::PropertyDoc pd;
- pd.name = E->get();
+ pd.name = E;
pd.type = "Texture2D";
c.theme_properties.push_back(pd);
}
l.clear();
Theme::get_default()->get_font_list(cname, &l);
- for (List<StringName>::Element *E = l.front(); E; E = E->next()) {
+ for (const StringName &E : l) {
DocData::PropertyDoc pd;
- pd.name = E->get();
+ pd.name = E;
pd.type = "Font";
c.theme_properties.push_back(pd);
}
l.clear();
Theme::get_default()->get_font_size_list(cname, &l);
- for (List<StringName>::Element *E = l.front(); E; E = E->next()) {
+ for (const StringName &E : l) {
DocData::PropertyDoc pd;
- pd.name = E->get();
+ pd.name = E;
pd.type = "int";
c.theme_properties.push_back(pd);
}
l.clear();
Theme::get_default()->get_stylebox_list(cname, &l);
- for (List<StringName>::Element *E = l.front(); E; E = E->next()) {
+ for (const StringName &E : l) {
DocData::PropertyDoc pd;
- pd.name = E->get();
+ pd.name = E;
pd.type = "StyleBox";
c.theme_properties.push_back(pd);
}
@@ -621,8 +621,7 @@ void DocTools::generate(bool p_basic_types) {
method_list.push_back(mi);
}
- for (List<MethodInfo>::Element *E = method_list.front(); E; E = E->next()) {
- MethodInfo &mi = E->get();
+ for (const MethodInfo &mi : method_list) {
DocData::MethodDoc method;
method.name = mi.name;
@@ -675,8 +674,7 @@ void DocTools::generate(bool p_basic_types) {
List<PropertyInfo> properties;
v.get_property_list(&properties);
- for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) {
- PropertyInfo pi = E->get();
+ for (const PropertyInfo &pi : properties) {
DocData::PropertyDoc property;
property.name = pi.name;
property.type = Variant::get_type_name(pi.type);
@@ -688,10 +686,10 @@ void DocTools::generate(bool p_basic_types) {
List<StringName> constants;
Variant::get_constants_for_type(Variant::Type(i), &constants);
- for (List<StringName>::Element *E = constants.front(); E; E = E->next()) {
+ for (const StringName &E : constants) {
DocData::ConstantDoc constant;
- constant.name = E->get();
- Variant value = Variant::get_constant_value(Variant::Type(i), E->get());
+ constant.name = E;
+ Variant value = Variant::get_constant_value(Variant::Type(i), E);
constant.value = value.get_type() == Variant::INT ? itos(value) : value.get_construct_string();
constant.is_value_valid = true;
c.constants.push_back(constant);
@@ -723,9 +721,8 @@ void DocTools::generate(bool p_basic_types) {
Engine::get_singleton()->get_singletons(&singletons);
//servers (this is kind of hackish)
- for (List<Engine::Singleton>::Element *E = singletons.front(); E; E = E->next()) {
+ for (const Engine::Singleton &s : singletons) {
DocData::PropertyDoc pd;
- Engine::Singleton &s = E->get();
if (!s.ptr) {
continue;
}
@@ -743,13 +740,13 @@ void DocTools::generate(bool p_basic_types) {
List<StringName> utility_functions;
Variant::get_utility_function_list(&utility_functions);
utility_functions.sort_custom<StringName::AlphCompare>();
- for (List<StringName>::Element *E = utility_functions.front(); E; E = E->next()) {
+ for (const StringName &E : utility_functions) {
DocData::MethodDoc md;
- md.name = E->get();
+ md.name = E;
//return
- if (Variant::has_utility_function_return_value(E->get())) {
+ if (Variant::has_utility_function_return_value(E)) {
PropertyInfo pi;
- pi.type = Variant::get_utility_function_return_type(E->get());
+ pi.type = Variant::get_utility_function_return_type(E);
if (pi.type == Variant::NIL) {
pi.usage = PROPERTY_USAGE_NIL_IS_VARIANT;
}
@@ -758,13 +755,13 @@ void DocTools::generate(bool p_basic_types) {
md.return_type = ad.type;
}
- if (Variant::is_utility_function_vararg(E->get())) {
+ if (Variant::is_utility_function_vararg(E)) {
md.qualifiers = "vararg";
} else {
- for (int i = 0; i < Variant::get_utility_function_argument_count(E->get()); i++) {
+ for (int i = 0; i < Variant::get_utility_function_argument_count(E); i++) {
PropertyInfo pi;
- pi.type = Variant::get_utility_function_argument_type(E->get(), i);
- pi.name = Variant::get_utility_function_argument_name(E->get(), i);
+ pi.type = Variant::get_utility_function_argument_type(E, i);
+ pi.name = Variant::get_utility_function_argument_name(E, i);
if (pi.type == Variant::NIL) {
pi.usage = PROPERTY_USAGE_NIL_IS_VARIANT;
}
@@ -793,8 +790,7 @@ void DocTools::generate(bool p_basic_types) {
List<MethodInfo> minfo;
lang->get_public_functions(&minfo);
- for (List<MethodInfo>::Element *E = minfo.front(); E; E = E->next()) {
- MethodInfo &mi = E->get();
+ for (const MethodInfo &mi : minfo) {
DocData::MethodDoc md;
md.name = mi.name;
@@ -813,7 +809,7 @@ void DocTools::generate(bool p_basic_types) {
int darg_idx = j - (mi.arguments.size() - mi.default_arguments.size());
if (darg_idx >= 0) {
- Variant default_arg = E->get().default_arguments[darg_idx];
+ Variant default_arg = mi.default_arguments[darg_idx];
ad.default_value = default_arg.get_construct_string();
}
@@ -827,10 +823,10 @@ void DocTools::generate(bool p_basic_types) {
List<Pair<String, Variant>> cinfo;
lang->get_public_constants(&cinfo);
- for (List<Pair<String, Variant>>::Element *E = cinfo.front(); E; E = E->next()) {
+ for (const Pair<String, Variant> &E : cinfo) {
DocData::ConstantDoc cd;
- cd.name = E->get().first;
- cd.value = E->get().second;
+ cd.name = E.first;
+ cd.value = E.second;
cd.is_value_valid = true;
c.constants.push_back(cd);
}
@@ -1212,8 +1208,7 @@ Error DocTools::save_classes(const String &p_default_path, const Map<String, Str
if (m.return_enum != String()) {
enum_text = " enum=\"" + m.return_enum + "\"";
}
- _write_string(f, 3, "<return type=\"" + m.return_type + "\"" + enum_text + ">");
- _write_string(f, 3, "</return>");
+ _write_string(f, 3, "<return type=\"" + m.return_type + "\"" + enum_text + " />");
}
for (int j = 0; j < m.arguments.size(); j++) {
@@ -1225,12 +1220,10 @@ Error DocTools::save_classes(const String &p_default_path, const Map<String, Str
}
if (a.default_value != "") {
- _write_string(f, 3, "<argument index=\"" + itos(j) + "\" name=\"" + a.name.xml_escape() + "\" type=\"" + a.type.xml_escape() + "\"" + enum_text + " default=\"" + a.default_value.xml_escape(true) + "\">");
+ _write_string(f, 3, "<argument index=\"" + itos(j) + "\" name=\"" + a.name.xml_escape() + "\" type=\"" + a.type.xml_escape() + "\"" + enum_text + " default=\"" + a.default_value.xml_escape(true) + "\" />");
} else {
- _write_string(f, 3, "<argument index=\"" + itos(j) + "\" name=\"" + a.name.xml_escape() + "\" type=\"" + a.type.xml_escape() + "\"" + enum_text + ">");
+ _write_string(f, 3, "<argument index=\"" + itos(j) + "\" name=\"" + a.name.xml_escape() + "\" type=\"" + a.type.xml_escape() + "\"" + enum_text + " />");
}
-
- _write_string(f, 3, "</argument>");
}
_write_string(f, 3, "<description>");
@@ -1278,8 +1271,7 @@ Error DocTools::save_classes(const String &p_default_path, const Map<String, Str
_write_string(f, 2, "<signal name=\"" + m.name + "\">");
for (int j = 0; j < m.arguments.size(); j++) {
const DocData::ArgumentDoc &a = m.arguments[j];
- _write_string(f, 3, "<argument index=\"" + itos(j) + "\" name=\"" + a.name.xml_escape() + "\" type=\"" + a.type.xml_escape() + "\">");
- _write_string(f, 3, "</argument>");
+ _write_string(f, 3, "<argument index=\"" + itos(j) + "\" name=\"" + a.name.xml_escape() + "\" type=\"" + a.type.xml_escape() + "\" />");
}
_write_string(f, 3, "<description>");