Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to get list of non objects (like String, Plane etc.) and its methods from GDScript #2344

Open
qarmin opened this issue Feb 24, 2021 · 1 comment

Comments

@qarmin
Copy link

qarmin commented Feb 24, 2021

Describe the project you are working on

Currently I'm working on Qarminer - automated tool(or maybe fuzzer is better name) to check every available functions with random parameters.

Describe the problem or limitation you are having in your project

Currently I don't see possibility to get from Godot list of all available classes which don't instance from Object like String, int, GDScript(global scope class) etc. and execute on them not known at compilation time functions.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

  1. Get list of functions of non objects like String
    If Godot will provide API to get list of such things, then I will be able to check every single class and its methods.
    This will allow to find some hidden bugs in engine.
    e.g.
ClassDB.get_non_object_methods_list(TYPE_STRING) # Should return method info just like get_methods_list()
  1. Instance non object with default values
    Something like this:
ClassDB.instance_non_object(TYPE_VECTOR2)

should do same thing as

Vector2()

This is not so important since it can be easily implemented manually with match/if/else

  1. Allow to execute on non object, not known at "compilation" time function
    For object I can use such code
get_random_object().call("show")

This will fail when object is type Timer and work properly when this will be Node2D
I cannot do this with e.g. Vector2

Vector2().call("size")

because they don't implement call function.
This will allow users to use exactly same code across different Godot version, without worrying about breaking changes
e.g.

var text : String = "allow"

if text.has_method("length"): # Godot 20 before breaking change
    print(text.call("length")
else: # Godot 21 after breaking change
    print(text.call("size"))

Example: https://github.com/qarmin/RegressionTestProject/blob/aa250456edea167c9f110cb85a2db2a4ddabbc47/Autoload/Autoload.gd#L27-L30

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

I think that ClassDB.get_class_list() should return all available classes.

If this enhancement will not be used often, can it be worked around with a few lines of script?

I don't think it would be a frequently used feature, but it would make it possible to attach it to CI, where it would automatically respond to API changes.

Manually created project needs constant changes when someone add/remove/modify functions

Is there a reason why this should be core and not an add-on in the asset library?

Yes, this are API changes which must be done in core.

@qarmin
Copy link
Author

qarmin commented Feb 25, 2021

@Calinou Calinou changed the title Allow to get list of non objects(like String, Plane etc.) and its methods from GDScript Allow to get list of non objects (like String, Plane etc.) and its methods from GDScript Feb 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants