feat: modules moved and engine moved to submodule
This commit is contained in:
parent
dfb5e645cd
commit
c33d2130cc
5136 changed files with 225275 additions and 64485 deletions
|
|
@ -59,8 +59,6 @@
|
|||
#include "editor/editor_paths.h"
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
///////////////////////////
|
||||
|
||||
GDScriptNativeClass::GDScriptNativeClass(const StringName &p_name) {
|
||||
|
|
@ -1123,7 +1121,7 @@ Error GDScript::load_source_code(const String &p_path) {
|
|||
w[len] = 0;
|
||||
|
||||
String s;
|
||||
if (s.parse_utf8((const char *)w, len) != OK) {
|
||||
if (s.append_utf8((const char *)w, len) != OK) {
|
||||
ERR_FAIL_V_MSG(ERR_INVALID_DATA, "Script '" + p_path + "' contains invalid unicode (UTF-8), so it was not loaded. Please ensure that scripts are saved in valid UTF-8 unicode.");
|
||||
}
|
||||
|
||||
|
|
@ -1625,6 +1623,27 @@ void GDScript::clear(ClearData *p_clear_data) {
|
|||
}
|
||||
}
|
||||
|
||||
void GDScript::cancel_pending_functions(bool warn) {
|
||||
MutexLock lock(GDScriptLanguage::get_singleton()->mutex);
|
||||
|
||||
while (SelfList<GDScriptFunctionState> *E = pending_func_states.first()) {
|
||||
// Order matters since clearing the stack may already cause
|
||||
// the GDScriptFunctionState to be destroyed and thus removed from the list.
|
||||
pending_func_states.remove(E);
|
||||
GDScriptFunctionState *state = E->self();
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (warn) {
|
||||
WARN_PRINT("Canceling suspended execution of \"" + state->get_readable_function() + "\" due to a script reload.");
|
||||
}
|
||||
#endif
|
||||
ObjectID state_id = state->get_instance_id();
|
||||
state->_clear_connections();
|
||||
if (ObjectDB::get_instance(state_id)) {
|
||||
state->_clear_stack();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GDScript::~GDScript() {
|
||||
if (destructing) {
|
||||
return;
|
||||
|
|
@ -1640,21 +1659,7 @@ GDScript::~GDScript() {
|
|||
|
||||
clear();
|
||||
|
||||
{
|
||||
MutexLock lock(GDScriptLanguage::get_singleton()->mutex);
|
||||
|
||||
while (SelfList<GDScriptFunctionState> *E = pending_func_states.first()) {
|
||||
// Order matters since clearing the stack may already cause
|
||||
// the GDScriptFunctionState to be destroyed and thus removed from the list.
|
||||
pending_func_states.remove(E);
|
||||
GDScriptFunctionState *state = E->self();
|
||||
ObjectID state_id = state->get_instance_id();
|
||||
state->_clear_connections();
|
||||
if (ObjectDB::get_instance(state_id)) {
|
||||
state->_clear_stack();
|
||||
}
|
||||
}
|
||||
}
|
||||
cancel_pending_functions(false);
|
||||
|
||||
{
|
||||
MutexLock lock(GDScriptLanguage::get_singleton()->mutex);
|
||||
|
|
@ -2249,10 +2254,10 @@ void GDScriptLanguage::init() {
|
|||
_add_global(StaticCString::create(CoreConstants::get_global_constant_name(i)), CoreConstants::get_global_constant_value(i));
|
||||
}
|
||||
|
||||
_add_global(StaticCString::create("PI"), Math_PI);
|
||||
_add_global(StaticCString::create("TAU"), Math_TAU);
|
||||
_add_global(StaticCString::create("INF"), INFINITY);
|
||||
_add_global(StaticCString::create("NAN"), NAN);
|
||||
_add_global(StaticCString::create("PI"), Math::PI);
|
||||
_add_global(StaticCString::create("TAU"), Math::TAU);
|
||||
_add_global(StaticCString::create("INF"), Math::INF);
|
||||
_add_global(StaticCString::create("NAN"), Math::NaN);
|
||||
|
||||
//populate native classes
|
||||
|
||||
|
|
@ -2699,8 +2704,7 @@ void GDScriptLanguage::reload_scripts(const Array &p_scripts, bool p_soft_reload
|
|||
}
|
||||
|
||||
void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_soft_reload) {
|
||||
Array scripts;
|
||||
scripts.push_back(p_script);
|
||||
Array scripts = { p_script };
|
||||
reload_scripts(scripts, p_soft_reload);
|
||||
}
|
||||
|
||||
|
|
@ -2849,7 +2853,7 @@ String GDScriptLanguage::get_global_class_name(const String &p_path, String *r_b
|
|||
while (subclass) {
|
||||
if (subclass->extends_used) {
|
||||
if (!subclass->extends_path.is_empty()) {
|
||||
if (subclass->extends.size() == 0) {
|
||||
if (subclass->extends.is_empty()) {
|
||||
get_global_class_name(subclass->extends_path, r_base_type);
|
||||
subclass = nullptr;
|
||||
break;
|
||||
|
|
@ -3066,6 +3070,62 @@ void ResourceFormatLoaderGDScript::get_dependencies(const String &p_path, List<S
|
|||
}
|
||||
}
|
||||
|
||||
void ResourceFormatLoaderGDScript::get_classes_used(const String &p_path, HashSet<StringName> *r_classes) {
|
||||
Ref<GDScript> scr = ResourceLoader::load(p_path);
|
||||
if (scr.is_null()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const String source = scr->get_source_code();
|
||||
GDScriptTokenizerText tokenizer;
|
||||
tokenizer.set_source_code(source);
|
||||
GDScriptTokenizer::Token current = tokenizer.scan();
|
||||
while (current.type != GDScriptTokenizer::Token::TK_EOF) {
|
||||
if (!current.is_identifier()) {
|
||||
current = tokenizer.scan();
|
||||
continue;
|
||||
}
|
||||
|
||||
int insert_idx = 0;
|
||||
for (int i = 0; i < current.start_line - 1; i++) {
|
||||
insert_idx = source.find("\n", insert_idx) + 1;
|
||||
}
|
||||
// Insert the "cursor" character, needed for the lookup to work.
|
||||
const String source_with_cursor = source.insert(insert_idx + current.start_column, String::chr(0xFFFF));
|
||||
|
||||
ScriptLanguage::LookupResult result;
|
||||
if (scr->get_language()->lookup_code(source_with_cursor, current.get_identifier(), p_path, nullptr, result) == OK) {
|
||||
if (!result.class_name.is_empty() && ClassDB::class_exists(result.class_name)) {
|
||||
r_classes->insert(result.class_name);
|
||||
}
|
||||
|
||||
if (result.type == ScriptLanguage::LOOKUP_RESULT_CLASS_PROPERTY) {
|
||||
PropertyInfo prop;
|
||||
if (ClassDB::get_property_info(result.class_name, result.class_member, &prop)) {
|
||||
if (!prop.class_name.is_empty() && ClassDB::class_exists(prop.class_name)) {
|
||||
r_classes->insert(prop.class_name);
|
||||
}
|
||||
if (!prop.hint_string.is_empty() && ClassDB::class_exists(prop.hint_string)) {
|
||||
r_classes->insert(prop.hint_string);
|
||||
}
|
||||
}
|
||||
} else if (result.type == ScriptLanguage::LOOKUP_RESULT_CLASS_METHOD) {
|
||||
MethodInfo met;
|
||||
if (ClassDB::get_method_info(result.class_name, result.class_member, &met)) {
|
||||
if (!met.return_val.class_name.is_empty() && ClassDB::class_exists(met.return_val.class_name)) {
|
||||
r_classes->insert(met.return_val.class_name);
|
||||
}
|
||||
if (!met.return_val.hint_string.is_empty() && ClassDB::class_exists(met.return_val.hint_string)) {
|
||||
r_classes->insert(met.return_val.hint_string);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
current = tokenizer.scan();
|
||||
}
|
||||
}
|
||||
|
||||
Error ResourceFormatSaverGDScript::save(const Ref<Resource> &p_resource, const String &p_path, uint32_t p_flags) {
|
||||
Ref<GDScript> sqscr = p_resource;
|
||||
ERR_FAIL_COND_V(sqscr.is_null(), ERR_INVALID_PARAMETER);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue