Mono: Fixes annotated signal loading in exported binaries
(cherry picked from commit 489c9adf03
)
This commit is contained in:
parent
4ac9932128
commit
64bcefb7cd
|
@ -745,10 +745,9 @@ void CSharpLanguage::reload_assemblies_if_needed(bool p_soft_reload) {
|
||||||
for (Map<Ref<CSharpScript>, Map<ObjectID, List<Pair<StringName, Variant> > > >::Element *E = to_reload.front(); E; E = E->next()) {
|
for (Map<Ref<CSharpScript>, Map<ObjectID, List<Pair<StringName, Variant> > > >::Element *E = to_reload.front(); E; E = E->next()) {
|
||||||
|
|
||||||
Ref<CSharpScript> scr = E->key();
|
Ref<CSharpScript> scr = E->key();
|
||||||
scr->signals_invalidated = true;
|
|
||||||
scr->exports_invalidated = true;
|
scr->exports_invalidated = true;
|
||||||
|
scr->signals_invalidated = true;
|
||||||
scr->reload(p_soft_reload);
|
scr->reload(p_soft_reload);
|
||||||
scr->update_signals();
|
|
||||||
scr->update_exports();
|
scr->update_exports();
|
||||||
|
|
||||||
//restore state if saved
|
//restore state if saved
|
||||||
|
@ -1573,21 +1572,18 @@ bool CSharpScript::_update_exports() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSharpScript::_update_signals() {
|
void CSharpScript::load_script_signals(GDMonoClass *p_class, GDMonoClass *p_native_class) {
|
||||||
if (!valid)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
bool changed = false;
|
// no need to load the script's signals more than once
|
||||||
|
if (!signals_invalidated) {
|
||||||
if (signals_invalidated) {
|
return;
|
||||||
signals_invalidated = false;
|
}
|
||||||
|
|
||||||
GDMonoClass *top = script_class;
|
|
||||||
|
|
||||||
|
// make sure this classes signals are empty when loading for the first time
|
||||||
_signals.clear();
|
_signals.clear();
|
||||||
changed = true; // TODO Do a real check for change
|
|
||||||
|
|
||||||
while (top && top != native) {
|
GDMonoClass *top = p_class;
|
||||||
|
while (top && top != p_native_class) {
|
||||||
const Vector<GDMonoClass *> &delegates = top->get_all_delegates();
|
const Vector<GDMonoClass *> &delegates = top->get_all_delegates();
|
||||||
for (int i = delegates.size() - 1; i >= 0; --i) {
|
for (int i = delegates.size() - 1; i >= 0; --i) {
|
||||||
Vector<Argument> parameters;
|
Vector<Argument> parameters;
|
||||||
|
@ -1601,9 +1597,8 @@ bool CSharpScript::_update_signals() {
|
||||||
|
|
||||||
top = top->get_parent_class();
|
top = top->get_parent_class();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return changed;
|
signals_invalidated = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSharpScript::_get_signal(GDMonoClass *p_class, GDMonoClass *p_delegate, Vector<Argument> ¶ms) {
|
bool CSharpScript::_get_signal(GDMonoClass *p_class, GDMonoClass *p_delegate, Vector<Argument> ¶ms) {
|
||||||
|
@ -1836,6 +1831,8 @@ Ref<CSharpScript> CSharpScript::create_for_managed_type(GDMonoClass *p_class) {
|
||||||
top = top->get_parent_class();
|
top = top->get_parent_class();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
script->load_script_signals(script->script_class, script->native);
|
||||||
|
|
||||||
return script;
|
return script;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1961,7 +1958,6 @@ ScriptInstance *CSharpScript::instance_create(Object *p_this) {
|
||||||
PlaceHolderScriptInstance *si = memnew(PlaceHolderScriptInstance(CSharpLanguage::get_singleton(), Ref<Script>(this), p_this));
|
PlaceHolderScriptInstance *si = memnew(PlaceHolderScriptInstance(CSharpLanguage::get_singleton(), Ref<Script>(this), p_this));
|
||||||
placeholders.insert(si);
|
placeholders.insert(si);
|
||||||
_update_exports();
|
_update_exports();
|
||||||
_update_signals();
|
|
||||||
return si;
|
return si;
|
||||||
#else
|
#else
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1980,8 +1976,6 @@ ScriptInstance *CSharpScript::instance_create(Object *p_this) {
|
||||||
ERR_FAIL_V(NULL);
|
ERR_FAIL_V(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
update_signals();
|
|
||||||
|
|
||||||
if (native) {
|
if (native) {
|
||||||
String native_name = native->get_name();
|
String native_name = native->get_name();
|
||||||
if (!ClassDB::is_parent_class(p_this->get_class_name(), native_name)) {
|
if (!ClassDB::is_parent_class(p_this->get_class_name(), native_name)) {
|
||||||
|
@ -2102,6 +2096,8 @@ Error CSharpScript::reload(bool p_keep_state) {
|
||||||
top->fetch_methods_with_godot_api_checks(native);
|
top->fetch_methods_with_godot_api_checks(native);
|
||||||
top = top->get_parent_class();
|
top = top->get_parent_class();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
load_script_signals(script_class, native);
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
|
@ -2161,10 +2157,6 @@ void CSharpScript::get_script_signal_list(List<MethodInfo> *r_signals) const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSharpScript::update_signals() {
|
|
||||||
_update_signals();
|
|
||||||
}
|
|
||||||
|
|
||||||
Ref<Script> CSharpScript::get_base_script() const {
|
Ref<Script> CSharpScript::get_base_script() const {
|
||||||
|
|
||||||
// TODO search in metadata file once we have it, not important any way?
|
// TODO search in metadata file once we have it, not important any way?
|
||||||
|
@ -2229,9 +2221,10 @@ CSharpScript::CSharpScript() :
|
||||||
#ifdef TOOLS_ENABLED
|
#ifdef TOOLS_ENABLED
|
||||||
source_changed_cache = false;
|
source_changed_cache = false;
|
||||||
exports_invalidated = true;
|
exports_invalidated = true;
|
||||||
signals_invalidated = true;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
signals_invalidated = true;
|
||||||
|
|
||||||
_resource_path_changed();
|
_resource_path_changed();
|
||||||
|
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
|
|
|
@ -111,7 +111,7 @@ class CSharpScript : public Script {
|
||||||
|
|
||||||
void _clear();
|
void _clear();
|
||||||
|
|
||||||
bool _update_signals();
|
void load_script_signals(GDMonoClass *p_class, GDMonoClass *p_native_class);
|
||||||
bool _get_signal(GDMonoClass *p_class, GDMonoClass *p_delegate, Vector<Argument> ¶ms);
|
bool _get_signal(GDMonoClass *p_class, GDMonoClass *p_delegate, Vector<Argument> ¶ms);
|
||||||
|
|
||||||
bool _update_exports();
|
bool _update_exports();
|
||||||
|
@ -149,7 +149,6 @@ public:
|
||||||
|
|
||||||
virtual bool has_script_signal(const StringName &p_signal) const;
|
virtual bool has_script_signal(const StringName &p_signal) const;
|
||||||
virtual void get_script_signal_list(List<MethodInfo> *r_signals) const;
|
virtual void get_script_signal_list(List<MethodInfo> *r_signals) const;
|
||||||
virtual void update_signals();
|
|
||||||
|
|
||||||
/* TODO */ virtual bool get_property_default_value(const StringName &p_property, Variant &r_value) const;
|
/* TODO */ virtual bool get_property_default_value(const StringName &p_property, Variant &r_value) const;
|
||||||
virtual void get_script_property_list(List<PropertyInfo> *p_list) const;
|
virtual void get_script_property_list(List<PropertyInfo> *p_list) const;
|
||||||
|
|
Loading…
Reference in New Issue