Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/config/project_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1627,6 +1627,7 @@ ProjectSettings::ProjectSettings() {

GLOBAL_DEF(PropertyInfo(Variant::INT, "debug/settings/profiler/max_functions", PROPERTY_HINT_RANGE, "128,65535,1"), 16384);
GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "debug/settings/profiler/max_timestamp_query_elements", PROPERTY_HINT_RANGE, "256,65535,1"), 256);
GLOBAL_DEF("debug/gdscript/warnings/show_experimental_trait_warning", true); // @todo: remove experimental tag in 27.1-rc.1

GLOBAL_DEF(PropertyInfo(Variant::BOOL, "compression/formats/zstd/long_distance_matching"), Compression::zstd_long_distance_matching);
GLOBAL_DEF(PropertyInfo(Variant::INT, "compression/formats/zstd/compression_level", PROPERTY_HINT_RANGE, "1,22,1"), Compression::zstd_level);
Expand Down
10 changes: 6 additions & 4 deletions core/core_bind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1586,14 +1586,16 @@ namespace Special {
////// ClassDB //////

PackedStringArray ClassDB::get_class_list() const {
List<StringName> classes;
::ClassDB::get_class_list(&classes);
LocalVector<StringName> classes;
::ClassDB::get_class_list(classes);

PackedStringArray ret;
ret.resize(classes.size());
String *ptrw = ret.ptrw();
int idx = 0;
for (const StringName &E : classes) {
ret.set(idx++, E);
for (const StringName &cls : classes) {
ptrw[idx] = cls;
idx++;
}

return ret;
Expand Down
24 changes: 12 additions & 12 deletions core/debugger/remote_debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,25 +571,25 @@ void RemoteDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) {
input_vals.append(V);
}

List<StringName> native_types;
ClassDB::get_class_list(&native_types);
for (const StringName &E : native_types) {
if (!ClassDB::is_class_exposed(E) || !Engine::get_singleton()->has_singleton(E) || Engine::get_singleton()->is_singleton_editor_only(E)) {
LocalVector<StringName> native_types;
ClassDB::get_class_list(native_types);
for (const StringName &class_name : native_types) {
if (!ClassDB::is_class_exposed(class_name) || !Engine::get_singleton()->has_singleton(class_name) || Engine::get_singleton()->is_singleton_editor_only(class_name)) {
continue;
}

input_names.append(E);
input_vals.append(Engine::get_singleton()->get_singleton_object(E));
input_names.append(class_name);
input_vals.append(Engine::get_singleton()->get_singleton_object(class_name));
}

List<StringName> user_types;
ScriptServer::get_global_class_list(&user_types);
for (const StringName &S : user_types) {
String scr_path = ScriptServer::get_global_class_path(S);
LocalVector<StringName> user_types;
ScriptServer::get_global_class_list(user_types);
for (const StringName &class_name : user_types) {
String scr_path = ScriptServer::get_global_class_path(class_name);
Ref<Script> scr = ResourceLoader::load(scr_path, "Script");
ERR_CONTINUE_MSG(scr.is_null(), vformat(R"(Could not load the global class %s from resource path: "%s".)", S, scr_path));
ERR_CONTINUE_MSG(scr.is_null(), vformat(R"(Could not load the global class %s from resource path: "%s".)", class_name, scr_path));

input_names.append(S);
input_names.append(class_name);
input_vals.append(scr);
}

Expand Down
6 changes: 2 additions & 4 deletions core/extension/extension_api_dump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -931,11 +931,9 @@ Dictionary GDExtensionAPIDump::generate_extension_api(bool p_include_docs) {
// classes
Array classes;

List<StringName> class_list;
LocalVector<StringName> class_list;

ClassDB::get_class_list(&class_list);

class_list.sort_custom<StringName::AlphCompare>();
ClassDB::get_class_list(class_list);

for (const StringName &class_name : class_list) {
if (!ClassDB::is_class_exposed(class_name)) {
Expand Down
4 changes: 2 additions & 2 deletions core/io/resource_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1492,8 +1492,8 @@ void ResourceLoader::set_create_missing_resources_if_class_unavailable(bool p_en
void ResourceLoader::add_custom_loaders() {
String custom_loader_base_class = ResourceFormatLoader::get_class_static();

List<StringName> global_classes;
ScriptServer::get_global_class_list(&global_classes);
LocalVector<StringName> global_classes;
ScriptServer::get_global_class_list(global_classes);

for (const StringName &class_name : global_classes) {
StringName base_class = ScriptServer::get_global_class_native_base(class_name);
Expand Down
4 changes: 2 additions & 2 deletions core/io/resource_saver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ bool ResourceSaver::add_custom_resource_format_saver(const String &script_path)
void ResourceSaver::add_custom_savers() {
String custom_saver_base_class = ResourceFormatSaver::get_class_static();

List<StringName> global_classes;
ScriptServer::get_global_class_list(&global_classes);
LocalVector<StringName> global_classes;
ScriptServer::get_global_class_list(global_classes);

for (const StringName &class_name : global_classes) {
StringName base_class = ScriptServer::get_global_class_native_base(class_name);
Expand Down
33 changes: 26 additions & 7 deletions core/object/class_db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "core/config/engine.h"
#include "core/io/resource_loader.h"
#include "core/object/script_language.h"
#include "core/templates/sort_array.h"
#include "core/version.h"

#ifdef DEBUG_ENABLED
Expand Down Expand Up @@ -248,28 +249,46 @@ bool ClassDB::is_parent_class(const StringName &p_class, const StringName &p_inh
return _is_parent_class(p_class, p_inherits);
}

void ClassDB::get_class_list(List<StringName> *p_classes) {
// This function only sorts items added by this function.
// If `p_classes` is not empty before calling and a global sort is needed, caller must handle that separately.
void ClassDB::get_class_list(LocalVector<StringName> &p_classes) {
Locker::Lock lock(Locker::STATE_READ);

for (const KeyValue<StringName, ClassInfo> &E : classes) {
p_classes->push_back(E.key);
if (classes.is_empty()) {
return;
}

p_classes->sort_custom<StringName::AlphCompare>();
p_classes.reserve(p_classes.size() + classes.size());
for (const KeyValue<StringName, ClassInfo> &cls : classes) {
p_classes.push_back(cls.key);
}

SortArray<StringName, StringName::AlphCompare> sorter;
sorter.sort(&p_classes[p_classes.size() - classes.size()], classes.size());
}

#ifdef TOOLS_ENABLED
void ClassDB::get_extensions_class_list(List<StringName> *p_classes) {
// This function only sorts items added by this function.
// If `p_classes` is not empty before calling and a global sort is needed, caller must handle that separately.
void ClassDB::get_extensions_class_list(LocalVector<StringName> &p_classes) {
Locker::Lock lock(Locker::STATE_READ);

uint32_t original_size = p_classes.size();

for (const KeyValue<StringName, ClassInfo> &E : classes) {
if (E.value.api != API_EXTENSION && E.value.api != API_EDITOR_EXTENSION) {
continue;
}
p_classes->push_back(E.key);
p_classes.push_back(E.key);
}

p_classes->sort_custom<StringName::AlphCompare>();
// Nothing appended.
if (p_classes.size() == original_size) {
return;
}

SortArray<StringName, StringName::AlphCompare> sorter;
sorter.sort(&p_classes[original_size], p_classes.size() - original_size);
}

void ClassDB::get_extension_class_list(const Ref<GDExtension> &p_extension, List<StringName> *p_classes) {
Expand Down
4 changes: 2 additions & 2 deletions core/object/class_db.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,9 @@ class ClassDB {
T::register_custom_data_to_otdb();
}

static void get_class_list(List<StringName> *p_classes);
static void get_class_list(LocalVector<StringName> &p_classes);
#ifdef TOOLS_ENABLED
static void get_extensions_class_list(List<StringName> *p_classes);
static void get_extensions_class_list(LocalVector<StringName> &p_classes);
static void get_extension_class_list(const Ref<GDExtension> &p_extension, List<StringName> *p_classes);
static ObjectGDExtension *get_placeholder_extension(const StringName &p_class);
#endif
Expand Down
30 changes: 17 additions & 13 deletions core/object/script_language.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "core/debugger/engine_debugger.h"
#include "core/debugger/script_debugger.h"
#include "core/io/resource_loader.h"
#include "core/templates/sort_array.h"

ScriptLanguage *ScriptServer::_languages[MAX_LANGUAGES];
int ScriptServer::_language_count = 0;
Expand Down Expand Up @@ -515,15 +516,18 @@ bool ScriptServer::is_global_class_tool(const String &p_class) {
return global_classes[p_class].is_tool;
}

void ScriptServer::get_global_class_list(List<StringName> *r_global_classes) {
List<StringName> classes;
for (const KeyValue<StringName, GlobalScriptClass> &E : global_classes) {
classes.push_back(E.key);
// This function only sorts items added by this function.
// If `r_global_classes` is not empty before calling and a global sort is needed, caller must handle that separately.
void ScriptServer::get_global_class_list(LocalVector<StringName> &r_global_classes) {
if (global_classes.is_empty()) {
return;
}
classes.sort_custom<StringName::AlphCompare>();
for (const StringName &E : classes) {
r_global_classes->push_back(E);
r_global_classes.reserve(r_global_classes.size() + global_classes.size());
for (const KeyValue<StringName, GlobalScriptClass> &global_class : global_classes) {
r_global_classes.push_back(global_class.key);
}
SortArray<StringName, StringName::AlphCompare> sorter;
sorter.sort(&r_global_classes[r_global_classes.size() - global_classes.size()], global_classes.size());
}

void ScriptServer::save_global_classes() {
Expand All @@ -538,17 +542,17 @@ void ScriptServer::save_global_classes() {
class_icons[d["name"]] = d["icon"];
}

List<StringName> gc;
get_global_class_list(&gc);
LocalVector<StringName> gc;
get_global_class_list(gc);
Array gcarr;
for (const StringName &E : gc) {
const GlobalScriptClass &global_class = global_classes[E];
for (const StringName &class_name : gc) {
const GlobalScriptClass &global_class = global_classes[class_name];
Dictionary d;
d["class"] = E;
d["class"] = class_name;
d["language"] = global_class.language;
d["path"] = global_class.path;
d["base"] = global_class.base;
d["icon"] = class_icons.get(E, "");
d["icon"] = class_icons.get(class_name, "");
d["is_abstract"] = global_class.is_abstract;
d["is_tool"] = global_class.is_tool;
gcarr.push_back(d);
Expand Down
2 changes: 1 addition & 1 deletion core/object/script_language.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class ScriptServer {
static StringName get_global_class_native_base(const String &p_class);
static bool is_global_class_abstract(const String &p_class);
static bool is_global_class_tool(const String &p_class);
static void get_global_class_list(List<StringName> *r_global_classes);
static void get_global_class_list(LocalVector<StringName> &r_global_classes);
static void get_inheriters_list(const StringName &p_base_type, List<StringName> *r_classes);
static void save_global_classes();

Expand Down
9 changes: 9 additions & 0 deletions doc/classes/ProjectSettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,9 @@
<member name="debug/gdscript/warnings/exclude_addons" type="bool" setter="" getter="" default="true">
If [code]true[/code], scripts in the [code]res://addons[/code] folder will not generate warnings.
</member>
<member name="debug/gdscript/warnings/experimental_trait" type="int" setter="" getter="" default="1">
When set to [code]warn[/code] or [code]error[/code], produces a warning or an error respectively when using traits, as they are still experimental and may be subject to changes in future releases.
</member>
<member name="debug/gdscript/warnings/get_node_default_without_onready" type="int" setter="" getter="" default="2">
When set to [code]warn[/code] or [code]error[/code], produces a warning or an error respectively when [method Node.get_node] (or the shorthand [code]$[/code]) is used as default value of a class variable without the [code]@onready[/code] annotation.
</member>
Expand Down Expand Up @@ -611,6 +614,9 @@
<member name="debug/gdscript/warnings/shadowed_variable_base_class" type="int" setter="" getter="" default="1">
When set to [code]warn[/code] or [code]error[/code], produces a warning or an error respectively when a local variable or local constant shadows a member declared in a base class.
</member>
<member name="debug/gdscript/warnings/show_experimental_trait_warning" type="bool" setter="" getter="" default="true">
When set to [code]true[/code], the editor will generate warnings when using traits, as they are still experimental and may be subject to changes in future releases.
</member>
<member name="debug/gdscript/warnings/standalone_expression" type="int" setter="" getter="" default="1">
When set to [code]warn[/code] or [code]error[/code], produces a warning or an error respectively when calling an expression that may have no effect on the surrounding code, such as writing [code]2 + 2[/code] as a statement.
</member>
Expand Down Expand Up @@ -663,6 +669,9 @@
<member name="debug/gdscript/warnings/unused_signal" type="int" setter="" getter="" default="1">
When set to [code]warn[/code] or [code]error[/code], produces a warning or an error respectively when a signal is declared but never explicitly used in the class.
</member>
<member name="debug/gdscript/warnings/unused_static_overriding_trait" type="int" setter="" getter="" default="1">
When set to [code]warn[/code] or [code]error[/code], produces a warning or an error respectively when an overridden static member from a trait is not declared with the [code]static[/code] keyword.
</member>
<member name="debug/gdscript/warnings/unused_variable" type="int" setter="" getter="" default="1">
When set to [code]warn[/code] or [code]error[/code], produces a warning or an error respectively when a local variable is unused.
</member>
Expand Down
16 changes: 7 additions & 9 deletions editor/doc/doc_tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,23 +413,23 @@ void DocTools::generate(BitField<GenerateFlags> p_flags) {

// Add ClassDB-exposed classes.
{
List<StringName> classes;
LocalVector<StringName> classes;
if (p_flags.has_flag(GENERATE_FLAG_EXTENSION_CLASSES_ONLY)) {
ClassDB::get_extensions_class_list(&classes);
ClassDB::get_extensions_class_list(classes);
} else {
ClassDB::get_class_list(&classes);
ClassDB::get_class_list(classes);
// Move ProjectSettings, so that other classes can register properties there.
classes.move_to_back(classes.find("ProjectSettings"));
classes.erase("ProjectSettings");
classes.push_back("ProjectSettings");
}

bool skip_setter_getter_methods = true;

// Populate documentation data for each exposed class.
while (classes.size()) {
const String &name = classes.front()->get();
for (uint32_t classes_idx = 0; classes_idx < classes.size(); classes_idx++) {
const String &name = classes[classes_idx];
if (!ClassDB::is_class_exposed(name)) {
print_verbose(vformat("Class '%s' is not exposed, skipping.", name));
classes.pop_front();
continue;
}

Expand Down Expand Up @@ -734,8 +734,6 @@ void DocTools::generate(BitField<GenerateFlags> p_flags) {

c.theme_properties.sort();
}

classes.pop_front();
}
}

Expand Down
4 changes: 2 additions & 2 deletions editor/editor_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1053,8 +1053,8 @@ void EditorData::script_class_set_name(const String &p_path, const StringName &p
}

void EditorData::script_class_save_global_classes() {
List<StringName> global_classes;
ScriptServer::get_global_class_list(&global_classes);
LocalVector<StringName> global_classes;
ScriptServer::get_global_class_list(global_classes);
Array array_classes;
for (const StringName &class_name : global_classes) {
Dictionary d;
Expand Down
4 changes: 2 additions & 2 deletions editor/file_system/editor_file_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1657,9 +1657,9 @@ void EditorFileSystem::_thread_func_sources(void *_userdata) {
}

bool EditorFileSystem::_remove_invalid_global_class_names(const HashSet<String> &p_existing_class_names) {
List<StringName> global_classes;
LocalVector<StringName> global_classes;
bool must_save = false;
ScriptServer::get_global_class_list(&global_classes);
ScriptServer::get_global_class_list(global_classes);
for (const StringName &class_name : global_classes) {
if (!p_existing_class_names.has(class_name)) {
ScriptServer::remove_global_class(class_name);
Expand Down
6 changes: 3 additions & 3 deletions editor/gui/create_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ void CreateDialog::for_inherit() {
}

void CreateDialog::_fill_type_list() {
List<StringName> complete_type_list;
ClassDB::get_class_list(&complete_type_list);
ScriptServer::get_global_class_list(&complete_type_list);
LocalVector<StringName> complete_type_list;
ClassDB::get_class_list(complete_type_list);
ScriptServer::get_global_class_list(complete_type_list);

EditorData &ed = EditorNode::get_editor_data();
HashMap<String, DocData::ClassDoc> &class_docs_list = EditorHelp::get_doc_data()->class_list;
Expand Down
4 changes: 2 additions & 2 deletions editor/project_upgrade/project_converter_3_to_4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1193,8 +1193,8 @@ bool ProjectConverter3To4::test_array_names() {
// }
//}

List<StringName> classes_list;
ClassDB::get_class_list(&classes_list);
LocalVector<StringName> classes_list;
ClassDB::get_class_list(classes_list);
for (StringName &name_of_class : classes_list) {
List<MethodInfo> method_list;
ClassDB::get_method_list(name_of_class, &method_list, true);
Expand Down
16 changes: 8 additions & 8 deletions editor/script/script_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,18 +133,18 @@ void EditorStandardSyntaxHighlighter::_update_cache() {

/* Engine types. */
const Color type_color = EDITOR_GET("text_editor/theme/highlighting/engine_type_color");
List<StringName> types;
ClassDB::get_class_list(&types);
for (const StringName &E : types) {
highlighter->add_keyword_color(E, type_color);
LocalVector<StringName> types;
ClassDB::get_class_list(types);
for (const StringName &type : types) {
highlighter->add_keyword_color(type, type_color);
}

/* User types. */
const Color usertype_color = EDITOR_GET("text_editor/theme/highlighting/user_type_color");
List<StringName> global_classes;
ScriptServer::get_global_class_list(&global_classes);
for (const StringName &E : global_classes) {
highlighter->add_keyword_color(E, usertype_color);
LocalVector<StringName> global_classes;
ScriptServer::get_global_class_list(global_classes);
for (const StringName &class_name : global_classes) {
highlighter->add_keyword_color(class_name, usertype_color);
}

/* Autoloads. */
Expand Down
Loading
Loading