Merge pull request #111490 from HolonProduction/rm-base
Remove raw base pointer from `GDScript`
This commit is contained in:
@ -123,7 +123,7 @@ GDScriptFunction *GDScript::_super_constructor(GDScript *p_script) {
|
||||
if (likely(p_script->valid) && p_script->initializer) {
|
||||
return p_script->initializer;
|
||||
} else {
|
||||
GDScript *base_src = p_script->_base;
|
||||
GDScript *base_src = p_script->base.ptr();
|
||||
if (base_src != nullptr) {
|
||||
return _super_constructor(base_src);
|
||||
} else {
|
||||
@ -133,7 +133,7 @@ GDScriptFunction *GDScript::_super_constructor(GDScript *p_script) {
|
||||
}
|
||||
|
||||
void GDScript::_super_implicit_constructor(GDScript *p_script, GDScriptInstance *p_instance, Callable::CallError &r_error) {
|
||||
GDScript *base_src = p_script->_base;
|
||||
GDScript *base_src = p_script->base.ptr();
|
||||
if (base_src != nullptr) {
|
||||
_super_implicit_constructor(base_src, p_instance, r_error);
|
||||
if (r_error.error != Callable::CallError::CALL_OK) {
|
||||
@ -217,8 +217,8 @@ Variant GDScript::_new(const Variant **p_args, int p_argcount, Callable::CallErr
|
||||
Object *owner = nullptr;
|
||||
|
||||
GDScript *_baseptr = this;
|
||||
while (_baseptr->_base) {
|
||||
_baseptr = _baseptr->_base;
|
||||
while (_baseptr->base.ptr()) {
|
||||
_baseptr = _baseptr->base.ptr();
|
||||
}
|
||||
|
||||
ERR_FAIL_COND_V(_baseptr->native.is_null(), Variant());
|
||||
@ -258,11 +258,7 @@ bool GDScript::can_instantiate() const {
|
||||
}
|
||||
|
||||
Ref<Script> GDScript::get_base_script() const {
|
||||
if (_base) {
|
||||
return Ref<GDScript>(_base);
|
||||
} else {
|
||||
return Ref<Script>();
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
StringName GDScript::get_global_name() const {
|
||||
@ -304,7 +300,7 @@ void GDScript::_get_script_method_list(List<MethodInfo> *r_list, bool p_include_
|
||||
return;
|
||||
}
|
||||
|
||||
current = current->_base;
|
||||
current = current->base.ptr();
|
||||
}
|
||||
}
|
||||
|
||||
@ -347,7 +343,7 @@ void GDScript::_get_script_property_list(List<PropertyInfo> *r_list, bool p_incl
|
||||
}
|
||||
|
||||
props.clear();
|
||||
sptr = sptr->_base;
|
||||
sptr = sptr->base.ptr();
|
||||
}
|
||||
}
|
||||
|
||||
@ -407,8 +403,8 @@ ScriptInstance *GDScript::instance_create(Object *p_this) {
|
||||
ERR_FAIL_COND_V_MSG(!valid, nullptr, "Script is invalid!");
|
||||
|
||||
GDScript *top = this;
|
||||
while (top->_base) {
|
||||
top = top->_base;
|
||||
while (top->base.ptr()) {
|
||||
top = top->base.ptr();
|
||||
}
|
||||
|
||||
if (top->native.is_valid()) {
|
||||
@ -599,7 +595,6 @@ bool GDScript::_update_exports(bool *r_err, bool p_recursive_call, PlaceHolderSc
|
||||
base_cache->inheriters_cache.clear(); // to prevent future stackoverflows
|
||||
base_cache.unref();
|
||||
base.unref();
|
||||
_base = nullptr;
|
||||
ERR_FAIL_V_MSG(false, "Cyclic inheritance in script class.");
|
||||
}
|
||||
}
|
||||
@ -947,7 +942,7 @@ Variant GDScript::callp(const StringName &p_method, const Variant **p_args, int
|
||||
return E->value->call(nullptr, p_args, p_argcount, r_error);
|
||||
}
|
||||
}
|
||||
top = top->_base;
|
||||
top = top->base.ptr();
|
||||
}
|
||||
|
||||
//none found, regular
|
||||
@ -1005,7 +1000,7 @@ bool GDScript::_get(const StringName &p_name, Variant &r_ret) const {
|
||||
}
|
||||
}
|
||||
|
||||
top = top->_base;
|
||||
top = top->base.ptr();
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -1043,7 +1038,7 @@ bool GDScript::_set(const StringName &p_name, const Variant &p_value) {
|
||||
}
|
||||
}
|
||||
|
||||
top = top->_base;
|
||||
top = top->base.ptr();
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -1056,7 +1051,7 @@ void GDScript::_get_property_list(List<PropertyInfo> *p_properties) const {
|
||||
const GDScript *top = this;
|
||||
while (top) {
|
||||
classes.push_back(top);
|
||||
top = top->_base;
|
||||
top = top->base.ptr();
|
||||
}
|
||||
|
||||
for (const List<const GDScript *>::Element *E = classes.back(); E; E = E->prev()) {
|
||||
@ -1195,7 +1190,7 @@ bool GDScript::inherits_script(const Ref<Script> &p_script) const {
|
||||
if (s == p_script.ptr()) {
|
||||
return true;
|
||||
}
|
||||
s = s->_base;
|
||||
s = s->base.ptr();
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -1745,7 +1740,7 @@ bool GDScriptInstance::set(const StringName &p_name, const Variant &p_value) {
|
||||
}
|
||||
}
|
||||
|
||||
sptr = sptr->_base;
|
||||
sptr = sptr->base.ptr();
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -1832,7 +1827,7 @@ bool GDScriptInstance::get(const StringName &p_name, Variant &r_ret) const {
|
||||
}
|
||||
}
|
||||
}
|
||||
sptr = sptr->_base;
|
||||
sptr = sptr->base.ptr();
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -1869,7 +1864,7 @@ void GDScriptInstance::validate_property(PropertyInfo &p_property) const {
|
||||
}
|
||||
}
|
||||
}
|
||||
sptr = sptr->_base;
|
||||
sptr = sptr->base.ptr();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1949,7 +1944,7 @@ void GDScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const
|
||||
|
||||
props.clear();
|
||||
|
||||
sptr = sptr->_base;
|
||||
sptr = sptr->base.ptr();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1969,7 +1964,7 @@ bool GDScriptInstance::property_can_revert(const StringName &p_name) const {
|
||||
}
|
||||
}
|
||||
}
|
||||
sptr = sptr->_base;
|
||||
sptr = sptr->base.ptr();
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -1992,7 +1987,7 @@ bool GDScriptInstance::property_get_revert(const StringName &p_name, Variant &r_
|
||||
}
|
||||
}
|
||||
}
|
||||
sptr = sptr->_base;
|
||||
sptr = sptr->base.ptr();
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -2004,7 +1999,7 @@ void GDScriptInstance::get_method_list(List<MethodInfo> *p_list) const {
|
||||
for (const KeyValue<StringName, GDScriptFunction *> &E : sptr->member_functions) {
|
||||
p_list->push_back(E.value->get_method_info());
|
||||
}
|
||||
sptr = sptr->_base;
|
||||
sptr = sptr->base.ptr();
|
||||
}
|
||||
}
|
||||
|
||||
@ -2015,7 +2010,7 @@ bool GDScriptInstance::has_method(const StringName &p_method) const {
|
||||
if (E) {
|
||||
return true;
|
||||
}
|
||||
sptr = sptr->_base;
|
||||
sptr = sptr->base.ptr();
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -2031,7 +2026,7 @@ int GDScriptInstance::get_method_argument_count(const StringName &p_method, bool
|
||||
}
|
||||
return E->value->get_argument_count();
|
||||
}
|
||||
sptr = sptr->_base;
|
||||
sptr = sptr->base.ptr();
|
||||
}
|
||||
|
||||
if (r_is_valid) {
|
||||
@ -2042,8 +2037,8 @@ int GDScriptInstance::get_method_argument_count(const StringName &p_method, bool
|
||||
|
||||
void GDScriptInstance::_call_implicit_ready_recursively(GDScript *p_script) {
|
||||
// Call base class first.
|
||||
if (p_script->_base) {
|
||||
_call_implicit_ready_recursively(p_script->_base);
|
||||
if (p_script->base.ptr()) {
|
||||
_call_implicit_ready_recursively(p_script->base.ptr());
|
||||
}
|
||||
if (likely(p_script->valid) && p_script->implicit_ready) {
|
||||
Callable::CallError err;
|
||||
@ -2064,7 +2059,7 @@ Variant GDScriptInstance::callp(const StringName &p_method, const Variant **p_ar
|
||||
return E->value->call(this, p_args, p_argcount, r_error);
|
||||
}
|
||||
}
|
||||
sptr = sptr->_base;
|
||||
sptr = sptr->base.ptr();
|
||||
}
|
||||
|
||||
r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
|
||||
@ -2083,7 +2078,7 @@ void GDScriptInstance::notification(int p_notification, bool p_reversed) {
|
||||
|
||||
LocalVector<GDScript *> script_stack;
|
||||
uint32_t script_count = 0;
|
||||
for (GDScript *sptr = script.ptr(); sptr; sptr = sptr->_base, ++script_count) {
|
||||
for (GDScript *sptr = script.ptr(); sptr; sptr = sptr->base.ptr(), ++script_count) {
|
||||
script_stack.push_back(sptr);
|
||||
}
|
||||
|
||||
|
||||
@ -93,7 +93,6 @@ class GDScript : public Script {
|
||||
|
||||
Ref<GDScriptNativeClass> native;
|
||||
Ref<GDScript> base;
|
||||
GDScript *_base = nullptr; //fast pointer access
|
||||
GDScript *_owner = nullptr; //for subclasses
|
||||
|
||||
// Members are just indices to the instantiated script.
|
||||
|
||||
@ -59,7 +59,7 @@ bool GDScriptCompiler::_is_class_member_property(GDScript *owner, const StringNa
|
||||
if (scr->native.is_valid()) {
|
||||
nc = scr->native.ptr();
|
||||
}
|
||||
scr = scr->_base;
|
||||
scr = scr->base.ptr();
|
||||
}
|
||||
|
||||
ERR_FAIL_NULL_V(nc, false);
|
||||
@ -343,7 +343,7 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
|
||||
if (scr->native.is_valid()) {
|
||||
nc = scr->native.ptr();
|
||||
}
|
||||
scr = scr->_base;
|
||||
scr = scr->base.ptr();
|
||||
}
|
||||
|
||||
if (nc && (identifier == CoreStringName(free_) || ClassDB::has_signal(nc->get_name(), identifier) || ClassDB::has_method(nc->get_name(), identifier))) {
|
||||
@ -371,7 +371,7 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
|
||||
if (scr->native.is_valid()) {
|
||||
nc = scr->native.ptr();
|
||||
}
|
||||
scr = scr->_base;
|
||||
scr = scr->base.ptr();
|
||||
}
|
||||
|
||||
// Class C++ integer constant.
|
||||
@ -407,7 +407,7 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
|
||||
return temp;
|
||||
}
|
||||
}
|
||||
scr = scr->_base;
|
||||
scr = scr->base.ptr();
|
||||
}
|
||||
} break;
|
||||
|
||||
@ -1051,7 +1051,7 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
|
||||
static_var_data_type = minfo.data_type;
|
||||
break;
|
||||
}
|
||||
scr = scr->_base;
|
||||
scr = scr->base.ptr();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1320,7 +1320,7 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
|
||||
static_var_data_type = minfo.data_type;
|
||||
break;
|
||||
}
|
||||
scr = scr->_base;
|
||||
scr = scr->base.ptr();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2707,7 +2707,6 @@ Error GDScriptCompiler::_prepare_compilation(GDScript *p_script, const GDScriptP
|
||||
|
||||
p_script->native = Ref<GDScriptNativeClass>();
|
||||
p_script->base = Ref<GDScript>();
|
||||
p_script->_base = nullptr;
|
||||
p_script->members.clear();
|
||||
|
||||
// This makes possible to clear script constants and member_functions without heap-use-after-free errors.
|
||||
@ -2818,7 +2817,6 @@ Error GDScriptCompiler::_prepare_compilation(GDScript *p_script, const GDScriptP
|
||||
}
|
||||
|
||||
p_script->base = base;
|
||||
p_script->_base = base.ptr();
|
||||
p_script->member_indices = base->member_indices;
|
||||
} break;
|
||||
default: {
|
||||
|
||||
Reference in New Issue
Block a user