diff options
Diffstat (limited to 'core/script_language.cpp')
-rw-r--r-- | core/script_language.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/core/script_language.cpp b/core/script_language.cpp index 4a6f904f9d..cbe4681eca 100644 --- a/core/script_language.cpp +++ b/core/script_language.cpp @@ -30,6 +30,7 @@ #include "script_language.h" +#include "core/core_string_names.h" #include "core/project_settings.h" ScriptLanguage *ScriptServer::_languages[MAX_LANGUAGES]; @@ -49,6 +50,52 @@ void Script::_notification(int p_what) { } } +Variant Script::_get_property_default_value(const StringName &p_property) { + Variant ret; + get_property_default_value(p_property, ret); + return ret; +} + +Array Script::_get_script_property_list() { + Array ret; + List<PropertyInfo> list; + get_script_property_list(&list); + for (List<PropertyInfo>::Element *E = list.front(); E; E = E->next()) { + ret.append(E->get().operator Dictionary()); + } + return ret; +} + +Array Script::_get_script_method_list() { + Array ret; + List<MethodInfo> list; + get_script_method_list(&list); + for (List<MethodInfo>::Element *E = list.front(); E; E = E->next()) { + ret.append(E->get().operator Dictionary()); + } + return ret; +} + +Array Script::_get_script_signal_list() { + Array ret; + List<MethodInfo> list; + get_script_signal_list(&list); + for (List<MethodInfo>::Element *E = list.front(); E; E = E->next()) { + ret.append(E->get().operator Dictionary()); + } + return ret; +} + +Dictionary Script::_get_script_constant_map() { + Dictionary ret; + Map<StringName, Variant> map; + get_constants(&map); + for (Map<StringName, Variant>::Element *E = map.front(); E; E = E->next()) { + ret[E->key()] = E->value(); + } + return ret; +} + void Script::_bind_methods() { ClassDB::bind_method(D_METHOD("can_instance"), &Script::can_instance); @@ -63,6 +110,12 @@ void Script::_bind_methods() { ClassDB::bind_method(D_METHOD("has_script_signal", "signal_name"), &Script::has_script_signal); + ClassDB::bind_method(D_METHOD("get_script_property_list"), &Script::_get_script_property_list); + ClassDB::bind_method(D_METHOD("get_script_method_list"), &Script::_get_script_method_list); + ClassDB::bind_method(D_METHOD("get_script_signal_list"), &Script::_get_script_signal_list); + ClassDB::bind_method(D_METHOD("get_script_constant_map"), &Script::_get_script_constant_map); + ClassDB::bind_method(D_METHOD("get_property_default_value", "property"), &Script::_get_property_default_value); + ClassDB::bind_method(D_METHOD("is_tool"), &Script::is_tool); ADD_PROPERTY(PropertyInfo(Variant::STRING, "source_code", PROPERTY_HINT_NONE, "", 0), "set_source_code", "get_source_code"); @@ -165,6 +218,7 @@ void ScriptServer::global_classes_clear() { } void ScriptServer::add_global_class(const StringName &p_class, const StringName &p_base, const StringName &p_language, const String &p_path) { + ERR_FAIL_COND_MSG(p_class == p_base || (global_classes.has(p_base) && get_global_class_native_base(p_base) == p_class), "Cyclic inheritance in script class."); GlobalScriptClass g; g.language = p_language; g.path = p_path; |