Extract ScriptInstance into its own file to simplify includes#81388
Merged
akien-mga merged 1 commit intogodotengine:masterfrom Sep 7, 2023
Merged
Conversation
a2c3e7d to
74716db
Compare
This allows to include script_instance.h directly in the generated gdvirtual.gen.inc, and remove excessive includes from the codebase. This should also allow Resource to use GDVIRTUAL macros, which wasn't possible previously due to a circular dependency.
74716db to
d8ff69d
Compare
Member
|
I can confirm after testing that this PR does address the issue described. |
akien-mga
approved these changes
Sep 7, 2023
Member
akien-mga
left a comment
There was a problem hiding this comment.
Looks good to me. Makes sense to split the classes to separate files if it helps reduce circular dependencies.
Member
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.incandscript_language.h. The only reason for the second file, as far as I can see, is because macros need a definition forScriptInstance.ScriptInstanceis 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 thatResourcescan't useGDVIRTUALfor some reason (see #67080).Solution
So I tried to divorce
ScriptInstancefrom the rest ofscript_language.h, to simplify the includes. I also added an include for this simple file directly into thegdvirtual.gen.incgenerator. This allows to include onlygdvirtual.gen.incwhen 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.hwherever 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!