Rename instance()->instantiate() when it's a verb
This commit is contained in:
@@ -177,7 +177,7 @@
|
||||
[b]Note:[/b] Resource paths can be obtained by right clicking on a resource in the Assets Panel and choosing "Copy Path" or by dragging the file from the FileSystem dock into the script.
|
||||
[codeblock]
|
||||
# Instance a scene.
|
||||
var diamond = preload("res://diamond.tscn").instance()
|
||||
var diamond = preload("res://diamond.tscn").instantiate()
|
||||
[/codeblock]
|
||||
</description>
|
||||
</method>
|
||||
|
||||
@@ -622,6 +622,6 @@ void GDScriptSyntaxHighlighter::add_color_region(const String &p_start_key, cons
|
||||
|
||||
Ref<EditorSyntaxHighlighter> GDScriptSyntaxHighlighter::_create() const {
|
||||
Ref<GDScriptSyntaxHighlighter> syntax_highlighter;
|
||||
syntax_highlighter.instance();
|
||||
syntax_highlighter.instantiate();
|
||||
return syntax_highlighter;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ void GDScriptNativeClass::_bind_methods() {
|
||||
}
|
||||
|
||||
Variant GDScriptNativeClass::_new() {
|
||||
Object *o = instance();
|
||||
Object *o = instantiate();
|
||||
ERR_FAIL_COND_V_MSG(!o, Variant(), "Class type: '" + String(name) + "' is not instantiable.");
|
||||
|
||||
RefCounted *rc = Object::cast_to<RefCounted>(o);
|
||||
@@ -83,8 +83,8 @@ Variant GDScriptNativeClass::_new() {
|
||||
}
|
||||
}
|
||||
|
||||
Object *GDScriptNativeClass::instance() {
|
||||
return ClassDB::instance(name);
|
||||
Object *GDScriptNativeClass::instantiate() {
|
||||
return ClassDB::instantiate(name);
|
||||
}
|
||||
|
||||
void GDScript::_super_implicit_constructor(GDScript *p_script, GDScriptInstance *p_instance, Callable::CallError &r_error) {
|
||||
@@ -170,7 +170,7 @@ Variant GDScript::_new(const Variant **p_args, int p_argcount, Callable::CallErr
|
||||
|
||||
ERR_FAIL_COND_V(_baseptr->native.is_null(), Variant());
|
||||
if (_baseptr->native.ptr()) {
|
||||
owner = _baseptr->native->instance();
|
||||
owner = _baseptr->native->instantiate();
|
||||
} else {
|
||||
owner = memnew(RefCounted); //by default, no base means use reference
|
||||
}
|
||||
@@ -196,7 +196,7 @@ Variant GDScript::_new(const Variant **p_args, int p_argcount, Callable::CallErr
|
||||
}
|
||||
}
|
||||
|
||||
bool GDScript::can_instance() const {
|
||||
bool GDScript::can_instantiate() const {
|
||||
#ifdef TOOLS_ENABLED
|
||||
return valid && (tool || ScriptServer::is_scripting_enabled());
|
||||
#else
|
||||
@@ -346,9 +346,9 @@ ScriptInstance *GDScript::instance_create(Object *p_this) {
|
||||
if (top->native.is_valid()) {
|
||||
if (!ClassDB::is_parent_class(p_this->get_class_name(), top->native->get_name())) {
|
||||
if (EngineDebugger::is_active()) {
|
||||
GDScriptLanguage::get_singleton()->debug_break_parse(get_path(), 1, "Script inherits from native type '" + String(top->native->get_name()) + "', so it can't be instanced in object of type: '" + p_this->get_class() + "'");
|
||||
GDScriptLanguage::get_singleton()->debug_break_parse(get_path(), 1, "Script inherits from native type '" + String(top->native->get_name()) + "', so it can't be instantiated in object of type: '" + p_this->get_class() + "'");
|
||||
}
|
||||
ERR_FAIL_V_MSG(nullptr, "Script inherits from native type '" + String(top->native->get_name()) + "', so it can't be instanced in object of type '" + p_this->get_class() + "'" + ".");
|
||||
ERR_FAIL_V_MSG(nullptr, "Script inherits from native type '" + String(top->native->get_name()) + "', so it can't be instantiated in object of type '" + p_this->get_class() + "'" + ".");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2256,7 +2256,7 @@ RES ResourceFormatLoaderGDScript::load(const String &p_path, const String &p_ori
|
||||
|
||||
if (script.is_null()) {
|
||||
// Don't fail loading because of parsing error.
|
||||
script.instance();
|
||||
script.instantiate();
|
||||
}
|
||||
|
||||
if (r_error) {
|
||||
|
||||
@@ -51,7 +51,7 @@ protected:
|
||||
public:
|
||||
_FORCE_INLINE_ const StringName &get_name() const { return name; }
|
||||
Variant _new();
|
||||
Object *instance();
|
||||
Object *instantiate();
|
||||
GDScriptNativeClass(const StringName &p_name);
|
||||
};
|
||||
|
||||
@@ -80,10 +80,10 @@ class GDScript : public Script {
|
||||
GDScript *_base = nullptr; //fast pointer access
|
||||
GDScript *_owner = nullptr; //for subclasses
|
||||
|
||||
Set<StringName> members; //members are just indices to the instanced script.
|
||||
Set<StringName> members; //members are just indices to the instantiated script.
|
||||
Map<StringName, Variant> constants;
|
||||
Map<StringName, GDScriptFunction *> member_functions;
|
||||
Map<StringName, MemberInfo> member_indices; //members are just indices to the instanced script.
|
||||
Map<StringName, MemberInfo> member_indices; //members are just indices to the instantiated script.
|
||||
Map<StringName, Ref<GDScript>> subclasses;
|
||||
Map<StringName, Vector<StringName>> _signals;
|
||||
Vector<MultiplayerAPI::RPCConfig> rpc_functions;
|
||||
@@ -196,7 +196,7 @@ public:
|
||||
StringName debug_get_member_by_index(int p_idx) const;
|
||||
|
||||
Variant _new(const Variant **p_args, int p_argcount, Callable::CallError &r_error);
|
||||
virtual bool can_instance() const override;
|
||||
virtual bool can_instantiate() const override;
|
||||
|
||||
virtual Ref<Script> get_base_script() const override;
|
||||
|
||||
|
||||
@@ -229,7 +229,7 @@ Error GDScriptAnalyzer::resolve_inheritance(GDScriptParser::ClassNode *p_class,
|
||||
push_error(vformat(R"(Could not resolve super class inheritance from "%s".)", name), p_class);
|
||||
return err;
|
||||
}
|
||||
} else if (class_exists(name) && ClassDB::can_instance(GDScriptParser::get_real_class_name(name))) {
|
||||
} else if (class_exists(name) && ClassDB::can_instantiate(GDScriptParser::get_real_class_name(name))) {
|
||||
base.kind = GDScriptParser::DataType::NATIVE;
|
||||
base.native_type = name;
|
||||
} else {
|
||||
|
||||
@@ -134,7 +134,7 @@ Ref<GDScriptParserRef> GDScriptCache::get_parser(const String &p_path, GDScriptP
|
||||
return ref;
|
||||
}
|
||||
GDScriptParser *parser = memnew(GDScriptParser);
|
||||
ref.instance();
|
||||
ref.instantiate();
|
||||
ref->parser = parser;
|
||||
ref->path = p_path;
|
||||
singleton->parser_map[p_path] = ref.ptr();
|
||||
@@ -180,7 +180,7 @@ Ref<GDScript> GDScriptCache::get_shallow_script(const String &p_path, const Stri
|
||||
}
|
||||
|
||||
Ref<GDScript> script;
|
||||
script.instance();
|
||||
script.instantiate();
|
||||
script->set_path(p_path, true);
|
||||
script->set_script_path(p_path);
|
||||
script->load_source_code(p_path);
|
||||
|
||||
@@ -2587,7 +2587,7 @@ void GDScriptCompiler::_make_scripts(GDScript *p_script, const GDScriptParser::C
|
||||
if (orphan_subclass.is_valid()) {
|
||||
subclass = orphan_subclass;
|
||||
} else {
|
||||
subclass.instance();
|
||||
subclass.instantiate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ Ref<Script> GDScriptLanguage::get_template(const String &p_class_name, const Str
|
||||
_template = _get_processed_template(_template, p_base_class_name);
|
||||
|
||||
Ref<GDScript> script;
|
||||
script.instance();
|
||||
script.instantiate();
|
||||
script->set_source_code(_template);
|
||||
|
||||
return script;
|
||||
@@ -2900,7 +2900,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
|
||||
Variant v;
|
||||
REF v_ref;
|
||||
if (base_type.builtin_type == Variant::OBJECT) {
|
||||
v_ref.instance();
|
||||
v_ref.instantiate();
|
||||
v = v_ref;
|
||||
} else {
|
||||
Callable::CallError err;
|
||||
|
||||
@@ -293,10 +293,10 @@ bool GDScriptLanguageProtocol::is_goto_native_symbols_enabled() const {
|
||||
}
|
||||
|
||||
GDScriptLanguageProtocol::GDScriptLanguageProtocol() {
|
||||
server.instance();
|
||||
server.instantiate();
|
||||
singleton = this;
|
||||
workspace.instance();
|
||||
text_document.instance();
|
||||
workspace.instantiate();
|
||||
text_document.instantiate();
|
||||
set_scope("textDocument", text_document.ptr());
|
||||
set_scope("completionItem", text_document.ptr());
|
||||
set_scope("workspace", workspace.ptr());
|
||||
|
||||
@@ -426,7 +426,7 @@ Node *GDScriptWorkspace::_get_owner_scene_node(String p_path) {
|
||||
RES owner_res = ResourceLoader::load(owner_path);
|
||||
if (Object::cast_to<PackedScene>(owner_res.ptr())) {
|
||||
Ref<PackedScene> owner_packed_scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*owner_res));
|
||||
owner_scene_node = owner_packed_scene->instance();
|
||||
owner_scene_node = owner_packed_scene->instantiate();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,12 +92,12 @@ public:
|
||||
|
||||
static void _editor_init() {
|
||||
Ref<EditorExportGDScript> gd_export;
|
||||
gd_export.instance();
|
||||
gd_export.instantiate();
|
||||
EditorExport::get_singleton()->add_export_plugin(gd_export);
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
Ref<GDScriptSyntaxHighlighter> gdscript_syntax_highlighter;
|
||||
gdscript_syntax_highlighter.instance();
|
||||
gdscript_syntax_highlighter.instantiate();
|
||||
ScriptEditor::get_singleton()->register_syntax_highlighter(gdscript_syntax_highlighter);
|
||||
#endif
|
||||
|
||||
@@ -117,10 +117,10 @@ void register_gdscript_types() {
|
||||
script_language_gd = memnew(GDScriptLanguage);
|
||||
ScriptServer::register_language(script_language_gd);
|
||||
|
||||
resource_loader_gd.instance();
|
||||
resource_loader_gd.instantiate();
|
||||
ResourceLoader::add_resource_format_loader(resource_loader_gd);
|
||||
|
||||
resource_saver_gd.instance();
|
||||
resource_saver_gd.instantiate();
|
||||
ResourceSaver::add_resource_format_saver(resource_saver_gd);
|
||||
|
||||
gdscript_cache = memnew(GDScriptCache);
|
||||
@@ -128,7 +128,7 @@ void register_gdscript_types() {
|
||||
#ifdef TOOLS_ENABLED
|
||||
EditorNode::add_init_callback(_editor_init);
|
||||
|
||||
gdscript_translation_parser_plugin.instance();
|
||||
gdscript_translation_parser_plugin.instantiate();
|
||||
EditorTranslationParser::get_singleton()->add_parser(gdscript_translation_parser_plugin, EditorTranslationParser::STANDARD);
|
||||
#endif // TOOLS_ENABLED
|
||||
|
||||
|
||||
@@ -75,14 +75,14 @@ void init_autoloads() {
|
||||
Node *n = nullptr;
|
||||
if (res->is_class("PackedScene")) {
|
||||
Ref<PackedScene> ps = res;
|
||||
n = ps->instance();
|
||||
n = ps->instantiate();
|
||||
} else if (res->is_class("Script")) {
|
||||
Ref<Script> script_res = res;
|
||||
StringName ibt = script_res->get_instance_base_type();
|
||||
bool valid_type = ClassDB::is_parent_class(ibt, "Node");
|
||||
ERR_CONTINUE_MSG(!valid_type, "Script does not inherit a Node: " + info.path);
|
||||
|
||||
Object *obj = ClassDB::instance(ibt);
|
||||
Object *obj = ClassDB::instantiate(ibt);
|
||||
|
||||
ERR_CONTINUE_MSG(obj == nullptr,
|
||||
"Cannot instance script for autoload, expected 'Node' inheritance, got: " +
|
||||
@@ -420,7 +420,7 @@ GDScriptTest::TestResult GDScriptTest::execute_test_code(bool p_is_generating) {
|
||||
|
||||
// Create script.
|
||||
Ref<GDScript> script;
|
||||
script.instance();
|
||||
script.instantiate();
|
||||
script->set_path(source_file);
|
||||
script->set_script_path(source_file);
|
||||
err = script->load_source_code(source_file);
|
||||
@@ -510,7 +510,7 @@ GDScriptTest::TestResult GDScriptTest::execute_test_code(bool p_is_generating) {
|
||||
script->reload();
|
||||
|
||||
// Create object instance for test.
|
||||
Object *obj = ClassDB::instance(script->get_native()->get_name());
|
||||
Object *obj = ClassDB::instantiate(script->get_native()->get_name());
|
||||
Ref<RefCounted> obj_ref;
|
||||
if (obj->is_ref_counted()) {
|
||||
obj_ref = Ref<RefCounted>(Object::cast_to<RefCounted>(obj));
|
||||
|
||||
@@ -165,7 +165,7 @@ static void test_compiler(const String &p_code, const String &p_script_path, con
|
||||
|
||||
GDScriptCompiler compiler;
|
||||
Ref<GDScript> script;
|
||||
script.instance();
|
||||
script.instantiate();
|
||||
script->set_path(p_script_path);
|
||||
|
||||
err = compiler.compile(&parser, script.ptr(), false);
|
||||
|
||||
Reference in New Issue
Block a user