You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Use type information to enable GDScript introspection
This makes the Script API provide accurate information when requesting property or method info.
This commit is contained in:
@@ -220,16 +220,14 @@ void GDScript::_placeholder_erased(PlaceHolderScriptInstance *p_placeholder) {
|
||||
void GDScript::get_script_method_list(List<MethodInfo> *p_list) const {
|
||||
|
||||
for (const Map<StringName, GDScriptFunction *>::Element *E = member_functions.front(); E; E = E->next()) {
|
||||
GDScriptFunction *func = E->get();
|
||||
MethodInfo mi;
|
||||
mi.name = E->key();
|
||||
for (int i = 0; i < E->get()->get_argument_count(); i++) {
|
||||
PropertyInfo arg;
|
||||
arg.type = Variant::NIL; //variant
|
||||
arg.name = E->get()->get_argument_name(i);
|
||||
mi.arguments.push_back(arg);
|
||||
for (int i = 0; i < func->get_argument_count(); i++) {
|
||||
mi.arguments.push_back(func->get_argument_type(i));
|
||||
}
|
||||
|
||||
mi.return_val.name = "Variant";
|
||||
mi.return_val = func->get_return_type();
|
||||
p_list->push_back(mi);
|
||||
}
|
||||
}
|
||||
@@ -277,16 +275,14 @@ MethodInfo GDScript::get_method_info(const StringName &p_method) const {
|
||||
if (!E)
|
||||
return MethodInfo();
|
||||
|
||||
GDScriptFunction *func = E->get();
|
||||
MethodInfo mi;
|
||||
mi.name = E->key();
|
||||
for (int i = 0; i < E->get()->get_argument_count(); i++) {
|
||||
PropertyInfo arg;
|
||||
arg.type = Variant::NIL; //variant
|
||||
arg.name = E->get()->get_argument_name(i);
|
||||
mi.arguments.push_back(arg);
|
||||
for (int i = 0; i < func->get_argument_count(); i++) {
|
||||
mi.arguments.push_back(func->get_argument_type(i));
|
||||
}
|
||||
|
||||
mi.return_val.name = "Variant";
|
||||
mi.return_val = func->get_return_type();
|
||||
return mi;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user