Extract ScriptInstance
into its own file to simplify includes
#81388
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Two issues
First of all, every time we want to use
GDVIRTUAL*
macros, we need to include two files:gdvirtual.gen.inc
andscript_language.h
. The only reason for the second file, as far as I can see, is because macros need a definition forScriptInstance
.ScriptInstance
is a plain C++ class, so not only is the extra inclusion annoying, it's also excessive.Second, we can't use
GDVIRTUAL*
macros inResource
. I think this is because of the circular dependency between it and the contents ofscript_language.h
, which in turn tries to includeResource
. At least, that's the problem that is immediately obvious, but there might be some other limitations, since @reduz believed thatResources
can't useGDVIRTUAL
for some reason (see #67080).Solution
So I tried to divorce
ScriptInstance
from the rest ofscript_language.h
, to simplify the includes. I also added an include for this simple file directly into thegdvirtual.gen.inc
generator. This allows to include onlygdvirtual.gen.inc
when we need the macros. Simpler!The divorce didn't cause any obvious issues, a bit surprisingly, so I went ahead and removed excessive includes of
script_language.h
wherever possible. This, of course, had a cascading effect on the codebase, which is full of indirect dependencies. I fixed everything until it started to compile locally. I think the end result here is that compile times should improve, which is also nice. Faster!I haven't tried if this actually unblocks #67080 or if there are further problems. I leave it as an exercise for my colleagues 🙃 Now, let's see if it compiles on CI!