aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/bind/core_bind.cpp2
-rw-r--r--core/image.cpp6
-rw-r--r--core/image.h1
-rw-r--r--core/io/marshalls.cpp4
-rw-r--r--core/io/resource_format_binary.cpp23
-rw-r--r--core/make_binders.py4
-rw-r--r--core/object.cpp6
-rw-r--r--core/object.h45
-rw-r--r--core/os/input_event.cpp77
-rw-r--r--core/os/input_event.h7
-rw-r--r--core/os/os.cpp2
-rw-r--r--core/ref_ptr.cpp2
-rw-r--r--core/reference.cpp2
-rw-r--r--core/reference.h12
-rw-r--r--core/undo_redo.cpp28
-rw-r--r--core/variant.cpp4
-rw-r--r--core/variant_parser.cpp2
17 files changed, 158 insertions, 69 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index 5f534f63a..7f4a83ed4 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -2354,7 +2354,7 @@ Variant _ClassDB::instance(const StringName &p_class) const {
if (!obj)
return Variant();
- Reference *r = obj->cast_to<Reference>();
+ Reference *r = Object::cast_to<Reference>(obj);
if (r) {
return REF(r);
} else {
diff --git a/core/image.cpp b/core/image.cpp
index 91572e44e..0f09fbc0c 100644
--- a/core/image.cpp
+++ b/core/image.cpp
@@ -343,6 +343,11 @@ int Image::get_height() const {
return height;
}
+Vector2 Image::get_size() const {
+
+ return Vector2(width, height);
+}
+
bool Image::has_mipmaps() const {
return mipmaps;
@@ -2215,6 +2220,7 @@ void Image::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_width"), &Image::get_width);
ClassDB::bind_method(D_METHOD("get_height"), &Image::get_height);
+ ClassDB::bind_method(D_METHOD("get_size"), &Image::get_size);
ClassDB::bind_method(D_METHOD("has_mipmaps"), &Image::has_mipmaps);
ClassDB::bind_method(D_METHOD("get_format"), &Image::get_format);
ClassDB::bind_method(D_METHOD("get_data"), &Image::get_data);
diff --git a/core/image.h b/core/image.h
index 7acc4744e..2d6103289 100644
--- a/core/image.h
+++ b/core/image.h
@@ -177,6 +177,7 @@ private:
public:
int get_width() const; ///< Get image width
int get_height() const; ///< Get image height
+ Vector2 get_size() const;
bool has_mipmaps() const;
int get_mipmap_count() const;
diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp
index e701a89c7..93002e544 100644
--- a/core/io/marshalls.cpp
+++ b/core/io/marshalls.cpp
@@ -463,8 +463,8 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
obj->set(str, value);
}
- if (obj->cast_to<Reference>()) {
- REF ref = REF(obj->cast_to<Reference>());
+ if (Object::cast_to<Reference>(obj)) {
+ REF ref = REF(Object::cast_to<Reference>(obj));
r_variant = ref;
} else {
r_variant = obj;
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index fd8928b8a..0977b03e2 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -28,12 +28,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "resource_format_binary.h"
-#include "image.h"
-#include "io/file_access_compressed.h"
-#include "io/marshalls.h"
-#include "os/dir_access.h"
-#include "project_settings.h"
-#include "version.h"
+
+#include "core/image.h"
+#include "core/io/file_access_compressed.h"
+#include "core/io/marshalls.h"
+#include "core/os/dir_access.h"
+#include "core/project_settings.h"
+#include "core/version.h"
+
//#define print_bl(m_what) print_line(m_what)
#define print_bl(m_what)
@@ -713,7 +715,7 @@ Error ResourceInteractiveLoaderBinary::poll() {
}
ERR_FAIL_COND_V(!obj, ERR_FILE_CORRUPT);
- Resource *r = obj->cast_to<Resource>();
+ Resource *r = Object::cast_to<Resource>(obj);
if (!r) {
error = ERR_FILE_CORRUPT;
memdelete(obj); //bye
@@ -1798,7 +1800,6 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p
}
ERR_FAIL_COND_V(err, err);
- FileAccessRef _fref(f);
relative_paths = p_flags & ResourceSaver::FLAG_RELATIVE_PATHS;
skip_editor = p_flags & ResourceSaver::FLAG_OMIT_EDITOR_PROPERTIES;
@@ -1810,7 +1811,6 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p
takeover_paths = false;
local_path = p_path.get_base_dir();
- //bin_meta_idx = get_string_index("__bin_meta__"); //is often used, so create
_find_resources(p_resource, true);
@@ -1836,7 +1836,6 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p
return ERR_CANT_CREATE;
}
- //f->store_32(saved_resources.size()+external_resources.size()); // load steps -not needed
save_unicode_string(p_resource->get_class());
uint64_t md_at = f->get_pos();
f->store_64(0); //offset to impoty metadata
@@ -1875,7 +1874,6 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p
f->store_32(strings.size()); //string table size
for (int i = 0; i < strings.size(); i++) {
- //print_bl("saving string: "+strings[i]);
save_unicode_string(strings[i]);
}
@@ -1944,9 +1942,8 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p
}
Vector<uint64_t> ofs_table;
- //int saved_idx=0;
- //now actually save the resources
+ //now actually save the resources
for (List<ResourceData>::Element *E = resources.front(); E; E = E->next()) {
ResourceData &rd = E->get();
diff --git a/core/make_binders.py b/core/make_binders.py
index 0252bb638..6468c029f 100644
--- a/core/make_binders.py
+++ b/core/make_binders.py
@@ -29,7 +29,7 @@ public:
virtual Variant call(Object* p_object,const Variant** p_args,int p_arg_count, Variant::CallError& r_error) {
- T *instance=p_object->cast_to<T>();
+ T *instance=Object::cast_to<T>(p_object);
r_error.error=Variant::CallError::CALL_OK;
#ifdef DEBUG_METHODS_ENABLED
@@ -57,7 +57,7 @@ public:
#ifdef PTRCALL_ENABLED
virtual void ptrcall(Object*p_object,const void** p_args,void *r_ret) {
- T *instance=p_object->cast_to<T>();
+ T *instance=Object::cast_to<T>(p_object);
$ifret PtrToArg<R>::encode( $ (instance->*method)($arg, PtrToArg<P@>::convert(p_args[@-1])$) $ifret ,r_ret)$ ;
}
#endif
diff --git a/core/object.cpp b/core/object.cpp
index 928e9bb97..cd084a0c4 100644
--- a/core/object.cpp
+++ b/core/object.cpp
@@ -654,7 +654,7 @@ void Object::call_multilevel(const StringName &p_method, const Variant **p_args,
if (p_method == CoreStringNames::get_singleton()->_free) {
#ifdef DEBUG_ENABLED
- if (cast_to<Reference>()) {
+ if (Object::cast_to<Reference>(this)) {
ERR_EXPLAIN("Can't 'free' a reference.");
ERR_FAIL();
return;
@@ -900,7 +900,7 @@ Variant Object::call(const StringName &p_method, const Variant **p_args, int p_a
r_error.error = Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
return Variant();
}
- if (cast_to<Reference>()) {
+ if (Object::cast_to<Reference>(this)) {
r_error.argument = 0;
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
ERR_EXPLAIN("Can't 'free' a reference.");
@@ -1472,7 +1472,7 @@ Error Object::connect(const StringName &p_signal, Object *p_to_object, const Str
Signal::Target target(p_to_object->get_instance_id(), p_to_method);
if (s->slot_map.has(target)) {
- ERR_EXPLAIN("Signal '" + p_signal + "'' already connected to given method '" + p_to_method + "' in that object.");
+ ERR_EXPLAIN("Signal '" + p_signal + "' is already connected to given method '" + p_to_method + "' in that object.");
ERR_FAIL_COND_V(s->slot_map.has(target), ERR_INVALID_PARAMETER);
}
diff --git a/core/object.h b/core/object.h
index 43d77ed49..746450ef6 100644
--- a/core/object.h
+++ b/core/object.h
@@ -185,6 +185,7 @@ struct MethodInfo {
uint32_t flags;
int id;
+ inline bool operator==(const MethodInfo &p_method) const { return id == p_method.id; }
inline bool operator<(const MethodInfo &p_method) const { return id == p_method.id ? (name < p_method.name) : (id < p_method.id); }
operator Dictionary() const;
@@ -558,46 +559,46 @@ public:
void add_change_receptor(Object *p_receptor);
void remove_change_receptor(Object *p_receptor);
-// TODO: ensure 'this' is never NULL since it's UB, but by now, avoid warning flood
-#ifdef __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wundefined-bool-conversion"
-#endif
-
template <class T>
- T *cast_to() {
-
+ static T *cast_to(Object *p_object) {
+#ifdef DEBUG_ENABLED
+ // TODO there are some legitimate reasons to pass NULL as p_object.
+ // we need to figure out how to deal with that in debug mode.
+ // This code will return NULL for a NULL input in release mode also.
+ ERR_FAIL_COND_V(p_object == NULL, NULL);
+#endif
#ifndef NO_SAFE_CAST
- return SAFE_CAST<T *>(this);
+ return dynamic_cast<T *>(p_object);
#else
- if (!this)
+ if (!p_object)
return NULL;
- if (is_class_ptr(T::get_class_ptr_static()))
- return static_cast<T *>(this);
+ if (p_object->is_class_ptr(T::get_class_ptr_static()))
+ return static_cast<T *>(p_object);
else
return NULL;
#endif
}
template <class T>
- const T *cast_to() const {
-
+ static const T *cast_to(const Object *p_object) {
+#ifdef DEBUG_ENABLED
+ // TODO there are some legitimate reasons to pass NULL as p_object.
+ // we need to figure out how to deal with that in debug mode.
+ // This code will return NULL for a NULL input in release mode also.
+ ERR_FAIL_COND_V(p_object == NULL, NULL);
+#endif
#ifndef NO_SAFE_CAST
- return SAFE_CAST<const T *>(this);
+ return dynamic_cast<const T *>(p_object);
#else
- if (!this)
+ if (!p_object)
return NULL;
- if (is_class_ptr(T::get_class_ptr_static()))
- return static_cast<const T *>(this);
+ if (p_object->is_class_ptr(T::get_class_ptr_static()))
+ return static_cast<const T *>(p_object);
else
return NULL;
#endif
}
-#ifdef __clang__
-#pragma clang diagnostic pop
-#endif
-
enum {
NOTIFICATION_POSTINITIALIZE = 0,
diff --git a/core/os/input_event.cpp b/core/os/input_event.cpp
index cb38eb67b..c5f787b6c 100644
--- a/core/os/input_event.cpp
+++ b/core/os/input_event.cpp
@@ -483,6 +483,38 @@ bool InputEventMouseButton::action_match(const Ref<InputEvent> &p_event) const {
return mb->button_index == button_index;
}
+String InputEventMouseButton::as_text() const {
+
+ String button_index_string = "";
+ switch (get_button_index()) {
+ case BUTTON_LEFT:
+ button_index_string = "BUTTON_LEFT";
+ break;
+ case BUTTON_RIGHT:
+ button_index_string = "BUTTON_RIGHT";
+ break;
+ case BUTTON_MIDDLE:
+ button_index_string = "BUTTON_MIDDLE";
+ break;
+ case BUTTON_WHEEL_UP:
+ button_index_string = "BUTTON_WHEEL_UP";
+ break;
+ case BUTTON_WHEEL_DOWN:
+ button_index_string = "BUTTON_WHEEL_DOWN";
+ break;
+ case BUTTON_WHEEL_LEFT:
+ button_index_string = "BUTTON_WHEEL_LEFT";
+ break;
+ case BUTTON_WHEEL_RIGHT:
+ button_index_string = "BUTTON_WHEEL_RIGHT";
+ break;
+ default:
+ button_index_string = itos(get_button_index());
+ break;
+ }
+ return "InputEventMouseButton : button_index=" + button_index_string + ", pressed=" + (pressed ? "true" : "false") + ", position=(" + String(get_position()) + "), button_mask=" + itos(get_button_mask()) + ", doubleclick=" + (doubleclick ? "true" : "false");
+}
+
void InputEventMouseButton::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_factor", "factor"), &InputEventMouseButton::set_factor);
@@ -559,6 +591,26 @@ Ref<InputEvent> InputEventMouseMotion::xformed_by(const Transform2D &p_xform, co
return mm;
}
+String InputEventMouseMotion::as_text() const {
+
+ String button_mask_string = "";
+ switch (get_button_mask()) {
+ case BUTTON_MASK_LEFT:
+ button_mask_string = "BUTTON_MASK_LEFT";
+ break;
+ case BUTTON_MASK_MIDDLE:
+ button_mask_string = "BUTTON_MASK_MIDDLE";
+ break;
+ case BUTTON_MASK_RIGHT:
+ button_mask_string = "BUTTON_MASK_RIGHT";
+ break;
+ default:
+ button_mask_string = itos(get_button_mask());
+ break;
+ }
+ return "InputEventMouseMotion : button_mask=" + button_mask_string + ", position=(" + String(get_position()) + "), relative=(" + String(get_relative()) + "), speed=(" + String(get_speed()) + ")";
+}
+
void InputEventMouseMotion::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_relative", "relative"), &InputEventMouseMotion::set_relative);
@@ -609,6 +661,11 @@ bool InputEventJoypadMotion::action_match(const Ref<InputEvent> &p_event) const
return (axis == jm->axis && (axis_value < 0) == (jm->axis_value < 0));
}
+String InputEventJoypadMotion::as_text() const {
+
+ return "InputEventJoypadMotion : axis=" + itos(axis) + ", axis_value=" + String(Variant(axis_value));
+}
+
void InputEventJoypadMotion::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_axis", "axis"), &InputEventJoypadMotion::set_axis);
@@ -665,6 +722,11 @@ bool InputEventJoypadButton::action_match(const Ref<InputEvent> &p_event) const
return button_index == jb->button_index;
}
+String InputEventJoypadButton::as_text() const {
+
+ return "InputEventJoypadButton : button_index=" + itos(button_index) + ", pressed=" + (pressed ? "true" : "false") + ", pressure=" + String(Variant(pressure));
+}
+
void InputEventJoypadButton::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_button_index", "button_index"), &InputEventJoypadButton::set_button_index);
@@ -730,6 +792,11 @@ Ref<InputEvent> InputEventScreenTouch::xformed_by(const Transform2D &p_xform, co
return st;
}
+String InputEventScreenTouch::as_text() const {
+
+ return "InputEventScreenTouch : index=" + itos(index) + ", pressed=" + (pressed ? "true" : "false") + ", position=(" + String(get_position()) + ")";
+}
+
void InputEventScreenTouch::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_index", "index"), &InputEventScreenTouch::set_index);
@@ -808,6 +875,11 @@ Ref<InputEvent> InputEventScreenDrag::xformed_by(const Transform2D &p_xform, con
return sd;
}
+String InputEventScreenDrag::as_text() const {
+
+ return "InputEventScreenDrag : index=" + itos(index) + ", position=(" + String(get_position()) + "), relative=(" + String(get_relative()) + "), speed=(" + String(get_speed()) + ")";
+}
+
void InputEventScreenDrag::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_index", "index"), &InputEventScreenDrag::set_index);
@@ -857,6 +929,11 @@ bool InputEventAction::is_action(const StringName &p_action) const {
return action == p_action;
}
+String InputEventAction::as_text() const {
+
+ return "InputEventAction : action=" + action + ", pressed=(" + (pressed ? "true" : "false");
+}
+
void InputEventAction::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_action", "action"), &InputEventAction::set_action);
diff --git a/core/os/input_event.h b/core/os/input_event.h
index d1fd7cc90..06d157b2b 100644
--- a/core/os/input_event.h
+++ b/core/os/input_event.h
@@ -307,6 +307,7 @@ public:
virtual bool action_match(const Ref<InputEvent> &p_event) const;
virtual bool is_action_type() const { return true; }
+ virtual String as_text() const;
InputEventMouseButton();
};
@@ -328,6 +329,7 @@ public:
Vector2 get_speed() const;
virtual Ref<InputEvent> xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const;
+ virtual String as_text() const;
InputEventMouseMotion();
};
@@ -352,6 +354,7 @@ public:
virtual bool action_match(const Ref<InputEvent> &p_event) const;
virtual bool is_action_type() const { return true; }
+ virtual String as_text() const;
InputEventJoypadMotion();
};
@@ -378,6 +381,7 @@ public:
virtual bool action_match(const Ref<InputEvent> &p_event) const;
virtual bool is_action_type() const { return true; }
+ virtual String as_text() const;
InputEventJoypadButton();
};
@@ -402,6 +406,7 @@ public:
virtual bool is_pressed() const;
virtual Ref<InputEvent> xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const;
+ virtual String as_text() const;
InputEventScreenTouch();
};
@@ -431,6 +436,7 @@ public:
Vector2 get_speed() const;
virtual Ref<InputEvent> xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const;
+ virtual String as_text() const;
InputEventScreenDrag();
};
@@ -455,6 +461,7 @@ public:
virtual bool is_action(const StringName &p_action) const;
virtual bool is_action_type() const { return true; }
+ virtual String as_text() const;
InputEventAction();
};
diff --git a/core/os/os.cpp b/core/os/os.cpp
index 3a06a3fa8..c49ab6f70 100644
--- a/core/os/os.cpp
+++ b/core/os/os.cpp
@@ -171,7 +171,7 @@ static FileAccess *_OSPRF = NULL;
static void _OS_printres(Object *p_obj) {
- Resource *res = p_obj->cast_to<Resource>();
+ Resource *res = Object::cast_to<Resource>(p_obj);
if (!res)
return;
diff --git a/core/ref_ptr.cpp b/core/ref_ptr.cpp
index c2128fd45..7bd852329 100644
--- a/core/ref_ptr.cpp
+++ b/core/ref_ptr.cpp
@@ -69,7 +69,7 @@ RID RefPtr::get_rid() const {
Ref<Reference> *ref = reinterpret_cast<Ref<Reference> *>(&data[0]);
if (ref->is_null())
return RID();
- Resource *res = (*ref)->cast_to<Resource>();
+ Resource *res = Object::cast_to<Resource>(ref->ptr());
if (res)
return res->get_rid();
return RID();
diff --git a/core/reference.cpp b/core/reference.cpp
index e9629ee7c..1380dbd56 100644
--- a/core/reference.cpp
+++ b/core/reference.cpp
@@ -98,7 +98,7 @@ Variant WeakRef::get_ref() const {
Object *obj = ObjectDB::get_instance(ref);
if (!obj)
return Variant();
- Reference *r = obj->cast_to<Reference>();
+ Reference *r = cast_to<Reference>(obj);
if (r) {
return REF(r);
diff --git a/core/reference.h b/core/reference.h
index 764c924cd..a8034a73c 100644
--- a/core/reference.h
+++ b/core/reference.h
@@ -180,7 +180,7 @@ public:
return;
}
Ref r;
- r.reference = refb->cast_to<T>();
+ r.reference = Object::cast_to<T>(refb);
ref(r);
r.reference = NULL;
}
@@ -194,7 +194,7 @@ public:
return;
}
Ref r;
- r.reference = refb->cast_to<T>();
+ r.reference = Object::cast_to<T>(refb);
ref(r);
r.reference = NULL;
}
@@ -209,7 +209,7 @@ public:
return;
}
Ref r;
- r.reference = refb->cast_to<T>();
+ r.reference = Object::cast_to<T>(refb);
ref(r);
r.reference = NULL;
}
@@ -230,7 +230,7 @@ public:
return;
}
Ref r;
- r.reference = refb->cast_to<T>();
+ r.reference = Object::cast_to<T>(refb);
ref(r);
r.reference = NULL;
}
@@ -254,7 +254,7 @@ public:
return;
}
Ref r;
- r.reference = refb->cast_to<T>();
+ r.reference = Object::cast_to<T>(refb);
ref(r);
r.reference = NULL;
}
@@ -269,7 +269,7 @@ public:
return;
}
Ref r;
- r.reference = refb->cast_to<T>();
+ r.reference = Object::cast_to<T>(refb);
ref(r);
r.reference = NULL;
}
diff --git a/core/undo_redo.cpp b/core/undo_redo.cpp
index bb7014639..00a468816 100644
--- a/core/undo_redo.cpp
+++ b/core/undo_redo.cpp
@@ -111,8 +111,8 @@ void UndoRedo::add_do_method(Object *p_object, const String &p_method, VARIANT_A
ERR_FAIL_COND((current_action + 1) >= actions.size());
Operation do_op;
do_op.object = p_object->get_instance_id();
- if (p_object->cast_to<Resource>())
- do_op.resref = Ref<Resource>(p_object->cast_to<Resource>());
+ if (Object::cast_to<Resource>(p_object))
+ do_op.resref = Ref<Resource>(Object::cast_to<Resource>(p_object));
do_op.type = Operation::TYPE_METHOD;
do_op.name = p_method;
@@ -135,8 +135,8 @@ void UndoRedo::add_undo_method(Object *p_object, const String &p_method, VARIANT
Operation undo_op;
undo_op.object = p_object->get_instance_id();
- if (p_object->cast_to<Resource>())
- undo_op.resref = Ref<Resource>(p_object->cast_to<Resource>());
+ if (Object::cast_to<Resource>(p_object))
+ undo_op.resref = Ref<Resource>(Object::cast_to<Resource>(p_object));
undo_op.type = Operation::TYPE_METHOD;
undo_op.name = p_method;
@@ -152,8 +152,8 @@ void UndoRedo::add_do_property(Object *p_object, const String &p_property, const
ERR_FAIL_COND((current_action + 1) >= actions.size());
Operation do_op;
do_op.object = p_object->get_instance_id();
- if (p_object->cast_to<Resource>())
- do_op.resref = Ref<Resource>(p_object->cast_to<Resource>());
+ if (Object::cast_to<Resource>(p_object))
+ do_op.resref = Ref<Resource>(Object::cast_to<Resource>(p_object));
do_op.type = Operation::TYPE_PROPERTY;
do_op.name = p_property;
@@ -171,8 +171,8 @@ void UndoRedo::add_undo_property(Object *p_object, const String &p_property, con
Operation undo_op;
undo_op.object = p_object->get_instance_id();
- if (p_object->cast_to<Resource>())
- undo_op.resref = Ref<Resource>(p_object->cast_to<Resource>());
+ if (Object::cast_to<Resource>(p_object))
+ undo_op.resref = Ref<Resource>(Object::cast_to<Resource>(p_object));
undo_op.type = Operation::TYPE_PROPERTY;
undo_op.name = p_property;
@@ -185,8 +185,8 @@ void UndoRedo::add_do_reference(Object *p_object) {
ERR_FAIL_COND((current_action + 1) >= actions.size());
Operation do_op;
do_op.object = p_object->get_instance_id();
- if (p_object->cast_to<Resource>())
- do_op.resref = Ref<Resource>(p_object->cast_to<Resource>());
+ if (Object::cast_to<Resource>(p_object))
+ do_op.resref = Ref<Resource>(Object::cast_to<Resource>(p_object));
do_op.type = Operation::TYPE_REFERENCE;
actions[current_action + 1].do_ops.push_back(do_op);
@@ -202,8 +202,8 @@ void UndoRedo::add_undo_reference(Object *p_object) {
Operation undo_op;
undo_op.object = p_object->get_instance_id();
- if (p_object->cast_to<Resource>())
- undo_op.resref = Ref<Resource>(p_object->cast_to<Resource>());
+ if (Object::cast_to<Resource>(p_object))
+ undo_op.resref = Ref<Resource>(Object::cast_to<Resource>(p_object));
undo_op.type = Operation::TYPE_REFERENCE;
actions[current_action + 1].undo_ops.push_back(undo_op);
@@ -270,7 +270,7 @@ void UndoRedo::_process_operation_list(List<Operation>::Element *E) {
obj->call(op.name, VARIANT_ARGS_FROM_ARRAY(op.args));
#ifdef TOOLS_ENABLED
- Resource *res = obj->cast_to<Resource>();
+ Resource *res = Object::cast_to<Resource>(obj);
if (res)
res->set_edited(true);
@@ -284,7 +284,7 @@ void UndoRedo::_process_operation_list(List<Operation>::Element *E) {
obj->set(op.name, op.args[0]);
#ifdef TOOLS_ENABLED
- Resource *res = obj->cast_to<Resource>();
+ Resource *res = Object::cast_to<Resource>(obj);
if (res)
res->set_edited(true);
#endif
diff --git a/core/variant.cpp b/core/variant.cpp
index 51c4b70bd..e6a69edd0 100644
--- a/core/variant.cpp
+++ b/core/variant.cpp
@@ -1764,14 +1764,14 @@ Variant::operator Object *() const {
Variant::operator Node *() const {
if (type == OBJECT)
- return _get_obj().obj ? _get_obj().obj->cast_to<Node>() : NULL;
+ return Object::cast_to<Node>(_get_obj().obj);
else
return NULL;
}
Variant::operator Control *() const {
if (type == OBJECT)
- return _get_obj().obj ? _get_obj().obj->cast_to<Control>() : NULL;
+ return Object::cast_to<Control>(_get_obj().obj);
else
return NULL;
}
diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp
index 5aa71f670..a1b168621 100644
--- a/core/variant_parser.cpp
+++ b/core/variant_parser.cpp
@@ -742,7 +742,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
return err;
if (token.type == TK_PARENTHESIS_CLOSE) {
- Reference *reference = obj->cast_to<Reference>();
+ Reference *reference = Object::cast_to<Reference>(obj);
if (reference) {
value = REF(reference);
} else {