-
Notifications
You must be signed in to change notification settings - Fork 42
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
Add coroutines await() to signals #660
base: master
Are you sure you want to change the base?
Conversation
1b3ce84
to
f1981cc
Compare
f1981cc
to
ada89ae
Compare
5a448ec
to
4f5785c
Compare
ada89ae
to
d5f38e7
Compare
6cc3d6e
to
5db9b2a
Compare
018d284
to
587e9f3
Compare
587e9f3
to
21283d1
Compare
f213992
to
f017f4e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you check that none of the IDE checks are requiring the signals to be in the signal package?
kt/api-generator/src/main/kotlin/godot/codegen/services/impl/AwaitGenerationService.kt
Show resolved
Hide resolved
tasks { | ||
compileKotlin { | ||
dependsOn(":godot-library:generateAPI") | ||
} | ||
|
||
// here so the sourcesJar task has an explicit dependency on the generateApi task. Needed since gradle 8 | ||
withType<Jar> { | ||
dependsOn(":godot-library:generateAPI") | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block should not be needed as you depend on the godot-library
project which itself defines these dependency constraints.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to remove it but it doesn't want to build without that.
I get the following error:
What went wrong:
A problem was found with the configuration of task ':kt:godot-coroutine-library:sourcesJar' (type 'Jar').
-
Gradle detected a problem with the following location: 'D:\Godot\Module\kotlin\modules\kotlin_jvm\kt\godot-coroutine-library\src\main\kotlin'.
Reason: Task ':kt:godot-coroutine-library:sourcesJar' uses this output of task ':kt:godot-library:generateAPI' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
Possible solutions:
- Declare task ':kt:godot-library:generateAPI' as an input of ':kt:godot-coroutine-library:sourcesJar'.
- Declare an explicit dependency on ':kt:godot-library:generateAPI' from ':kt:godot-coroutine-library:sourcesJar' using Task#dependsOn.
- Declare an explicit dependency on ':kt:godot-library:generateAPI' from ':kt:godot-coroutine-library:sourcesJar' using Task#mustRunAfter.
kt/godot-coroutine-library/src/main/kotlin/godot/coroutines/GodotCoroutine.kt
Outdated
Show resolved
Hide resolved
override fun apply(target: Project) = with(target) { | ||
checkKotlinVersionCompatibility() | ||
|
||
val extension = target.extensions.create("godot", GodotExtension::class.java).also { | ||
it.configureExtensionDefaults(target) | ||
val extension = extensions.create("godot", GodotExtension::class.java).also { | ||
it.configureExtensionDefaults(this) | ||
} | ||
|
||
target.configureThirdPartyPlugins() | ||
target.setupConfigurationsAndCompilations() | ||
target.setupTasks() | ||
configureThirdPartyPlugins() | ||
setupConfigurationsAndCompilations() | ||
setupTasks() | ||
|
||
// registers the tooling model builder, so it can be used by the ide plugin | ||
target.afterEvaluate { | ||
afterEvaluate { | ||
if (godotJvmExtension.enableGodotCoroutines.get()) { | ||
dependencies.add( | ||
"implementation", | ||
dependencies.create("com.utopia-rise:${godotCoroutineLibraryArtifactName}:${GodotBuildProperties.assembledGodotKotlinJvmVersion}") | ||
) | ||
} | ||
registry.register( | ||
PropertiesModelBuilder( | ||
isFqNameRegistrationEnabled = extension.isFqNameRegistrationEnabled.get(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please leave the explicit target be. There were some scoping issues IIRC before and i would not like to introduce such issues again
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But as i cannot remember them, you can also leave it be like that. I do not have a strong opinion here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't have any problem running it. It just felt normal switching the receiver when almost all calls use "target"
kotlinx.coroutines
)await()
functions to all signals that will suspend the coroutines until the signal is emitted.await()
can return the signal's arguments, directly (when 1), as a tuple (when 2 and 3), and as list (4+)I also changed the package of Signal and Callable (I needed them for the await implementation so I took the opportunity).
So far everything has been in the same
godot.core
package except for those 2. Maybe it's an error and we should split everything into smaller packages but right now I wanted to focus on more consistency.Note that the await() functions are in the
godot.coroutines
package as it's not considered the same library.