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

[Help wanted] Convert to GDExtension. #26

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Faless
Copy link
Contributor

@Faless Faless commented Aug 24, 2022

Some minimal initial work to start the project of converting the module to a GDExtension.

The PR does not yet properly compile, but the build system is there, you can try by just typing scons.

The godot-cpp submodule uses this branch: godotengine/godot-cpp#819 .

Bare minimum things to implement:

  • "ScriptInstanceExtension" via a GDNativeExtensionScriptInstanceInfo wrapper.
  • ScriptLanguageExtension methods name (prefix with _?).
  • ...

see (741f131).

I sadly don't have time to work on this right now, but I hope this PR can at least open a path to external contributions.

@Faless Faless marked this pull request as draft August 24, 2022 20:50
@Calinou Calinou added enhancement New feature or request help wanted Extra attention is needed labels Aug 24, 2022
@derkork
Copy link

derkork commented Aug 30, 2022

I am working on this, I already fixed about a million compile errors. Currently working on some final parts of the VisualScriptCustomNode and then there are some things left over which seem to be currently not exposed to GDExtensions:

  • there seems to be no way to access the ScriptDebugger from a GDExtension (e.g. EngineDebugger::get_script_debugger) is missing.
  • godot::Callable::CallError does not seem to be available for a GDExtension
  • godot::MultiplayerAPI::RPCMode does not seem to be available for a GDExtension
  • also ScriptServer is missing, so the extension cannot register its custom language

I am pretty new to this so I wonder how the workflow is. Should I open Tickets in godot-cpp for these or make pull requests in godot-cpp? Or is this not supposed to be exposed for GDExtensions - in which case I would need to know what is the intended replacement for these facilities.

@Faless
Copy link
Contributor Author

Faless commented Aug 30, 2022

godot::MultiplayerAPI::RPCMode does not seem to be available for a GDExtension

That's defined in gen/include/godot_cpp/classes/multiplayer_api.hpp

also ScriptServer is missing, so the extension cannot register its custom language

I think it can be registered via: Engine::get_singleton()->register_script_language(language);

  • there seems to be no way to access the ScriptDebugger from a GDExtension (e.g. EngineDebugger::get_script_debugger) is missing.

Yeah, you can access the debugger but not the script-specific part, I don't think that's required to be able to implement the language (only for it to support debugging), but it's something that will need to look into at some point.

  • godot::Callable::CallError does not seem to be available for a GDExtension

Yeah, I think those will have to be exposed to GDExtension so proper call error handling can be implemented, at least knowing if the callable call has succeeded.

Should I open Tickets in godot-cpp for these or make pull requests in godot-cpp?

Both are fine, if in doubt open a ticket or ask on the contributor chat.

@nathanfranke
Copy link
Contributor

nathanfranke commented Sep 8, 2022

Those wanting to do this, feel free to start with this template: https://github.com/nathanfranke/gdextension

This isn't endorsed by Godot, but it is licensed as unlicense/public domain so no copyright troubles.

(P.S., can a similar template be hosted at godotengine/gdextension?)

Edit: Oh, I didn't realize this was a PR, so I guess the first step is already done 😃

@derkork
Copy link

derkork commented Sep 20, 2022

My current progress is in https://github.com/derkork/godot-visual-script/tree/spike/extension . It is still quite a long way to go, as godot-cpp is not exposing quite a few engine functions/classes that the VisualScript module uses. I'll report these in godot-cpp one by one as I encounter them.

I don't think this is a particularly efficient way of doing things, though as every missing thing first needs to be added in godot-cpp, e.g. a PR needs to be made and reviewed and eventually the changes will be in. This can take quite a while during which I am basically blocked. In some cases I also have resorted to copy/paste from the engine source code (in hacks.cpp) to get some progress, but I will eventually need to clean this up.

I am very new to this so I probably am doing things the wrong way. If someone more experienced could give me a few tips on how this can be done more efficiently, I'd greatly appreciate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants