-
-
Notifications
You must be signed in to change notification settings - Fork 634
[DRAFT] Add ScriptInstance
class which mimicks the API of Godot's internal ScriptInstance
class
#1544
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
base: master
Are you sure you want to change the base?
Conversation
b8ecc3d
to
11f8c4c
Compare
We discussed this PR at the last GDExtension meetup, and decided that it'd be best for I've updated this PR with everything that I think we need to do in order to do that, however, I still haven't had a chance to actually test it. So, leaving as a draft until I do. |
649b5ff
to
00c42a5
Compare
Do you think it is possible to add the same for ScriptInstancePlaceholder in this PR ? |
Yes, I think we could do a similar thing with This one has already been sitting here for ~9 months because it's gotten insufficient testing. Adding a new thing means even more things to test :-) If you had time to help test this PR, that would be much appreciated! |
5bf7efc
to
cf248a0
Compare
I've made some updates (a few of which were discussed on RocketChat):
|
43c5844
to
70f584e
Compare
ScriptInstanceExtension
class which mimicks the API of Godot's internal ScriptInstance
classScriptInstance
class which mimicks the API of Godot's internal ScriptInstance
class
70f584e
to
59bd75f
Compare
…`ScriptInstance` class
59bd75f
to
2e40d13
Compare
I've added an implementation of |
Background
Godot's internal
ScriptInstance
class (which is used in implementing scripting languages, like GDScript) isn't exposed the normal way, because we don't want scripts (ex a user script written in GDScript) to be able to directly interact with it.Instead, GDExtensions get a special API from
gdextension_interface.h
to create script instances, allowing GDExtensions to provide new scripting languages for Godot.However, working directly with that C API from C++ isn't ideal. And it also means big differences between GDExtensions and modules.
A number of extension projects have made their own C++ wrapper classes over this API to make life easier:
Given that this is something frequently done, I personally think it makes sense to have a wrapper in godot-cpp, so each project doesn't need to recreate it.
Implementation
This PR has the implementation I used in 'godot-gravity-lang', updated for the latest
gdextension_interface.h
, but I haven't re-tested it.The main thing I don't like about it, is that it doesn't exactly mimick the API ofScriptInstance
because it uses some types fromgdextension_interface.h
, rather than the equivalent Godot types (most of which also exist in godot-cpp).The reason for this is that we'd need to copy data back and forth between the Godot types andgdextension_interface.h
types, but script instances need to aim to be fairly performant. However, complete API compatibility may be worth it? It's something we'll need to discuss.UPDATE: We discussed and decided that it was more important to mimick the Godot API as much as possible, and not worry about the performance of copying data in some cases, so the PR has been updated to reflect that.
Making a DRAFT for now so that we can discuss whether or not we want this in godot-cpp, and if this implementation makes sense.