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

Expose ClassDB.get_api_type() for better GDExtension interoperability with non-GDScript languages #9526

Closed
ZerxZ opened this issue Apr 15, 2024 · 2 comments · Fixed by godotengine/godot#90703
Milestone

Comments

@ZerxZ
Copy link

ZerxZ commented Apr 15, 2024

Describe the project you are working on

GDExtension is a great plugin system.
However, the current implementation of GDExtension as a plugin doesn't effectively communicate with languages other than GDScript (including other GDExtensions and C#).
We aim to expose the ‘get_api_type’ method of ClassDB to allow developers to enumerate the types provided by GDExtension and generate corresponding bindings for other languages.

Describe the problem or limitation you are having in your project

Currently it is almost impossible to easily obatin a list of currently activated GDExtension types from the ClassDB API.

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

After exposing this method, the developer may use this API to fillter out the GDExtension types (instead of maintaining a list of hard-coded editor types).

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

public static string[] GetGDExtensionTypes(bool includeEditorTypes = false)
    {
        var classList = ClassDB.GetClassList();
        var hash      = new HashSet<string>();
        foreach (var className in classList)
        {
            var apiType = ClassDB.GetApiType(className);
            if (apiType == ClassDB.ApiType.ApiExtesion)
            {
                hash.Add(className);
            }
            if (!includeEditorTypes)
            {
                continue;
            }
            if (apiType == ClassDB.ApiType.ApiEditorExtesion)
            {
                hash.Add(className);
            }
        }
        return hash.ToArray();
    }

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

This can be achieve by manually record all Godot builtin types, and GodotTools builtin types by hand, for each Editor Release, which is neither easy nor sustainable for a wrapper generator.

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

It is impossible to achieve the descirbed need without changing the Core.

@ZerxZ
Copy link
Author

ZerxZ commented Apr 15, 2024

@Calinou Calinou changed the title public Api ClassDB Methods ClassDB::get_api_type in BindMethods Expose ClassDB.get_api_type() for better GDExtension interoperability with non-GDScript languages Apr 15, 2024
@akien-mga
Copy link
Member

Implemented by godotengine/godot#90703.

@akien-mga akien-mga added this to the 4.4 milestone Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants