diff --git a/harness/tests/src/main/java/godot/tests/JavaTestClass.java b/harness/tests/src/main/java/godot/tests/JavaTestClass.java index 663bbce5c..a20712010 100644 --- a/harness/tests/src/main/java/godot/tests/JavaTestClass.java +++ b/harness/tests/src/main/java/godot/tests/JavaTestClass.java @@ -10,11 +10,11 @@ @RegisterClass public class JavaTestClass extends Node { - @RegisterSignal - public Signal0 testSignal = Signal0.create(this, "test_signal"); - - @RegisterSignal(parameters = {"param1", "param2"}) - public Signal2 testSignal2 = Signal2.create(this, "test_signal_2"); + //@RegisterSignal + //public Signal0 testSignal = Signal0.create(this, "test_signal"); +// + //@RegisterSignal(parameters = {"param1", "param2"}) + //public Signal2 testSignal2 = Signal2.create(this, "test_signal_2"); // The following should NOT work as we cannot extract parameter names. The compiler checks should catch that and throw a build error // @RegisterSignal @@ -71,15 +71,15 @@ public String greeting() { @RegisterProperty public Dictionary dictionary = new Dictionary<>(Float.class, String.class); - public LambdaCallable lambdaCallable = LambdaCallable0.create( - Void.class, - () -> { - System.out.println("Hello from Callable"); - return null; - } - ); - - public NativeCallable methodCallable = Callable.create(this, StringNames.asStringName("DummyName")); + //public LambdaCallable lambdaCallable = LambdaCallable0.create( + // Void.class, + // () -> { + // System.out.println("Hello from Callable"); + // return null; + // } + //); +// + //public NativeCallable methodCallable = Callable.create(this, StringNames.asStringName("DummyName")); @RegisterFunction @Override @@ -96,12 +96,12 @@ public void _ready() { @RegisterFunction public void connectAndTriggerSignal() { - connect( - StringNames.asStringName("test_signal"), - new NativeCallable(this, StringNames.asStringName("signal_callback")), - (int) ConnectFlags.ONE_SHOT.getId() - ); - emitSignal(StringNames.asStringName("test_signal")); + //connect( + // StringNames.asStringName("test_signal"), + // new NativeCallable(this, StringNames.asStringName("signal_callback")), + // (int) ConnectFlags.ONE_SHOT.getId() + //); + //emitSignal(StringNames.asStringName("test_signal")); } @NotNull diff --git a/harness/tests/src/main/kotlin/godot/tests/FuncRefTest.kt b/harness/tests/src/main/kotlin/godot/tests/FuncRefTest.kt index f6a0b33ed..7eaf186e2 100644 --- a/harness/tests/src/main/kotlin/godot/tests/FuncRefTest.kt +++ b/harness/tests/src/main/kotlin/godot/tests/FuncRefTest.kt @@ -6,9 +6,10 @@ import godot.annotation.RegisterFunction import godot.annotation.RegisterProperty import godot.annotation.RegisterSignal import godot.annotation.Rpc +import godot.core.callable0 +import godot.core.callable1 +import godot.core.connect import godot.core.signal0 -import godot.extension.call -import godot.extension.callDeferred @RegisterClass class FuncRefTest : Node() { @@ -51,12 +52,12 @@ class FuncRefTest : Node() { @RegisterFunction fun testCallWithoutParam() { - call(this::withoutParamCallback) + callable0(this::withoutParamCallback).call() } @RegisterFunction fun testCallDeferredWithoutParam() { - callDeferred(this::withoutParamCallback) + callable0(this::withoutParamCallback).callDeferred() } @RegisterFunction @@ -66,11 +67,11 @@ class FuncRefTest : Node() { @RegisterFunction fun testCallWithParam() { - call(this::withParamCallback, true) + callable1(this::withParamCallback).call(true) } @RegisterFunction fun testCallDeferredWithParam() { - callDeferred(this::withParamCallback, true) + callable1(this::withParamCallback).callDeferred(true) } } diff --git a/harness/tests/src/main/kotlin/godot/tests/Invocation.kt b/harness/tests/src/main/kotlin/godot/tests/Invocation.kt index 6d249d1ce..29de29e12 100644 --- a/harness/tests/src/main/kotlin/godot/tests/Invocation.kt +++ b/harness/tests/src/main/kotlin/godot/tests/Invocation.kt @@ -42,6 +42,7 @@ import godot.extension.getNodeAs import godot.registration.Range import godot.tests.subpackage.OtherScript import godot.common.util.RealT +import godot.core.connect import org.joda.time.DateTime enum class TestEnum { diff --git a/harness/tests/src/main/kotlin/godot/tests/callable/CallableMethodBindTest.kt b/harness/tests/src/main/kotlin/godot/tests/callable/CallableMethodBindTest.kt index f01b363fa..3eddea009 100644 --- a/harness/tests/src/main/kotlin/godot/tests/callable/CallableMethodBindTest.kt +++ b/harness/tests/src/main/kotlin/godot/tests/callable/CallableMethodBindTest.kt @@ -4,8 +4,9 @@ import godot.api.Node import godot.annotation.RegisterClass import godot.annotation.RegisterFunction import godot.annotation.RegisterProperty -import godot.core.NativeCallable +import godot.core.MethodCallable import godot.core.VariantArray +import godot.core.toGodotName import godot.core.variantArrayOf import godot.global.GD @@ -16,22 +17,22 @@ class CallableMethodBindTest: Node() { @RegisterFunction fun callWithMethodWithAllBinds() { - NativeCallable(this, CallableMethodBindTest::readySignalMethodBindTest).bind(1, 2, 3).call() + MethodCallable(this, CallableMethodBindTest::readySignalMethodBindTest.toGodotName()).bindUnsafe(1, 2, 3).callUnsafe() } @RegisterFunction fun callWithMethodWithTwoBinds() { - NativeCallable(this, CallableMethodBindTest::readySignalMethodBindTest).bind(2, 3).call(0) + MethodCallable(this, CallableMethodBindTest::readySignalMethodBindTest.toGodotName()).bindUnsafe(2, 3).callUnsafe(0) } @RegisterFunction fun callWithMethodWithOneBind() { - NativeCallable(this, CallableMethodBindTest::readySignalMethodBindTest).bind(3).call(0, 0) + MethodCallable(this, CallableMethodBindTest::readySignalMethodBindTest.toGodotName()).bindUnsafe(3).callUnsafe(0, 0) } @RegisterFunction fun callWithMethodWithNoBind() { - NativeCallable(this, CallableMethodBindTest::readySignalMethodBindTest).bind().call(0, 0, 0) + MethodCallable(this, CallableMethodBindTest::readySignalMethodBindTest.toGodotName()).bindUnsafe().callUnsafe(0, 0, 0) } @RegisterFunction diff --git a/harness/tests/src/main/kotlin/godot/tests/coroutine/CoroutineTest.kt b/harness/tests/src/main/kotlin/godot/tests/coroutine/CoroutineTest.kt index 585249250..be58f9412 100644 --- a/harness/tests/src/main/kotlin/godot/tests/coroutine/CoroutineTest.kt +++ b/harness/tests/src/main/kotlin/godot/tests/coroutine/CoroutineTest.kt @@ -124,9 +124,7 @@ class CoroutineTest : Object() { @RegisterFunction fun asyncLoadResource() { godotCoroutine { - val resource = ResourceLoader.awaitLoadAs("res://Spatial.tscn") { progress -> - GD.print("Resource load progress: $progress") - } + val resource = ResourceLoader.awaitLoadAs("res://Spatial.tscn") GD.print("Resource: $resource") diff --git a/harness/tests/test/unit/test_call_java_class.gd b/harness/tests/test/unit/test_call_java_class.gd index cc3958300..813200de4 100644 --- a/harness/tests/test/unit/test_call_java_class.gd +++ b/harness/tests/test/unit/test_call_java_class.gd @@ -21,9 +21,9 @@ func test_field_set(): java_scene.free() -func test_signal(): - var java_scene: JavaTestClass = load("res://java_test_scene.tscn").instantiate() - get_tree().root.add_child(java_scene) - await get_tree().create_timer(1).timeout - java_scene.connect_and_trigger_signal() - assert_true(java_scene.signal_emitted, "Signal should've been emitted in java") +#func test_signal(): +# var java_scene: JavaTestClass = load("res://java_test_scene.tscn").instantiate() +# get_tree().root.add_child(java_scene) +# await get_tree().create_timer(1).timeout +# java_scene.connect_and_trigger_signal() +# assert_true(java_scene.signal_emitted, "Signal should've been emitted in java") diff --git a/harness/tests/test/unit/test_funcref.gd b/harness/tests/test/unit/test_funcref.gd index 0627f554b..6de9ad025 100644 --- a/harness/tests/test/unit/test_funcref.gd +++ b/harness/tests/test/unit/test_funcref.gd @@ -2,36 +2,36 @@ extends "res://addons/gut/test.gd" func test_call_without_param(): - var func_ref_test_script = FuncRefTest.new() - func_ref_test_script.test_call_without_param() - assert_true(func_ref_test_script.call_flag) - func_ref_test_script.free() + var func_ref_test_script = FuncRefTest.new() + func_ref_test_script.test_call_without_param() + assert_true(func_ref_test_script.call_flag) + func_ref_test_script.free() func test_call_deferred_without_param(): - var func_ref_test_script = FuncRefTest.new() - func_ref_test_script.test_call_deferred_without_param() - await get_tree().create_timer(1).timeout - assert_true(func_ref_test_script.call_flag) - func_ref_test_script.free() + var func_ref_test_script = FuncRefTest.new() + func_ref_test_script.test_call_deferred_without_param() + await get_tree().create_timer(1).timeout + assert_true(func_ref_test_script.call_flag) + func_ref_test_script.free() func test_call_with_param(): - var func_ref_test_script = FuncRefTest.new() - func_ref_test_script.test_call_with_param() - assert_true(func_ref_test_script.call_with_param_flag) - func_ref_test_script.free() + var func_ref_test_script = FuncRefTest.new() + func_ref_test_script.test_call_with_param() + assert_true(func_ref_test_script.call_with_param_flag) + func_ref_test_script.free() func test_call_deferred_with_param(): - var func_ref_test_script = FuncRefTest.new() - func_ref_test_script.test_call_deferred_with_param() - await get_tree().create_timer(3).timeout - assert_true(func_ref_test_script.call_with_param_flag) - func_ref_test_script.free() + var func_ref_test_script = FuncRefTest.new() + func_ref_test_script.test_call_deferred_with_param() + await get_tree().create_timer(3).timeout + assert_true(func_ref_test_script.call_with_param_flag) + func_ref_test_script.free() func test_signal_call(): - var func_ref_test_script = FuncRefTest.new() - get_tree().root.add_child(func_ref_test_script) - func_ref_test_script.test_signal_call() - await get_tree().create_timer(1).timeout - assert_true(func_ref_test_script.signal_call_flag) - get_tree().root.remove_child(func_ref_test_script) - func_ref_test_script.free() + var func_ref_test_script = FuncRefTest.new() + get_tree().root.add_child(func_ref_test_script) + func_ref_test_script.test_signal_call() + await get_tree().create_timer(1).timeout + assert_true(func_ref_test_script.signal_call_flag) + get_tree().root.remove_child(func_ref_test_script) + func_ref_test_script.free() diff --git a/harness/tests/test/unit/test_signals.gd b/harness/tests/test/unit/test_signals.gd index 16953ef44..63ef4006d 100644 --- a/harness/tests/test/unit/test_signals.gd +++ b/harness/tests/test/unit/test_signals.gd @@ -1,42 +1,42 @@ extends "res://addons/gut/test.gd" func test_signal_connection_script_instantiation(): - var script = SignalTest.new() - get_tree().root.add_child(script) - assert_eq(script.is_connected("no_param_signal_delegate", Callable(script.other_script, "hook_no_param")), true, "signal \"no_param_signal_delegate\" should be connected to \"otherScript::hook_no_param\"") - assert_eq(script.is_connected("one_param_signal_delegate", Callable(script.other_script, "hook_one_param")), true, "signal \"one_param_signal_delegate\" should be connected to \"otherScript::hook_one_param\"") - assert_eq(script.is_connected("two_param_signal_delegate", Callable(script.other_script, "hook_two_param")), true, "signal \"two_param_signal_delegate\" should be connected to \"otherScript::hook_two_param\"") + var script = SignalTest.new() + get_tree().root.add_child(script) + assert_eq(script.is_connected("no_param_signal_delegate", Callable(script.other_script, "hook_no_param")), true, "signal \"no_param_signal_delegate\" should be connected to \"otherScript::hook_no_param\"") + assert_eq(script.is_connected("one_param_signal_delegate", Callable(script.other_script, "hook_one_param")), true, "signal \"one_param_signal_delegate\" should be connected to \"otherScript::hook_one_param\"") + assert_eq(script.is_connected("two_param_signal_delegate", Callable(script.other_script, "hook_two_param")), true, "signal \"two_param_signal_delegate\" should be connected to \"otherScript::hook_two_param\"") - assert_eq(script.is_connected("no_param_signal_field", Callable(script.other_script, "hook_no_param")), true, "signal \"no_param_signal_field\" should be connected to \"otherScript::hook_no_param\"") - assert_eq(script.is_connected("one_param_signal_field", Callable(script.other_script, "hook_one_param")), true, "signal \"one_param_signal_field\" should be connected to \"otherScript::hook_one_param\"") - assert_eq(script.is_connected("two_param_signal_field", Callable(script.other_script, "hook_two_param")), true, "signal \"two_param_signal_field\" should be connected to \"otherScript::hook_two_param\"") + assert_eq(script.is_connected("no_param_signal_field", Callable(script.other_script, "hook_no_param")), true, "signal \"no_param_signal_field\" should be connected to \"otherScript::hook_no_param\"") + assert_eq(script.is_connected("one_param_signal_field", Callable(script.other_script, "hook_one_param")), true, "signal \"one_param_signal_field\" should be connected to \"otherScript::hook_one_param\"") + assert_eq(script.is_connected("two_param_signal_field", Callable(script.other_script, "hook_two_param")), true, "signal \"two_param_signal_field\" should be connected to \"otherScript::hook_two_param\"") - script.free() + script.free() func test_signal_connection_code(): - var invocation_script = load("res://Spatial.tscn").instantiate() - get_tree().root.add_child(invocation_script) - assert_eq(invocation_script.button.is_connected("pressed", Callable(invocation_script.invocation, "hook_no_param")), true, "signal \"pressed\" of button should be connected to \"invocation_script.invocation::hook_no_param\"") - invocation_script.free() + var invocation_script = load("res://Spatial.tscn").instantiate() + get_tree().root.add_child(invocation_script) + assert_eq(invocation_script.button.is_connected("pressed", Callable(invocation_script.invocation, "hook_no_param")), true, "signal \"pressed\" of button should be connected to \"invocation_script.invocation::hook_no_param\"") + invocation_script.free() func test_signal_emitted_with_multiple_targets(): - var script = SignalTest.new() - get_tree().root.add_child(script) - assert_eq(script.array.size(), 16) - assert_eq(script.array[0], Vector2(0,0)) - assert_eq(script.array[1], Vector2(1,1)) - assert_eq(script.array[2], Vector2(1,2)) - assert_eq(script.array[3], Vector2(1,3)) - assert_eq(script.array[4], Vector2(1,4)) - assert_eq(script.array[5], Vector2(1,5)) - assert_eq(script.array[6], Vector2(1,6)) - assert_eq(script.array[7], Vector2(1,7)) - assert_eq(script.array[8], Vector2(1,7)) - assert_eq(script.array[9], Vector2(1,6)) - assert_eq(script.array[10], Vector2(1,5)) - assert_eq(script.array[11], Vector2(1,4)) - assert_eq(script.array[12], Vector2(1,3)) - assert_eq(script.array[13], Vector2(1,2)) - assert_eq(script.array[14], Vector2(1,1)) - assert_eq(script.array[15], Vector2(0,0)) - script.free() + var script = SignalTest.new() + get_tree().root.add_child(script) + assert_eq(script.array.size(), 16) + assert_eq(script.array[0], Vector2(0,0)) + assert_eq(script.array[1], Vector2(1,1)) + assert_eq(script.array[2], Vector2(1,2)) + assert_eq(script.array[3], Vector2(1,3)) + assert_eq(script.array[4], Vector2(1,4)) + assert_eq(script.array[5], Vector2(1,5)) + assert_eq(script.array[6], Vector2(1,6)) + assert_eq(script.array[7], Vector2(1,7)) + assert_eq(script.array[8], Vector2(1,7)) + assert_eq(script.array[9], Vector2(1,6)) + assert_eq(script.array[10], Vector2(1,5)) + assert_eq(script.array[11], Vector2(1,4)) + assert_eq(script.array[12], Vector2(1,3)) + assert_eq(script.array[13], Vector2(1,2)) + assert_eq(script.array[14], Vector2(1,1)) + assert_eq(script.array[15], Vector2(0,0)) + script.free() diff --git a/install_vulkan_sdk_macos.sh b/install_vulkan_sdk_macos.sh index f96eb49c0..38fdad48e 100644 --- a/install_vulkan_sdk_macos.sh +++ b/install_vulkan_sdk_macos.sh @@ -1,19 +1,45 @@ + #!/usr/bin/env sh set -euo pipefail IFS=$'\n\t' +new_ver_full='' + +# Check currently installed and latest available Vulkan SDK versions. +if command -v jq 2>&1 >/dev/null; then + curl -L "https://sdk.lunarg.com/sdk/download/latest/mac/config.json" -o /tmp/vulkan-sdk.json + + new_ver_full=`jq -r '.version' /tmp/vulkan-sdk.json` + new_ver=`echo "$new_ver_full" | awk -F. '{ printf("%d%02d%04d%02d\n", $1,$2,$3,$4); }';` + + rm -f /tmp/vulkan-sdk.json + + for f in $HOME/VulkanSDK/*; do + if [ -d "$f" ]; then + f=`echo "${f##*/}" | awk -F. '{ printf("%d%02d%04d%02d\n", $1,$2,$3,$4); }';` + if [ $f -ge $new_ver ]; then + echo 'Latest or newer Vulkan SDK is already installed. Skipping installation.' + exit 0 + fi + fi + done +else + echo 'Error: Could not find 'jq' command. Is jq installed? Try running "brew install jq" or "port install jq" and rerunning this script.' + exit 1 +fi # Download and install the Vulkan SDK. curl -L "https://sdk.lunarg.com/sdk/download/latest/mac/vulkan-sdk.zip" -o /tmp/vulkan-sdk.zip -unzip -l /tmp/vulkan-sdk.zip | grep 'InstallVulkan.*\.app' | head -n 1 | awk '{print $4}' | tr -d '/' > /tmp/install_app_name - unzip /tmp/vulkan-sdk.zip -d /tmp -install_app_name=$(cat /tmp/install_app_name) -/tmp/$install_app_name/Contents/MacOS/${install_app_name%\.app} \ - --accept-licenses --default-answer --confirm-command install -rm -rf /tmp/$install_app_name +if [ -d "/tmp/vulkansdk-macOS-$new_ver_full.app" ]; then + /tmp/vulkansdk-macOS-$new_ver_full.app/Contents/MacOS/vulkansdk-macOS-$new_ver_full --accept-licenses --default-answer --confirm-command install + rm -rf /tmp/vulkansdk-macOS-$new_ver_full.app +else + echo "Couldn't install the Vulkan SDK, the unzipped contents may no longer match what this script expects." + exit 1 +fi + rm -f /tmp/vulkan-sdk.zip -rm -f /tmp/install_app_name -echo 'Vulkan SDK installed successfully! You can now build Godot by running "scons".' \ No newline at end of file +echo 'Vulkan SDK installed successfully! You can now build Godot by running "scons".' diff --git a/kt/api-generator/src/main/kotlin/godot/codegen/generation/rule/ApiRule.kt b/kt/api-generator/src/main/kotlin/godot/codegen/generation/rule/ApiRule.kt index e4ea7854f..f8a9fd69e 100644 --- a/kt/api-generator/src/main/kotlin/godot/codegen/generation/rule/ApiRule.kt +++ b/kt/api-generator/src/main/kotlin/godot/codegen/generation/rule/ApiRule.kt @@ -14,6 +14,7 @@ import godot.codegen.generation.task.EnrichedClassTask import godot.codegen.generation.task.FileTask import godot.codegen.models.traits.GenerationType import godot.codegen.models.ApiType +import godot.codegen.models.EnumValue import godot.codegen.models.enriched.EnrichedClass import godot.codegen.models.enriched.EnrichedMethod import godot.codegen.models.enriched.EnrichedNativeStructure @@ -25,6 +26,42 @@ import godot.tools.common.constants.GodotKotlinJvmTypes import godot.tools.common.constants.GodotTypes import godot.tools.common.constants.TO_GODOT_NAME_UTIL_FUNCTION +class UseConnectFlagRule : GodotApiRule() { + override fun apply(task: ApiTask, context: GenerationContext) { + val objectClassIndex = context.api.classes.indexOfFirst { it.name == GodotKotlinJvmTypes.obj } + val objectRawClass = context.api.classes[objectClassIndex] + + val connectEnumIndex = objectRawClass.enums!!.indexOfFirst { it.name == "ConnectFlags" } + val connectRawEnum = objectRawClass.enums[connectEnumIndex] + + val newValues = listOf( + EnumValue( + "DEFAULT", + 0, + "Default connections that are immediately emitted" + ) + ) + connectRawEnum.values + val newEnum = connectRawEnum.copy(values = newValues) + + val enumList = objectRawClass.enums.toMutableList() + enumList[connectEnumIndex] = newEnum + + val connectMethodIndex = objectRawClass.methods!!.indexOfFirst { it.name == "connect" } + val connectMethod = objectRawClass.methods[connectMethodIndex] + + val flagArgumentIndex = connectMethod.arguments!!.indexOfFirst { it.name == "flags" } + val flagArgument = connectMethod.arguments[flagArgumentIndex] + + val newArgument = flagArgument.copy(type="enum::Object.ConnectFlags", meta = null) + val newMethod = connectMethod.copy(arguments = connectMethod.arguments.dropLast(1) + newArgument) + val newMethodList = objectRawClass.methods.toMutableList() + newMethodList[connectMethodIndex] = newMethod + + val newClass = objectRawClass.copy(enums = enumList, methods = newMethodList) + context.api.classes[objectClassIndex] = newClass + } +} + class EnrichedCoreRule : GodotApiRule() { override fun apply(task: ApiTask, context: GenerationContext) { val coreTypes = context.api.builtinClasses.associate { it.name to (it.enums?.toEnriched(GenerationType(it.name)) ?: listOf()) } diff --git a/kt/api-generator/src/main/kotlin/godot/codegen/generationEntry.kt b/kt/api-generator/src/main/kotlin/godot/codegen/generationEntry.kt index d27c73f79..e95ccb1c1 100644 --- a/kt/api-generator/src/main/kotlin/godot/codegen/generationEntry.kt +++ b/kt/api-generator/src/main/kotlin/godot/codegen/generationEntry.kt @@ -6,7 +6,8 @@ import godot.codegen.models.ApiDescription import godot.codegen.services.IApiGenerationService import godot.codegen.services.impl.ApiGenerationService import godot.codegen.services.impl.AwaitGenerationService -import godot.codegen.services.impl.LambdaCallableGenerationService +import godot.codegen.services.impl.ConnectorGenerationService +import godot.codegen.services.impl.CallableGenerationService import godot.codegen.services.impl.SignalGenerationService import java.io.File @@ -15,12 +16,9 @@ fun generateApiFrom(jsonSource: File, coreDir: File, apiDir: File) { val generationService: IApiGenerationService = ApiGenerationService(apiDescription) generationService.generateApi(coreDir, apiDir) - LambdaCallableGenerationService.generate(coreDir) - SignalGenerationService.generateCore(coreDir) -} - -fun generateExtension(outputDir: File) { - SignalGenerationService.generateExtension(outputDir) + SignalGenerationService.generate(coreDir) + CallableGenerationService.generate(coreDir) + ConnectorGenerationService.generate(coreDir) } fun generateCoroutine(outputDir: File) { diff --git a/kt/api-generator/src/main/kotlin/godot/codegen/models/ApiDescription.kt b/kt/api-generator/src/main/kotlin/godot/codegen/models/ApiDescription.kt index 6353d3f6c..95110d92b 100644 --- a/kt/api-generator/src/main/kotlin/godot/codegen/models/ApiDescription.kt +++ b/kt/api-generator/src/main/kotlin/godot/codegen/models/ApiDescription.kt @@ -4,14 +4,14 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty data class ApiDescription @JsonCreator constructor( - @JsonProperty("header") val header: Header, - @JsonProperty("builtin_class_sizes") val builtinClassSizes: List, - @JsonProperty("builtin_class_member_offsets") val builtinClassMemberOffsets: List, - @JsonProperty("global_constants") val globalConstants: List, - @JsonProperty("global_enums") val globalEnums: List, - @JsonProperty("utility_functions") val utilityFunctions: List, - @JsonProperty("builtin_classes") val builtinClasses: List, - @JsonProperty("classes") val classes: List, - @JsonProperty("singletons") val singletons: List, - @JsonProperty("native_structures") val nativeStructures: List + @JsonProperty("header") var header: Header, + @JsonProperty("builtin_class_sizes") var builtinClassSizes: MutableList, + @JsonProperty("builtin_class_member_offsets") var builtinClassMemberOffsets: MutableList, + @JsonProperty("global_constants") var globalConstants: MutableList, + @JsonProperty("global_enums") var globalEnums: MutableList, + @JsonProperty("utility_functions") var utilityFunctions: MutableList, + @JsonProperty("builtin_classes") val builtinClasses: MutableList, + @JsonProperty("classes") var classes: MutableList, + @JsonProperty("singletons") var singletons: MutableList, + @JsonProperty("native_structures") var nativeStructures: MutableList ) diff --git a/kt/api-generator/src/main/kotlin/godot/codegen/models/traits/GenerationType.kt b/kt/api-generator/src/main/kotlin/godot/codegen/models/traits/GenerationType.kt index 1ca0868b0..c0b3fdbc0 100644 --- a/kt/api-generator/src/main/kotlin/godot/codegen/models/traits/GenerationType.kt +++ b/kt/api-generator/src/main/kotlin/godot/codegen/models/traits/GenerationType.kt @@ -10,7 +10,7 @@ import com.squareup.kotlinpoet.STRING import com.squareup.kotlinpoet.TypeName import com.squareup.kotlinpoet.UNIT import godot.tools.common.constants.GODOT_ARRAY -import godot.tools.common.constants.GODOT_CALLABLE_BASE +import godot.tools.common.constants.GODOT_CALLABLE import godot.tools.common.constants.GODOT_DICTIONARY import godot.tools.common.constants.GodotTypes import godot.tools.common.constants.VARIANT_CASTER_ANY @@ -113,7 +113,7 @@ fun ClassName.Companion.from(type: TypeGenerationTrait) = when { type.identifier == GodotTypes.float -> DOUBLE type.identifier == GodotTypes.string -> STRING type.identifier == GodotTypes.variant -> ANY - type.identifier == GodotTypes.callable -> GODOT_CALLABLE_BASE + type.identifier == GodotTypes.callable -> GODOT_CALLABLE type.identifier == GodotTypes.array || type.isTypedArray() -> GODOT_ARRAY type.identifier == GodotTypes.dictionary -> GODOT_DICTIONARY type.isCoreType() -> ClassName(godotCorePackage, type.identifier) diff --git a/kt/api-generator/src/main/kotlin/godot/codegen/poet/GenericClassNameInfo.kt b/kt/api-generator/src/main/kotlin/godot/codegen/poet/GenericClassNameInfo.kt index cae8f7d05..df779e6ff 100644 --- a/kt/api-generator/src/main/kotlin/godot/codegen/poet/GenericClassNameInfo.kt +++ b/kt/api-generator/src/main/kotlin/godot/codegen/poet/GenericClassNameInfo.kt @@ -7,17 +7,43 @@ import com.squareup.kotlinpoet.KModifier import com.squareup.kotlinpoet.LambdaTypeName import com.squareup.kotlinpoet.ParameterSpec import com.squareup.kotlinpoet.ParameterizedTypeName.Companion.parameterizedBy +import com.squareup.kotlinpoet.TypeName import com.squareup.kotlinpoet.TypeSpec import com.squareup.kotlinpoet.TypeVariableName -// Helper that provide utilities to handle generic classes. +/** + * Provides utilities to handle generic classes and generate KotlinPoet builders for them. + * + * @property className The base [ClassName] representing the class. + * @param numberOfGenericParameters The number of generic type parameters for the class. + */ class GenericClassNameInfo( val className: ClassName, numberOfGenericParameters: Int ) { + /** + * Return list of generic argument type names. + * + * Example: genericTypes = [P0, P1] + */ val genericTypes = Array(numberOfGenericParameters) { TypeVariableName("P$it") }.toList() + + + /** + * List of reified type variables for inline functions. + * + * Example: [reified P0, reified P1] + */ + val reifiedTypes = genericTypes.map { it.copy(reified = true) } + + + /** + * Parameterized [ClassName] with generic type variables. + * + * Example: MyClass + */ val genericClassName = className.run { if (genericTypes.isNotEmpty()) { parameterizedBy(genericTypes) @@ -26,7 +52,11 @@ class GenericClassNameInfo( } } - val reifiedTypes = genericTypes.map { it.copy(reified = true) } + /** + * Parameterized [ClassName] with reified generic type variables. + * + * Example: MyClass + */ val reifiedClassName = className.run { if (reifiedTypes.isNotEmpty()) { parameterizedBy(reifiedTypes) @@ -35,6 +65,11 @@ class GenericClassNameInfo( } } + /** + * Parameterized [ClassName] with generic parameters erased to [ANY]. + * + * Example: MyClass + */ val erasedGenericClassName = className.run { if (genericTypes.isNotEmpty()) { parameterizedBy(genericTypes.map { ANY }) @@ -43,34 +78,130 @@ class GenericClassNameInfo( } } - fun toTypeSpecBuilder() = TypeSpec - .classBuilder(className) - .addTypeVariables(genericTypes) + /** + * Combine optional [prefix], core [genericTypes], and optional [suffix] into one list. + */ + private fun allTypeVariables( + prefix: List = emptyList(), + suffix: List = emptyList() + ) = prefix + genericTypes + suffix + + /** + * Builds a [TypeSpec.Builder] for the class with type variables. + * + * Example: toTypeSpecBuilder(prefix, suffix) -> TypeSpec.classBuilder("MyClass").addTypeVariables(prefix + [P0,P1] + suffix) + */ + fun toTypeSpecBuilder( + prefix: List = emptyList(), + suffix: List = emptyList() + ) = TypeSpec.classBuilder(className.simpleName) + .addTypeVariables(allTypeVariables(prefix, suffix)) + + /** + * Builds a [FunSpec.Builder] with generic type variables. + * + * Example: builder("foo", prefix, suffix) -> builder("foo").addTypeVariables(prefix + [P0,P1] + suffix) + */ + fun toFunSpecBuilder( + name: String, + prefix: List = emptyList(), + suffix: List = emptyList() + ) = FunSpec.builder(name) + .addTypeVariables(allTypeVariables(prefix, suffix)) - fun toFunSpecBuilder(name: String) = FunSpec - .builder(name) - .addTypeVariables(genericTypes) - fun toExtensionFunSpecBuilder(name: String) = toFunSpecBuilder(name).receiver(genericClassName) + /** + * Builds an extension [FunSpec.Builder] on [genericClassName]. + * + * Example: fun MyClass.foo() {...} + */ + fun toExtensionFunSpecBuilder( + name: String, + prefix: List = emptyList(), + suffix: List = emptyList() + ) = toFunSpecBuilder(name, prefix, suffix) + .receiver(genericClassName) - fun toReifiedFunSpecBuilder(name: String) = FunSpec - .builder(name) - .addTypeVariables(reifiedTypes) + + /** + * Begin building a reified inline FunSpec with reified type parameters. + * + * Example: inline fun foo() {...} + */ + fun toReifiedFunSpecBuilder( + name: String, + prefix: List = emptyList(), + suffix: List = emptyList() + ) = FunSpec.builder(name) .addModifiers(KModifier.INLINE) + .addTypeVariables(prefix + reifiedTypes + suffix) + - fun toReifiedExtensionFunSpecBuilder(name: String) = toReifiedFunSpecBuilder(name).receiver(reifiedClassName) + /** + * Begin building a reified inline extension FunSpec on the class. + * + * Example: inline fun MyClass.foo() {...} + */ + fun toReifiedExtensionFunSpecBuilder( + name: String, + prefix: List = emptyList(), + suffix: List = emptyList() + ) = toReifiedFunSpecBuilder(name, prefix, suffix) + .receiver(reifiedClassName) + + /** + * Generate a list of parameters matching the generic type variables. + * + * Example: [ParameterSpec("p0", P0), ParameterSpec("p1", P1)] + */ fun toParameterSpecList() = genericTypes .mapIndexed { index: Int, typeVariableName: TypeVariableName -> ParameterSpec.builder("p$index", typeVariableName).build() } - fun toLambdaTypeName(returnType: TypeVariableName) = LambdaTypeName.get( - receiver = null, + /** + * Build a comma-separated argument string based on a template. + * + * @param template String template where occurrences of `{$indexKey}` will be replaced by index + * @param indexKey placeholder key in template (e.g., "%d") + * + * Example: toArgumentsString("p%{i}", "{i}") -> "p0, p1" + */ + fun toArgumentsString(template: String, indexKey: String): String { + return buildString { + genericTypes.mapIndexed { index: Int, typeVariableName: TypeVariableName -> + if (index != 0) append(",·") + append(template.replace(indexKey, index.toString())) + } + } + } + + /** + * Create a LambdaTypeName taking generic types as parameters and returning [returnType]. + * + * Example: toLambdaTypeName(R) -> (p0: P0, p1: P1) -> R + */ + fun toLambdaTypeName(returnType: TypeName, receiver: TypeName? = null) = LambdaTypeName.get( + receiver = receiver, parameters = genericTypes .mapIndexed { index: Int, typeVariableName: TypeVariableName -> ParameterSpec.builder("p$index", typeVariableName).build() }, returnType = returnType ) + + /** + * Create a LambdaTypeName that use all parameters as Any? and returning [returnType]. + * + * Example: toErasedLambdaTypeName(R) -> (p0: Any?, p1: Any?) -> R + */ + fun toErasedLambdaTypeName(returnType: TypeName, receiver: TypeName? = null) = LambdaTypeName.get( + receiver = receiver, + parameters = genericTypes + .mapIndexed { index: Int, typeVariableName: TypeVariableName -> + ParameterSpec.builder("p$index", ANY.copy(nullable = true)).build() + }, + returnType = returnType + ) } diff --git a/kt/api-generator/src/main/kotlin/godot/codegen/services/ILambdaCallableGenerationService.kt b/kt/api-generator/src/main/kotlin/godot/codegen/services/ICallableGenerationService.kt similarity index 66% rename from kt/api-generator/src/main/kotlin/godot/codegen/services/ILambdaCallableGenerationService.kt rename to kt/api-generator/src/main/kotlin/godot/codegen/services/ICallableGenerationService.kt index 38e433b40..b53d9d3ce 100644 --- a/kt/api-generator/src/main/kotlin/godot/codegen/services/ILambdaCallableGenerationService.kt +++ b/kt/api-generator/src/main/kotlin/godot/codegen/services/ICallableGenerationService.kt @@ -2,6 +2,6 @@ package godot.codegen.services import java.io.File -interface ILambdaCallableGenerationService { +interface ICallableGenerationService { fun generate(outputDir: File) } diff --git a/kt/api-generator/src/main/kotlin/godot/codegen/services/IConnectorGenerationService.kt b/kt/api-generator/src/main/kotlin/godot/codegen/services/IConnectorGenerationService.kt new file mode 100644 index 000000000..7cc8b5c3a --- /dev/null +++ b/kt/api-generator/src/main/kotlin/godot/codegen/services/IConnectorGenerationService.kt @@ -0,0 +1,7 @@ +package godot.codegen.services + +import java.io.File + +interface IConnectorGenerationService { + fun generate(output: File) +} diff --git a/kt/api-generator/src/main/kotlin/godot/codegen/services/ISignalGenerationService.kt b/kt/api-generator/src/main/kotlin/godot/codegen/services/ISignalGenerationService.kt index de2abba47..7b4471bf8 100644 --- a/kt/api-generator/src/main/kotlin/godot/codegen/services/ISignalGenerationService.kt +++ b/kt/api-generator/src/main/kotlin/godot/codegen/services/ISignalGenerationService.kt @@ -3,6 +3,5 @@ package godot.codegen.services import java.io.File interface ISignalGenerationService { - fun generateCore(outputDir: File) - fun generateExtension(outputDir: File) + fun generate(outputDir: File) } diff --git a/kt/api-generator/src/main/kotlin/godot/codegen/services/impl/ApiGenerationService.kt b/kt/api-generator/src/main/kotlin/godot/codegen/services/impl/ApiGenerationService.kt index 4bb0ccf96..bb0417b02 100644 --- a/kt/api-generator/src/main/kotlin/godot/codegen/services/impl/ApiGenerationService.kt +++ b/kt/api-generator/src/main/kotlin/godot/codegen/services/impl/ApiGenerationService.kt @@ -6,7 +6,6 @@ import godot.codegen.generation.rule.BindingRule import godot.codegen.generation.rule.BitfieldExtensionRule import godot.codegen.generation.rule.ConstantRule import godot.codegen.generation.rule.CoreRule -import godot.codegen.generation.rule.LocalCopyHelperRule import godot.codegen.generation.rule.DocumentationRule import godot.codegen.generation.rule.EnrichedClassRule import godot.codegen.generation.rule.EnrichedCoreRule @@ -14,6 +13,7 @@ import godot.codegen.generation.rule.EnumRule import godot.codegen.generation.rule.FileRule import godot.codegen.generation.rule.HeaderCommentRule import godot.codegen.generation.rule.ImportRule +import godot.codegen.generation.rule.LocalCopyHelperRule import godot.codegen.generation.rule.MemberRule import godot.codegen.generation.rule.MethodRule import godot.codegen.generation.rule.ObjectRule @@ -23,6 +23,7 @@ import godot.codegen.generation.rule.RegistrationRule import godot.codegen.generation.rule.SignalRule import godot.codegen.generation.rule.StaticRule import godot.codegen.generation.rule.StringOnlyRule +import godot.codegen.generation.rule.UseConnectFlagRule import godot.codegen.generation.rule.WarningRule import godot.codegen.generation.rule.compile import godot.codegen.generation.task.ApiTask @@ -43,6 +44,7 @@ class ApiGenerationService( val context = GenerationContext(api) ApiTask(coreDir, apiDir).compile(context) { + rule(::UseConnectFlagRule) rule(::EnrichedCoreRule) rule(::EnrichedClassRule) rule(::CoreRule) diff --git a/kt/api-generator/src/main/kotlin/godot/codegen/services/impl/AwaitGenerationService.kt b/kt/api-generator/src/main/kotlin/godot/codegen/services/impl/AwaitGenerationService.kt index d2c19336d..232269cc9 100644 --- a/kt/api-generator/src/main/kotlin/godot/codegen/services/impl/AwaitGenerationService.kt +++ b/kt/api-generator/src/main/kotlin/godot/codegen/services/impl/AwaitGenerationService.kt @@ -14,19 +14,16 @@ import com.squareup.kotlinpoet.TypeVariableName import com.squareup.kotlinpoet.UNIT import godot.codegen.services.IAwaitGenerationService import godot.common.constants.Constraints -import godot.tools.common.constants.AS_CALLABLE_UTIL_FUNCTION -import godot.tools.common.constants.GODOT_OBJECT import godot.tools.common.constants.GodotKotlinJvmTypes.signal import godot.tools.common.constants.godotCorePackage import godot.tools.common.constants.godotCoroutinePackage -import godot.tools.common.constants.godotExtensionPackage import godot.tools.common.constants.kotlinCoroutinePackage import godot.tools.common.constants.kotlinxCoroutinePackage import java.io.File private val cancellableContinuationClass = ClassName(kotlinxCoroutinePackage, "CancellableContinuation") private val suspendCancellableCoroutine = MemberName(kotlinxCoroutinePackage, "suspendCancellableCoroutine") -private val connectThreadSafe = MemberName(godotExtensionPackage, "connectThreadSafe") +private val promise = MemberName(godotCorePackage, "promise") private val resume = MemberName(kotlinCoroutinePackage, "resume") private const val cancel = "cancel" @@ -138,14 +135,10 @@ object AwaitGenerationService : IAwaitGenerationService { return this .beginControlFlow("return·%M", suspendCancellableCoroutine) .addStatement("cont:·%T<%T>·->", cancellableContinuationClass, returnType) - .beginControlFlow("%M(", connectThreadSafe) - .addStatement("$lambdaParametersWithType·->") - .addStatement("cont.%M($resumeParameters)", resume) - .endControlFlow() - .beginControlFlow(".%M", AS_CALLABLE_UTIL_FUNCTION) - .addStatement("cont.%L()", cancel) - .endControlFlow() - .addCode(",·%T.ConnectFlags.ONE_SHOT.id.toInt())", GODOT_OBJECT) + .addStatement("%M(", promise) + .addStatement("{·$lambdaParametersWithType·->·cont.%M($resumeParameters)·},", resume) + .addStatement("{·cont.%L()·},", cancel) + .addStatement(")") .endControlFlow() } } diff --git a/kt/api-generator/src/main/kotlin/godot/codegen/services/impl/CallableGenerationService.kt b/kt/api-generator/src/main/kotlin/godot/codegen/services/impl/CallableGenerationService.kt new file mode 100644 index 000000000..5cb14e0ec --- /dev/null +++ b/kt/api-generator/src/main/kotlin/godot/codegen/services/impl/CallableGenerationService.kt @@ -0,0 +1,317 @@ +package godot.codegen.services.impl + +import com.squareup.kotlinpoet.ANY +import com.squareup.kotlinpoet.ARRAY +import com.squareup.kotlinpoet.AnnotationSpec +import com.squareup.kotlinpoet.ClassName +import com.squareup.kotlinpoet.CodeBlock +import com.squareup.kotlinpoet.FileSpec +import com.squareup.kotlinpoet.FunSpec +import com.squareup.kotlinpoet.KModifier +import com.squareup.kotlinpoet.MemberName +import com.squareup.kotlinpoet.ParameterSpec +import com.squareup.kotlinpoet.ParameterizedTypeName.Companion.parameterizedBy +import com.squareup.kotlinpoet.TypeSpec +import com.squareup.kotlinpoet.TypeVariableName +import godot.codegen.poet.GenericClassNameInfo +import godot.codegen.services.ICallableGenerationService +import godot.common.constants.Constraints +import godot.tools.common.constants.GodotFunctions +import godot.tools.common.constants.GodotKotlinJvmTypes +import godot.tools.common.constants.VARIANT_PARSER_NIL +import godot.tools.common.constants.godotCorePackage +import godot.tools.common.constants.godotInteropPackage +import java.io.File + + +object CallableGenerationService : ICallableGenerationService { + private const val FUNCTION_PARAMETER_NAME = "function" + private const val LAMBDA_CALLABLE_NAME = "LambdaCallable" + private const val LAMBDA_CONTAINER_NAME = "LambdaContainer" + private const val CONTAINER_ARGUMENT_NAME = "container" + private const val BOUND_ARGS_ARGUMENT_NAME = "boundArgs" + private const val CALLABLE_FUNCTION_NAME = "callable" + private const val VARIANT_TYPE_RETURN_NAME = "returnConverter" + private const val VARIANT_TYPE_ARGUMENT_NAME = "typeConverters" + private val LAMBDA_CALLABLE_CLASS_NAME = ClassName(godotCorePackage, LAMBDA_CALLABLE_NAME) + private val LAMBDA_CONTAINER_CLASS_NAME = ClassName(godotCorePackage, LAMBDA_CONTAINER_NAME) + private val returnTypeParameter = TypeVariableName("R", ANY.copy(nullable = true)) + private val variantConverterClassName = ClassName(godotInteropPackage, GodotKotlinJvmTypes.variantConverter) + + override fun generate(outputDir: File) { + val callableFileSpec = FileSpec.builder(godotCorePackage, "LambdaCallables") + val containerFileSpec = FileSpec.builder(godotCorePackage, "LambdaContainers") + + for (argCount in 0..Constraints.MAX_FUNCTION_ARG_COUNT) { + + val lambdaContainerClassName = ClassName(godotCorePackage, "$LAMBDA_CONTAINER_NAME$argCount") + val lambdaCallableClassName = ClassName(godotCorePackage, "$LAMBDA_CALLABLE_NAME$argCount") + + val containerInfo = GenericClassNameInfo(lambdaContainerClassName, argCount) + val callableInfo = GenericClassNameInfo(lambdaCallableClassName, argCount) + + val genericParameters = containerInfo.genericTypes + val lambdaTypeName = callableInfo.toLambdaTypeName(returnType = returnTypeParameter) + + + val lambdaContainerClassBuilder = TypeSpec + .classBuilder(lambdaContainerClassName) + .superclass(LAMBDA_CONTAINER_CLASS_NAME.parameterizedBy(returnTypeParameter)) + .addSuperclassConstructorParameter(VARIANT_TYPE_RETURN_NAME) + .addSuperclassConstructorParameter(VARIANT_TYPE_ARGUMENT_NAME) + .addSuperclassConstructorParameter(FUNCTION_PARAMETER_NAME) + .addTypeVariable(returnTypeParameter) + .addTypeVariables(genericParameters) + .primaryConstructor( + FunSpec + .constructorBuilder() + .addModifiers(KModifier.INTERNAL) + .addParameter( + ParameterSpec + .builder( + VARIANT_TYPE_RETURN_NAME, + variantConverterClassName + ) + .build() + ) + .addParameter( + ParameterSpec + .builder( + VARIANT_TYPE_ARGUMENT_NAME, + ARRAY.parameterizedBy(variantConverterClassName) + ) + .build() + ) + .addParameter( + ParameterSpec + .builder( + FUNCTION_PARAMETER_NAME, + lambdaTypeName + ) + .build() + ) + .addAnnotation(PublishedApi::class) + .build() + ) + .addFunction( + FunSpec + .builder("invokeUnsafe") + .addModifiers(KModifier.OVERRIDE) + .addParameter( + ParameterSpec + .builder("args", ANY.copy(nullable = true), KModifier.VARARG) + .build() + ) + .returns(returnTypeParameter) + .addCode( + CodeBlock.of( + buildString { + append("return·($FUNCTION_PARAMETER_NAME·as?·%T)?.invoke(") + append(callableInfo.toArgumentsString("args[INDEX]", "INDEX")) + append(")?:·throw·%T()") + }, + callableInfo.toErasedLambdaTypeName(returnType = returnTypeParameter), + ClassName(godotCorePackage, "InvalidJvmLambdaException") + ) + ) + .build() + + ) + + val lambdaCallableClassBuilder = TypeSpec + .classBuilder(lambdaCallableClassName) + .superclass(LAMBDA_CALLABLE_CLASS_NAME.parameterizedBy(returnTypeParameter)) + .addTypeVariable(returnTypeParameter) + .addTypeVariables(genericParameters) + .primaryConstructor( + FunSpec + .constructorBuilder() + .addModifiers(KModifier.INTERNAL) + .addParameter( + ParameterSpec + .builder( + CONTAINER_ARGUMENT_NAME, + LAMBDA_CONTAINER_CLASS_NAME.parameterizedBy(returnTypeParameter) + ) + .build() + ) + .addParameter( + ParameterSpec + .builder( + BOUND_ARGS_ARGUMENT_NAME, + ARRAY.parameterizedBy(ANY.copy(nullable = true)) + ) + .defaultValue("emptyArray()") + .build() + ) + .addAnnotation(PublishedApi::class) + .build() + ) + .addSuperclassConstructorParameter(CONTAINER_ARGUMENT_NAME, BOUND_ARGS_ARGUMENT_NAME) + .addFunction( + FunSpec + .builder("call") + .addParameters(callableInfo.toParameterSpecList()) + .returns(returnTypeParameter) + .addCode( + CodeBlock.of( + buildString { + append("return·$CONTAINER_ARGUMENT_NAME.invokeUnsafe(") + append(callableInfo.toArgumentsString("pINDEX", "INDEX")) + append(')') + } + ) + ) + .build() + ) + .addFunction( + FunSpec.builder("callDeferred") + .addParameters(callableInfo.toParameterSpecList()) + .addCode( + CodeBlock.of( + buildString { + append("return·callDeferredUnsafe(") + append(callableInfo.toArgumentsString("pINDEX", "INDEX")) + append(")") + } + ) + ) + .build() + ) + .addFunction( + FunSpec.builder("invoke") + .addParameters(callableInfo.toParameterSpecList()) + .returns(returnTypeParameter) + .addCode( + CodeBlock.of( + buildString { + append("return·call(") + append(callableInfo.toArgumentsString("pINDEX", "INDEX")) + append(')') + }, + *genericParameters.toTypedArray() + ) + ) + .addModifiers(KModifier.OPERATOR) + .build() + ) + + val typeVariables = genericParameters.toMutableList() + var remainingParameters = 0 + while (typeVariables.isNotEmpty()) { + val bindClassName = ClassName(godotCorePackage, "$LAMBDA_CALLABLE_NAME${remainingParameters}") + val bindInfo = GenericClassNameInfo(bindClassName, remainingParameters) + + lambdaCallableClassBuilder.addFunction( + FunSpec.builder("bind") + .addParameters( + typeVariables + .mapIndexed { index: Int, typeVariableName: TypeVariableName -> + ParameterSpec.builder("p${index + remainingParameters}", typeVariableName) + .build() + } + ) + .addCode( + buildString { + append("return·%T($CONTAINER_ARGUMENT_NAME, arrayOf(") + + for (index in (0.. + if (index != 0) append(",·") + append("%M[%T::class]!!") + } + append("),·") + append(FUNCTION_PARAMETER_NAME) + append("))") + }, + callableInfo.className.parameterizedBy(listOf(returnTypeParameter) + callableInfo.genericTypes), + containerInfo.className.parameterizedBy(listOf(returnTypeParameter) + containerInfo.genericTypes), + variantMapperMember, + returnTypeParameter, + VARIANT_PARSER_NIL, + *genericParameters + .flatMap { + listOf(variantMapperMember, it) + } + .toTypedArray() + ) + ) + .build() + ) + + callableFileSpec + .addFunction( + FunSpec + .builder(GodotFunctions.asCallable) + .addTypeVariables(genericParameters.map { it.copy(reified = true) }) + .addTypeVariable(returnTypeParameter.copy(reified = true)) + .addModifiers(KModifier.INLINE) + .receiver(lambdaTypeName) + .addCode("return·$CALLABLE_FUNCTION_NAME$argCount(this)") + .build() + ) + } + + callableFileSpec + .addAnnotation( + AnnotationSpec + .builder(ClassName("kotlin", "Suppress")) + .addMember("\"PackageDirectoryMismatch\", \"UNCHECKED_CAST\"") + .addMember("\"unused\"") + .build() + ) + .build() + .writeTo(outputDir) + + containerFileSpec + .addAnnotation( + AnnotationSpec + .builder(ClassName("kotlin", "Suppress")) + .addMember("\"PackageDirectoryMismatch\", \"UNCHECKED_CAST\"") + .addMember("\"unused\"") + .build() + ) + .build() + .writeTo(outputDir) + } +} diff --git a/kt/api-generator/src/main/kotlin/godot/codegen/services/impl/ConnectorGenerationService.kt b/kt/api-generator/src/main/kotlin/godot/codegen/services/impl/ConnectorGenerationService.kt new file mode 100644 index 000000000..f851902b9 --- /dev/null +++ b/kt/api-generator/src/main/kotlin/godot/codegen/services/impl/ConnectorGenerationService.kt @@ -0,0 +1,191 @@ +package godot.codegen.services.impl + +import com.squareup.kotlinpoet.AnnotationSpec +import com.squareup.kotlinpoet.ClassName +import com.squareup.kotlinpoet.CodeBlock +import com.squareup.kotlinpoet.FileSpec +import com.squareup.kotlinpoet.KModifier +import com.squareup.kotlinpoet.LambdaTypeName +import com.squareup.kotlinpoet.MemberName +import com.squareup.kotlinpoet.ParameterSpec +import com.squareup.kotlinpoet.ParameterizedTypeName.Companion.parameterizedBy +import com.squareup.kotlinpoet.TypeVariableName +import com.squareup.kotlinpoet.UNIT +import com.squareup.kotlinpoet.asClassName +import godot.codegen.poet.GenericClassNameInfo +import godot.codegen.services.IConnectorGenerationService +import godot.common.constants.Constraints +import godot.tools.common.constants.GODOT_METHOD_CALLABLE +import godot.tools.common.constants.GODOT_SIGNAL_CONNECTOR +import godot.tools.common.constants.GODOT_OBJECT +import godot.tools.common.constants.GodotKotlinJvmTypes +import godot.tools.common.constants.TO_GODOT_NAME_UTIL_FUNCTION +import godot.tools.common.constants.godotCorePackage +import java.io.File +import kotlin.reflect.KCallable + +object ConnectorGenerationService : IConnectorGenerationService { + private const val LAMBDA_CONTAINER_NAME = "LambdaContainer" + private const val SIGNAL_CLASS_NAME = "Signal" + private const val CONNECT_METHOD_NAME = "connect" + private const val PROMISE_METHOD_NAME = "promise" + private const val METHOD_PARAMETER_NAME = "method" + private const val CANCEL_PARAMETER_NAME = "cancel" + private const val FLAGS_PARAMETER_NAME = "flags" + private const val TARGET_PARAMETER_NAME = "target" + private val godotObjectBoundTypeVariable = TypeVariableName("T", GODOT_OBJECT) + private val connectFlagClassName = ClassName(godotCorePackage, "Object.ConnectFlags") + private val variantConverterClassName = ClassName(godotCorePackage, GodotKotlinJvmTypes.variantParser) + private val variantMapperMember = MemberName(godotCorePackage, "variantMapper") + + override fun generate(output: File) { + val connectorFileSpec = FileSpec.builder(godotCorePackage, "SignalConnectors") + + for (argCount in 0..Constraints.MAX_FUNCTION_ARG_COUNT) { + val signalClassName = ClassName(godotCorePackage, "$SIGNAL_CLASS_NAME$argCount") + val genericClassNameInfo = GenericClassNameInfo(signalClassName, argCount) + val genericParameters = genericClassNameInfo.genericTypes + + val flagsParameter = ParameterSpec.builder(FLAGS_PARAMETER_NAME, connectFlagClassName) + .defaultValue("%T.%L", connectFlagClassName, "DEFAULT") + .build() + + + connectorFileSpec.addFunction( + genericClassNameInfo + .toReifiedExtensionFunSpecBuilder(CONNECT_METHOD_NAME) + .addParameters( + listOf( + flagsParameter, + ParameterSpec + .builder( + METHOD_PARAMETER_NAME, + LambdaTypeName.get( + parameters = genericClassNameInfo.toParameterSpecList(), + returnType = UNIT + ) + ) + .addModifiers(KModifier.NOINLINE) + .build() + ) + ) + .addCode( + CodeBlock.of( + """ + val connector = %T( + this, + $METHOD_PARAMETER_NAME.asCallable() + ) + connector.connect($FLAGS_PARAMETER_NAME) + return connector + """.trimIndent(), + GODOT_SIGNAL_CONNECTOR, + ) + ) + .returns( + GODOT_SIGNAL_CONNECTOR + ) + .build() + ) + + + val lambdaTypeName = genericClassNameInfo.toLambdaTypeName(UNIT, godotObjectBoundTypeVariable) + + connectorFileSpec.addFunction( + genericClassNameInfo + .toExtensionFunSpecBuilder(CONNECT_METHOD_NAME, listOf(godotObjectBoundTypeVariable)) + .addParameters( + listOf( + ParameterSpec + .builder(TARGET_PARAMETER_NAME, godotObjectBoundTypeVariable) + .build(), + ParameterSpec + .builder(METHOD_PARAMETER_NAME, lambdaTypeName) + .build(), + flagsParameter + ) + ) + .returns(GODOT_SIGNAL_CONNECTOR) + .addCode( + CodeBlock.of( + """ + val connector = %T( + this, + %T($TARGET_PARAMETER_NAME,·($METHOD_PARAMETER_NAME·as·%T<*>).name.%M()) + ) + connector.connect($FLAGS_PARAMETER_NAME) + return connector + """.trimIndent(), + GODOT_SIGNAL_CONNECTOR, + GODOT_METHOD_CALLABLE, + KCallable::class.asClassName(), + TO_GODOT_NAME_UTIL_FUNCTION, + ) + ) + .build() + ) + + val lambdaContainerClassName = ClassName(godotCorePackage, "$LAMBDA_CONTAINER_NAME$argCount") + val containerInfo = GenericClassNameInfo(lambdaContainerClassName, argCount) + connectorFileSpec.addFunction( + genericClassNameInfo + .toReifiedExtensionFunSpecBuilder(PROMISE_METHOD_NAME) + .addParameters( + listOf( + ParameterSpec + .builder( + METHOD_PARAMETER_NAME, + LambdaTypeName.get( + parameters = genericClassNameInfo.toParameterSpecList(), + returnType = UNIT + ) + ) + .addModifiers(KModifier.NOINLINE) + .build(), + ParameterSpec + .builder( + CANCEL_PARAMETER_NAME, LambdaTypeName.get( + returnType = UNIT + ) + ) + .addModifiers(KModifier.NOINLINE) + .build(), + + ) + ) + .addCode( + CodeBlock.of( + buildString { + append("%T(%T.NIL,·arrayOf(") + genericParameters.forEachIndexed { index, _ -> + if (index != 0) append(",·") + append("%M[%T::class]!!") + } + append("),·$METHOD_PARAMETER_NAME).setAsCancellable(this,·$CANCEL_PARAMETER_NAME)") + }, + containerInfo.className.parameterizedBy(listOf(UNIT) + containerInfo.genericTypes), + variantConverterClassName, + *genericParameters + .flatMap { + listOf(variantMapperMember, it) + } + .toTypedArray() + ) + ) + .build() + ) + } + + connectorFileSpec + .addAnnotation( + AnnotationSpec + .builder(ClassName("kotlin", "Suppress")) + .addMember("\"PackageDirectoryMismatch\", \"UNCHECKED_CAST\"") + .addMember("\"unused\"") + .addMember("\"NOTHING_TO_INLINE\"") + .build() + ) + .build() + .writeTo(output) + } +} diff --git a/kt/api-generator/src/main/kotlin/godot/codegen/services/impl/LambdaCallableGenerationService.kt b/kt/api-generator/src/main/kotlin/godot/codegen/services/impl/LambdaCallableGenerationService.kt deleted file mode 100644 index fa09b2509..000000000 --- a/kt/api-generator/src/main/kotlin/godot/codegen/services/impl/LambdaCallableGenerationService.kt +++ /dev/null @@ -1,444 +0,0 @@ -package godot.codegen.services.impl - -import com.squareup.kotlinpoet.ANY -import com.squareup.kotlinpoet.AnnotationSpec -import com.squareup.kotlinpoet.ClassName -import com.squareup.kotlinpoet.CodeBlock -import com.squareup.kotlinpoet.FileSpec -import com.squareup.kotlinpoet.FunSpec -import com.squareup.kotlinpoet.KModifier -import com.squareup.kotlinpoet.LambdaTypeName -import com.squareup.kotlinpoet.MemberName -import com.squareup.kotlinpoet.ParameterSpec -import com.squareup.kotlinpoet.ParameterizedTypeName.Companion.parameterizedBy -import com.squareup.kotlinpoet.PropertySpec -import com.squareup.kotlinpoet.TypeSpec -import com.squareup.kotlinpoet.TypeVariableName -import com.squareup.kotlinpoet.UNIT -import godot.codegen.poet.GenericClassNameInfo -import godot.codegen.services.ILambdaCallableGenerationService -import godot.common.constants.Constraints -import godot.tools.common.constants.GodotFunctions -import godot.tools.common.constants.GodotKotlinJvmTypes -import godot.tools.common.constants.VARIANT_PARSER_NIL -import godot.tools.common.constants.godotCorePackage -import godot.tools.common.constants.godotInteropPackage -import java.io.File - - -object LambdaCallableGenerationService : ILambdaCallableGenerationService { - private const val FUNCTION_PARAMETER_NAME = "function" - private const val LAMBDA_CALLABLE_NAME = "LambdaCallable" - private const val CALLABLE_FUNCTION_NAME = "callable" - private const val JAVA_CREATE_METHOD_NAME = "javaCreate" - private const val VARIANT_TYPE_ARGUMENT_NAME = "variantConverter" - private const val ON_CANCEL_CALL_ARGUMENT_NAME = "onCancelCall" - private val LAMBDA_CALLABLE_CLASS_NAME = ClassName(godotCorePackage, LAMBDA_CALLABLE_NAME) - private val returnTypeParameter = TypeVariableName("R", ANY.copy(nullable = true)) - - //Java - private val REFLECTION_CLASS_NAME = ClassName("kotlin.jvm.internal", "Reflection") - private val JAVA_CLASS_CLASS_NAME = ClassName("java.lang", "Class") - - override fun generate(outputDir: File) { - val callableFileSpec = FileSpec.builder(godotCorePackage, "Callables") - - val onDestroyCallLambdaType = LambdaTypeName.get(returnType = UNIT).copy(nullable = true) - - for (argCount in 0..Constraints.MAX_FUNCTION_ARG_COUNT) { - val ktCallableClassName = ClassName(godotCorePackage, "$LAMBDA_CALLABLE_NAME$argCount") - val classBuilder = TypeSpec - .classBuilder(ktCallableClassName) - .superclass( - LAMBDA_CALLABLE_CLASS_NAME - .parameterizedBy(returnTypeParameter) - ) - - val argumentRange = 0.. - ParameterSpec.builder("p$index", typeVariableName).build() - }, - returnType = returnTypeParameter - ) - - classBuilder - .addProperty( - PropertySpec - .builder( - FUNCTION_PARAMETER_NAME, - lambdaTypeName, - KModifier.PRIVATE - ) - .initializer(FUNCTION_PARAMETER_NAME) - .build() - ) - - val variantConverterClassName = ClassName( - godotInteropPackage, - GodotKotlinJvmTypes.variantConverter - ) - - primaryConstructor - .addParameter( - ParameterSpec - .builder( - VARIANT_TYPE_ARGUMENT_NAME, - variantConverterClassName - ) - .build() - ) - - for (arg in argumentRange) { - val typeProperty = "p${arg}Type" - - if (arg != argumentRange.last) { - classBuilder - .addProperty( - PropertySpec - .builder( - typeProperty, - variantConverterClassName, - KModifier.PRIVATE - ) - .initializer(typeProperty) - .build() - ) - } - - primaryConstructor - .addParameter( - ParameterSpec - .builder( - typeProperty, - variantConverterClassName - ) - .build() - ) - } - - primaryConstructor - .addParameter( - ParameterSpec - .builder( - ON_CANCEL_CALL_ARGUMENT_NAME, - onDestroyCallLambdaType - ) - .defaultValue("null") - .build() - ) - - primaryConstructor - .addParameter( - ParameterSpec - .builder( - FUNCTION_PARAMETER_NAME, - lambdaTypeName - ) - .build() - ) - .addModifiers(KModifier.INTERNAL) - .addAnnotation(PublishedApi::class) - - classBuilder.primaryConstructor(primaryConstructor.build()) - - classBuilder - .addFunction( - FunSpec.builder("invokeKt") - .returns( - returnTypeParameter - ) - .addCode( - CodeBlock.of( - buildString { - append("return·$FUNCTION_PARAMETER_NAME(") - for (i in argumentRange) { - if (i != 0) append(",·") - - append("paramsArray[$i]·as·%T") - } - append(')') - }, - *typeVariableNames.toTypedArray() - ) - ) - .addModifiers(KModifier.OVERRIDE) - .build() - ) - - classBuilder - .addFunction( - FunSpec.builder("invoke") - .returns( - returnTypeParameter - ) - .addParameters( - typeVariableNames - .mapIndexed { index: Int, typeVariableName: TypeVariableName -> - ParameterSpec.builder("p$index", typeVariableName) - .build() - } - ) - .addCode( - CodeBlock.of( - buildString { - append("return·$FUNCTION_PARAMETER_NAME(") - for (i in argumentRange) { - if (i != 0) append(",·") - - append("p$i") - } - append(')') - } - ) - ) - .addModifiers(KModifier.OPERATOR) - .build() - ) - - classBuilder - .addFunction( - FunSpec.builder("call") - .returns(ANY.copy(nullable = true)) - .addParameter( - ParameterSpec.builder("args", ANY.copy(nullable = true)) - .addModifiers(KModifier.VARARG) - .build() - ) - .addCode( - CodeBlock.of( - buildString { - append("return·$FUNCTION_PARAMETER_NAME(") - for (i in argumentRange) { - if (i != 0) append(",·") - - append("args[$i]·as·%T") - } - append(')') - }, - *typeVariableNames.toTypedArray() - ) - ) - .addModifiers(KModifier.OVERRIDE) - .build() - ) - - val typeVariables = typeVariableNames.toMutableList() - var removedTypeVariables = 0 - while (typeVariables.isNotEmpty()) { - val bindReturnType = - ClassName(godotCorePackage, "$LAMBDA_CALLABLE_NAME${typeVariableNames.size - typeVariables.size}") - classBuilder.addFunction( - FunSpec.builder("bind") - .addParameters( - typeVariables - .mapIndexed { index: Int, typeVariableName: TypeVariableName -> - ParameterSpec.builder("p${index + removedTypeVariables}", typeVariableName) - .build() - } - ) - .addCode( - buildString { - append("return·%T($VARIANT_TYPE_ARGUMENT_NAME") - - for (index in (0..·$FUNCTION_PARAMETER_NAME(") - - for (i in typeVariableNames.indices) { - if (i != 0) append(",·") - - append("p$i") - } - - append(")·}") - }, - bindReturnType, - *typeVariableNames.take(removedTypeVariables).toTypedArray() - ) - .build() - ) - - typeVariables.removeFirst() - ++removedTypeVariables - } - - val genericClassNameInfo = GenericClassNameInfo(ktCallableClassName, argCount) - classBuilder.addType(generateKtCallableCompanion(argCount, genericClassNameInfo)) - - callableFileSpec.addType(classBuilder.build()) - - val variantMapperMember = MemberName(godotCorePackage, "variantMapper") - callableFileSpec.addFunction( - FunSpec.builder(CALLABLE_FUNCTION_NAME + argCount) - .addTypeVariables(typeVariableNames.map { it.copy(reified = true) }) - .addTypeVariable(returnTypeParameter.copy(reified = true)) - .addModifiers(KModifier.INLINE) - .addParameters( - listOf( - ParameterSpec - .builder(ON_CANCEL_CALL_ARGUMENT_NAME, onDestroyCallLambdaType) - .addModifiers(KModifier.NOINLINE) - .defaultValue("null") - .build(), - ParameterSpec - .builder( - FUNCTION_PARAMETER_NAME, - lambdaTypeName - ) - .addModifiers(KModifier.NOINLINE) - .build() - ) - ) - .addCode( - CodeBlock.of( - buildString { - append("return·$LAMBDA_CALLABLE_NAME$argCount(") - append("%M.getOrDefault(%T::class,·%T),·") - for (typeParameter in typeVariableNames) { - append("%M[%T::class]!!,·") - } - append("$ON_CANCEL_CALL_ARGUMENT_NAME,·") - append(FUNCTION_PARAMETER_NAME) - append(')') - }, - variantMapperMember, - returnTypeParameter, - VARIANT_PARSER_NIL, - *typeVariableNames - .flatMap { - listOf(variantMapperMember, it) - } - .toTypedArray() - ) - ) - .build() - ) - - callableFileSpec - .addFunction( - FunSpec - .builder(GodotFunctions.asCallable) - .addTypeVariables(typeVariableNames.map { it.copy(reified = true) }) - .addTypeVariable(returnTypeParameter.copy(reified = true)) - .addModifiers(KModifier.INLINE) - .receiver(lambdaTypeName) - .addParameter( - ParameterSpec - .builder(ON_CANCEL_CALL_ARGUMENT_NAME, onDestroyCallLambdaType) - .addModifiers(KModifier.NOINLINE) - .defaultValue("null") - .build() - ) - .addCode("return·$CALLABLE_FUNCTION_NAME$argCount($ON_CANCEL_CALL_ARGUMENT_NAME,·this)") - .build() - ) - } - - callableFileSpec.addAnnotation( - AnnotationSpec.builder(ClassName("kotlin", "Suppress")) - .addMember("\"PackageDirectoryMismatch\", \"UNCHECKED_CAST\"") - .build() - ) - .build() - .writeTo(outputDir) - } - - // JAVA BRIDGE FUNCTION - private fun generateKtCallableCompanion(argCount: Int, genericClassNameInfo: GenericClassNameInfo): TypeSpec { - val variantMapperMember = MemberName(godotCorePackage, "variantMapper") - - return TypeSpec - .companionObjectBuilder() - .addFunction( - FunSpec - .builder(JAVA_CREATE_METHOD_NAME) - .addTypeVariable(returnTypeParameter) - .addTypeVariables(genericClassNameInfo.genericTypes) - .addParameter( - ParameterSpec - .builder("returnClass", JAVA_CLASS_CLASS_NAME.parameterizedBy(returnTypeParameter)) - .build() - ) - .addParameters(genericClassNameInfo.toParameterSpecList().map { - ParameterSpec - .builder(it.name + "Class", JAVA_CLASS_CLASS_NAME.parameterizedBy(it.type)) - .build() - }) - .addParameter( - ParameterSpec - .builder( - FUNCTION_PARAMETER_NAME, - genericClassNameInfo.toLambdaTypeName(returnTypeParameter) - ) - .build() - ) - .addCode( - CodeBlock.of( - buildString { - append("return·$LAMBDA_CALLABLE_NAME$argCount(") - append("%M.getOrDefault(%T.getOrCreateKotlinClass(returnClass),·%T),·") - genericClassNameInfo.toParameterSpecList().forEach { - append("%M[%T.getOrCreateKotlinClass(${it.name}Class)]!!,·") - } - append("null,·") - append(FUNCTION_PARAMETER_NAME) - append(')') - }, - variantMapperMember, - REFLECTION_CLASS_NAME, - VARIANT_PARSER_NIL, - *genericClassNameInfo.genericTypes - .flatMap { - listOf(variantMapperMember, REFLECTION_CLASS_NAME) - } - .toTypedArray() - ) - ) - .addAnnotation(JvmStatic::class) - .addAnnotation( - AnnotationSpec - .builder(JvmName::class) - .addMember("\"create\"") - .build() - ) - .build() - ) - .build() - } -} diff --git a/kt/api-generator/src/main/kotlin/godot/codegen/services/impl/SignalGenerationService.kt b/kt/api-generator/src/main/kotlin/godot/codegen/services/impl/SignalGenerationService.kt index 173454e9b..f4e0bf9c1 100644 --- a/kt/api-generator/src/main/kotlin/godot/codegen/services/impl/SignalGenerationService.kt +++ b/kt/api-generator/src/main/kotlin/godot/codegen/services/impl/SignalGenerationService.kt @@ -1,36 +1,25 @@ package godot.codegen.services.impl -import com.squareup.kotlinpoet.ANY import com.squareup.kotlinpoet.AnnotationSpec import com.squareup.kotlinpoet.ClassName import com.squareup.kotlinpoet.CodeBlock import com.squareup.kotlinpoet.FileSpec import com.squareup.kotlinpoet.FunSpec -import com.squareup.kotlinpoet.INT import com.squareup.kotlinpoet.KModifier -import com.squareup.kotlinpoet.LambdaTypeName import com.squareup.kotlinpoet.ParameterSpec import com.squareup.kotlinpoet.ParameterizedTypeName.Companion.parameterizedBy import com.squareup.kotlinpoet.PropertySpec import com.squareup.kotlinpoet.STAR import com.squareup.kotlinpoet.STRING import com.squareup.kotlinpoet.TypeSpec -import com.squareup.kotlinpoet.TypeVariableName import com.squareup.kotlinpoet.UNIT -import com.squareup.kotlinpoet.asClassName import godot.codegen.poet.GenericClassNameInfo import godot.codegen.services.ISignalGenerationService import godot.common.constants.Constraints -import godot.tools.common.constants.AS_CALLABLE_UTIL_FUNCTION -import godot.tools.common.constants.GODOT_CALLABLE -import godot.tools.common.constants.GODOT_ERROR import godot.tools.common.constants.GODOT_OBJECT -import godot.tools.common.constants.TO_GODOT_NAME_UTIL_FUNCTION import godot.tools.common.constants.godotCorePackage -import godot.tools.common.constants.godotExtensionPackage import godot.tools.common.constants.kotlinReflectPackage import java.io.File -import kotlin.reflect.KCallable object SignalGenerationService : ISignalGenerationService { @@ -38,25 +27,18 @@ object SignalGenerationService : ISignalGenerationService { private const val INSTANCE_PARAMETER = "instance" private const val NAME_PARAMETER = "name" private const val PROPERTY_PARAMETER = "property" - private const val TARGET_PARAMETER_NAME = "target" - private const val METHOD_PARAMETER_NAME = "method" - private const val FLAGS_PARAMETER_NAME = "flags" private const val THIS_REF_PARAMETER_NAME = "thisRef" private const val EMIT_METHOD_NAME = "emit" - private const val CONNECT_METHOD_NAME = "connect" - private const val CONNECT_THREAD_SAFE_METHOD_NAME = "connectThreadSafe" - private const val DISCONNECT_METHOD_NAME = "disconnect" private const val SIGNAL_METHOD_NAME = "signal" - private const val JAVA_CREATE_METHOD_NAME = "javaCreate" + private const val UNSAFE_SUFFIX = "Unsafe" private const val DELEGATE_PROPERTY_NAME = "delegate" private val propertyClassname = ClassName(kotlinReflectPackage, "KProperty").parameterizedBy(STAR) private val readOnlyPropertyClassName = ClassName("kotlin.properties", "ReadOnlyProperty") - private val godotObjectBoundTypeVariable = TypeVariableName("T", GODOT_OBJECT) - override fun generateCore(outputDir: File) { + override fun generate(outputDir: File) { val signalFileSpec = FileSpec.builder(godotCorePackage, "Signals") for (argCount in 0..Constraints.MAX_FUNCTION_ARG_COUNT) { @@ -67,7 +49,6 @@ object SignalGenerationService : ISignalGenerationService { signalFileSpec.addFunction(generateFakeSignalConstructor(argCount, genericClassNameInfo)) signalFileSpec.addFunction(generateSignalDelegate(argCount, genericClassNameInfo)) - signalFileSpec.addFunction(generateSignalExtension(genericClassNameInfo, false)) } signalFileSpec @@ -77,6 +58,7 @@ object SignalGenerationService : ISignalGenerationService { .addMember("\"PackageDirectoryMismatch\"") .addMember("\"NOTHING_TO_INLINE\"") .addMember("\"UNUSED_PARAMETER\"") + .addMember("\"unused\"") .build() ) .indent(" ") @@ -84,48 +66,8 @@ object SignalGenerationService : ISignalGenerationService { .writeTo(outputDir) } - override fun generateExtension(outputDir: File) { - val signalFileSpec = FileSpec.builder(godotExtensionPackage, "SignalUtils") - - for (argCount in 0..Constraints.MAX_FUNCTION_ARG_COUNT) { - val signalClassName = ClassName(godotCorePackage, "$SIGNAL_CLASS_NAME$argCount") - val genericClassNameInfo = GenericClassNameInfo(signalClassName, argCount) - - signalFileSpec.addFunction(generateThreadSafeExtension(argCount, genericClassNameInfo)) - signalFileSpec.addFunction(generateSignalExtension(genericClassNameInfo, true)) - } - - signalFileSpec - .addAnnotation( - AnnotationSpec - .builder(Suppress::class) - .addMember("\"PackageDirectoryMismatch\"") - .addMember("\"NOTHING_TO_INLINE\"") - .addMember("\"UNUSED_PARAMETER\"") - .build() - ) - .indent(" ") - .addImport( - "godot.extension", - "connectThreadSafe" - ) - .build() - .writeTo(outputDir) - } - - private fun generateSignalClass(argCount: Int, genericClassNameInfo: GenericClassNameInfo): TypeSpec { - val flagsParameter = ParameterSpec.builder(FLAGS_PARAMETER_NAME, INT) - .defaultValue("0") - .build() - - val lambdaTypeName = LambdaTypeName.get( - receiver = godotObjectBoundTypeVariable, - parameters = genericClassNameInfo.toParameterSpecList(), - returnType = UNIT - ) - return genericClassNameInfo .toTypeSpecBuilder() .superclass(ClassName(godotCorePackage, SIGNAL_CLASS_NAME)) @@ -153,7 +95,7 @@ object SignalGenerationService : ISignalGenerationService { .addCode( CodeBlock.of( buildString { - append("emitSignal(") + append("$EMIT_METHOD_NAME$UNSAFE_SUFFIX(") for (i in 0..).name.%M())$flagsParameters)", - GODOT_CALLABLE, - KCallable::class.asClassName(), - TO_GODOT_NAME_UTIL_FUNCTION, - ) - } private fun generateSignalCompanion(argCount: Int, genericClassNameInfo: GenericClassNameInfo): TypeSpec { val erasedReadOnlyPropertyClassName = readOnlyPropertyClassName.parameterizedBy(GODOT_OBJECT, genericClassNameInfo.erasedGenericClassName) @@ -273,25 +145,6 @@ object SignalGenerationService : ISignalGenerationService { ) .build() ) - .addFunction( - genericClassNameInfo - .toFunSpecBuilder(JAVA_CREATE_METHOD_NAME) - .addParameter(ParameterSpec.builder("`object`", GODOT_OBJECT).build()) - .addParameter(ParameterSpec.builder("signalName", STRING).build()) - .returns(genericClassNameInfo.genericClassName) - .addCode( - "return·%T(`object`,·signalName)", - genericClassNameInfo.className - ) - .addAnnotation(JvmStatic::class) - .addAnnotation( - AnnotationSpec - .builder(JvmName::class) - .addMember("\"create\"") - .build() - ) - .build() - ) .build() } @@ -343,48 +196,4 @@ object SignalGenerationService : ISignalGenerationService { } .build() } - - - private fun generateSignalExtension(genericClassNameInfo: GenericClassNameInfo, isThreadSafe: Boolean): FunSpec { - val flagsParameter = ParameterSpec.builder(FLAGS_PARAMETER_NAME, INT) - .defaultValue("0") - .build() - - val signalConnectExtensionGenericParameters = ParameterSpec.builder( - METHOD_PARAMETER_NAME, - LambdaTypeName.get( - parameters = genericClassNameInfo.toParameterSpecList(), - returnType = UNIT - ) - ) - .addModifiers(KModifier.NOINLINE) - .build() - - val methodName = if (isThreadSafe) { - CONNECT_THREAD_SAFE_METHOD_NAME - } else { - CONNECT_METHOD_NAME - } - - return genericClassNameInfo - .toReifiedExtensionFunSpecBuilder(methodName) - .addParameters( - listOf( - flagsParameter, - signalConnectExtensionGenericParameters - ) - ) - .addCode( - "return·$methodName($METHOD_PARAMETER_NAME.%M(),·$FLAGS_PARAMETER_NAME)", - AS_CALLABLE_UTIL_FUNCTION - ) - .returns( - if (isThreadSafe) { - ANY.copy(nullable = true) - } else { - GODOT_ERROR - } - ) - .build() - } } diff --git a/kt/api-generator/src/main/kotlin/godot/gradle/ApiGeneratorPlugin.kt b/kt/api-generator/src/main/kotlin/godot/gradle/ApiGeneratorPlugin.kt index cb4f8f783..8d8114499 100644 --- a/kt/api-generator/src/main/kotlin/godot/gradle/ApiGeneratorPlugin.kt +++ b/kt/api-generator/src/main/kotlin/godot/gradle/ApiGeneratorPlugin.kt @@ -2,7 +2,6 @@ package godot.gradle import godot.codegen.generateApiFrom import godot.codegen.generateCoroutine -import godot.codegen.generateExtension import org.gradle.api.DefaultTask import org.gradle.api.Plugin import org.gradle.api.Project @@ -49,10 +48,6 @@ open class GenerateAPI : DefaultTask() { apiOutput, ) - val extensionOutput = extensionOutputDir.get().asFile - extensionOutput.deleteRecursively() - generateExtension(extensionOutput) - val coroutineOutput = coroutineOutputDir.get().asFile coroutineOutput.deleteRecursively() generateCoroutine(coroutineOutput) diff --git a/kt/godot-library/godot-core-library/src/main/kotlin/gen/godot/api/Object.kt b/kt/godot-library/godot-core-library/src/main/kotlin/gen/godot/api/Object.kt index 170acade1..592aa1163 100644 --- a/kt/godot-library/godot-core-library/src/main/kotlin/gen/godot/api/Object.kt +++ b/kt/godot-library/godot-core-library/src/main/kotlin/gen/godot/api/Object.kt @@ -995,9 +995,9 @@ public open class Object : KtObject() { public final fun connect( signal: StringName, callable: Callable, - flags: Long = 0, + flags: ConnectFlags = Object.ConnectFlags.DEFAULT, ): Error { - TransferContext.writeArguments(STRING_NAME to signal, CALLABLE to callable, LONG to flags) + TransferContext.writeArguments(STRING_NAME to signal, CALLABLE to callable, LONG to flags.id) TransferContext.callMethod(ptr, MethodBindings.connectPtr, LONG) return Error.from(TransferContext.readReturnValue(LONG) as Long) } @@ -1740,7 +1740,7 @@ public open class Object : KtObject() { public final fun connect( signal: String, callable: Callable, - flags: Long = 0, + flags: ConnectFlags = Object.ConnectFlags.DEFAULT, ): Error = connect(signal.asCachedStringName(), callable, flags) /** @@ -1826,6 +1826,10 @@ public open class Object : KtObject() { public enum class ConnectFlags( id: Long, ) { + /** + * Default connections that are immediately emitted + */ + DEFAULT(0), /** * Deferred connections trigger their [Callable]s on idle time (at the end of the frame), rather * than instantly. diff --git a/kt/godot-library/godot-core-library/src/main/kotlin/gen/godot/core/Callables.kt b/kt/godot-library/godot-core-library/src/main/kotlin/gen/godot/core/Callables.kt deleted file mode 100644 index 9a583a300..000000000 --- a/kt/godot-library/godot-core-library/src/main/kotlin/gen/godot/core/Callables.kt +++ /dev/null @@ -1,2845 +0,0 @@ -@file:Suppress("PackageDirectoryMismatch", "UNCHECKED_CAST") - -package godot.core - -import godot.common.interop.VariantConverter -import godot.core.VariantParser.NIL -import java.lang.Class -import kotlin.Any -import kotlin.PublishedApi -import kotlin.Suppress -import kotlin.Unit -import kotlin.jvm.JvmName -import kotlin.jvm.JvmStatic -import kotlin.jvm.`internal`.Reflection - -public class LambdaCallable0 @PublishedApi internal constructor( - variantConverter: VariantConverter, - onCancelCall: (() -> Unit)? = null, - private val function: () -> R, -) : LambdaCallable(variantConverter, onCancelCall) { - public override fun invokeKt(): R = function() - - public operator fun invoke(): R = function() - - public override fun call(vararg args: Any?): Any? = function() - - public companion object { - @JvmStatic - @JvmName("create") - public fun javaCreate(returnClass: Class, function: () -> R) = - LambdaCallable0(variantMapper.getOrDefault(Reflection.getOrCreateKotlinClass(returnClass), NIL), null, function) - } -} - -public inline fun callable0(noinline onCancelCall: (() -> Unit)? = null, noinline - function: () -> R) = - LambdaCallable0(variantMapper.getOrDefault(R::class, NIL), onCancelCall, function) - -public inline fun (() -> R).asCallable(noinline onCancelCall: (() -> Unit)? = null) = - callable0(onCancelCall, this) - -public class LambdaCallable1 @PublishedApi internal constructor( - variantConverter: VariantConverter, - p0Type: VariantConverter, - onCancelCall: (() -> Unit)? = null, - private val function: (p0: P0) -> R, -) : LambdaCallable(variantConverter, onCancelCall, p0Type) { - public override fun invokeKt(): R = function(paramsArray[0] as P0) - - public operator fun invoke(p0: P0): R = function(p0) - - public override fun call(vararg args: Any?): Any? = function(args[0] as P0) - - public fun bind(p0: P0) = LambdaCallable0(variantConverter, onCancelCall) { -> function(p0) } - - public companion object { - @JvmStatic - @JvmName("create") - public fun javaCreate( - returnClass: Class, - p0Class: Class, - function: (p0: P0) -> R, - ) = - LambdaCallable1(variantMapper.getOrDefault(Reflection.getOrCreateKotlinClass(returnClass), NIL), variantMapper[Reflection.getOrCreateKotlinClass(p0Class)]!!, null, function) - } -} - -public inline fun callable1(noinline onCancelCall: (() -> Unit)? = null, - noinline function: (p0: P0) -> R) = - LambdaCallable1(variantMapper.getOrDefault(R::class, NIL), variantMapper[P0::class]!!, onCancelCall, function) - -public inline fun ((p0: P0) -> R).asCallable(noinline - onCancelCall: (() -> Unit)? = null) = callable1(onCancelCall, this) - -public class LambdaCallable2 @PublishedApi internal constructor( - variantConverter: VariantConverter, - private val p0Type: VariantConverter, - p1Type: VariantConverter, - onCancelCall: (() -> Unit)? = null, - private val function: (p0: P0, p1: P1) -> R, -) : LambdaCallable(variantConverter, onCancelCall, p0Type, p1Type) { - public override fun invokeKt(): R = function(paramsArray[0] as P0, paramsArray[1] as P1) - - public operator fun invoke(p0: P0, p1: P1): R = function(p0, p1) - - public override fun call(vararg args: Any?): Any? = function(args[0] as P0, args[1] as P1) - - public fun bind(p0: P0, p1: P1) = - LambdaCallable0(variantConverter, onCancelCall) { -> function(p0, p1) } - - public fun bind(p1: P1) = - LambdaCallable1(variantConverter, p0Type, onCancelCall) { p0: P0 -> function(p0, p1) } - - public companion object { - @JvmStatic - @JvmName("create") - public fun javaCreate( - returnClass: Class, - p0Class: Class, - p1Class: Class, - function: (p0: P0, p1: P1) -> R, - ) = - LambdaCallable2(variantMapper.getOrDefault(Reflection.getOrCreateKotlinClass(returnClass), NIL), variantMapper[Reflection.getOrCreateKotlinClass(p0Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p1Class)]!!, null, function) - } -} - -public inline fun callable2(noinline onCancelCall: (() -> Unit)? - = null, noinline function: (p0: P0, p1: P1) -> R) = - LambdaCallable2(variantMapper.getOrDefault(R::class, NIL), variantMapper[P0::class]!!, variantMapper[P1::class]!!, onCancelCall, function) - -public inline fun ((p0: P0, p1: P1) -> R).asCallable(noinline - onCancelCall: (() -> Unit)? = null) = callable2(onCancelCall, this) - -public class LambdaCallable3 @PublishedApi internal constructor( - variantConverter: VariantConverter, - private val p0Type: VariantConverter, - private val p1Type: VariantConverter, - p2Type: VariantConverter, - onCancelCall: (() -> Unit)? = null, - private val function: ( - p0: P0, - p1: P1, - p2: P2, - ) -> R, -) : LambdaCallable(variantConverter, onCancelCall, p0Type, p1Type, p2Type) { - public override fun invokeKt(): R = - function(paramsArray[0] as P0, paramsArray[1] as P1, paramsArray[2] as P2) - - public operator fun invoke( - p0: P0, - p1: P1, - p2: P2, - ): R = function(p0, p1, p2) - - public override fun call(vararg args: Any?): Any? = - function(args[0] as P0, args[1] as P1, args[2] as P2) - - public fun bind( - p0: P0, - p1: P1, - p2: P2, - ) = LambdaCallable0(variantConverter, onCancelCall) { -> function(p0, p1, p2) } - - public fun bind(p1: P1, p2: P2) = - LambdaCallable1(variantConverter, p0Type, onCancelCall) { p0: P0 -> function(p0, p1, p2) } - - public fun bind(p2: P2) = - LambdaCallable2(variantConverter, p0Type, p1Type, onCancelCall) { p0: P0, p1: P1 -> function(p0, p1, p2) } - - public companion object { - @JvmStatic - @JvmName("create") - public fun javaCreate( - returnClass: Class, - p0Class: Class, - p1Class: Class, - p2Class: Class, - function: ( - p0: P0, - p1: P1, - p2: P2, - ) -> R, - ) = - LambdaCallable3(variantMapper.getOrDefault(Reflection.getOrCreateKotlinClass(returnClass), NIL), variantMapper[Reflection.getOrCreateKotlinClass(p0Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p1Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p2Class)]!!, null, function) - } -} - -public inline fun callable3(noinline - onCancelCall: (() -> Unit)? = null, noinline function: ( - p0: P0, - p1: P1, - p2: P2, -) -> R) = - LambdaCallable3(variantMapper.getOrDefault(R::class, NIL), variantMapper[P0::class]!!, variantMapper[P1::class]!!, variantMapper[P2::class]!!, onCancelCall, function) - -public inline fun (( - p0: P0, - p1: P1, - p2: P2, -) -> R).asCallable(noinline onCancelCall: (() -> Unit)? = null) = callable3(onCancelCall, this) - -public class LambdaCallable4 @PublishedApi internal constructor( - variantConverter: VariantConverter, - private val p0Type: VariantConverter, - private val p1Type: VariantConverter, - private val p2Type: VariantConverter, - p3Type: VariantConverter, - onCancelCall: (() -> Unit)? = null, - private val function: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - ) -> R, -) : LambdaCallable(variantConverter, onCancelCall, p0Type, p1Type, p2Type, p3Type) { - public override fun invokeKt(): R = - function(paramsArray[0] as P0, paramsArray[1] as P1, paramsArray[2] as P2, paramsArray[3] as P3) - - public operator fun invoke( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - ): R = function(p0, p1, p2, p3) - - public override fun call(vararg args: Any?): Any? = - function(args[0] as P0, args[1] as P1, args[2] as P2, args[3] as P3) - - public fun bind( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - ) = LambdaCallable0(variantConverter, onCancelCall) { -> function(p0, p1, p2, p3) } - - public fun bind( - p1: P1, - p2: P2, - p3: P3, - ) = LambdaCallable1(variantConverter, p0Type, onCancelCall) { p0: P0 -> function(p0, p1, p2, p3) } - - public fun bind(p2: P2, p3: P3) = - LambdaCallable2(variantConverter, p0Type, p1Type, onCancelCall) { p0: P0, p1: P1 -> function(p0, p1, p2, p3) } - - public fun bind(p3: P3) = - LambdaCallable3(variantConverter, p0Type, p1Type, p2Type, onCancelCall) { p0: P0, p1: P1, p2: P2 -> function(p0, p1, p2, p3) } - - public companion object { - @JvmStatic - @JvmName("create") - public fun javaCreate( - returnClass: Class, - p0Class: Class, - p1Class: Class, - p2Class: Class, - p3Class: Class, - function: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - ) -> R, - ) = - LambdaCallable4(variantMapper.getOrDefault(Reflection.getOrCreateKotlinClass(returnClass), NIL), variantMapper[Reflection.getOrCreateKotlinClass(p0Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p1Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p2Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p3Class)]!!, null, function) - } -} - -public inline fun callable4(noinline - onCancelCall: (() -> Unit)? = null, noinline function: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, -) -> R) = - LambdaCallable4(variantMapper.getOrDefault(R::class, NIL), variantMapper[P0::class]!!, variantMapper[P1::class]!!, variantMapper[P2::class]!!, variantMapper[P3::class]!!, onCancelCall, function) - -public inline fun (( - p0: P0, - p1: P1, - p2: P2, - p3: P3, -) -> R).asCallable(noinline onCancelCall: (() -> Unit)? = null) = callable4(onCancelCall, this) - -public class LambdaCallable5 @PublishedApi internal constructor( - variantConverter: VariantConverter, - private val p0Type: VariantConverter, - private val p1Type: VariantConverter, - private val p2Type: VariantConverter, - private val p3Type: VariantConverter, - p4Type: VariantConverter, - onCancelCall: (() -> Unit)? = null, - private val function: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - ) -> R, -) : LambdaCallable(variantConverter, onCancelCall, p0Type, p1Type, p2Type, p3Type, p4Type) { - public override fun invokeKt(): R = - function(paramsArray[0] as P0, paramsArray[1] as P1, paramsArray[2] as P2, paramsArray[3] as P3, paramsArray[4] as P4) - - public operator fun invoke( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - ): R = function(p0, p1, p2, p3, p4) - - public override fun call(vararg args: Any?): Any? = - function(args[0] as P0, args[1] as P1, args[2] as P2, args[3] as P3, args[4] as P4) - - public fun bind( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - ) = LambdaCallable0(variantConverter, onCancelCall) { -> function(p0, p1, p2, p3, p4) } - - public fun bind( - p1: P1, - p2: P2, - p3: P3, - p4: P4, - ) = - LambdaCallable1(variantConverter, p0Type, onCancelCall) { p0: P0 -> function(p0, p1, p2, p3, p4) } - - public fun bind( - p2: P2, - p3: P3, - p4: P4, - ) = - LambdaCallable2(variantConverter, p0Type, p1Type, onCancelCall) { p0: P0, p1: P1 -> function(p0, p1, p2, p3, p4) } - - public fun bind(p3: P3, p4: P4) = - LambdaCallable3(variantConverter, p0Type, p1Type, p2Type, onCancelCall) { p0: P0, p1: P1, p2: P2 -> function(p0, p1, p2, p3, p4) } - - public fun bind(p4: P4) = - LambdaCallable4(variantConverter, p0Type, p1Type, p2Type, p3Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3 -> function(p0, p1, p2, p3, p4) } - - public companion object { - @JvmStatic - @JvmName("create") - public fun javaCreate( - returnClass: Class, - p0Class: Class, - p1Class: Class, - p2Class: Class, - p3Class: Class, - p4Class: Class, - function: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - ) -> R, - ) = - LambdaCallable5(variantMapper.getOrDefault(Reflection.getOrCreateKotlinClass(returnClass), NIL), variantMapper[Reflection.getOrCreateKotlinClass(p0Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p1Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p2Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p3Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p4Class)]!!, null, function) - } -} - -public inline fun - callable5(noinline onCancelCall: (() -> Unit)? = null, noinline function: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, -) -> R) = - LambdaCallable5(variantMapper.getOrDefault(R::class, NIL), variantMapper[P0::class]!!, variantMapper[P1::class]!!, variantMapper[P2::class]!!, variantMapper[P3::class]!!, variantMapper[P4::class]!!, onCancelCall, function) - -public inline fun (( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, -) -> R).asCallable(noinline onCancelCall: (() -> Unit)? = null) = callable5(onCancelCall, this) - -public class LambdaCallable6 @PublishedApi internal constructor( - variantConverter: VariantConverter, - private val p0Type: VariantConverter, - private val p1Type: VariantConverter, - private val p2Type: VariantConverter, - private val p3Type: VariantConverter, - private val p4Type: VariantConverter, - p5Type: VariantConverter, - onCancelCall: (() -> Unit)? = null, - private val function: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - ) -> R, -) : LambdaCallable(variantConverter, onCancelCall, p0Type, p1Type, p2Type, p3Type, p4Type, - p5Type) { - public override fun invokeKt(): R = - function(paramsArray[0] as P0, paramsArray[1] as P1, paramsArray[2] as P2, paramsArray[3] as P3, paramsArray[4] as P4, paramsArray[5] as P5) - - public operator fun invoke( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - ): R = function(p0, p1, p2, p3, p4, p5) - - public override fun call(vararg args: Any?): Any? = - function(args[0] as P0, args[1] as P1, args[2] as P2, args[3] as P3, args[4] as P4, args[5] as P5) - - public fun bind( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - ) = LambdaCallable0(variantConverter, onCancelCall) { -> function(p0, p1, p2, p3, p4, p5) } - - public fun bind( - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - ) = - LambdaCallable1(variantConverter, p0Type, onCancelCall) { p0: P0 -> function(p0, p1, p2, p3, p4, p5) } - - public fun bind( - p2: P2, - p3: P3, - p4: P4, - p5: P5, - ) = - LambdaCallable2(variantConverter, p0Type, p1Type, onCancelCall) { p0: P0, p1: P1 -> function(p0, p1, p2, p3, p4, p5) } - - public fun bind( - p3: P3, - p4: P4, - p5: P5, - ) = - LambdaCallable3(variantConverter, p0Type, p1Type, p2Type, onCancelCall) { p0: P0, p1: P1, p2: P2 -> function(p0, p1, p2, p3, p4, p5) } - - public fun bind(p4: P4, p5: P5) = - LambdaCallable4(variantConverter, p0Type, p1Type, p2Type, p3Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3 -> function(p0, p1, p2, p3, p4, p5) } - - public fun bind(p5: P5) = - LambdaCallable5(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4 -> function(p0, p1, p2, p3, p4, p5) } - - public companion object { - @JvmStatic - @JvmName("create") - public fun javaCreate( - returnClass: Class, - p0Class: Class, - p1Class: Class, - p2Class: Class, - p3Class: Class, - p4Class: Class, - p5Class: Class, - function: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - ) -> R, - ) = - LambdaCallable6(variantMapper.getOrDefault(Reflection.getOrCreateKotlinClass(returnClass), NIL), variantMapper[Reflection.getOrCreateKotlinClass(p0Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p1Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p2Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p3Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p4Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p5Class)]!!, null, function) - } -} - -public inline fun callable6(noinline onCancelCall: (() -> Unit)? = null, noinline function: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, -) -> R) = - LambdaCallable6(variantMapper.getOrDefault(R::class, NIL), variantMapper[P0::class]!!, variantMapper[P1::class]!!, variantMapper[P2::class]!!, variantMapper[P3::class]!!, variantMapper[P4::class]!!, variantMapper[P5::class]!!, onCancelCall, function) - -public inline fun (( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, -) -> R).asCallable(noinline onCancelCall: (() -> Unit)? = null) = callable6(onCancelCall, this) - -public class LambdaCallable7 @PublishedApi internal constructor( - variantConverter: VariantConverter, - private val p0Type: VariantConverter, - private val p1Type: VariantConverter, - private val p2Type: VariantConverter, - private val p3Type: VariantConverter, - private val p4Type: VariantConverter, - private val p5Type: VariantConverter, - p6Type: VariantConverter, - onCancelCall: (() -> Unit)? = null, - private val function: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - ) -> R, -) : LambdaCallable(variantConverter, onCancelCall, p0Type, p1Type, p2Type, p3Type, p4Type, - p5Type, p6Type) { - public override fun invokeKt(): R = - function(paramsArray[0] as P0, paramsArray[1] as P1, paramsArray[2] as P2, paramsArray[3] as P3, paramsArray[4] as P4, paramsArray[5] as P5, paramsArray[6] as P6) - - public operator fun invoke( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - ): R = function(p0, p1, p2, p3, p4, p5, p6) - - public override fun call(vararg args: Any?): Any? = - function(args[0] as P0, args[1] as P1, args[2] as P2, args[3] as P3, args[4] as P4, args[5] as P5, args[6] as P6) - - public fun bind( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - ) = LambdaCallable0(variantConverter, onCancelCall) { -> function(p0, p1, p2, p3, p4, p5, p6) } - - public fun bind( - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - ) = - LambdaCallable1(variantConverter, p0Type, onCancelCall) { p0: P0 -> function(p0, p1, p2, p3, p4, p5, p6) } - - public fun bind( - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - ) = - LambdaCallable2(variantConverter, p0Type, p1Type, onCancelCall) { p0: P0, p1: P1 -> function(p0, p1, p2, p3, p4, p5, p6) } - - public fun bind( - p3: P3, - p4: P4, - p5: P5, - p6: P6, - ) = - LambdaCallable3(variantConverter, p0Type, p1Type, p2Type, onCancelCall) { p0: P0, p1: P1, p2: P2 -> function(p0, p1, p2, p3, p4, p5, p6) } - - public fun bind( - p4: P4, - p5: P5, - p6: P6, - ) = - LambdaCallable4(variantConverter, p0Type, p1Type, p2Type, p3Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3 -> function(p0, p1, p2, p3, p4, p5, p6) } - - public fun bind(p5: P5, p6: P6) = - LambdaCallable5(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4 -> function(p0, p1, p2, p3, p4, p5, p6) } - - public fun bind(p6: P6) = - LambdaCallable6(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5 -> function(p0, p1, p2, p3, p4, p5, p6) } - - public companion object { - @JvmStatic - @JvmName("create") - public fun javaCreate( - returnClass: Class, - p0Class: Class, - p1Class: Class, - p2Class: Class, - p3Class: Class, - p4Class: Class, - p5Class: Class, - p6Class: Class, - function: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - ) -> R, - ) = - LambdaCallable7(variantMapper.getOrDefault(Reflection.getOrCreateKotlinClass(returnClass), NIL), variantMapper[Reflection.getOrCreateKotlinClass(p0Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p1Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p2Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p3Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p4Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p5Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p6Class)]!!, null, function) - } -} - -public inline fun callable7(noinline onCancelCall: (() -> Unit)? = null, noinline function: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, -) -> R) = - LambdaCallable7(variantMapper.getOrDefault(R::class, NIL), variantMapper[P0::class]!!, variantMapper[P1::class]!!, variantMapper[P2::class]!!, variantMapper[P3::class]!!, variantMapper[P4::class]!!, variantMapper[P5::class]!!, variantMapper[P6::class]!!, onCancelCall, function) - -public inline fun (( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, -) -> R).asCallable(noinline onCancelCall: (() -> Unit)? = null) = callable7(onCancelCall, this) - -public class LambdaCallable8 @PublishedApi internal constructor( - variantConverter: VariantConverter, - private val p0Type: VariantConverter, - private val p1Type: VariantConverter, - private val p2Type: VariantConverter, - private val p3Type: VariantConverter, - private val p4Type: VariantConverter, - private val p5Type: VariantConverter, - private val p6Type: VariantConverter, - p7Type: VariantConverter, - onCancelCall: (() -> Unit)? = null, - private val function: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - ) -> R, -) : LambdaCallable(variantConverter, onCancelCall, p0Type, p1Type, p2Type, p3Type, p4Type, - p5Type, p6Type, p7Type) { - public override fun invokeKt(): R = - function(paramsArray[0] as P0, paramsArray[1] as P1, paramsArray[2] as P2, paramsArray[3] as P3, paramsArray[4] as P4, paramsArray[5] as P5, paramsArray[6] as P6, paramsArray[7] as P7) - - public operator fun invoke( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - ): R = function(p0, p1, p2, p3, p4, p5, p6, p7) - - public override fun call(vararg args: Any?): Any? = - function(args[0] as P0, args[1] as P1, args[2] as P2, args[3] as P3, args[4] as P4, args[5] as P5, args[6] as P6, args[7] as P7) - - public fun bind( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - ) = - LambdaCallable0(variantConverter, onCancelCall) { -> function(p0, p1, p2, p3, p4, p5, p6, p7) } - - public fun bind( - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - ) = - LambdaCallable1(variantConverter, p0Type, onCancelCall) { p0: P0 -> function(p0, p1, p2, p3, p4, p5, p6, p7) } - - public fun bind( - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - ) = - LambdaCallable2(variantConverter, p0Type, p1Type, onCancelCall) { p0: P0, p1: P1 -> function(p0, p1, p2, p3, p4, p5, p6, p7) } - - public fun bind( - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - ) = - LambdaCallable3(variantConverter, p0Type, p1Type, p2Type, onCancelCall) { p0: P0, p1: P1, p2: P2 -> function(p0, p1, p2, p3, p4, p5, p6, p7) } - - public fun bind( - p4: P4, - p5: P5, - p6: P6, - p7: P7, - ) = - LambdaCallable4(variantConverter, p0Type, p1Type, p2Type, p3Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3 -> function(p0, p1, p2, p3, p4, p5, p6, p7) } - - public fun bind( - p5: P5, - p6: P6, - p7: P7, - ) = - LambdaCallable5(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4 -> function(p0, p1, p2, p3, p4, p5, p6, p7) } - - public fun bind(p6: P6, p7: P7) = - LambdaCallable6(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5 -> function(p0, p1, p2, p3, p4, p5, p6, p7) } - - public fun bind(p7: P7) = - LambdaCallable7(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6 -> function(p0, p1, p2, p3, p4, p5, p6, p7) } - - public companion object { - @JvmStatic - @JvmName("create") - public fun javaCreate( - returnClass: Class, - p0Class: Class, - p1Class: Class, - p2Class: Class, - p3Class: Class, - p4Class: Class, - p5Class: Class, - p6Class: Class, - p7Class: Class, - function: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - ) -> R, - ) = - LambdaCallable8(variantMapper.getOrDefault(Reflection.getOrCreateKotlinClass(returnClass), NIL), variantMapper[Reflection.getOrCreateKotlinClass(p0Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p1Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p2Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p3Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p4Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p5Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p6Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p7Class)]!!, null, function) - } -} - -public inline fun callable8(noinline onCancelCall: (() -> Unit)? = null, noinline - function: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, -) -> R) = - LambdaCallable8(variantMapper.getOrDefault(R::class, NIL), variantMapper[P0::class]!!, variantMapper[P1::class]!!, variantMapper[P2::class]!!, variantMapper[P3::class]!!, variantMapper[P4::class]!!, variantMapper[P5::class]!!, variantMapper[P6::class]!!, variantMapper[P7::class]!!, onCancelCall, function) - -public inline fun (( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, -) -> R).asCallable(noinline onCancelCall: (() -> Unit)? = null) = callable8(onCancelCall, this) - -public class LambdaCallable9 @PublishedApi internal - constructor( - variantConverter: VariantConverter, - private val p0Type: VariantConverter, - private val p1Type: VariantConverter, - private val p2Type: VariantConverter, - private val p3Type: VariantConverter, - private val p4Type: VariantConverter, - private val p5Type: VariantConverter, - private val p6Type: VariantConverter, - private val p7Type: VariantConverter, - p8Type: VariantConverter, - onCancelCall: (() -> Unit)? = null, - private val function: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - ) -> R, -) : LambdaCallable(variantConverter, onCancelCall, p0Type, p1Type, p2Type, p3Type, p4Type, - p5Type, p6Type, p7Type, p8Type) { - public override fun invokeKt(): R = - function(paramsArray[0] as P0, paramsArray[1] as P1, paramsArray[2] as P2, paramsArray[3] as P3, paramsArray[4] as P4, paramsArray[5] as P5, paramsArray[6] as P6, paramsArray[7] as P7, paramsArray[8] as P8) - - public operator fun invoke( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - ): R = function(p0, p1, p2, p3, p4, p5, p6, p7, p8) - - public override fun call(vararg args: Any?): Any? = - function(args[0] as P0, args[1] as P1, args[2] as P2, args[3] as P3, args[4] as P4, args[5] as P5, args[6] as P6, args[7] as P7, args[8] as P8) - - public fun bind( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - ) = - LambdaCallable0(variantConverter, onCancelCall) { -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8) } - - public fun bind( - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - ) = - LambdaCallable1(variantConverter, p0Type, onCancelCall) { p0: P0 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8) } - - public fun bind( - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - ) = - LambdaCallable2(variantConverter, p0Type, p1Type, onCancelCall) { p0: P0, p1: P1 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8) } - - public fun bind( - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - ) = - LambdaCallable3(variantConverter, p0Type, p1Type, p2Type, onCancelCall) { p0: P0, p1: P1, p2: P2 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8) } - - public fun bind( - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - ) = - LambdaCallable4(variantConverter, p0Type, p1Type, p2Type, p3Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8) } - - public fun bind( - p5: P5, - p6: P6, - p7: P7, - p8: P8, - ) = - LambdaCallable5(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8) } - - public fun bind( - p6: P6, - p7: P7, - p8: P8, - ) = - LambdaCallable6(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8) } - - public fun bind(p7: P7, p8: P8) = - LambdaCallable7(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8) } - - public fun bind(p8: P8) = - LambdaCallable8(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8) } - - public companion object { - @JvmStatic - @JvmName("create") - public fun javaCreate( - returnClass: Class, - p0Class: Class, - p1Class: Class, - p2Class: Class, - p3Class: Class, - p4Class: Class, - p5Class: Class, - p6Class: Class, - p7Class: Class, - p8Class: Class, - function: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - ) -> R, - ) = - LambdaCallable9(variantMapper.getOrDefault(Reflection.getOrCreateKotlinClass(returnClass), NIL), variantMapper[Reflection.getOrCreateKotlinClass(p0Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p1Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p2Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p3Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p4Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p5Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p6Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p7Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p8Class)]!!, null, function) - } -} - -public inline fun callable9(noinline onCancelCall: (() -> Unit)? = null, - noinline function: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, -) -> R) = - LambdaCallable9(variantMapper.getOrDefault(R::class, NIL), variantMapper[P0::class]!!, variantMapper[P1::class]!!, variantMapper[P2::class]!!, variantMapper[P3::class]!!, variantMapper[P4::class]!!, variantMapper[P5::class]!!, variantMapper[P6::class]!!, variantMapper[P7::class]!!, variantMapper[P8::class]!!, onCancelCall, function) - -public inline fun (( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, -) -> R).asCallable(noinline onCancelCall: (() -> Unit)? = null) = callable9(onCancelCall, this) - -public class LambdaCallable10 @PublishedApi internal - constructor( - variantConverter: VariantConverter, - private val p0Type: VariantConverter, - private val p1Type: VariantConverter, - private val p2Type: VariantConverter, - private val p3Type: VariantConverter, - private val p4Type: VariantConverter, - private val p5Type: VariantConverter, - private val p6Type: VariantConverter, - private val p7Type: VariantConverter, - private val p8Type: VariantConverter, - p9Type: VariantConverter, - onCancelCall: (() -> Unit)? = null, - private val function: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - ) -> R, -) : LambdaCallable(variantConverter, onCancelCall, p0Type, p1Type, p2Type, p3Type, p4Type, - p5Type, p6Type, p7Type, p8Type, p9Type) { - public override fun invokeKt(): R = - function(paramsArray[0] as P0, paramsArray[1] as P1, paramsArray[2] as P2, paramsArray[3] as P3, paramsArray[4] as P4, paramsArray[5] as P5, paramsArray[6] as P6, paramsArray[7] as P7, paramsArray[8] as P8, paramsArray[9] as P9) - - public operator fun invoke( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - ): R = function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9) - - public override fun call(vararg args: Any?): Any? = - function(args[0] as P0, args[1] as P1, args[2] as P2, args[3] as P3, args[4] as P4, args[5] as P5, args[6] as P6, args[7] as P7, args[8] as P8, args[9] as P9) - - public fun bind( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - ) = - LambdaCallable0(variantConverter, onCancelCall) { -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9) } - - public fun bind( - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - ) = - LambdaCallable1(variantConverter, p0Type, onCancelCall) { p0: P0 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9) } - - public fun bind( - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - ) = - LambdaCallable2(variantConverter, p0Type, p1Type, onCancelCall) { p0: P0, p1: P1 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9) } - - public fun bind( - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - ) = - LambdaCallable3(variantConverter, p0Type, p1Type, p2Type, onCancelCall) { p0: P0, p1: P1, p2: P2 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9) } - - public fun bind( - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - ) = - LambdaCallable4(variantConverter, p0Type, p1Type, p2Type, p3Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9) } - - public fun bind( - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - ) = - LambdaCallable5(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9) } - - public fun bind( - p6: P6, - p7: P7, - p8: P8, - p9: P9, - ) = - LambdaCallable6(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9) } - - public fun bind( - p7: P7, - p8: P8, - p9: P9, - ) = - LambdaCallable7(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9) } - - public fun bind(p8: P8, p9: P9) = - LambdaCallable8(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9) } - - public fun bind(p9: P9) = - LambdaCallable9(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9) } - - public companion object { - @JvmStatic - @JvmName("create") - public fun javaCreate( - returnClass: Class, - p0Class: Class, - p1Class: Class, - p2Class: Class, - p3Class: Class, - p4Class: Class, - p5Class: Class, - p6Class: Class, - p7Class: Class, - p8Class: Class, - p9Class: Class, - function: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - ) -> R, - ) = - LambdaCallable10(variantMapper.getOrDefault(Reflection.getOrCreateKotlinClass(returnClass), NIL), variantMapper[Reflection.getOrCreateKotlinClass(p0Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p1Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p2Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p3Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p4Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p5Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p6Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p7Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p8Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p9Class)]!!, null, function) - } -} - -public inline fun callable10(noinline - onCancelCall: (() -> Unit)? = null, noinline function: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, -) -> R) = - LambdaCallable10(variantMapper.getOrDefault(R::class, NIL), variantMapper[P0::class]!!, variantMapper[P1::class]!!, variantMapper[P2::class]!!, variantMapper[P3::class]!!, variantMapper[P4::class]!!, variantMapper[P5::class]!!, variantMapper[P6::class]!!, variantMapper[P7::class]!!, variantMapper[P8::class]!!, variantMapper[P9::class]!!, onCancelCall, function) - -public inline fun (( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, -) -> R).asCallable(noinline onCancelCall: (() -> Unit)? = null) = callable10(onCancelCall, this) - -public class LambdaCallable11 @PublishedApi internal - constructor( - variantConverter: VariantConverter, - private val p0Type: VariantConverter, - private val p1Type: VariantConverter, - private val p2Type: VariantConverter, - private val p3Type: VariantConverter, - private val p4Type: VariantConverter, - private val p5Type: VariantConverter, - private val p6Type: VariantConverter, - private val p7Type: VariantConverter, - private val p8Type: VariantConverter, - private val p9Type: VariantConverter, - p10Type: VariantConverter, - onCancelCall: (() -> Unit)? = null, - private val function: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - ) -> R, -) : LambdaCallable(variantConverter, onCancelCall, p0Type, p1Type, p2Type, p3Type, p4Type, - p5Type, p6Type, p7Type, p8Type, p9Type, p10Type) { - public override fun invokeKt(): R = - function(paramsArray[0] as P0, paramsArray[1] as P1, paramsArray[2] as P2, paramsArray[3] as P3, paramsArray[4] as P4, paramsArray[5] as P5, paramsArray[6] as P6, paramsArray[7] as P7, paramsArray[8] as P8, paramsArray[9] as P9, paramsArray[10] as P10) - - public operator fun invoke( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - ): R = function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) - - public override fun call(vararg args: Any?): Any? = - function(args[0] as P0, args[1] as P1, args[2] as P2, args[3] as P3, args[4] as P4, args[5] as P5, args[6] as P6, args[7] as P7, args[8] as P8, args[9] as P9, args[10] as P10) - - public fun bind( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - ) = - LambdaCallable0(variantConverter, onCancelCall) { -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) } - - public fun bind( - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - ) = - LambdaCallable1(variantConverter, p0Type, onCancelCall) { p0: P0 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) } - - public fun bind( - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - ) = - LambdaCallable2(variantConverter, p0Type, p1Type, onCancelCall) { p0: P0, p1: P1 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) } - - public fun bind( - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - ) = - LambdaCallable3(variantConverter, p0Type, p1Type, p2Type, onCancelCall) { p0: P0, p1: P1, p2: P2 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) } - - public fun bind( - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - ) = - LambdaCallable4(variantConverter, p0Type, p1Type, p2Type, p3Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) } - - public fun bind( - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - ) = - LambdaCallable5(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) } - - public fun bind( - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - ) = - LambdaCallable6(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) } - - public fun bind( - p7: P7, - p8: P8, - p9: P9, - p10: P10, - ) = - LambdaCallable7(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) } - - public fun bind( - p8: P8, - p9: P9, - p10: P10, - ) = - LambdaCallable8(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) } - - public fun bind(p9: P9, p10: P10) = - LambdaCallable9(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) } - - public fun bind(p10: P10) = - LambdaCallable10(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) } - - public companion object { - @JvmStatic - @JvmName("create") - public fun javaCreate( - returnClass: Class, - p0Class: Class, - p1Class: Class, - p2Class: Class, - p3Class: Class, - p4Class: Class, - p5Class: Class, - p6Class: Class, - p7Class: Class, - p8Class: Class, - p9Class: Class, - p10Class: Class, - function: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - ) -> R, - ) = - LambdaCallable11(variantMapper.getOrDefault(Reflection.getOrCreateKotlinClass(returnClass), NIL), variantMapper[Reflection.getOrCreateKotlinClass(p0Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p1Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p2Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p3Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p4Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p5Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p6Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p7Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p8Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p9Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p10Class)]!!, null, function) - } -} - -public inline fun callable11(noinline - onCancelCall: (() -> Unit)? = null, noinline function: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, -) -> R) = - LambdaCallable11(variantMapper.getOrDefault(R::class, NIL), variantMapper[P0::class]!!, variantMapper[P1::class]!!, variantMapper[P2::class]!!, variantMapper[P3::class]!!, variantMapper[P4::class]!!, variantMapper[P5::class]!!, variantMapper[P6::class]!!, variantMapper[P7::class]!!, variantMapper[P8::class]!!, variantMapper[P9::class]!!, variantMapper[P10::class]!!, onCancelCall, function) - -public inline fun (( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, -) -> R).asCallable(noinline onCancelCall: (() -> Unit)? = null) = callable11(onCancelCall, this) - -public class LambdaCallable12 @PublishedApi - internal constructor( - variantConverter: VariantConverter, - private val p0Type: VariantConverter, - private val p1Type: VariantConverter, - private val p2Type: VariantConverter, - private val p3Type: VariantConverter, - private val p4Type: VariantConverter, - private val p5Type: VariantConverter, - private val p6Type: VariantConverter, - private val p7Type: VariantConverter, - private val p8Type: VariantConverter, - private val p9Type: VariantConverter, - private val p10Type: VariantConverter, - p11Type: VariantConverter, - onCancelCall: (() -> Unit)? = null, - private val function: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - ) -> R, -) : LambdaCallable(variantConverter, onCancelCall, p0Type, p1Type, p2Type, p3Type, p4Type, - p5Type, p6Type, p7Type, p8Type, p9Type, p10Type, p11Type) { - public override fun invokeKt(): R = - function(paramsArray[0] as P0, paramsArray[1] as P1, paramsArray[2] as P2, paramsArray[3] as P3, paramsArray[4] as P4, paramsArray[5] as P5, paramsArray[6] as P6, paramsArray[7] as P7, paramsArray[8] as P8, paramsArray[9] as P9, paramsArray[10] as P10, paramsArray[11] as P11) - - public operator fun invoke( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - ): R = function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11) - - public override fun call(vararg args: Any?): Any? = - function(args[0] as P0, args[1] as P1, args[2] as P2, args[3] as P3, args[4] as P4, args[5] as P5, args[6] as P6, args[7] as P7, args[8] as P8, args[9] as P9, args[10] as P10, args[11] as P11) - - public fun bind( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - ) = - LambdaCallable0(variantConverter, onCancelCall) { -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11) } - - public fun bind( - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - ) = - LambdaCallable1(variantConverter, p0Type, onCancelCall) { p0: P0 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11) } - - public fun bind( - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - ) = - LambdaCallable2(variantConverter, p0Type, p1Type, onCancelCall) { p0: P0, p1: P1 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11) } - - public fun bind( - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - ) = - LambdaCallable3(variantConverter, p0Type, p1Type, p2Type, onCancelCall) { p0: P0, p1: P1, p2: P2 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11) } - - public fun bind( - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - ) = - LambdaCallable4(variantConverter, p0Type, p1Type, p2Type, p3Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11) } - - public fun bind( - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - ) = - LambdaCallable5(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11) } - - public fun bind( - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - ) = - LambdaCallable6(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11) } - - public fun bind( - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - ) = - LambdaCallable7(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11) } - - public fun bind( - p8: P8, - p9: P9, - p10: P10, - p11: P11, - ) = - LambdaCallable8(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11) } - - public fun bind( - p9: P9, - p10: P10, - p11: P11, - ) = - LambdaCallable9(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11) } - - public fun bind(p10: P10, p11: P11) = - LambdaCallable10(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11) } - - public fun bind(p11: P11) = - LambdaCallable11(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type, p10Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11) } - - public companion object { - @JvmStatic - @JvmName("create") - public fun javaCreate( - returnClass: Class, - p0Class: Class, - p1Class: Class, - p2Class: Class, - p3Class: Class, - p4Class: Class, - p5Class: Class, - p6Class: Class, - p7Class: Class, - p8Class: Class, - p9Class: Class, - p10Class: Class, - p11Class: Class, - function: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - ) -> R, - ) = - LambdaCallable12(variantMapper.getOrDefault(Reflection.getOrCreateKotlinClass(returnClass), NIL), variantMapper[Reflection.getOrCreateKotlinClass(p0Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p1Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p2Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p3Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p4Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p5Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p6Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p7Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p8Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p9Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p10Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p11Class)]!!, null, function) - } -} - -public inline fun callable12(noinline - onCancelCall: (() -> Unit)? = null, noinline function: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, -) -> R) = - LambdaCallable12(variantMapper.getOrDefault(R::class, NIL), variantMapper[P0::class]!!, variantMapper[P1::class]!!, variantMapper[P2::class]!!, variantMapper[P3::class]!!, variantMapper[P4::class]!!, variantMapper[P5::class]!!, variantMapper[P6::class]!!, variantMapper[P7::class]!!, variantMapper[P8::class]!!, variantMapper[P9::class]!!, variantMapper[P10::class]!!, variantMapper[P11::class]!!, onCancelCall, function) - -public inline fun (( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, -) -> R).asCallable(noinline onCancelCall: (() -> Unit)? = null) = callable12(onCancelCall, this) - -public class LambdaCallable13 - @PublishedApi internal constructor( - variantConverter: VariantConverter, - private val p0Type: VariantConverter, - private val p1Type: VariantConverter, - private val p2Type: VariantConverter, - private val p3Type: VariantConverter, - private val p4Type: VariantConverter, - private val p5Type: VariantConverter, - private val p6Type: VariantConverter, - private val p7Type: VariantConverter, - private val p8Type: VariantConverter, - private val p9Type: VariantConverter, - private val p10Type: VariantConverter, - private val p11Type: VariantConverter, - p12Type: VariantConverter, - onCancelCall: (() -> Unit)? = null, - private val function: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - ) -> R, -) : LambdaCallable(variantConverter, onCancelCall, p0Type, p1Type, p2Type, p3Type, p4Type, - p5Type, p6Type, p7Type, p8Type, p9Type, p10Type, p11Type, p12Type) { - public override fun invokeKt(): R = - function(paramsArray[0] as P0, paramsArray[1] as P1, paramsArray[2] as P2, paramsArray[3] as P3, paramsArray[4] as P4, paramsArray[5] as P5, paramsArray[6] as P6, paramsArray[7] as P7, paramsArray[8] as P8, paramsArray[9] as P9, paramsArray[10] as P10, paramsArray[11] as P11, paramsArray[12] as P12) - - public operator fun invoke( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - ): R = function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12) - - public override fun call(vararg args: Any?): Any? = - function(args[0] as P0, args[1] as P1, args[2] as P2, args[3] as P3, args[4] as P4, args[5] as P5, args[6] as P6, args[7] as P7, args[8] as P8, args[9] as P9, args[10] as P10, args[11] as P11, args[12] as P12) - - public fun bind( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - ) = - LambdaCallable0(variantConverter, onCancelCall) { -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12) } - - public fun bind( - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - ) = - LambdaCallable1(variantConverter, p0Type, onCancelCall) { p0: P0 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12) } - - public fun bind( - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - ) = - LambdaCallable2(variantConverter, p0Type, p1Type, onCancelCall) { p0: P0, p1: P1 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12) } - - public fun bind( - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - ) = - LambdaCallable3(variantConverter, p0Type, p1Type, p2Type, onCancelCall) { p0: P0, p1: P1, p2: P2 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12) } - - public fun bind( - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - ) = - LambdaCallable4(variantConverter, p0Type, p1Type, p2Type, p3Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12) } - - public fun bind( - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - ) = - LambdaCallable5(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12) } - - public fun bind( - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - ) = - LambdaCallable6(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12) } - - public fun bind( - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - ) = - LambdaCallable7(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12) } - - public fun bind( - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - ) = - LambdaCallable8(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12) } - - public fun bind( - p9: P9, - p10: P10, - p11: P11, - p12: P12, - ) = - LambdaCallable9(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12) } - - public fun bind( - p10: P10, - p11: P11, - p12: P12, - ) = - LambdaCallable10(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12) } - - public fun bind(p11: P11, p12: P12) = - LambdaCallable11(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type, p10Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12) } - - public fun bind(p12: P12) = - LambdaCallable12(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type, p10Type, p11Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12) } - - public companion object { - @JvmStatic - @JvmName("create") - public fun javaCreate( - returnClass: Class, - p0Class: Class, - p1Class: Class, - p2Class: Class, - p3Class: Class, - p4Class: Class, - p5Class: Class, - p6Class: Class, - p7Class: Class, - p8Class: Class, - p9Class: Class, - p10Class: Class, - p11Class: Class, - p12Class: Class, - function: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - ) -> R, - ) = - LambdaCallable13(variantMapper.getOrDefault(Reflection.getOrCreateKotlinClass(returnClass), NIL), variantMapper[Reflection.getOrCreateKotlinClass(p0Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p1Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p2Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p3Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p4Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p5Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p6Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p7Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p8Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p9Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p10Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p11Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p12Class)]!!, null, function) - } -} - -public inline fun - callable13(noinline onCancelCall: (() -> Unit)? = null, noinline function: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, -) -> R) = - LambdaCallable13(variantMapper.getOrDefault(R::class, NIL), variantMapper[P0::class]!!, variantMapper[P1::class]!!, variantMapper[P2::class]!!, variantMapper[P3::class]!!, variantMapper[P4::class]!!, variantMapper[P5::class]!!, variantMapper[P6::class]!!, variantMapper[P7::class]!!, variantMapper[P8::class]!!, variantMapper[P9::class]!!, variantMapper[P10::class]!!, variantMapper[P11::class]!!, variantMapper[P12::class]!!, onCancelCall, function) - -public inline fun (( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, -) -> R).asCallable(noinline onCancelCall: (() -> Unit)? = null) = callable13(onCancelCall, this) - -public class LambdaCallable14 - @PublishedApi internal constructor( - variantConverter: VariantConverter, - private val p0Type: VariantConverter, - private val p1Type: VariantConverter, - private val p2Type: VariantConverter, - private val p3Type: VariantConverter, - private val p4Type: VariantConverter, - private val p5Type: VariantConverter, - private val p6Type: VariantConverter, - private val p7Type: VariantConverter, - private val p8Type: VariantConverter, - private val p9Type: VariantConverter, - private val p10Type: VariantConverter, - private val p11Type: VariantConverter, - private val p12Type: VariantConverter, - p13Type: VariantConverter, - onCancelCall: (() -> Unit)? = null, - private val function: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - ) -> R, -) : LambdaCallable(variantConverter, onCancelCall, p0Type, p1Type, p2Type, p3Type, p4Type, - p5Type, p6Type, p7Type, p8Type, p9Type, p10Type, p11Type, p12Type, p13Type) { - public override fun invokeKt(): R = - function(paramsArray[0] as P0, paramsArray[1] as P1, paramsArray[2] as P2, paramsArray[3] as P3, paramsArray[4] as P4, paramsArray[5] as P5, paramsArray[6] as P6, paramsArray[7] as P7, paramsArray[8] as P8, paramsArray[9] as P9, paramsArray[10] as P10, paramsArray[11] as P11, paramsArray[12] as P12, paramsArray[13] as P13) - - public operator fun invoke( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - ): R = function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13) - - public override fun call(vararg args: Any?): Any? = - function(args[0] as P0, args[1] as P1, args[2] as P2, args[3] as P3, args[4] as P4, args[5] as P5, args[6] as P6, args[7] as P7, args[8] as P8, args[9] as P9, args[10] as P10, args[11] as P11, args[12] as P12, args[13] as P13) - - public fun bind( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - ) = - LambdaCallable0(variantConverter, onCancelCall) { -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13) } - - public fun bind( - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - ) = - LambdaCallable1(variantConverter, p0Type, onCancelCall) { p0: P0 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13) } - - public fun bind( - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - ) = - LambdaCallable2(variantConverter, p0Type, p1Type, onCancelCall) { p0: P0, p1: P1 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13) } - - public fun bind( - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - ) = - LambdaCallable3(variantConverter, p0Type, p1Type, p2Type, onCancelCall) { p0: P0, p1: P1, p2: P2 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13) } - - public fun bind( - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - ) = - LambdaCallable4(variantConverter, p0Type, p1Type, p2Type, p3Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13) } - - public fun bind( - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - ) = - LambdaCallable5(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13) } - - public fun bind( - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - ) = - LambdaCallable6(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13) } - - public fun bind( - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - ) = - LambdaCallable7(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13) } - - public fun bind( - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - ) = - LambdaCallable8(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13) } - - public fun bind( - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - ) = - LambdaCallable9(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13) } - - public fun bind( - p10: P10, - p11: P11, - p12: P12, - p13: P13, - ) = - LambdaCallable10(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13) } - - public fun bind( - p11: P11, - p12: P12, - p13: P13, - ) = - LambdaCallable11(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type, p10Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13) } - - public fun bind(p12: P12, p13: P13) = - LambdaCallable12(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type, p10Type, p11Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13) } - - public fun bind(p13: P13) = - LambdaCallable13(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type, p10Type, p11Type, p12Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13) } - - public companion object { - @JvmStatic - @JvmName("create") - public fun javaCreate( - returnClass: Class, - p0Class: Class, - p1Class: Class, - p2Class: Class, - p3Class: Class, - p4Class: Class, - p5Class: Class, - p6Class: Class, - p7Class: Class, - p8Class: Class, - p9Class: Class, - p10Class: Class, - p11Class: Class, - p12Class: Class, - p13Class: Class, - function: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - ) -> R, - ) = - LambdaCallable14(variantMapper.getOrDefault(Reflection.getOrCreateKotlinClass(returnClass), NIL), variantMapper[Reflection.getOrCreateKotlinClass(p0Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p1Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p2Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p3Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p4Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p5Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p6Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p7Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p8Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p9Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p10Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p11Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p12Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p13Class)]!!, null, function) - } -} - -public inline fun callable14(noinline onCancelCall: (() -> Unit)? = null, noinline function: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, -) -> R) = - LambdaCallable14(variantMapper.getOrDefault(R::class, NIL), variantMapper[P0::class]!!, variantMapper[P1::class]!!, variantMapper[P2::class]!!, variantMapper[P3::class]!!, variantMapper[P4::class]!!, variantMapper[P5::class]!!, variantMapper[P6::class]!!, variantMapper[P7::class]!!, variantMapper[P8::class]!!, variantMapper[P9::class]!!, variantMapper[P10::class]!!, variantMapper[P11::class]!!, variantMapper[P12::class]!!, variantMapper[P13::class]!!, onCancelCall, function) - -public inline fun (( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, -) -> R).asCallable(noinline onCancelCall: (() -> Unit)? = null) = callable14(onCancelCall, this) - -public class LambdaCallable15 - @PublishedApi internal constructor( - variantConverter: VariantConverter, - private val p0Type: VariantConverter, - private val p1Type: VariantConverter, - private val p2Type: VariantConverter, - private val p3Type: VariantConverter, - private val p4Type: VariantConverter, - private val p5Type: VariantConverter, - private val p6Type: VariantConverter, - private val p7Type: VariantConverter, - private val p8Type: VariantConverter, - private val p9Type: VariantConverter, - private val p10Type: VariantConverter, - private val p11Type: VariantConverter, - private val p12Type: VariantConverter, - private val p13Type: VariantConverter, - p14Type: VariantConverter, - onCancelCall: (() -> Unit)? = null, - private val function: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - p14: P14, - ) -> R, -) : LambdaCallable(variantConverter, onCancelCall, p0Type, p1Type, p2Type, p3Type, p4Type, - p5Type, p6Type, p7Type, p8Type, p9Type, p10Type, p11Type, p12Type, p13Type, p14Type) { - public override fun invokeKt(): R = - function(paramsArray[0] as P0, paramsArray[1] as P1, paramsArray[2] as P2, paramsArray[3] as P3, paramsArray[4] as P4, paramsArray[5] as P5, paramsArray[6] as P6, paramsArray[7] as P7, paramsArray[8] as P8, paramsArray[9] as P9, paramsArray[10] as P10, paramsArray[11] as P11, paramsArray[12] as P12, paramsArray[13] as P13, paramsArray[14] as P14) - - public operator fun invoke( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - p14: P14, - ): R = function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14) - - public override fun call(vararg args: Any?): Any? = - function(args[0] as P0, args[1] as P1, args[2] as P2, args[3] as P3, args[4] as P4, args[5] as P5, args[6] as P6, args[7] as P7, args[8] as P8, args[9] as P9, args[10] as P10, args[11] as P11, args[12] as P12, args[13] as P13, args[14] as P14) - - public fun bind( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - p14: P14, - ) = - LambdaCallable0(variantConverter, onCancelCall) { -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14) } - - public fun bind( - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - p14: P14, - ) = - LambdaCallable1(variantConverter, p0Type, onCancelCall) { p0: P0 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14) } - - public fun bind( - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - p14: P14, - ) = - LambdaCallable2(variantConverter, p0Type, p1Type, onCancelCall) { p0: P0, p1: P1 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14) } - - public fun bind( - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - p14: P14, - ) = - LambdaCallable3(variantConverter, p0Type, p1Type, p2Type, onCancelCall) { p0: P0, p1: P1, p2: P2 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14) } - - public fun bind( - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - p14: P14, - ) = - LambdaCallable4(variantConverter, p0Type, p1Type, p2Type, p3Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14) } - - public fun bind( - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - p14: P14, - ) = - LambdaCallable5(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14) } - - public fun bind( - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - p14: P14, - ) = - LambdaCallable6(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14) } - - public fun bind( - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - p14: P14, - ) = - LambdaCallable7(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14) } - - public fun bind( - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - p14: P14, - ) = - LambdaCallable8(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14) } - - public fun bind( - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - p14: P14, - ) = - LambdaCallable9(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14) } - - public fun bind( - p10: P10, - p11: P11, - p12: P12, - p13: P13, - p14: P14, - ) = - LambdaCallable10(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14) } - - public fun bind( - p11: P11, - p12: P12, - p13: P13, - p14: P14, - ) = - LambdaCallable11(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type, p10Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14) } - - public fun bind( - p12: P12, - p13: P13, - p14: P14, - ) = - LambdaCallable12(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type, p10Type, p11Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14) } - - public fun bind(p13: P13, p14: P14) = - LambdaCallable13(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type, p10Type, p11Type, p12Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14) } - - public fun bind(p14: P14) = - LambdaCallable14(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type, p10Type, p11Type, p12Type, p13Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14) } - - public companion object { - @JvmStatic - @JvmName("create") - public fun javaCreate( - returnClass: Class, - p0Class: Class, - p1Class: Class, - p2Class: Class, - p3Class: Class, - p4Class: Class, - p5Class: Class, - p6Class: Class, - p7Class: Class, - p8Class: Class, - p9Class: Class, - p10Class: Class, - p11Class: Class, - p12Class: Class, - p13Class: Class, - p14Class: Class, - function: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - p14: P14, - ) -> R, - ) = - LambdaCallable15(variantMapper.getOrDefault(Reflection.getOrCreateKotlinClass(returnClass), NIL), variantMapper[Reflection.getOrCreateKotlinClass(p0Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p1Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p2Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p3Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p4Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p5Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p6Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p7Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p8Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p9Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p10Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p11Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p12Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p13Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p14Class)]!!, null, function) - } -} - -public inline fun callable15(noinline onCancelCall: (() -> Unit)? = null, noinline - function: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - p14: P14, -) -> R) = - LambdaCallable15(variantMapper.getOrDefault(R::class, NIL), variantMapper[P0::class]!!, variantMapper[P1::class]!!, variantMapper[P2::class]!!, variantMapper[P3::class]!!, variantMapper[P4::class]!!, variantMapper[P5::class]!!, variantMapper[P6::class]!!, variantMapper[P7::class]!!, variantMapper[P8::class]!!, variantMapper[P9::class]!!, variantMapper[P10::class]!!, variantMapper[P11::class]!!, variantMapper[P12::class]!!, variantMapper[P13::class]!!, variantMapper[P14::class]!!, onCancelCall, function) - -public inline fun (( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - p14: P14, -) -> R).asCallable(noinline onCancelCall: (() -> Unit)? = null) = callable15(onCancelCall, this) - -public class LambdaCallable16 @PublishedApi internal constructor( - variantConverter: VariantConverter, - private val p0Type: VariantConverter, - private val p1Type: VariantConverter, - private val p2Type: VariantConverter, - private val p3Type: VariantConverter, - private val p4Type: VariantConverter, - private val p5Type: VariantConverter, - private val p6Type: VariantConverter, - private val p7Type: VariantConverter, - private val p8Type: VariantConverter, - private val p9Type: VariantConverter, - private val p10Type: VariantConverter, - private val p11Type: VariantConverter, - private val p12Type: VariantConverter, - private val p13Type: VariantConverter, - private val p14Type: VariantConverter, - p15Type: VariantConverter, - onCancelCall: (() -> Unit)? = null, - private val function: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - p14: P14, - p15: P15, - ) -> R, -) : LambdaCallable(variantConverter, onCancelCall, p0Type, p1Type, p2Type, p3Type, p4Type, - p5Type, p6Type, p7Type, p8Type, p9Type, p10Type, p11Type, p12Type, p13Type, p14Type, p15Type) { - public override fun invokeKt(): R = - function(paramsArray[0] as P0, paramsArray[1] as P1, paramsArray[2] as P2, paramsArray[3] as P3, paramsArray[4] as P4, paramsArray[5] as P5, paramsArray[6] as P6, paramsArray[7] as P7, paramsArray[8] as P8, paramsArray[9] as P9, paramsArray[10] as P10, paramsArray[11] as P11, paramsArray[12] as P12, paramsArray[13] as P13, paramsArray[14] as P14, paramsArray[15] as P15) - - public operator fun invoke( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - p14: P14, - p15: P15, - ): R = function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15) - - public override fun call(vararg args: Any?): Any? = - function(args[0] as P0, args[1] as P1, args[2] as P2, args[3] as P3, args[4] as P4, args[5] as P5, args[6] as P6, args[7] as P7, args[8] as P8, args[9] as P9, args[10] as P10, args[11] as P11, args[12] as P12, args[13] as P13, args[14] as P14, args[15] as P15) - - public fun bind( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - p14: P14, - p15: P15, - ) = - LambdaCallable0(variantConverter, onCancelCall) { -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15) } - - public fun bind( - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - p14: P14, - p15: P15, - ) = - LambdaCallable1(variantConverter, p0Type, onCancelCall) { p0: P0 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15) } - - public fun bind( - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - p14: P14, - p15: P15, - ) = - LambdaCallable2(variantConverter, p0Type, p1Type, onCancelCall) { p0: P0, p1: P1 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15) } - - public fun bind( - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - p14: P14, - p15: P15, - ) = - LambdaCallable3(variantConverter, p0Type, p1Type, p2Type, onCancelCall) { p0: P0, p1: P1, p2: P2 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15) } - - public fun bind( - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - p14: P14, - p15: P15, - ) = - LambdaCallable4(variantConverter, p0Type, p1Type, p2Type, p3Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15) } - - public fun bind( - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - p14: P14, - p15: P15, - ) = - LambdaCallable5(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15) } - - public fun bind( - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - p14: P14, - p15: P15, - ) = - LambdaCallable6(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15) } - - public fun bind( - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - p14: P14, - p15: P15, - ) = - LambdaCallable7(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15) } - - public fun bind( - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - p14: P14, - p15: P15, - ) = - LambdaCallable8(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15) } - - public fun bind( - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - p14: P14, - p15: P15, - ) = - LambdaCallable9(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15) } - - public fun bind( - p10: P10, - p11: P11, - p12: P12, - p13: P13, - p14: P14, - p15: P15, - ) = - LambdaCallable10(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15) } - - public fun bind( - p11: P11, - p12: P12, - p13: P13, - p14: P14, - p15: P15, - ) = - LambdaCallable11(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type, p10Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15) } - - public fun bind( - p12: P12, - p13: P13, - p14: P14, - p15: P15, - ) = - LambdaCallable12(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type, p10Type, p11Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15) } - - public fun bind( - p13: P13, - p14: P14, - p15: P15, - ) = - LambdaCallable13(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type, p10Type, p11Type, p12Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15) } - - public fun bind(p14: P14, p15: P15) = - LambdaCallable14(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type, p10Type, p11Type, p12Type, p13Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15) } - - public fun bind(p15: P15) = - LambdaCallable15(variantConverter, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type, p10Type, p11Type, p12Type, p13Type, p14Type, onCancelCall) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14 -> function(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15) } - - public companion object { - @JvmStatic - @JvmName("create") - public fun javaCreate( - returnClass: Class, - p0Class: Class, - p1Class: Class, - p2Class: Class, - p3Class: Class, - p4Class: Class, - p5Class: Class, - p6Class: Class, - p7Class: Class, - p8Class: Class, - p9Class: Class, - p10Class: Class, - p11Class: Class, - p12Class: Class, - p13Class: Class, - p14Class: Class, - p15Class: Class, - function: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - p14: P14, - p15: P15, - ) -> R, - ) = - LambdaCallable16(variantMapper.getOrDefault(Reflection.getOrCreateKotlinClass(returnClass), NIL), variantMapper[Reflection.getOrCreateKotlinClass(p0Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p1Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p2Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p3Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p4Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p5Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p6Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p7Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p8Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p9Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p10Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p11Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p12Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p13Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p14Class)]!!, variantMapper[Reflection.getOrCreateKotlinClass(p15Class)]!!, null, function) - } -} - -public inline fun callable16(noinline onCancelCall: (() -> Unit)? = null, - noinline function: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - p14: P14, - p15: P15, -) -> R) = - LambdaCallable16(variantMapper.getOrDefault(R::class, NIL), variantMapper[P0::class]!!, variantMapper[P1::class]!!, variantMapper[P2::class]!!, variantMapper[P3::class]!!, variantMapper[P4::class]!!, variantMapper[P5::class]!!, variantMapper[P6::class]!!, variantMapper[P7::class]!!, variantMapper[P8::class]!!, variantMapper[P9::class]!!, variantMapper[P10::class]!!, variantMapper[P11::class]!!, variantMapper[P12::class]!!, variantMapper[P13::class]!!, variantMapper[P14::class]!!, variantMapper[P15::class]!!, onCancelCall, function) - -public inline fun (( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - p14: P14, - p15: P15, -) -> R).asCallable(noinline onCancelCall: (() -> Unit)? = null) = callable16(onCancelCall, this) diff --git a/kt/godot-library/godot-core-library/src/main/kotlin/gen/godot/core/LambdaCallables.kt b/kt/godot-library/godot-core-library/src/main/kotlin/gen/godot/core/LambdaCallables.kt new file mode 100644 index 000000000..a510be006 --- /dev/null +++ b/kt/godot-library/godot-core-library/src/main/kotlin/gen/godot/core/LambdaCallables.kt @@ -0,0 +1,2272 @@ +@file:Suppress( + "PackageDirectoryMismatch", "UNCHECKED_CAST", + "unused", +) + +package godot.core + +import godot.core.VariantParser.NIL +import kotlin.Any +import kotlin.Array +import kotlin.PublishedApi +import kotlin.Suppress + +public class LambdaCallable0 @PublishedApi internal constructor( + container: LambdaContainer, + boundArgs: Array = emptyArray(), +) : LambdaCallable(container) { + public fun call(): R = container.invokeUnsafe() + + public fun callDeferred() = callDeferredUnsafe() + + public operator fun invoke(): R = call() +} + +public inline fun callable0(noinline function: () -> R) = + LambdaCallable0(LambdaContainer0(variantMapper.getOrDefault(R::class, NIL), arrayOf(), function)) + +public inline fun (() -> R).asCallable() = callable0(this) + +public class LambdaCallable1 @PublishedApi internal constructor( + container: LambdaContainer, + boundArgs: Array = emptyArray(), +) : LambdaCallable(container) { + public fun call(p0: P0): R = container.invokeUnsafe(p0) + + public fun callDeferred(p0: P0) = callDeferredUnsafe(p0) + + public operator fun invoke(p0: P0): R = call(p0) + + public fun bind(p0: P0) = LambdaCallable0(container, arrayOf(p0)) +} + +public inline fun callable1(noinline function: (p0: P0) -> R) = + LambdaCallable1(LambdaContainer1(variantMapper.getOrDefault(R::class, NIL), arrayOf(variantMapper[P0::class]!!), function)) + +public inline fun ((p0: P0) -> R).asCallable() = callable1(this) + +public class LambdaCallable2 @PublishedApi internal constructor( + container: LambdaContainer, + boundArgs: Array = emptyArray(), +) : LambdaCallable(container) { + public fun call(p0: P0, p1: P1): R = container.invokeUnsafe(p0, p1) + + public fun callDeferred(p0: P0, p1: P1) = callDeferredUnsafe(p0, p1) + + public operator fun invoke(p0: P0, p1: P1): R = call(p0, p1) + + public fun bind(p0: P0, p1: P1) = LambdaCallable0(container, arrayOf(p0, p1)) + + public fun bind(p1: P1) = LambdaCallable1(container, arrayOf(p1)) +} + +public inline fun callable2(noinline function: (p0: P0, + p1: P1) -> R) = + LambdaCallable2(LambdaContainer2(variantMapper.getOrDefault(R::class, NIL), arrayOf(variantMapper[P0::class]!!, variantMapper[P1::class]!!), function)) + +public inline fun ((p0: P0, p1: P1) -> R).asCallable() = + callable2(this) + +public class LambdaCallable3 @PublishedApi internal constructor( + container: LambdaContainer, + boundArgs: Array = emptyArray(), +) : LambdaCallable(container) { + public fun call( + p0: P0, + p1: P1, + p2: P2, + ): R = container.invokeUnsafe(p0, p1, p2) + + public fun callDeferred( + p0: P0, + p1: P1, + p2: P2, + ) = callDeferredUnsafe(p0, p1, p2) + + public operator fun invoke( + p0: P0, + p1: P1, + p2: P2, + ): R = call(p0, p1, p2) + + public fun bind( + p0: P0, + p1: P1, + p2: P2, + ) = LambdaCallable0(container, arrayOf(p0, p1, p2)) + + public fun bind(p1: P1, p2: P2) = LambdaCallable1(container, arrayOf(p1, p2)) + + public fun bind(p2: P2) = LambdaCallable2(container, arrayOf(p2)) +} + +public inline fun callable3(noinline function: ( + p0: P0, + p1: P1, + p2: P2, +) -> R) = + LambdaCallable3(LambdaContainer3(variantMapper.getOrDefault(R::class, NIL), arrayOf(variantMapper[P0::class]!!, variantMapper[P1::class]!!, variantMapper[P2::class]!!), function)) + +public inline fun (( + p0: P0, + p1: P1, + p2: P2, +) -> R).asCallable() = callable3(this) + +public class LambdaCallable4 @PublishedApi internal constructor( + container: LambdaContainer, + boundArgs: Array = emptyArray(), +) : LambdaCallable(container) { + public fun call( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + ): R = container.invokeUnsafe(p0, p1, p2, p3) + + public fun callDeferred( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + ) = callDeferredUnsafe(p0, p1, p2, p3) + + public operator fun invoke( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + ): R = call(p0, p1, p2, p3) + + public fun bind( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + ) = LambdaCallable0(container, arrayOf(p0, p1, p2, p3)) + + public fun bind( + p1: P1, + p2: P2, + p3: P3, + ) = LambdaCallable1(container, arrayOf(p1, p2, p3)) + + public fun bind(p2: P2, p3: P3) = LambdaCallable2(container, arrayOf(p2, p3)) + + public fun bind(p3: P3) = LambdaCallable3(container, arrayOf(p3)) +} + +public inline fun callable4(noinline + function: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, +) -> R) = + LambdaCallable4(LambdaContainer4(variantMapper.getOrDefault(R::class, NIL), arrayOf(variantMapper[P0::class]!!, variantMapper[P1::class]!!, variantMapper[P2::class]!!, variantMapper[P3::class]!!), function)) + +public inline fun (( + p0: P0, + p1: P1, + p2: P2, + p3: P3, +) -> R).asCallable() = callable4(this) + +public class LambdaCallable5 @PublishedApi internal constructor( + container: LambdaContainer, + boundArgs: Array = emptyArray(), +) : LambdaCallable(container) { + public fun call( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + ): R = container.invokeUnsafe(p0, p1, p2, p3, p4) + + public fun callDeferred( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + ) = callDeferredUnsafe(p0, p1, p2, p3, p4) + + public operator fun invoke( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + ): R = call(p0, p1, p2, p3, p4) + + public fun bind( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + ) = LambdaCallable0(container, arrayOf(p0, p1, p2, p3, p4)) + + public fun bind( + p1: P1, + p2: P2, + p3: P3, + p4: P4, + ) = LambdaCallable1(container, arrayOf(p1, p2, p3, p4)) + + public fun bind( + p2: P2, + p3: P3, + p4: P4, + ) = LambdaCallable2(container, arrayOf(p2, p3, p4)) + + public fun bind(p3: P3, p4: P4) = LambdaCallable3(container, arrayOf(p3, p4)) + + public fun bind(p4: P4) = LambdaCallable4(container, arrayOf(p4)) +} + +public inline fun + callable5(noinline function: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, +) -> R) = + LambdaCallable5(LambdaContainer5(variantMapper.getOrDefault(R::class, NIL), arrayOf(variantMapper[P0::class]!!, variantMapper[P1::class]!!, variantMapper[P2::class]!!, variantMapper[P3::class]!!, variantMapper[P4::class]!!), function)) + +public inline fun (( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, +) -> R).asCallable() = callable5(this) + +public class LambdaCallable6 @PublishedApi internal constructor( + container: LambdaContainer, + boundArgs: Array = emptyArray(), +) : LambdaCallable(container) { + public fun call( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + ): R = container.invokeUnsafe(p0, p1, p2, p3, p4, p5) + + public fun callDeferred( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + ) = callDeferredUnsafe(p0, p1, p2, p3, p4, p5) + + public operator fun invoke( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + ): R = call(p0, p1, p2, p3, p4, p5) + + public fun bind( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + ) = LambdaCallable0(container, arrayOf(p0, p1, p2, p3, p4, p5)) + + public fun bind( + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + ) = LambdaCallable1(container, arrayOf(p1, p2, p3, p4, p5)) + + public fun bind( + p2: P2, + p3: P3, + p4: P4, + p5: P5, + ) = LambdaCallable2(container, arrayOf(p2, p3, p4, p5)) + + public fun bind( + p3: P3, + p4: P4, + p5: P5, + ) = LambdaCallable3(container, arrayOf(p3, p4, p5)) + + public fun bind(p4: P4, p5: P5) = LambdaCallable4(container, arrayOf(p4, p5)) + + public fun bind(p5: P5) = LambdaCallable5(container, arrayOf(p5)) +} + +public inline fun callable6(noinline function: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, +) -> R) = + LambdaCallable6(LambdaContainer6(variantMapper.getOrDefault(R::class, NIL), arrayOf(variantMapper[P0::class]!!, variantMapper[P1::class]!!, variantMapper[P2::class]!!, variantMapper[P3::class]!!, variantMapper[P4::class]!!, variantMapper[P5::class]!!), function)) + +public inline fun (( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, +) -> R).asCallable() = callable6(this) + +public class LambdaCallable7 @PublishedApi internal constructor( + container: LambdaContainer, + boundArgs: Array = emptyArray(), +) : LambdaCallable(container) { + public fun call( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + ): R = container.invokeUnsafe(p0, p1, p2, p3, p4, p5, p6) + + public fun callDeferred( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + ) = callDeferredUnsafe(p0, p1, p2, p3, p4, p5, p6) + + public operator fun invoke( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + ): R = call(p0, p1, p2, p3, p4, p5, p6) + + public fun bind( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + ) = LambdaCallable0(container, arrayOf(p0, p1, p2, p3, p4, p5, p6)) + + public fun bind( + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + ) = LambdaCallable1(container, arrayOf(p1, p2, p3, p4, p5, p6)) + + public fun bind( + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + ) = LambdaCallable2(container, arrayOf(p2, p3, p4, p5, p6)) + + public fun bind( + p3: P3, + p4: P4, + p5: P5, + p6: P6, + ) = LambdaCallable3(container, arrayOf(p3, p4, p5, p6)) + + public fun bind( + p4: P4, + p5: P5, + p6: P6, + ) = LambdaCallable4(container, arrayOf(p4, p5, p6)) + + public fun bind(p5: P5, p6: P6) = LambdaCallable5(container, + arrayOf(p5, p6)) + + public fun bind(p6: P6) = LambdaCallable6(container, arrayOf(p6)) +} + +public inline fun callable7(noinline function: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, +) -> R) = + LambdaCallable7(LambdaContainer7(variantMapper.getOrDefault(R::class, NIL), arrayOf(variantMapper[P0::class]!!, variantMapper[P1::class]!!, variantMapper[P2::class]!!, variantMapper[P3::class]!!, variantMapper[P4::class]!!, variantMapper[P5::class]!!, variantMapper[P6::class]!!), function)) + +public inline fun (( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, +) -> R).asCallable() = callable7(this) + +public class LambdaCallable8 @PublishedApi internal constructor( + container: LambdaContainer, + boundArgs: Array = emptyArray(), +) : LambdaCallable(container) { + public fun call( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + ): R = container.invokeUnsafe(p0, p1, p2, p3, p4, p5, p6, p7) + + public fun callDeferred( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + ) = callDeferredUnsafe(p0, p1, p2, p3, p4, p5, p6, p7) + + public operator fun invoke( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + ): R = call(p0, p1, p2, p3, p4, p5, p6, p7) + + public fun bind( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + ) = LambdaCallable0(container, arrayOf(p0, p1, p2, p3, p4, p5, p6, p7)) + + public fun bind( + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + ) = LambdaCallable1(container, arrayOf(p1, p2, p3, p4, p5, p6, p7)) + + public fun bind( + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + ) = LambdaCallable2(container, arrayOf(p2, p3, p4, p5, p6, p7)) + + public fun bind( + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + ) = LambdaCallable3(container, arrayOf(p3, p4, p5, p6, p7)) + + public fun bind( + p4: P4, + p5: P5, + p6: P6, + p7: P7, + ) = LambdaCallable4(container, arrayOf(p4, p5, p6, p7)) + + public fun bind( + p5: P5, + p6: P6, + p7: P7, + ) = LambdaCallable5(container, arrayOf(p5, p6, p7)) + + public fun bind(p6: P6, p7: P7) = LambdaCallable6(container, + arrayOf(p6, p7)) + + public fun bind(p7: P7) = LambdaCallable7(container, arrayOf(p7)) +} + +public inline fun callable8(noinline function: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, +) -> R) = + LambdaCallable8(LambdaContainer8(variantMapper.getOrDefault(R::class, NIL), arrayOf(variantMapper[P0::class]!!, variantMapper[P1::class]!!, variantMapper[P2::class]!!, variantMapper[P3::class]!!, variantMapper[P4::class]!!, variantMapper[P5::class]!!, variantMapper[P6::class]!!, variantMapper[P7::class]!!), function)) + +public inline fun (( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, +) -> R).asCallable() = callable8(this) + +public class LambdaCallable9 @PublishedApi internal + constructor( + container: LambdaContainer, + boundArgs: Array = emptyArray(), +) : LambdaCallable(container) { + public fun call( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + ): R = container.invokeUnsafe(p0, p1, p2, p3, p4, p5, p6, p7, p8) + + public fun callDeferred( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + ) = callDeferredUnsafe(p0, p1, p2, p3, p4, p5, p6, p7, p8) + + public operator fun invoke( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + ): R = call(p0, p1, p2, p3, p4, p5, p6, p7, p8) + + public fun bind( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + ) = LambdaCallable0(container, arrayOf(p0, p1, p2, p3, p4, p5, p6, p7, p8)) + + public fun bind( + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + ) = LambdaCallable1(container, arrayOf(p1, p2, p3, p4, p5, p6, p7, p8)) + + public fun bind( + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + ) = LambdaCallable2(container, arrayOf(p2, p3, p4, p5, p6, p7, p8)) + + public fun bind( + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + ) = LambdaCallable3(container, arrayOf(p3, p4, p5, p6, p7, p8)) + + public fun bind( + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + ) = LambdaCallable4(container, arrayOf(p4, p5, p6, p7, p8)) + + public fun bind( + p5: P5, + p6: P6, + p7: P7, + p8: P8, + ) = LambdaCallable5(container, arrayOf(p5, p6, p7, p8)) + + public fun bind( + p6: P6, + p7: P7, + p8: P8, + ) = LambdaCallable6(container, arrayOf(p6, p7, p8)) + + public fun bind(p7: P7, p8: P8) = LambdaCallable7(container, + arrayOf(p7, p8)) + + public fun bind(p8: P8) = LambdaCallable8(container, + arrayOf(p8)) +} + +public inline fun callable9(noinline function: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, +) -> R) = + LambdaCallable9(LambdaContainer9(variantMapper.getOrDefault(R::class, NIL), arrayOf(variantMapper[P0::class]!!, variantMapper[P1::class]!!, variantMapper[P2::class]!!, variantMapper[P3::class]!!, variantMapper[P4::class]!!, variantMapper[P5::class]!!, variantMapper[P6::class]!!, variantMapper[P7::class]!!, variantMapper[P8::class]!!), function)) + +public inline fun (( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, +) -> R).asCallable() = callable9(this) + +public class LambdaCallable10 @PublishedApi internal + constructor( + container: LambdaContainer, + boundArgs: Array = emptyArray(), +) : LambdaCallable(container) { + public fun call( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + ): R = container.invokeUnsafe(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9) + + public fun callDeferred( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + ) = callDeferredUnsafe(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9) + + public operator fun invoke( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + ): R = call(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9) + + public fun bind( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + ) = LambdaCallable0(container, arrayOf(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)) + + public fun bind( + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + ) = LambdaCallable1(container, arrayOf(p1, p2, p3, p4, p5, p6, p7, p8, p9)) + + public fun bind( + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + ) = LambdaCallable2(container, arrayOf(p2, p3, p4, p5, p6, p7, p8, p9)) + + public fun bind( + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + ) = LambdaCallable3(container, arrayOf(p3, p4, p5, p6, p7, p8, p9)) + + public fun bind( + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + ) = LambdaCallable4(container, arrayOf(p4, p5, p6, p7, p8, p9)) + + public fun bind( + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + ) = LambdaCallable5(container, arrayOf(p5, p6, p7, p8, p9)) + + public fun bind( + p6: P6, + p7: P7, + p8: P8, + p9: P9, + ) = LambdaCallable6(container, arrayOf(p6, p7, p8, p9)) + + public fun bind( + p7: P7, + p8: P8, + p9: P9, + ) = LambdaCallable7(container, arrayOf(p7, p8, p9)) + + public fun bind(p8: P8, p9: P9) = LambdaCallable8(container, + arrayOf(p8, p9)) + + public fun bind(p9: P9) = LambdaCallable9(container, + arrayOf(p9)) +} + +public inline fun callable10(noinline function: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, +) -> R) = + LambdaCallable10(LambdaContainer10(variantMapper.getOrDefault(R::class, NIL), arrayOf(variantMapper[P0::class]!!, variantMapper[P1::class]!!, variantMapper[P2::class]!!, variantMapper[P3::class]!!, variantMapper[P4::class]!!, variantMapper[P5::class]!!, variantMapper[P6::class]!!, variantMapper[P7::class]!!, variantMapper[P8::class]!!, variantMapper[P9::class]!!), function)) + +public inline fun (( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, +) -> R).asCallable() = callable10(this) + +public class LambdaCallable11 @PublishedApi internal + constructor( + container: LambdaContainer, + boundArgs: Array = emptyArray(), +) : LambdaCallable(container) { + public fun call( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + ): R = container.invokeUnsafe(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) + + public fun callDeferred( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + ) = callDeferredUnsafe(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) + + public operator fun invoke( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + ): R = call(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) + + public fun bind( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + ) = LambdaCallable0(container, arrayOf(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10)) + + public fun bind( + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + ) = LambdaCallable1(container, arrayOf(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10)) + + public fun bind( + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + ) = LambdaCallable2(container, arrayOf(p2, p3, p4, p5, p6, p7, p8, p9, p10)) + + public fun bind( + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + ) = LambdaCallable3(container, arrayOf(p3, p4, p5, p6, p7, p8, p9, p10)) + + public fun bind( + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + ) = LambdaCallable4(container, arrayOf(p4, p5, p6, p7, p8, p9, p10)) + + public fun bind( + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + ) = LambdaCallable5(container, arrayOf(p5, p6, p7, p8, p9, p10)) + + public fun bind( + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + ) = LambdaCallable6(container, arrayOf(p6, p7, p8, p9, p10)) + + public fun bind( + p7: P7, + p8: P8, + p9: P9, + p10: P10, + ) = LambdaCallable7(container, arrayOf(p7, p8, p9, p10)) + + public fun bind( + p8: P8, + p9: P9, + p10: P10, + ) = LambdaCallable8(container, arrayOf(p8, p9, p10)) + + public fun bind(p9: P9, p10: P10) = + LambdaCallable9(container, arrayOf(p9, p10)) + + public fun bind(p10: P10) = LambdaCallable10(container, + arrayOf(p10)) +} + +public inline fun callable11(noinline function: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, +) -> R) = + LambdaCallable11(LambdaContainer11(variantMapper.getOrDefault(R::class, NIL), arrayOf(variantMapper[P0::class]!!, variantMapper[P1::class]!!, variantMapper[P2::class]!!, variantMapper[P3::class]!!, variantMapper[P4::class]!!, variantMapper[P5::class]!!, variantMapper[P6::class]!!, variantMapper[P7::class]!!, variantMapper[P8::class]!!, variantMapper[P9::class]!!, variantMapper[P10::class]!!), function)) + +public inline fun (( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, +) -> R).asCallable() = callable11(this) + +public class LambdaCallable12 @PublishedApi + internal constructor( + container: LambdaContainer, + boundArgs: Array = emptyArray(), +) : LambdaCallable(container) { + public fun call( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + ): R = container.invokeUnsafe(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11) + + public fun callDeferred( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + ) = callDeferredUnsafe(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11) + + public operator fun invoke( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + ): R = call(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11) + + public fun bind( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + ) = LambdaCallable0(container, arrayOf(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11)) + + public fun bind( + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + ) = LambdaCallable1(container, arrayOf(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11)) + + public fun bind( + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + ) = LambdaCallable2(container, arrayOf(p2, p3, p4, p5, p6, p7, p8, p9, p10, p11)) + + public fun bind( + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + ) = LambdaCallable3(container, arrayOf(p3, p4, p5, p6, p7, p8, p9, p10, p11)) + + public fun bind( + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + ) = LambdaCallable4(container, arrayOf(p4, p5, p6, p7, p8, p9, p10, p11)) + + public fun bind( + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + ) = LambdaCallable5(container, arrayOf(p5, p6, p7, p8, p9, p10, p11)) + + public fun bind( + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + ) = LambdaCallable6(container, arrayOf(p6, p7, p8, p9, p10, p11)) + + public fun bind( + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + ) = LambdaCallable7(container, arrayOf(p7, p8, p9, p10, p11)) + + public fun bind( + p8: P8, + p9: P9, + p10: P10, + p11: P11, + ) = LambdaCallable8(container, arrayOf(p8, p9, p10, p11)) + + public fun bind( + p9: P9, + p10: P10, + p11: P11, + ) = LambdaCallable9(container, arrayOf(p9, p10, p11)) + + public fun bind(p10: P10, p11: P11) = + LambdaCallable10(container, arrayOf(p10, p11)) + + public fun bind(p11: P11) = + LambdaCallable11(container, arrayOf(p11)) +} + +public inline fun callable12(noinline + function: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, +) -> R) = + LambdaCallable12(LambdaContainer12(variantMapper.getOrDefault(R::class, NIL), arrayOf(variantMapper[P0::class]!!, variantMapper[P1::class]!!, variantMapper[P2::class]!!, variantMapper[P3::class]!!, variantMapper[P4::class]!!, variantMapper[P5::class]!!, variantMapper[P6::class]!!, variantMapper[P7::class]!!, variantMapper[P8::class]!!, variantMapper[P9::class]!!, variantMapper[P10::class]!!, variantMapper[P11::class]!!), function)) + +public inline fun (( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, +) -> R).asCallable() = callable12(this) + +public class LambdaCallable13 + @PublishedApi internal constructor( + container: LambdaContainer, + boundArgs: Array = emptyArray(), +) : LambdaCallable(container) { + public fun call( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + ): R = container.invokeUnsafe(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12) + + public fun callDeferred( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + ) = callDeferredUnsafe(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12) + + public operator fun invoke( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + ): R = call(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12) + + public fun bind( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + ) = LambdaCallable0(container, arrayOf(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12)) + + public fun bind( + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + ) = LambdaCallable1(container, arrayOf(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12)) + + public fun bind( + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + ) = LambdaCallable2(container, arrayOf(p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12)) + + public fun bind( + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + ) = LambdaCallable3(container, arrayOf(p3, p4, p5, p6, p7, p8, p9, p10, p11, p12)) + + public fun bind( + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + ) = LambdaCallable4(container, arrayOf(p4, p5, p6, p7, p8, p9, p10, p11, p12)) + + public fun bind( + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + ) = LambdaCallable5(container, arrayOf(p5, p6, p7, p8, p9, p10, p11, p12)) + + public fun bind( + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + ) = LambdaCallable6(container, arrayOf(p6, p7, p8, p9, p10, p11, p12)) + + public fun bind( + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + ) = LambdaCallable7(container, arrayOf(p7, p8, p9, p10, p11, p12)) + + public fun bind( + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + ) = LambdaCallable8(container, arrayOf(p8, p9, p10, p11, p12)) + + public fun bind( + p9: P9, + p10: P10, + p11: P11, + p12: P12, + ) = LambdaCallable9(container, arrayOf(p9, p10, p11, p12)) + + public fun bind( + p10: P10, + p11: P11, + p12: P12, + ) = LambdaCallable10(container, arrayOf(p10, p11, p12)) + + public fun bind(p11: P11, p12: P12) = + LambdaCallable11(container, arrayOf(p11, p12)) + + public fun bind(p12: P12) = + LambdaCallable12(container, arrayOf(p12)) +} + +public inline fun + callable13(noinline function: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, +) -> R) = + LambdaCallable13(LambdaContainer13(variantMapper.getOrDefault(R::class, NIL), arrayOf(variantMapper[P0::class]!!, variantMapper[P1::class]!!, variantMapper[P2::class]!!, variantMapper[P3::class]!!, variantMapper[P4::class]!!, variantMapper[P5::class]!!, variantMapper[P6::class]!!, variantMapper[P7::class]!!, variantMapper[P8::class]!!, variantMapper[P9::class]!!, variantMapper[P10::class]!!, variantMapper[P11::class]!!, variantMapper[P12::class]!!), function)) + +public inline fun (( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, +) -> R).asCallable() = callable13(this) + +public class LambdaCallable14 + @PublishedApi internal constructor( + container: LambdaContainer, + boundArgs: Array = emptyArray(), +) : LambdaCallable(container) { + public fun call( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + ): R = container.invokeUnsafe(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13) + + public fun callDeferred( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + ) = callDeferredUnsafe(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13) + + public operator fun invoke( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + ): R = call(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13) + + public fun bind( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + ) = LambdaCallable0(container, + arrayOf(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13)) + + public fun bind( + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + ) = LambdaCallable1(container, + arrayOf(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13)) + + public fun bind( + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + ) = LambdaCallable2(container, + arrayOf(p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13)) + + public fun bind( + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + ) = LambdaCallable3(container, + arrayOf(p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13)) + + public fun bind( + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + ) = LambdaCallable4(container, + arrayOf(p4, p5, p6, p7, p8, p9, p10, p11, p12, p13)) + + public fun bind( + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + ) = LambdaCallable5(container, + arrayOf(p5, p6, p7, p8, p9, p10, p11, p12, p13)) + + public fun bind( + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + ) = LambdaCallable6(container, + arrayOf(p6, p7, p8, p9, p10, p11, p12, p13)) + + public fun bind( + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + ) = LambdaCallable7(container, + arrayOf(p7, p8, p9, p10, p11, p12, p13)) + + public fun bind( + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + ) = LambdaCallable8(container, + arrayOf(p8, p9, p10, p11, p12, p13)) + + public fun bind( + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + ) = LambdaCallable9(container, + arrayOf(p9, p10, p11, p12, p13)) + + public fun bind( + p10: P10, + p11: P11, + p12: P12, + p13: P13, + ) = LambdaCallable10(container, + arrayOf(p10, p11, p12, p13)) + + public fun bind( + p11: P11, + p12: P12, + p13: P13, + ) = LambdaCallable11(container, + arrayOf(p11, p12, p13)) + + public fun bind(p12: P12, p13: P13) = + LambdaCallable12(container, + arrayOf(p12, p13)) + + public fun bind(p13: P13) = + LambdaCallable13(container, + arrayOf(p13)) +} + +public inline fun callable14(noinline function: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, +) -> R) = + LambdaCallable14(LambdaContainer14(variantMapper.getOrDefault(R::class, NIL), arrayOf(variantMapper[P0::class]!!, variantMapper[P1::class]!!, variantMapper[P2::class]!!, variantMapper[P3::class]!!, variantMapper[P4::class]!!, variantMapper[P5::class]!!, variantMapper[P6::class]!!, variantMapper[P7::class]!!, variantMapper[P8::class]!!, variantMapper[P9::class]!!, variantMapper[P10::class]!!, variantMapper[P11::class]!!, variantMapper[P12::class]!!, variantMapper[P13::class]!!), function)) + +public inline fun (( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, +) -> R).asCallable() = callable14(this) + +public class LambdaCallable15 + @PublishedApi internal constructor( + container: LambdaContainer, + boundArgs: Array = emptyArray(), +) : LambdaCallable(container) { + public fun call( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + p14: P14, + ): R = container.invokeUnsafe(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14) + + public fun callDeferred( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + p14: P14, + ) = callDeferredUnsafe(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14) + + public operator fun invoke( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + p14: P14, + ): R = call(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14) + + public fun bind( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + p14: P14, + ) = LambdaCallable0(container, + arrayOf(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14)) + + public fun bind( + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + p14: P14, + ) = LambdaCallable1(container, + arrayOf(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14)) + + public fun bind( + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + p14: P14, + ) = LambdaCallable2(container, + arrayOf(p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14)) + + public fun bind( + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + p14: P14, + ) = LambdaCallable3(container, + arrayOf(p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14)) + + public fun bind( + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + p14: P14, + ) = LambdaCallable4(container, + arrayOf(p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14)) + + public fun bind( + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + p14: P14, + ) = LambdaCallable5(container, + arrayOf(p5, p6, p7, p8, p9, p10, p11, p12, p13, p14)) + + public fun bind( + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + p14: P14, + ) = LambdaCallable6(container, + arrayOf(p6, p7, p8, p9, p10, p11, p12, p13, p14)) + + public fun bind( + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + p14: P14, + ) = LambdaCallable7(container, + arrayOf(p7, p8, p9, p10, p11, p12, p13, p14)) + + public fun bind( + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + p14: P14, + ) = LambdaCallable8(container, + arrayOf(p8, p9, p10, p11, p12, p13, p14)) + + public fun bind( + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + p14: P14, + ) = LambdaCallable9(container, + arrayOf(p9, p10, p11, p12, p13, p14)) + + public fun bind( + p10: P10, + p11: P11, + p12: P12, + p13: P13, + p14: P14, + ) = LambdaCallable10(container, + arrayOf(p10, p11, p12, p13, p14)) + + public fun bind( + p11: P11, + p12: P12, + p13: P13, + p14: P14, + ) = LambdaCallable11(container, + arrayOf(p11, p12, p13, p14)) + + public fun bind( + p12: P12, + p13: P13, + p14: P14, + ) = LambdaCallable12(container, + arrayOf(p12, p13, p14)) + + public fun bind(p13: P13, p14: P14) = + LambdaCallable13(container, + arrayOf(p13, p14)) + + public fun bind(p14: P14) = + LambdaCallable14(container, + arrayOf(p14)) +} + +public inline fun callable15(noinline function: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + p14: P14, +) -> R) = + LambdaCallable15(LambdaContainer15(variantMapper.getOrDefault(R::class, NIL), arrayOf(variantMapper[P0::class]!!, variantMapper[P1::class]!!, variantMapper[P2::class]!!, variantMapper[P3::class]!!, variantMapper[P4::class]!!, variantMapper[P5::class]!!, variantMapper[P6::class]!!, variantMapper[P7::class]!!, variantMapper[P8::class]!!, variantMapper[P9::class]!!, variantMapper[P10::class]!!, variantMapper[P11::class]!!, variantMapper[P12::class]!!, variantMapper[P13::class]!!, variantMapper[P14::class]!!), function)) + +public inline fun (( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + p14: P14, +) -> R).asCallable() = callable15(this) + +public class LambdaCallable16 @PublishedApi internal constructor( + container: LambdaContainer, + boundArgs: Array = emptyArray(), +) : LambdaCallable(container) { + public fun call( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + p14: P14, + p15: P15, + ): R = + container.invokeUnsafe(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15) + + public fun callDeferred( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + p14: P14, + p15: P15, + ) = callDeferredUnsafe(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15) + + public operator fun invoke( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + p14: P14, + p15: P15, + ): R = call(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15) + + public fun bind( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + p14: P14, + p15: P15, + ) = LambdaCallable0(container, + arrayOf(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15)) + + public fun bind( + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + p14: P14, + p15: P15, + ) = LambdaCallable1(container, + arrayOf(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15)) + + public fun bind( + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + p14: P14, + p15: P15, + ) = LambdaCallable2(container, + arrayOf(p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15)) + + public fun bind( + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + p14: P14, + p15: P15, + ) = LambdaCallable3(container, + arrayOf(p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15)) + + public fun bind( + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + p14: P14, + p15: P15, + ) = LambdaCallable4(container, + arrayOf(p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15)) + + public fun bind( + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + p14: P14, + p15: P15, + ) = LambdaCallable5(container, + arrayOf(p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15)) + + public fun bind( + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + p14: P14, + p15: P15, + ) = LambdaCallable6(container, + arrayOf(p6, p7, p8, p9, p10, p11, p12, p13, p14, p15)) + + public fun bind( + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + p14: P14, + p15: P15, + ) = LambdaCallable7(container, + arrayOf(p7, p8, p9, p10, p11, p12, p13, p14, p15)) + + public fun bind( + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + p14: P14, + p15: P15, + ) = LambdaCallable8(container, + arrayOf(p8, p9, p10, p11, p12, p13, p14, p15)) + + public fun bind( + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + p14: P14, + p15: P15, + ) = LambdaCallable9(container, + arrayOf(p9, p10, p11, p12, p13, p14, p15)) + + public fun bind( + p10: P10, + p11: P11, + p12: P12, + p13: P13, + p14: P14, + p15: P15, + ) = LambdaCallable10(container, + arrayOf(p10, p11, p12, p13, p14, p15)) + + public fun bind( + p11: P11, + p12: P12, + p13: P13, + p14: P14, + p15: P15, + ) = LambdaCallable11(container, + arrayOf(p11, p12, p13, p14, p15)) + + public fun bind( + p12: P12, + p13: P13, + p14: P14, + p15: P15, + ) = LambdaCallable12(container, + arrayOf(p12, p13, p14, p15)) + + public fun bind( + p13: P13, + p14: P14, + p15: P15, + ) = LambdaCallable13(container, + arrayOf(p13, p14, p15)) + + public fun bind(p14: P14, p15: P15) = + LambdaCallable14(container, + arrayOf(p14, p15)) + + public fun bind(p15: P15) = + LambdaCallable15(container, + arrayOf(p15)) +} + +public inline fun callable16(noinline function: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + p14: P14, + p15: P15, +) -> R) = + LambdaCallable16(LambdaContainer16(variantMapper.getOrDefault(R::class, NIL), arrayOf(variantMapper[P0::class]!!, variantMapper[P1::class]!!, variantMapper[P2::class]!!, variantMapper[P3::class]!!, variantMapper[P4::class]!!, variantMapper[P5::class]!!, variantMapper[P6::class]!!, variantMapper[P7::class]!!, variantMapper[P8::class]!!, variantMapper[P9::class]!!, variantMapper[P10::class]!!, variantMapper[P11::class]!!, variantMapper[P12::class]!!, variantMapper[P13::class]!!, variantMapper[P14::class]!!, variantMapper[P15::class]!!), function)) + +public inline fun (( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + p14: P14, + p15: P15, +) -> R).asCallable() = callable16(this) diff --git a/kt/godot-library/godot-core-library/src/main/kotlin/gen/godot/core/LambdaContainers.kt b/kt/godot-library/godot-core-library/src/main/kotlin/gen/godot/core/LambdaContainers.kt new file mode 100644 index 000000000..138aebb49 --- /dev/null +++ b/kt/godot-library/godot-core-library/src/main/kotlin/gen/godot/core/LambdaContainers.kt @@ -0,0 +1,453 @@ +@file:Suppress( + "PackageDirectoryMismatch", "UNCHECKED_CAST", + "unused", +) + +package godot.core + +import godot.common.interop.VariantConverter +import kotlin.Any +import kotlin.Array +import kotlin.PublishedApi +import kotlin.Suppress + +public class LambdaContainer0 @PublishedApi internal constructor( + returnConverter: VariantConverter, + typeConverters: Array, + function: () -> R, +) : LambdaContainer(returnConverter, typeConverters, function) { + public override fun invokeUnsafe(vararg args: Any?): R = + (function as? () -> R)?.invoke()?: throw InvalidJvmLambdaException() +} + +public class LambdaContainer1 @PublishedApi internal constructor( + returnConverter: VariantConverter, + typeConverters: Array, + function: (p0: P0) -> R, +) : LambdaContainer(returnConverter, typeConverters, function) { + public override fun invokeUnsafe(vararg args: Any?): R = + (function as? (p0: Any?) -> R)?.invoke(args[0])?: throw InvalidJvmLambdaException() +} + +public class LambdaContainer2 @PublishedApi internal constructor( + returnConverter: VariantConverter, + typeConverters: Array, + function: (p0: P0, p1: P1) -> R, +) : LambdaContainer(returnConverter, typeConverters, function) { + public override fun invokeUnsafe(vararg args: Any?): R = (function as? (p0: Any?, + p1: Any?) -> R)?.invoke(args[0], args[1])?: throw InvalidJvmLambdaException() +} + +public class LambdaContainer3 @PublishedApi internal constructor( + returnConverter: VariantConverter, + typeConverters: Array, + function: ( + p0: P0, + p1: P1, + p2: P2, + ) -> R, +) : LambdaContainer(returnConverter, typeConverters, function) { + public override fun invokeUnsafe(vararg args: Any?): R = (function as? ( + p0: Any?, + p1: Any?, + p2: Any?, + ) -> R)?.invoke(args[0], args[1], args[2])?: throw InvalidJvmLambdaException() +} + +public class LambdaContainer4 @PublishedApi internal constructor( + returnConverter: VariantConverter, + typeConverters: Array, + function: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + ) -> R, +) : LambdaContainer(returnConverter, typeConverters, function) { + public override fun invokeUnsafe(vararg args: Any?): R = (function as? ( + p0: Any?, + p1: Any?, + p2: Any?, + p3: Any?, + ) -> R)?.invoke(args[0], args[1], args[2], args[3])?: throw InvalidJvmLambdaException() +} + +public class LambdaContainer5 @PublishedApi internal constructor( + returnConverter: VariantConverter, + typeConverters: Array, + function: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + ) -> R, +) : LambdaContainer(returnConverter, typeConverters, function) { + public override fun invokeUnsafe(vararg args: Any?): R = (function as? ( + p0: Any?, + p1: Any?, + p2: Any?, + p3: Any?, + p4: Any?, + ) -> R)?.invoke(args[0], args[1], args[2], args[3], args[4])?: throw InvalidJvmLambdaException() +} + +public class LambdaContainer6 @PublishedApi internal constructor( + returnConverter: VariantConverter, + typeConverters: Array, + function: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + ) -> R, +) : LambdaContainer(returnConverter, typeConverters, function) { + public override fun invokeUnsafe(vararg args: Any?): R = (function as? ( + p0: Any?, + p1: Any?, + p2: Any?, + p3: Any?, + p4: Any?, + p5: Any?, + ) -> R)?.invoke(args[0], args[1], args[2], args[3], args[4], args[5])?: throw InvalidJvmLambdaException() +} + +public class LambdaContainer7 @PublishedApi internal constructor( + returnConverter: VariantConverter, + typeConverters: Array, + function: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + ) -> R, +) : LambdaContainer(returnConverter, typeConverters, function) { + public override fun invokeUnsafe(vararg args: Any?): R = (function as? ( + p0: Any?, + p1: Any?, + p2: Any?, + p3: Any?, + p4: Any?, + p5: Any?, + p6: Any?, + ) -> R)?.invoke(args[0], args[1], args[2], args[3], args[4], args[5], args[6])?: throw InvalidJvmLambdaException() +} + +public class LambdaContainer8 @PublishedApi internal constructor( + returnConverter: VariantConverter, + typeConverters: Array, + function: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + ) -> R, +) : LambdaContainer(returnConverter, typeConverters, function) { + public override fun invokeUnsafe(vararg args: Any?): R = (function as? ( + p0: Any?, + p1: Any?, + p2: Any?, + p3: Any?, + p4: Any?, + p5: Any?, + p6: Any?, + p7: Any?, + ) -> R)?.invoke(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7])?: throw InvalidJvmLambdaException() +} + +public class LambdaContainer9 @PublishedApi internal + constructor( + returnConverter: VariantConverter, + typeConverters: Array, + function: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + ) -> R, +) : LambdaContainer(returnConverter, typeConverters, function) { + public override fun invokeUnsafe(vararg args: Any?): R = (function as? ( + p0: Any?, + p1: Any?, + p2: Any?, + p3: Any?, + p4: Any?, + p5: Any?, + p6: Any?, + p7: Any?, + p8: Any?, + ) -> R)?.invoke(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8])?: throw InvalidJvmLambdaException() +} + +public class LambdaContainer10 @PublishedApi internal + constructor( + returnConverter: VariantConverter, + typeConverters: Array, + function: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + ) -> R, +) : LambdaContainer(returnConverter, typeConverters, function) { + public override fun invokeUnsafe(vararg args: Any?): R = (function as? ( + p0: Any?, + p1: Any?, + p2: Any?, + p3: Any?, + p4: Any?, + p5: Any?, + p6: Any?, + p7: Any?, + p8: Any?, + p9: Any?, + ) -> R)?.invoke(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9])?: throw InvalidJvmLambdaException() +} + +public class LambdaContainer11 @PublishedApi + internal constructor( + returnConverter: VariantConverter, + typeConverters: Array, + function: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + ) -> R, +) : LambdaContainer(returnConverter, typeConverters, function) { + public override fun invokeUnsafe(vararg args: Any?): R = (function as? ( + p0: Any?, + p1: Any?, + p2: Any?, + p3: Any?, + p4: Any?, + p5: Any?, + p6: Any?, + p7: Any?, + p8: Any?, + p9: Any?, + p10: Any?, + ) -> R)?.invoke(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9], args[10])?: throw InvalidJvmLambdaException() +} + +public class LambdaContainer12 @PublishedApi + internal constructor( + returnConverter: VariantConverter, + typeConverters: Array, + function: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + ) -> R, +) : LambdaContainer(returnConverter, typeConverters, function) { + public override fun invokeUnsafe(vararg args: Any?): R = (function as? ( + p0: Any?, + p1: Any?, + p2: Any?, + p3: Any?, + p4: Any?, + p5: Any?, + p6: Any?, + p7: Any?, + p8: Any?, + p9: Any?, + p10: Any?, + p11: Any?, + ) -> R)?.invoke(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9], args[10], args[11])?: throw InvalidJvmLambdaException() +} + +public class LambdaContainer13 + @PublishedApi internal constructor( + returnConverter: VariantConverter, + typeConverters: Array, + function: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + ) -> R, +) : LambdaContainer(returnConverter, typeConverters, function) { + public override fun invokeUnsafe(vararg args: Any?): R = (function as? ( + p0: Any?, + p1: Any?, + p2: Any?, + p3: Any?, + p4: Any?, + p5: Any?, + p6: Any?, + p7: Any?, + p8: Any?, + p9: Any?, + p10: Any?, + p11: Any?, + p12: Any?, + ) -> R)?.invoke(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9], args[10], args[11], args[12])?: throw InvalidJvmLambdaException() +} + +public class LambdaContainer14 + @PublishedApi internal constructor( + returnConverter: VariantConverter, + typeConverters: Array, + function: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + ) -> R, +) : LambdaContainer(returnConverter, typeConverters, function) { + public override fun invokeUnsafe(vararg args: Any?): R = (function as? ( + p0: Any?, + p1: Any?, + p2: Any?, + p3: Any?, + p4: Any?, + p5: Any?, + p6: Any?, + p7: Any?, + p8: Any?, + p9: Any?, + p10: Any?, + p11: Any?, + p12: Any?, + p13: Any?, + ) -> R)?.invoke(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9], args[10], args[11], args[12], args[13])?: throw InvalidJvmLambdaException() +} + +public class LambdaContainer15 + @PublishedApi internal constructor( + returnConverter: VariantConverter, + typeConverters: Array, + function: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + p14: P14, + ) -> R, +) : LambdaContainer(returnConverter, typeConverters, function) { + public override fun invokeUnsafe(vararg args: Any?): R = (function as? ( + p0: Any?, + p1: Any?, + p2: Any?, + p3: Any?, + p4: Any?, + p5: Any?, + p6: Any?, + p7: Any?, + p8: Any?, + p9: Any?, + p10: Any?, + p11: Any?, + p12: Any?, + p13: Any?, + p14: Any?, + ) -> R)?.invoke(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9], args[10], args[11], args[12], args[13], args[14])?: throw InvalidJvmLambdaException() +} + +public class LambdaContainer16 @PublishedApi internal constructor( + returnConverter: VariantConverter, + typeConverters: Array, + function: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + p14: P14, + p15: P15, + ) -> R, +) : LambdaContainer(returnConverter, typeConverters, function) { + public override fun invokeUnsafe(vararg args: Any?): R = (function as? ( + p0: Any?, + p1: Any?, + p2: Any?, + p3: Any?, + p4: Any?, + p5: Any?, + p6: Any?, + p7: Any?, + p8: Any?, + p9: Any?, + p10: Any?, + p11: Any?, + p12: Any?, + p13: Any?, + p14: Any?, + p15: Any?, + ) -> R)?.invoke(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9], args[10], args[11], args[12], args[13], args[14], args[15])?: throw InvalidJvmLambdaException() +} diff --git a/kt/godot-library/godot-core-library/src/main/kotlin/gen/godot/core/SignalConnectors.kt b/kt/godot-library/godot-core-library/src/main/kotlin/gen/godot/core/SignalConnectors.kt new file mode 100644 index 000000000..e9c20430b --- /dev/null +++ b/kt/godot-library/godot-core-library/src/main/kotlin/gen/godot/core/SignalConnectors.kt @@ -0,0 +1,973 @@ +@file:Suppress( + "PackageDirectoryMismatch", "UNCHECKED_CAST", + "unused", + "NOTHING_TO_INLINE", +) + +package godot.core + +import godot.api.Object +import kotlin.Suppress +import kotlin.Unit +import kotlin.reflect.KCallable + +public inline fun Signal0.connect(flags: Object.ConnectFlags = Object.ConnectFlags.DEFAULT, noinline + method: () -> Unit): SignalConnector { + val connector = SignalConnector( + this, + method.asCallable() + ) + connector.connect(flags) + return connector +} + +public fun Signal0.connect( + target: T, + method: T.() -> Unit, + flags: Object.ConnectFlags = Object.ConnectFlags.DEFAULT, +): SignalConnector { + val connector = SignalConnector( + this, + MethodCallable(target, (method as KCallable<*>).name.toGodotName()) + ) + connector.connect(flags) + return connector +} + +public inline fun Signal0.promise(noinline method: () -> Unit, noinline cancel: () -> Unit): Unit { + LambdaContainer0(VariantParser.NIL, arrayOf(), method).setAsCancellable(this, cancel) +} + +public inline fun Signal1.connect(flags: Object.ConnectFlags = + Object.ConnectFlags.DEFAULT, noinline method: (p0: P0) -> Unit): SignalConnector { + val connector = SignalConnector( + this, + method.asCallable() + ) + connector.connect(flags) + return connector +} + +public fun Signal1.connect( + target: T, + method: T.(p0: P0) -> Unit, + flags: Object.ConnectFlags = Object.ConnectFlags.DEFAULT, +): SignalConnector { + val connector = SignalConnector( + this, + MethodCallable(target, (method as KCallable<*>).name.toGodotName()) + ) + connector.connect(flags) + return connector +} + +public inline fun Signal1.promise(noinline method: (p0: P0) -> Unit, noinline + cancel: () -> Unit): Unit { + LambdaContainer1(VariantParser.NIL, arrayOf(variantMapper[P0::class]!!), method).setAsCancellable(this, cancel) +} + +public inline fun Signal2.connect(flags: Object.ConnectFlags = + Object.ConnectFlags.DEFAULT, noinline method: (p0: P0, p1: P1) -> Unit): SignalConnector { + val connector = SignalConnector( + this, + method.asCallable() + ) + connector.connect(flags) + return connector +} + +public fun Signal2.connect( + target: T, + method: T.(p0: P0, p1: P1) -> Unit, + flags: Object.ConnectFlags = Object.ConnectFlags.DEFAULT, +): SignalConnector { + val connector = SignalConnector( + this, + MethodCallable(target, (method as KCallable<*>).name.toGodotName()) + ) + connector.connect(flags) + return connector +} + +public inline fun Signal2.promise(noinline method: (p0: P0, + p1: P1) -> Unit, noinline cancel: () -> Unit): Unit { + LambdaContainer2(VariantParser.NIL, arrayOf(variantMapper[P0::class]!!, variantMapper[P1::class]!!), method).setAsCancellable(this, cancel) +} + +public inline fun + Signal3.connect(flags: Object.ConnectFlags = Object.ConnectFlags.DEFAULT, noinline + method: ( + p0: P0, + p1: P1, + p2: P2, +) -> Unit): SignalConnector { + val connector = SignalConnector( + this, + method.asCallable() + ) + connector.connect(flags) + return connector +} + +public fun Signal3.connect( + target: T, + method: T.( + p0: P0, + p1: P1, + p2: P2, + ) -> Unit, + flags: Object.ConnectFlags = Object.ConnectFlags.DEFAULT, +): SignalConnector { + val connector = SignalConnector( + this, + MethodCallable(target, (method as KCallable<*>).name.toGodotName()) + ) + connector.connect(flags) + return connector +} + +public inline fun Signal3.promise(noinline + method: ( + p0: P0, + p1: P1, + p2: P2, +) -> Unit, noinline cancel: () -> Unit): Unit { + LambdaContainer3(VariantParser.NIL, arrayOf(variantMapper[P0::class]!!, variantMapper[P1::class]!!, variantMapper[P2::class]!!), method).setAsCancellable(this, cancel) +} + +public inline fun + Signal4.connect(flags: Object.ConnectFlags = Object.ConnectFlags.DEFAULT, + noinline method: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, +) -> Unit): SignalConnector { + val connector = SignalConnector( + this, + method.asCallable() + ) + connector.connect(flags) + return connector +} + +public fun Signal4.connect( + target: T, + method: T.( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + ) -> Unit, + flags: Object.ConnectFlags = Object.ConnectFlags.DEFAULT, +): SignalConnector { + val connector = SignalConnector( + this, + MethodCallable(target, (method as KCallable<*>).name.toGodotName()) + ) + connector.connect(flags) + return connector +} + +public inline fun + Signal4.promise(noinline method: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, +) -> Unit, noinline cancel: () -> Unit): Unit { + LambdaContainer4(VariantParser.NIL, arrayOf(variantMapper[P0::class]!!, variantMapper[P1::class]!!, variantMapper[P2::class]!!, variantMapper[P3::class]!!), method).setAsCancellable(this, cancel) +} + +public inline fun + Signal5.connect(flags: Object.ConnectFlags = Object.ConnectFlags.DEFAULT, + noinline method: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, +) -> Unit): SignalConnector { + val connector = SignalConnector( + this, + method.asCallable() + ) + connector.connect(flags) + return connector +} + +public fun Signal5.connect( + target: T, + method: T.( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + ) -> Unit, + flags: Object.ConnectFlags = Object.ConnectFlags.DEFAULT, +): SignalConnector { + val connector = SignalConnector( + this, + MethodCallable(target, (method as KCallable<*>).name.toGodotName()) + ) + connector.connect(flags) + return connector +} + +public inline fun + Signal5.promise(noinline method: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, +) -> Unit, noinline cancel: () -> Unit): Unit { + LambdaContainer5(VariantParser.NIL, arrayOf(variantMapper[P0::class]!!, variantMapper[P1::class]!!, variantMapper[P2::class]!!, variantMapper[P3::class]!!, variantMapper[P4::class]!!), method).setAsCancellable(this, cancel) +} + +public inline fun + Signal6.connect(flags: Object.ConnectFlags = + Object.ConnectFlags.DEFAULT, noinline method: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, +) -> Unit): SignalConnector { + val connector = SignalConnector( + this, + method.asCallable() + ) + connector.connect(flags) + return connector +} + +public fun Signal6.connect( + target: T, + method: T.( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + ) -> Unit, + flags: Object.ConnectFlags = Object.ConnectFlags.DEFAULT, +): SignalConnector { + val connector = SignalConnector( + this, + MethodCallable(target, (method as KCallable<*>).name.toGodotName()) + ) + connector.connect(flags) + return connector +} + +public inline fun + Signal6.promise(noinline method: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, +) -> Unit, noinline cancel: () -> Unit): Unit { + LambdaContainer6(VariantParser.NIL, arrayOf(variantMapper[P0::class]!!, variantMapper[P1::class]!!, variantMapper[P2::class]!!, variantMapper[P3::class]!!, variantMapper[P4::class]!!, variantMapper[P5::class]!!), method).setAsCancellable(this, cancel) +} + +public inline fun Signal7.connect(flags: Object.ConnectFlags = + Object.ConnectFlags.DEFAULT, noinline method: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, +) -> Unit): SignalConnector { + val connector = SignalConnector( + this, + method.asCallable() + ) + connector.connect(flags) + return connector +} + +public fun Signal7.connect( + target: T, + method: T.( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + ) -> Unit, + flags: Object.ConnectFlags = Object.ConnectFlags.DEFAULT, +): SignalConnector { + val connector = SignalConnector( + this, + MethodCallable(target, (method as KCallable<*>).name.toGodotName()) + ) + connector.connect(flags) + return connector +} + +public inline fun Signal7.promise(noinline method: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, +) -> Unit, noinline cancel: () -> Unit): Unit { + LambdaContainer7(VariantParser.NIL, arrayOf(variantMapper[P0::class]!!, variantMapper[P1::class]!!, variantMapper[P2::class]!!, variantMapper[P3::class]!!, variantMapper[P4::class]!!, variantMapper[P5::class]!!, variantMapper[P6::class]!!), method).setAsCancellable(this, cancel) +} + +public inline fun Signal8.connect(flags: Object.ConnectFlags = + Object.ConnectFlags.DEFAULT, noinline method: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, +) -> Unit): SignalConnector { + val connector = SignalConnector( + this, + method.asCallable() + ) + connector.connect(flags) + return connector +} + +public fun + Signal8.connect( + target: T, + method: T.( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + ) -> Unit, + flags: Object.ConnectFlags = Object.ConnectFlags.DEFAULT, +): SignalConnector { + val connector = SignalConnector( + this, + MethodCallable(target, (method as KCallable<*>).name.toGodotName()) + ) + connector.connect(flags) + return connector +} + +public inline fun Signal8.promise(noinline method: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, +) -> Unit, noinline cancel: () -> Unit): Unit { + LambdaContainer8(VariantParser.NIL, arrayOf(variantMapper[P0::class]!!, variantMapper[P1::class]!!, variantMapper[P2::class]!!, variantMapper[P3::class]!!, variantMapper[P4::class]!!, variantMapper[P5::class]!!, variantMapper[P6::class]!!, variantMapper[P7::class]!!), method).setAsCancellable(this, cancel) +} + +public inline fun + Signal9.connect(flags: Object.ConnectFlags = + Object.ConnectFlags.DEFAULT, noinline method: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, +) -> Unit): SignalConnector { + val connector = SignalConnector( + this, + method.asCallable() + ) + connector.connect(flags) + return connector +} + +public fun + Signal9.connect( + target: T, + method: T.( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + ) -> Unit, + flags: Object.ConnectFlags = Object.ConnectFlags.DEFAULT, +): SignalConnector { + val connector = SignalConnector( + this, + MethodCallable(target, (method as KCallable<*>).name.toGodotName()) + ) + connector.connect(flags) + return connector +} + +public inline fun Signal9.promise(noinline + method: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, +) -> Unit, noinline cancel: () -> Unit): Unit { + LambdaContainer9(VariantParser.NIL, arrayOf(variantMapper[P0::class]!!, variantMapper[P1::class]!!, variantMapper[P2::class]!!, variantMapper[P3::class]!!, variantMapper[P4::class]!!, variantMapper[P5::class]!!, variantMapper[P6::class]!!, variantMapper[P7::class]!!, variantMapper[P8::class]!!), method).setAsCancellable(this, cancel) +} + +public inline fun + Signal10.connect(flags: Object.ConnectFlags = + Object.ConnectFlags.DEFAULT, noinline method: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, +) -> Unit): SignalConnector { + val connector = SignalConnector( + this, + method.asCallable() + ) + connector.connect(flags) + return connector +} + +public fun + Signal10.connect( + target: T, + method: T.( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + ) -> Unit, + flags: Object.ConnectFlags = Object.ConnectFlags.DEFAULT, +): SignalConnector { + val connector = SignalConnector( + this, + MethodCallable(target, (method as KCallable<*>).name.toGodotName()) + ) + connector.connect(flags) + return connector +} + +public inline fun + Signal10.promise(noinline method: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, +) -> Unit, noinline cancel: () -> Unit): Unit { + LambdaContainer10(VariantParser.NIL, arrayOf(variantMapper[P0::class]!!, variantMapper[P1::class]!!, variantMapper[P2::class]!!, variantMapper[P3::class]!!, variantMapper[P4::class]!!, variantMapper[P5::class]!!, variantMapper[P6::class]!!, variantMapper[P7::class]!!, variantMapper[P8::class]!!, variantMapper[P9::class]!!), method).setAsCancellable(this, cancel) +} + +public inline fun + Signal11.connect(flags: Object.ConnectFlags = + Object.ConnectFlags.DEFAULT, noinline method: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, +) -> Unit): SignalConnector { + val connector = SignalConnector( + this, + method.asCallable() + ) + connector.connect(flags) + return connector +} + +public fun + Signal11.connect( + target: T, + method: T.( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + ) -> Unit, + flags: Object.ConnectFlags = Object.ConnectFlags.DEFAULT, +): SignalConnector { + val connector = SignalConnector( + this, + MethodCallable(target, (method as KCallable<*>).name.toGodotName()) + ) + connector.connect(flags) + return connector +} + +public inline fun + Signal11.promise(noinline method: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, +) -> Unit, noinline cancel: () -> Unit): Unit { + LambdaContainer11(VariantParser.NIL, arrayOf(variantMapper[P0::class]!!, variantMapper[P1::class]!!, variantMapper[P2::class]!!, variantMapper[P3::class]!!, variantMapper[P4::class]!!, variantMapper[P5::class]!!, variantMapper[P6::class]!!, variantMapper[P7::class]!!, variantMapper[P8::class]!!, variantMapper[P9::class]!!, variantMapper[P10::class]!!), method).setAsCancellable(this, cancel) +} + +public inline fun + Signal12.connect(flags: Object.ConnectFlags = + Object.ConnectFlags.DEFAULT, noinline method: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, +) -> Unit): SignalConnector { + val connector = SignalConnector( + this, + method.asCallable() + ) + connector.connect(flags) + return connector +} + +public fun + Signal12.connect( + target: T, + method: T.( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + ) -> Unit, + flags: Object.ConnectFlags = Object.ConnectFlags.DEFAULT, +): SignalConnector { + val connector = SignalConnector( + this, + MethodCallable(target, (method as KCallable<*>).name.toGodotName()) + ) + connector.connect(flags) + return connector +} + +public inline fun + Signal12.promise(noinline method: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, +) -> Unit, noinline cancel: () -> Unit): Unit { + LambdaContainer12(VariantParser.NIL, arrayOf(variantMapper[P0::class]!!, variantMapper[P1::class]!!, variantMapper[P2::class]!!, variantMapper[P3::class]!!, variantMapper[P4::class]!!, variantMapper[P5::class]!!, variantMapper[P6::class]!!, variantMapper[P7::class]!!, variantMapper[P8::class]!!, variantMapper[P9::class]!!, variantMapper[P10::class]!!, variantMapper[P11::class]!!), method).setAsCancellable(this, cancel) +} + +public inline fun + Signal13.connect(flags: Object.ConnectFlags + = Object.ConnectFlags.DEFAULT, noinline method: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, +) -> Unit): SignalConnector { + val connector = SignalConnector( + this, + method.asCallable() + ) + connector.connect(flags) + return connector +} + +public fun + Signal13.connect( + target: T, + method: T.( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + ) -> Unit, + flags: Object.ConnectFlags = Object.ConnectFlags.DEFAULT, +): SignalConnector { + val connector = SignalConnector( + this, + MethodCallable(target, (method as KCallable<*>).name.toGodotName()) + ) + connector.connect(flags) + return connector +} + +public inline fun + Signal13.promise(noinline method: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, +) -> Unit, noinline cancel: () -> Unit): Unit { + LambdaContainer13(VariantParser.NIL, arrayOf(variantMapper[P0::class]!!, variantMapper[P1::class]!!, variantMapper[P2::class]!!, variantMapper[P3::class]!!, variantMapper[P4::class]!!, variantMapper[P5::class]!!, variantMapper[P6::class]!!, variantMapper[P7::class]!!, variantMapper[P8::class]!!, variantMapper[P9::class]!!, variantMapper[P10::class]!!, variantMapper[P11::class]!!, variantMapper[P12::class]!!), method).setAsCancellable(this, cancel) +} + +public inline fun + Signal14.connect(flags: Object.ConnectFlags + = Object.ConnectFlags.DEFAULT, noinline method: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, +) -> Unit): SignalConnector { + val connector = SignalConnector( + this, + method.asCallable() + ) + connector.connect(flags) + return connector +} + +public fun + Signal14.connect( + target: T, + method: T.( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + ) -> Unit, + flags: Object.ConnectFlags = Object.ConnectFlags.DEFAULT, +): SignalConnector { + val connector = SignalConnector( + this, + MethodCallable(target, (method as KCallable<*>).name.toGodotName()) + ) + connector.connect(flags) + return connector +} + +public inline fun + Signal14.promise(noinline method: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, +) -> Unit, noinline cancel: () -> Unit): Unit { + LambdaContainer14(VariantParser.NIL, arrayOf(variantMapper[P0::class]!!, variantMapper[P1::class]!!, variantMapper[P2::class]!!, variantMapper[P3::class]!!, variantMapper[P4::class]!!, variantMapper[P5::class]!!, variantMapper[P6::class]!!, variantMapper[P7::class]!!, variantMapper[P8::class]!!, variantMapper[P9::class]!!, variantMapper[P10::class]!!, variantMapper[P11::class]!!, variantMapper[P12::class]!!, variantMapper[P13::class]!!), method).setAsCancellable(this, cancel) +} + +public inline fun + Signal15.connect(flags: Object.ConnectFlags + = Object.ConnectFlags.DEFAULT, noinline method: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + p14: P14, +) -> Unit): SignalConnector { + val connector = SignalConnector( + this, + method.asCallable() + ) + connector.connect(flags) + return connector +} + +public fun + Signal15.connect( + target: T, + method: T.( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + p14: P14, + ) -> Unit, + flags: Object.ConnectFlags = Object.ConnectFlags.DEFAULT, +): SignalConnector { + val connector = SignalConnector( + this, + MethodCallable(target, (method as KCallable<*>).name.toGodotName()) + ) + connector.connect(flags) + return connector +} + +public inline fun + Signal15.promise(noinline + method: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + p14: P14, +) -> Unit, noinline cancel: () -> Unit): Unit { + LambdaContainer15(VariantParser.NIL, arrayOf(variantMapper[P0::class]!!, variantMapper[P1::class]!!, variantMapper[P2::class]!!, variantMapper[P3::class]!!, variantMapper[P4::class]!!, variantMapper[P5::class]!!, variantMapper[P6::class]!!, variantMapper[P7::class]!!, variantMapper[P8::class]!!, variantMapper[P9::class]!!, variantMapper[P10::class]!!, variantMapper[P11::class]!!, variantMapper[P12::class]!!, variantMapper[P13::class]!!, variantMapper[P14::class]!!), method).setAsCancellable(this, cancel) +} + +public inline fun + Signal16.connect(flags: Object.ConnectFlags + = Object.ConnectFlags.DEFAULT, noinline method: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + p14: P14, + p15: P15, +) -> Unit): SignalConnector { + val connector = SignalConnector( + this, + method.asCallable() + ) + connector.connect(flags) + return connector +} + +public fun + Signal16.connect( + target: T, + method: T.( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + p14: P14, + p15: P15, + ) -> Unit, + flags: Object.ConnectFlags = Object.ConnectFlags.DEFAULT, +): SignalConnector { + val connector = SignalConnector( + this, + MethodCallable(target, (method as KCallable<*>).name.toGodotName()) + ) + connector.connect(flags) + return connector +} + +public inline fun + Signal16.promise(noinline + method: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + p11: P11, + p12: P12, + p13: P13, + p14: P14, + p15: P15, +) -> Unit, noinline cancel: () -> Unit): Unit { + LambdaContainer16(VariantParser.NIL, arrayOf(variantMapper[P0::class]!!, variantMapper[P1::class]!!, variantMapper[P2::class]!!, variantMapper[P3::class]!!, variantMapper[P4::class]!!, variantMapper[P5::class]!!, variantMapper[P6::class]!!, variantMapper[P7::class]!!, variantMapper[P8::class]!!, variantMapper[P9::class]!!, variantMapper[P10::class]!!, variantMapper[P11::class]!!, variantMapper[P12::class]!!, variantMapper[P13::class]!!, variantMapper[P14::class]!!, variantMapper[P15::class]!!), method).setAsCancellable(this, cancel) +} diff --git a/kt/godot-library/godot-core-library/src/main/kotlin/gen/godot/core/Signals.kt b/kt/godot-library/godot-core-library/src/main/kotlin/gen/godot/core/Signals.kt index bc24696e3..d49bf1a4f 100644 --- a/kt/godot-library/godot-core-library/src/main/kotlin/gen/godot/core/Signals.kt +++ b/kt/godot-library/godot-core-library/src/main/kotlin/gen/godot/core/Signals.kt @@ -2,21 +2,18 @@ "PackageDirectoryMismatch", "NOTHING_TO_INLINE", "UNUSED_PARAMETER", + "unused", ) package godot.core import godot.api.Object import kotlin.Any -import kotlin.Int import kotlin.PublishedApi import kotlin.String import kotlin.Suppress import kotlin.Unit -import kotlin.jvm.JvmName -import kotlin.jvm.JvmStatic import kotlin.properties.ReadOnlyProperty -import kotlin.reflect.KCallable import kotlin.reflect.KProperty public class Signal0 @PublishedApi internal constructor( @@ -24,18 +21,9 @@ public class Signal0 @PublishedApi internal constructor( name: String, ) : Signal(instance, name) { public fun emit(): Unit { - emitSignal() + emitUnsafe() } - public fun connect( - target: T, - method: T.() -> Unit, - flags: Int = 0, - ): Error = connect(Callable(target, (method as KCallable<*>).name.toGodotName()), flags) - - public fun disconnect(target: T, method: T.() -> Unit): Unit = - disconnect(Callable(target, (method as KCallable<*>).name.toGodotName())) - public companion object { @PublishedApi internal val `delegate`: ReadOnlyProperty = @@ -43,11 +31,6 @@ public class Signal0 @PublishedApi internal constructor( public inline operator fun getValue(thisRef: Object, `property`: KProperty<*>): Signal0 = Signal0(thisRef, property.name) - - @JvmStatic - @JvmName("create") - public fun javaCreate(`object`: Object, signalName: String): Signal0 = - Signal0(`object`, signalName) } } @@ -56,26 +39,14 @@ public inline fun Object.Signal0(signalName: String) = Signal0(this, signalName) public inline fun Object.signal0() = Signal0.delegate -public inline fun Signal0.connect(flags: Int = 0, noinline method: () -> Unit): Error = - connect(method.asCallable(), flags) - public class Signal1 @PublishedApi internal constructor( instance: Object, name: String, ) : Signal(instance, name) { public fun emit(p0: P0): Unit { - emitSignal(p0) + emitUnsafe(p0) } - public fun connect( - target: T, - method: T.(p0: P0) -> Unit, - flags: Int = 0, - ): Error = connect(Callable(target, (method as KCallable<*>).name.toGodotName()), flags) - - public fun disconnect(target: T, method: T.(p0: P0) -> Unit): Unit = - disconnect(Callable(target, (method as KCallable<*>).name.toGodotName())) - public companion object { @PublishedApi internal val `delegate`: ReadOnlyProperty> = @@ -83,11 +54,6 @@ public class Signal1 @PublishedApi internal constructor( public inline operator fun getValue(thisRef: Object, `property`: KProperty<*>): Signal1 = Signal1(thisRef, property.name) - - @JvmStatic - @JvmName("create") - public fun javaCreate(`object`: Object, signalName: String): Signal1 = - Signal1(`object`, signalName) } } @@ -97,26 +63,14 @@ public inline fun Object.Signal1(signalName: String) = Signal1(this, si @Suppress("UNCHECKED_CAST") public inline fun Object.signal1() = Signal1.delegate as ReadOnlyProperty> -public inline fun Signal1.connect(flags: Int = 0, noinline - method: (p0: P0) -> Unit): Error = connect(method.asCallable(), flags) - public class Signal2 @PublishedApi internal constructor( instance: Object, name: String, ) : Signal(instance, name) { public fun emit(p0: P0, p1: P1): Unit { - emitSignal(p0, p1) + emitUnsafe(p0, p1) } - public fun connect( - target: T, - method: T.(p0: P0, p1: P1) -> Unit, - flags: Int = 0, - ): Error = connect(Callable(target, (method as KCallable<*>).name.toGodotName()), flags) - - public fun disconnect(target: T, method: T.(p0: P0, p1: P1) -> Unit): Unit = - disconnect(Callable(target, (method as KCallable<*>).name.toGodotName())) - public companion object { @PublishedApi internal val `delegate`: ReadOnlyProperty> = @@ -124,11 +78,6 @@ public class Signal2 @PublishedApi internal constructor( public inline operator fun getValue(thisRef: Object, `property`: KProperty<*>): Signal2 = Signal2(thisRef, property.name) - - @JvmStatic - @JvmName("create") - public fun javaCreate(`object`: Object, signalName: String): Signal2 = - Signal2(`object`, signalName) } } @@ -139,9 +88,6 @@ public inline fun Object.Signal2(signalName: String) = Signal2( public inline fun Object.signal2() = Signal2.delegate as ReadOnlyProperty> -public inline fun Signal2.connect(flags: Int = 0, noinline - method: (p0: P0, p1: P1) -> Unit): Error = connect(method.asCallable(), flags) - public class Signal3 @PublishedApi internal constructor( instance: Object, name: String, @@ -151,25 +97,9 @@ public class Signal3 @PublishedApi internal constructor( p1: P1, p2: P2, ): Unit { - emitSignal(p0, p1, p2) + emitUnsafe(p0, p1, p2) } - public fun connect( - target: T, - method: T.( - p0: P0, - p1: P1, - p2: P2, - ) -> Unit, - flags: Int = 0, - ): Error = connect(Callable(target, (method as KCallable<*>).name.toGodotName()), flags) - - public fun disconnect(target: T, method: T.( - p0: P0, - p1: P1, - p2: P2, - ) -> Unit): Unit = disconnect(Callable(target, (method as KCallable<*>).name.toGodotName())) - public companion object { @PublishedApi internal val `delegate`: ReadOnlyProperty> = @@ -177,11 +107,6 @@ public class Signal3 @PublishedApi internal constructor( public inline operator fun getValue(thisRef: Object, `property`: KProperty<*>): Signal3 = Signal3(thisRef, property.name) - - @JvmStatic - @JvmName("create") - public fun javaCreate(`object`: Object, signalName: String): - Signal3 = Signal3(`object`, signalName) } } @@ -193,13 +118,6 @@ public inline fun Object.Signal3(signalName: String) = public inline fun Object.signal3() = Signal3.delegate as ReadOnlyProperty> -public inline fun Signal3.connect(flags: Int = 0, - noinline method: ( - p0: P0, - p1: P1, - p2: P2, -) -> Unit): Error = connect(method.asCallable(), flags) - public class Signal4 @PublishedApi internal constructor( instance: Object, name: String, @@ -210,27 +128,9 @@ public class Signal4 @PublishedApi internal constructor( p2: P2, p3: P3, ): Unit { - emitSignal(p0, p1, p2, p3) + emitUnsafe(p0, p1, p2, p3) } - public fun connect( - target: T, - method: T.( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - ) -> Unit, - flags: Int = 0, - ): Error = connect(Callable(target, (method as KCallable<*>).name.toGodotName()), flags) - - public fun disconnect(target: T, method: T.( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - ) -> Unit): Unit = disconnect(Callable(target, (method as KCallable<*>).name.toGodotName())) - public companion object { @PublishedApi internal val `delegate`: ReadOnlyProperty> = @@ -238,11 +138,6 @@ public class Signal4 @PublishedApi internal constructor( public inline operator fun getValue(thisRef: Object, `property`: KProperty<*>): Signal4 = Signal4(thisRef, property.name) - - @JvmStatic - @JvmName("create") - public fun javaCreate(`object`: Object, signalName: String): - Signal4 = Signal4(`object`, signalName) } } @@ -254,14 +149,6 @@ public inline fun Object.Signal4(signalName: String) = public inline fun Object.signal4() = Signal4.delegate as ReadOnlyProperty> -public inline fun - Signal4.connect(flags: Int = 0, noinline method: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, -) -> Unit): Error = connect(method.asCallable(), flags) - public class Signal5 @PublishedApi internal constructor( instance: Object, name: String, @@ -273,29 +160,9 @@ public class Signal5 @PublishedApi internal constructor( p3: P3, p4: P4, ): Unit { - emitSignal(p0, p1, p2, p3, p4) + emitUnsafe(p0, p1, p2, p3, p4) } - public fun connect( - target: T, - method: T.( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - ) -> Unit, - flags: Int = 0, - ): Error = connect(Callable(target, (method as KCallable<*>).name.toGodotName()), flags) - - public fun disconnect(target: T, method: T.( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - ) -> Unit): Unit = disconnect(Callable(target, (method as KCallable<*>).name.toGodotName())) - public companion object { @PublishedApi internal val `delegate`: ReadOnlyProperty> = @@ -304,11 +171,6 @@ public class Signal5 @PublishedApi internal constructor( public inline operator fun getValue(thisRef: Object, `property`: KProperty<*>): Signal5 = Signal5(thisRef, property.name) - - @JvmStatic - @JvmName("create") - public fun javaCreate(`object`: Object, signalName: String): - Signal5 = Signal5(`object`, signalName) } } @@ -320,15 +182,6 @@ public inline fun Object.Signal5(signalName: String) = public inline fun Object.signal5() = Signal5.delegate as ReadOnlyProperty> -public inline fun - Signal5.connect(flags: Int = 0, noinline method: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, -) -> Unit): Error = connect(method.asCallable(), flags) - public class Signal6 @PublishedApi internal constructor( instance: Object, name: String, @@ -341,31 +194,9 @@ public class Signal6 @PublishedApi internal constructor( p4: P4, p5: P5, ): Unit { - emitSignal(p0, p1, p2, p3, p4, p5) + emitUnsafe(p0, p1, p2, p3, p4, p5) } - public fun connect( - target: T, - method: T.( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - ) -> Unit, - flags: Int = 0, - ): Error = connect(Callable(target, (method as KCallable<*>).name.toGodotName()), flags) - - public fun disconnect(target: T, method: T.( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - ) -> Unit): Unit = disconnect(Callable(target, (method as KCallable<*>).name.toGodotName())) - public companion object { @PublishedApi internal val `delegate`: ReadOnlyProperty> = @@ -374,11 +205,6 @@ public class Signal6 @PublishedApi internal constructor( public inline operator fun getValue(thisRef: Object, `property`: KProperty<*>): Signal6 = Signal6(thisRef, property.name) - - @JvmStatic - @JvmName("create") - public fun javaCreate(`object`: Object, signalName: String): - Signal6 = Signal6(`object`, signalName) } } @@ -390,16 +216,6 @@ public inline fun Object.Signal6(signalName: String) = public inline fun Object.signal6() = Signal6.delegate as ReadOnlyProperty> -public inline fun - Signal6.connect(flags: Int = 0, noinline method: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, -) -> Unit): Error = connect(method.asCallable(), flags) - public class Signal7 @PublishedApi internal constructor( instance: Object, name: String, @@ -413,33 +229,9 @@ public class Signal7 @PublishedApi internal construc p5: P5, p6: P6, ): Unit { - emitSignal(p0, p1, p2, p3, p4, p5, p6) + emitUnsafe(p0, p1, p2, p3, p4, p5, p6) } - public fun connect( - target: T, - method: T.( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - ) -> Unit, - flags: Int = 0, - ): Error = connect(Callable(target, (method as KCallable<*>).name.toGodotName()), flags) - - public fun disconnect(target: T, method: T.( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - ) -> Unit): Unit = disconnect(Callable(target, (method as KCallable<*>).name.toGodotName())) - public companion object { @PublishedApi internal val `delegate`: @@ -449,11 +241,6 @@ public class Signal7 @PublishedApi internal construc public inline operator fun getValue(thisRef: Object, `property`: KProperty<*>): Signal7 = Signal7(thisRef, property.name) - - @JvmStatic - @JvmName("create") - public fun javaCreate(`object`: Object, signalName: String): - Signal7 = Signal7(`object`, signalName) } } @@ -465,17 +252,6 @@ public inline fun Object.Signal7(signalName: String public inline fun Object.signal7() = Signal7.delegate as ReadOnlyProperty> -public inline fun Signal7.connect(flags: Int = 0, noinline method: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, -) -> Unit): Error = connect(method.asCallable(), flags) - public class Signal8 @PublishedApi internal constructor( instance: Object, name: String, @@ -490,35 +266,9 @@ public class Signal8 @PublishedApi internal cons p6: P6, p7: P7, ): Unit { - emitSignal(p0, p1, p2, p3, p4, p5, p6, p7) + emitUnsafe(p0, p1, p2, p3, p4, p5, p6, p7) } - public fun connect( - target: T, - method: T.( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - ) -> Unit, - flags: Int = 0, - ): Error = connect(Callable(target, (method as KCallable<*>).name.toGodotName()), flags) - - public fun disconnect(target: T, method: T.( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - ) -> Unit): Unit = disconnect(Callable(target, (method as KCallable<*>).name.toGodotName())) - public companion object { @PublishedApi internal val `delegate`: @@ -528,12 +278,6 @@ public class Signal8 @PublishedApi internal cons public inline operator fun getValue(thisRef: Object, `property`: KProperty<*>): Signal8 = Signal8(thisRef, property.name) - - @JvmStatic - @JvmName("create") - public fun javaCreate(`object`: Object, - signalName: String): Signal8 = - Signal8(`object`, signalName) } } @@ -545,19 +289,6 @@ public inline fun Object.Signal8(signalName: St public inline fun Object.signal8() = Signal8.delegate as ReadOnlyProperty> -public inline fun Signal8.connect(flags: Int = 0, noinline - method: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, -) -> Unit): Error = connect(method.asCallable(), flags) - public class Signal9 @PublishedApi internal constructor( instance: Object, name: String, @@ -573,37 +304,9 @@ public class Signal9 @PublishedApi internal p7: P7, p8: P8, ): Unit { - emitSignal(p0, p1, p2, p3, p4, p5, p6, p7, p8) + emitUnsafe(p0, p1, p2, p3, p4, p5, p6, p7, p8) } - public fun connect( - target: T, - method: T.( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - ) -> Unit, - flags: Int = 0, - ): Error = connect(Callable(target, (method as KCallable<*>).name.toGodotName()), flags) - - public fun disconnect(target: T, method: T.( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - ) -> Unit): Unit = disconnect(Callable(target, (method as KCallable<*>).name.toGodotName())) - public companion object { @PublishedApi internal val `delegate`: @@ -613,12 +316,6 @@ public class Signal9 @PublishedApi internal public inline operator fun getValue(thisRef: Object, `property`: KProperty<*>): Signal9 = Signal9(thisRef, property.name) - - @JvmStatic - @JvmName("create") - public fun javaCreate(`object`: Object, - signalName: String): Signal9 = - Signal9(`object`, signalName) } } @@ -630,20 +327,6 @@ public inline fun Object.Signal9(signalName public inline fun Object.signal9() = Signal9.delegate as ReadOnlyProperty> -public inline fun Signal9.connect(flags: Int = - 0, noinline method: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, -) -> Unit): Error = connect(method.asCallable(), flags) - public class Signal10 @PublishedApi internal constructor( instance: Object, name: String, @@ -660,39 +343,9 @@ public class Signal10 @PublishedApi inte p8: P8, p9: P9, ): Unit { - emitSignal(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9) + emitUnsafe(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9) } - public fun connect( - target: T, - method: T.( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - ) -> Unit, - flags: Int = 0, - ): Error = connect(Callable(target, (method as KCallable<*>).name.toGodotName()), flags) - - public fun disconnect(target: T, method: T.( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - ) -> Unit): Unit = disconnect(Callable(target, (method as KCallable<*>).name.toGodotName())) - public companion object { @PublishedApi internal val `delegate`: @@ -702,12 +355,6 @@ public class Signal10 @PublishedApi inte public inline operator fun getValue(thisRef: Object, `property`: KProperty<*>): Signal10 = Signal10(thisRef, property.name) - - @JvmStatic - @JvmName("create") - public fun javaCreate(`object`: Object, - signalName: String): Signal10 = - Signal10(`object`, signalName) } } @@ -719,21 +366,6 @@ public inline fun Object.Signal10(signa public inline fun Object.signal10() = Signal10.delegate as ReadOnlyProperty> -public inline fun - Signal10.connect(flags: Int = 0, noinline method: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, -) -> Unit): Error = connect(method.asCallable(), flags) - public class Signal11 @PublishedApi internal constructor( instance: Object, @@ -752,41 +384,9 @@ public class Signal11 @PublishedApi p9: P9, p10: P10, ): Unit { - emitSignal(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) + emitUnsafe(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) } - public fun connect( - target: T, - method: T.( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - ) -> Unit, - flags: Int = 0, - ): Error = connect(Callable(target, (method as KCallable<*>).name.toGodotName()), flags) - - public fun disconnect(target: T, method: T.( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - ) -> Unit): Unit = disconnect(Callable(target, (method as KCallable<*>).name.toGodotName())) - public companion object { @PublishedApi internal val `delegate`: @@ -797,12 +397,6 @@ public class Signal11 @PublishedApi getValue(thisRef: Object, `property`: KProperty<*>): Signal11 = Signal11(thisRef, property.name) - - @JvmStatic - @JvmName("create") - public fun javaCreate(`object`: Object, - signalName: String): Signal11 = - Signal11(`object`, signalName) } } @@ -814,23 +408,6 @@ public inline fun Object.Signal11( public inline fun Object.signal11() = Signal11.delegate as ReadOnlyProperty> -public inline fun - Signal11.connect(flags: Int = 0, noinline - method: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, -) -> Unit): Error = connect(method.asCallable(), flags) - public class Signal12 @PublishedApi internal constructor( instance: Object, @@ -850,43 +427,9 @@ public class Signal12 @Publish p10: P10, p11: P11, ): Unit { - emitSignal(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11) + emitUnsafe(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11) } - public fun connect( - target: T, - method: T.( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - ) -> Unit, - flags: Int = 0, - ): Error = connect(Callable(target, (method as KCallable<*>).name.toGodotName()), flags) - - public fun disconnect(target: T, method: T.( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - ) -> Unit): Unit = disconnect(Callable(target, (method as KCallable<*>).name.toGodotName())) - public companion object { @PublishedApi internal val `delegate`: @@ -897,12 +440,6 @@ public class Signal12 @Publish getValue(thisRef: Object, `property`: KProperty<*>): Signal12 = Signal12(thisRef, property.name) - - @JvmStatic - @JvmName("create") - public fun javaCreate(`object`: Object, - signalName: String): Signal12 = - Signal12(`object`, signalName) } } @@ -915,24 +452,6 @@ public inline fun public inline fun Object.signal12() = Signal12.delegate as ReadOnlyProperty> -public inline fun - Signal12.connect(flags: Int = 0, noinline - method: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, -) -> Unit): Error = connect(method.asCallable(), flags) - public class Signal13 @PublishedApi internal constructor( instance: Object, @@ -953,45 +472,9 @@ public class Signal13 @Pu p11: P11, p12: P12, ): Unit { - emitSignal(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12) + emitUnsafe(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12) } - public fun connect( - target: T, - method: T.( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - ) -> Unit, - flags: Int = 0, - ): Error = connect(Callable(target, (method as KCallable<*>).name.toGodotName()), flags) - - public fun disconnect(target: T, method: T.( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - ) -> Unit): Unit = disconnect(Callable(target, (method as KCallable<*>).name.toGodotName())) - public companion object { @PublishedApi internal val `delegate`: @@ -1002,13 +485,6 @@ public class Signal13 @Pu getValue(thisRef: Object, `property`: KProperty<*>): Signal13 = Signal13(thisRef, property.name) - - @JvmStatic - @JvmName("create") - public fun - javaCreate(`object`: Object, signalName: String): - Signal13 = - Signal13(`object`, signalName) } } @@ -1021,25 +497,6 @@ public inline fun public inline fun Object.signal13() = Signal13.delegate as ReadOnlyProperty> -public inline fun - Signal13.connect(flags: Int = 0, - noinline method: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, -) -> Unit): Error = connect(method.asCallable(), flags) - public class Signal14 @PublishedApi internal constructor( instance: Object, @@ -1061,47 +518,9 @@ public class Signal14 connect( - target: T, - method: T.( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - ) -> Unit, - flags: Int = 0, - ): Error = connect(Callable(target, (method as KCallable<*>).name.toGodotName()), flags) - - public fun disconnect(target: T, method: T.( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - ) -> Unit): Unit = disconnect(Callable(target, (method as KCallable<*>).name.toGodotName())) - public companion object { @PublishedApi internal val `delegate`: @@ -1112,13 +531,6 @@ public class Signal14): Signal14 = Signal14(thisRef, property.name) - - @JvmStatic - @JvmName("create") - public fun - javaCreate(`object`: Object, signalName: String): - Signal14 = - Signal14(`object`, signalName) } } @@ -1131,26 +543,6 @@ public inline fun public inline fun Object.signal14() = Signal14.delegate as ReadOnlyProperty> -public inline fun - Signal14.connect(flags: Int = 0, - noinline method: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, -) -> Unit): Error = connect(method.asCallable(), flags) - public class Signal15 @PublishedApi internal constructor( instance: Object, @@ -1173,49 +565,9 @@ public class Signal15 connect( - target: T, - method: T.( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - p14: P14, - ) -> Unit, - flags: Int = 0, - ): Error = connect(Callable(target, (method as KCallable<*>).name.toGodotName()), flags) - - public fun disconnect(target: T, method: T.( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - p14: P14, - ) -> Unit): Unit = disconnect(Callable(target, (method as KCallable<*>).name.toGodotName())) - public companion object { @PublishedApi internal val `delegate`: @@ -1226,13 +578,6 @@ public class Signal15): Signal15 = Signal15(thisRef, property.name) - - @JvmStatic - @JvmName("create") - public fun - javaCreate(`object`: Object, signalName: String): - Signal15 = - Signal15(`object`, signalName) } } @@ -1246,28 +591,6 @@ public inline fun > -public inline fun - Signal15.connect(flags: Int - = 0, noinline method: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - p14: P14, -) -> Unit): Error = connect(method.asCallable(), flags) - public class Signal16 @PublishedApi internal constructor( instance: Object, @@ -1291,51 +614,9 @@ public class Signal16 connect( - target: T, - method: T.( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - p14: P14, - p15: P15, - ) -> Unit, - flags: Int = 0, - ): Error = connect(Callable(target, (method as KCallable<*>).name.toGodotName()), flags) - - public fun disconnect(target: T, method: T.( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - p14: P14, - p15: P15, - ) -> Unit): Unit = disconnect(Callable(target, (method as KCallable<*>).name.toGodotName())) - public companion object { @PublishedApi internal val `delegate`: @@ -1346,13 +627,6 @@ public class Signal16 getValue(thisRef: Object, `property`: KProperty<*>): Signal16 = Signal16(thisRef, property.name) - - @JvmStatic - @JvmName("create") - public fun - javaCreate(`object`: Object, signalName: String): - Signal16 = - Signal16(`object`, signalName) } } @@ -1365,26 +639,3 @@ public inline fun Object.signal16() = Signal16.delegate as ReadOnlyProperty> - -public inline fun - Signal16.connect(flags: Int - = 0, noinline method: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - p14: P14, - p15: P15, -) -> Unit): Error = connect(method.asCallable(), flags) diff --git a/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/CoreType.kt b/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/CoreType.kt index 33f22e289..02b9a9f7f 100644 --- a/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/CoreType.kt +++ b/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/CoreType.kt @@ -13,4 +13,5 @@ interface CoreType abstract class NativeCoreType : CoreType, NativePointer { override var ptr: VoidPtr = nullptr + protected set } diff --git a/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/ParametersReader.kt b/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/ParametersReader.kt index 008162617..760dd87f9 100644 --- a/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/ParametersReader.kt +++ b/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/ParametersReader.kt @@ -12,14 +12,10 @@ internal open class ParametersReader { } } - private fun resetParamsArray() { - paramsArray.fill(null) - } - internal inline fun withParameters(types: Array, code: () -> Unit) { TransferContext.readArguments(types, paramsArray) code() - resetParamsArray() + paramsArray.fill(null, 0, types.size) } internal inline fun withParametersReturn( @@ -28,7 +24,7 @@ internal open class ParametersReader { ): Any? { TransferContext.readArguments(types, paramsArray) val ret = code() - resetParamsArray() + paramsArray.fill(null, 0, types.size) return ret } } diff --git a/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/Variant.kt b/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/Variant.kt index 69fd14803..358667182 100644 --- a/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/Variant.kt +++ b/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/Variant.kt @@ -5,6 +5,7 @@ import godot.common.interop.ObjectID import godot.common.interop.VariantConverter import godot.common.interop.nullptr import godot.common.util.toRealT +import godot.core.Signal import godot.internal.memory.LongStringQueue import java.nio.ByteBuffer @@ -284,14 +285,14 @@ enum class VariantParser(override val id: Int) : VariantConverter { } }, AABB(16) { - override fun toUnsafeKotlin(buffer: ByteBuffer): godot.core.AABB { + override fun toUnsafeKotlin(buffer: ByteBuffer): AABB { val position = buffer.vector3 val size = buffer.vector3 return AABB(position, size) } override fun toUnsafeGodot(buffer: ByteBuffer, any: Any?) { - require(any is godot.core.AABB) + require(any is AABB) buffer.vector3 = any._position buffer.vector3 = any._size } @@ -364,26 +365,21 @@ enum class VariantParser(override val id: Int) : VariantConverter { }, OBJECT(24) { override fun toUnsafeKotlin(buffer: ByteBuffer) = buffer.obj - override fun toUnsafeGodot(buffer: ByteBuffer, any: Any?) { require(any is KtObject?) buffer.obj = any } }, CALLABLE(25) { - override fun toUnsafeKotlin(buffer: ByteBuffer): Callable { - val ptr = buffer.long - return NativeCallable(ptr) - } - + override fun toUnsafeKotlin(buffer: ByteBuffer) = VariantCallable(buffer.long) override fun toUnsafeGodot(buffer: ByteBuffer, any: Any?) { - if (any is NativeCallable) { - buffer.bool = false + if (any is VariantCallable) { buffer.putLong(any.ptr) } else { - require(any is LambdaCallable<*>) - buffer.bool = true - buffer.putLong(any.wrapInCustomCallable()) + require(any is LambdaCallable<*> || any is MethodCallable) + // Be careful that ::toNativeCallable doesn't itself use the shared buffer. + val ptr = any.toNativeCallable().ptr + buffer.putLong(ptr) } } }, diff --git a/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/VariantMapper.kt b/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/VariantMapper.kt index eaab34298..ff3432df1 100644 --- a/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/VariantMapper.kt +++ b/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/VariantMapper.kt @@ -1,15 +1,16 @@ package godot.core + val variantMapper = mutableMapOf( Unit::class to VariantParser.NIL, Void::class to VariantParser.NIL, Any::class to VariantCaster.ANY, java.lang.Object::class to VariantCaster.ANY, Boolean::class to VariantParser.BOOL, + Byte::class to VariantCaster.BYTE, Int::class to VariantCaster.INT, Long::class to VariantParser.LONG, Float::class to VariantCaster.FLOAT, - Byte::class to VariantCaster.BYTE, Double::class to VariantParser.DOUBLE, String::class to VariantParser.STRING, AABB::class to VariantParser.AABB, @@ -33,7 +34,8 @@ val variantMapper = mutableMapOf( Vector4::class to VariantParser.VECTOR4, Vector4i::class to VariantParser.VECTOR4I, Projection::class to VariantParser.PROJECTION, - NativeCallable::class to VariantParser.CALLABLE, + VariantCallable::class to VariantParser.CALLABLE, + MethodCallable::class to VariantParser.CALLABLE, LambdaCallable0::class to VariantParser.CALLABLE, LambdaCallable1::class to VariantParser.CALLABLE, LambdaCallable2::class to VariantParser.CALLABLE, @@ -109,9 +111,43 @@ val notNullableVariantSet = hashSetOf( Vector4::class, Vector4i::class, Projection::class, - NativeCallable::class, - LambdaCallable::class, - Signal::class, + VariantCallable::class to VariantParser.CALLABLE, + MethodCallable::class to VariantParser.CALLABLE, + LambdaCallable0::class to VariantParser.CALLABLE, + LambdaCallable1::class to VariantParser.CALLABLE, + LambdaCallable2::class to VariantParser.CALLABLE, + LambdaCallable3::class to VariantParser.CALLABLE, + LambdaCallable4::class to VariantParser.CALLABLE, + LambdaCallable5::class to VariantParser.CALLABLE, + LambdaCallable6::class to VariantParser.CALLABLE, + LambdaCallable7::class to VariantParser.CALLABLE, + LambdaCallable8::class to VariantParser.CALLABLE, + LambdaCallable9::class to VariantParser.CALLABLE, + LambdaCallable10::class to VariantParser.CALLABLE, + LambdaCallable11::class to VariantParser.CALLABLE, + LambdaCallable12::class to VariantParser.CALLABLE, + LambdaCallable13::class to VariantParser.CALLABLE, + LambdaCallable14::class to VariantParser.CALLABLE, + LambdaCallable15::class to VariantParser.CALLABLE, + LambdaCallable16::class to VariantParser.CALLABLE, + Signal::class to VariantParser.SIGNAL, + Signal0::class to VariantParser.SIGNAL, + Signal1::class to VariantParser.SIGNAL, + Signal2::class to VariantParser.SIGNAL, + Signal3::class to VariantParser.SIGNAL, + Signal4::class to VariantParser.SIGNAL, + Signal5::class to VariantParser.SIGNAL, + Signal6::class to VariantParser.SIGNAL, + Signal7::class to VariantParser.SIGNAL, + Signal8::class to VariantParser.SIGNAL, + Signal9::class to VariantParser.SIGNAL, + Signal10::class to VariantParser.SIGNAL, + Signal11::class to VariantParser.SIGNAL, + Signal12::class to VariantParser.SIGNAL, + Signal13::class to VariantParser.SIGNAL, + Signal14::class to VariantParser.SIGNAL, + Signal15::class to VariantParser.SIGNAL, + Signal16::class to VariantParser.SIGNAL, PackedByteArray::class, PackedColorArray::class, PackedInt32Array::class, diff --git a/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/bridge/Callable.kt b/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/bridge/Callable.kt deleted file mode 100644 index a57220f6c..000000000 --- a/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/bridge/Callable.kt +++ /dev/null @@ -1,27 +0,0 @@ -@file:JvmName("Callables") -@file:Suppress("PackageDirectoryMismatch") -package godot.core - -import godot.api.Object - -interface Callable: CoreType { - fun call(vararg args: Any?): Any? - - companion object { - @JvmStatic - @JvmName("create") - operator fun invoke() = NativeCallable() - - @JvmStatic - @JvmName("create") - operator fun invoke(target: Object, methodName: StringName) = NativeCallable(target, methodName) - - @JvmStatic - @JvmName("create") - operator fun invoke(nativeCallable: NativeCallable) = NativeCallable(nativeCallable) - - @JvmStatic - @JvmName("create") - operator fun invoke(lambdaCallable: LambdaCallable<*>) = NativeCallable(lambdaCallable) - } -} diff --git a/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/bridge/LambdaCallable.kt b/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/bridge/LambdaCallable.kt deleted file mode 100644 index 7ba390e08..000000000 --- a/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/bridge/LambdaCallable.kt +++ /dev/null @@ -1,63 +0,0 @@ -@file:Suppress("UNCHECKED_CAST", "PackageDirectoryMismatch") - -package godot.core - -import godot.common.interop.VariantConverter -import godot.common.interop.VoidPtr -import godot.internal.logging.GodotLogging -import godot.internal.memory.TransferContext - -abstract class LambdaCallable( - internal val variantConverter: VariantConverter, - internal val onCancelCall: (() -> Unit)?, - vararg parameterTypes: VariantConverter -) : Callable { - private val types: Array = parameterTypes.toList().toTypedArray() - - val returnVariantType: Int - get() = variantConverter.id - - fun invokeNoReturn(): Unit = withParameters(types) { - try { - invokeKt() - } catch (t: Throwable) { - GodotLogging.error("Error calling a JVM custom Callable from Godot:\n" + t.stackTraceToString()) - } - } - - fun invokeWithReturn(): Any? = withParametersReturn(types) { - var ret: Any? = Unit - try { - ret = invokeKt() - TransferContext.writeReturnValue(ret, variantConverter) - } catch (t: Throwable) { - GodotLogging.error("Error calling a JVM custom Callable from Godot:\n" + t.stackTraceToString()) - TransferContext.writeReturnValue(null, VariantParser.NIL) - } - ret - } - - fun onCancel() = onCancelCall!!() - - protected abstract fun invokeKt(): R - - internal companion object : ParametersReader() - - internal fun wrapInCustomCallable(): VoidPtr = Bridge.wrap_in_custom_callable( - this, - variantConverter.id, - hashCode(), - onCancelCall != null - ) - - @Suppress("FunctionName") - private object Bridge { - external fun wrap_in_custom_callable( - instance: LambdaCallable<*>, - variantTypeOrdinal: Int, - hashCode: Int, - hasOnCancel: Boolean - ): VoidPtr - } -} - diff --git a/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/bridge/NativeCallable.kt b/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/bridge/NativeCallable.kt deleted file mode 100644 index ee0b550b5..000000000 --- a/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/bridge/NativeCallable.kt +++ /dev/null @@ -1,229 +0,0 @@ -@file:JvmName("CallableUtils") -@file:Suppress("PackageDirectoryMismatch") - -package godot.core - -import godot.api.Object -import godot.common.interop.ObjectID -import godot.internal.memory.MemoryManager -import godot.internal.memory.TransferContext -import godot.common.interop.VoidPtr -import kotlin.reflect.KCallable - -class NativeCallable : NativeCoreType, Callable { - - internal constructor() { - ptr = Bridge.engine_call_constructor() - MemoryManager.registerNativeCoreType(this, VariantParser.CALLABLE) - } - - internal constructor(target: Object, methodName: StringName) { - TransferContext.writeArguments(VariantParser.OBJECT to target, VariantParser.STRING_NAME to methodName) - ptr = Bridge.engine_call_constructor_object_string_name() - MemoryManager.registerNativeCoreType(this, VariantParser.CALLABLE) - } - - internal constructor(callable: NativeCallable) { - TransferContext.writeArguments(VariantParser.CALLABLE to callable) - ptr = Bridge.engine_call_copy_constructor() - MemoryManager.registerNativeCoreType(this, VariantParser.CALLABLE) - } - - internal constructor(lambdaCallable: LambdaCallable<*>) { - // We pass all params using jni as we're often in a context of sending parameters to cpp, so we should not rewind buffer. - ptr = Bridge.engine_call_constructor_kt_custom_callable(lambdaCallable, lambdaCallable.variantConverter.id, lambdaCallable.hashCode(), lambdaCallable.onCancelCall != null) - MemoryManager.registerNativeCoreType(this, VariantParser.CALLABLE) - } - - internal constructor(_handle: VoidPtr){ - this.ptr = _handle - MemoryManager.registerNativeCoreType(this, VariantParser.CALLABLE) - } - - fun bind(vararg args: Any?): NativeCallable { - TransferContext.writeArguments(*args.map { VariantCaster.ANY to it }.toTypedArray()) - Bridge.engine_call_bind(ptr) - return TransferContext.readReturnValue(VariantParser.CALLABLE) as NativeCallable - } - - fun bindv(args: VariantArray): NativeCallable { - TransferContext.writeArguments(VariantParser.ARRAY to args) - Bridge.engine_call_bindv(ptr) - return TransferContext.readReturnValue(VariantParser.CALLABLE) as NativeCallable - } - - override fun call(vararg args: Any?): Any? { - TransferContext.writeArguments(*args.map { VariantCaster.ANY to it }.toTypedArray()) - Bridge.engine_call_call(ptr) - return TransferContext.readReturnValue(VariantCaster.ANY) - } - - fun callDeferred(vararg args: Any?) { - TransferContext.writeArguments(*args.map { VariantCaster.ANY to it }.toTypedArray()) - Bridge.engine_call_call_deferred(ptr) - } - - fun callv(args: VariantArray): Any? { - TransferContext.writeArguments(VariantParser.ARRAY to args) - Bridge.engine_call_callv(ptr) - return TransferContext.readReturnValue(VariantCaster.ANY) - } - - fun getBoundArguments(): VariantArray { - Bridge.engine_call_get_bound_arguments(ptr) - @Suppress("UNCHECKED_CAST") - return TransferContext.readReturnValue(VariantParser.ARRAY) as VariantArray - } - - fun getBoundArgumentCount(): Int { - Bridge.engine_call_get_bound_arguments_count(ptr) - return TransferContext.readReturnValue(VariantCaster.INT) as Int - } - - fun getMethod(): StringName { - Bridge.engine_call_get_method(ptr) - return TransferContext.readReturnValue(VariantParser.STRING_NAME) as StringName - } - - fun getObject(): Object { - Bridge.engine_call_get_object(ptr) - return TransferContext.readReturnValue(VariantParser.OBJECT) as Object - } - - fun getObjectId(): ObjectID { - Bridge.engine_call_get_object_id(ptr) - return ObjectID(TransferContext.readReturnValue(VariantParser.LONG) as Long) - } - - override fun hashCode(): Int { - Bridge.engine_call_hash(ptr) - return TransferContext.readReturnValue(VariantCaster.INT) as Int - } - - fun isCustom(): Boolean { - Bridge.engine_call_is_custom(ptr) - return TransferContext.readReturnValue(VariantParser.BOOL) as Boolean - } - - fun isNull(): Boolean { - Bridge.engine_call_is_null(ptr) - return TransferContext.readReturnValue(VariantParser.BOOL) as Boolean - } - - fun isStandard(): Boolean { - Bridge.engine_call_is_standard(ptr) - return TransferContext.readReturnValue(VariantParser.BOOL) as Boolean - } - - fun isValid(): Boolean { - Bridge.engine_call_is_valid(ptr) - return TransferContext.readReturnValue(VariantParser.BOOL) as Boolean - } - - fun rpc(vararg args: Any?) { - TransferContext.writeArguments(*args.map { VariantCaster.ANY to it }.toTypedArray()) - Bridge.engine_call_rpc(ptr) - } - - fun rpcId(peerId: Long, vararg args: Any?) { - TransferContext.writeArguments(VariantParser.LONG to peerId, *args.map { VariantCaster.ANY to it }.toTypedArray()) - Bridge.engine_call_rpc_id(ptr) - } - - fun unbind(argCount: Int): NativeCallable { - TransferContext.writeArguments(VariantCaster.INT to argCount) - Bridge.engine_call_unbind(ptr) - return TransferContext.readReturnValue(VariantParser.CALLABLE) as NativeCallable - } - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other !is NativeCallable) return false - if(getObject() != other.getObject() || getMethod() != other.getMethod()) return false - return true - } - - @Suppress("FunctionName") - object Bridge { - external fun engine_call_constructor(): VoidPtr - external fun engine_call_constructor_object_string_name(): VoidPtr - external fun engine_call_constructor_kt_custom_callable(callable: LambdaCallable<*>, variantTypeOrdinal: Int, hashCode: Int, hasOnCancel: Boolean): VoidPtr - external fun engine_call_copy_constructor(): VoidPtr - - external fun engine_call_bind(_handle: VoidPtr) - external fun engine_call_bindv(_handle: VoidPtr) - external fun engine_call_call(handle: VoidPtr) - external fun engine_call_call_deferred(handle: VoidPtr) - external fun engine_call_callv(_handle: VoidPtr) - external fun engine_call_get_bound_arguments(_handle: VoidPtr) - external fun engine_call_get_bound_arguments_count(_handle: VoidPtr) - external fun engine_call_get_method(_handle: VoidPtr) - external fun engine_call_get_object(_handle: VoidPtr) - external fun engine_call_get_object_id(_handle: VoidPtr) - external fun engine_call_hash(_handle: VoidPtr) - external fun engine_call_is_custom(_handle: VoidPtr) - external fun engine_call_is_null(_handle: VoidPtr) - external fun engine_call_is_standard(_handle: VoidPtr) - external fun engine_call_is_valid(_handle: VoidPtr) - external fun engine_call_rpc(_handle: VoidPtr) - external fun engine_call_rpc_id(_handle: VoidPtr) - external fun engine_call_unbind(_handle: VoidPtr) - } - - companion object { - operator fun invoke( - target: T, - callable: T.() -> Unit - ) = NativeCallable(target, (callable as KCallable<*>).name.toGodotName()) - - operator fun invoke( - target: T, - callable: T.(P) -> Unit - ) = NativeCallable(target, (callable as KCallable<*>).name.toGodotName()) - - operator fun invoke( - target: T, - callable: T.(P1, P2) -> Unit - ) = NativeCallable(target, (callable as KCallable<*>).name.toGodotName()) - - operator fun invoke( - target: T, - callable: T.(P1, P2, P3) -> Unit - ) = NativeCallable(target, (callable as KCallable<*>).name.toGodotName()) - - operator fun invoke( - target: T, - callable: T.(P1, P2, P3, P4) -> Unit - ) = NativeCallable(target, (callable as KCallable<*>).name.toGodotName()) - - operator fun invoke( - target: T, - callable: T.(P1, P2, P3, P4, P5) -> Unit - ) = NativeCallable(target, (callable as KCallable<*>).name.toGodotName()) - - operator fun invoke( - target: T, - callable: T.(P1, P2, P3, P4, P5, P6) -> Unit - ) = NativeCallable(target, (callable as KCallable<*>).name.toGodotName()) - - operator fun invoke( - target: T, - callable: T.(P1, P2, P3, P4, P5, P6, P7) -> Unit - ) = NativeCallable(target, (callable as KCallable<*>).name.toGodotName()) - - operator fun invoke( - target: T, - callable: T.(P1, P2, P3, P4, P5, P6, P7, P8) -> Unit - ) = NativeCallable(target, (callable as KCallable<*>).name.toGodotName()) - - operator fun invoke( - target: T, - callable: T.(P1, P2, P3, P4, P5, P6, P7, P8, P9) -> Unit - ) = NativeCallable(target, (callable as KCallable<*>).name.toGodotName()) - - operator fun invoke( - target: T, - callable: T.(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) -> Unit - ) = NativeCallable(target, (callable as KCallable<*>).name.toGodotName()) - } -} diff --git a/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/callback/Callable.kt b/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/callback/Callable.kt new file mode 100644 index 000000000..9840cc339 --- /dev/null +++ b/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/callback/Callable.kt @@ -0,0 +1,173 @@ +@file:Suppress("PackageDirectoryMismatch") + +package godot.core + +import godot.api.Object +import godot.common.interop.ObjectID +import godot.common.interop.VoidPtr + +/** + * Callable is a built-in Variant type that represents a function. + * + * It can either be a method within an Object instance, or a custom callable used for different purposes (see is_custom). + * + * Like all Variant types, it can be stored in variables and passed to other functions. It is most commonly used for signal callbacks. + * + * This JVM version added an "unsafe" prefix to several methods. It's encouraged to use the typed version of those methods instead. + */ +interface Callable : CoreType { + /** + * Returns a copy of this Callable with one or more arguments bound. + * When called, the bound arguments are passed after the arguments supplied by call. See also unbind. + * + * Note: When this method is chained with other similar methods, the order in which the argument list is modified is read from right to left. + */ + fun bindUnsafe(vararg args: Any?): Callable + + + /** + * Calls the method represented by this Callable. Arguments can be passed and should match the method's signature. + * */ + fun callUnsafe(vararg args: Any?): Any? + + /**Calls the method represented by this Callable in deferred mode, i.e. at the end of the current frame. + * Arguments can be passed and should match the method's signature. + * + * Note: Deferred calls are processed at idle time. + * Idle time happens mainly at the end of process and physics frames. + * In it, deferred calls will be run until there are none left, which means you can defer calls from other deferred calls and they'll still be run in the current idle time cycle. + * This means you should not call a method deferred from itself (or from a method called by it), as this causes infinite recursion the same way as if you had called the method directly. + */ + fun callDeferredUnsafe(vararg args: Any?) + + /** + * Returns the array of arguments bound via successive bind or unbind calls. These arguments will be added after the arguments passed to the call, from which get_unbound_arguments_count arguments on the right have been previously excluded. + * */ + fun getBoundArguments(): Collection + + /** + * Returns the total amount of arguments bound via successive bind or unbind calls. This is the same as the size of the array returned by get_bound_arguments. See get_bound_arguments for details + * + * Note: The get_bound_arguments_count and get_unbound_arguments_count methods can both return positive values. + * */ + fun getBoundArgumentCount(): Int + + /** + * Returns the name of the method represented by this Callable. + * If the callable is a GDScript lambda function, returns the function's name or "". + */ + fun getMethod(): StringName + + /**Returns the object on which this Callable is called.*/ + fun getObject(): Object? + + /**Returns the ID of this Callable's object (see [Object.getInstanceId]).*/ + fun getObjectId(): ObjectID + + /** + * Returns true if this Callable is a custom callable. Custom callables are used: + * + * -for binding/unbinding arguments (see bind and unbind); + * + * -for representing methods of built-in Variant types (see create); + * + * -for representing global, lambda, and RPC functions in GDScript; + * + * -for other purposes in the core, GDExtension, and C#. + * */ + fun isCustom(): Boolean + + /** + * Returns true if this Callable has no target to call the method on. Equivalent to callable == Callable(). + * + * Note: This is not the same as not is_valid() and using not is_null() will not guarantee that this callable can be called. + * Use is_valid instead.*/ + fun isNull(): Boolean + + /** + * Returns true if this Callable is a standard callable. + * This method is the opposite of is_custom. Returns false if this callable is a lambda function. + * */ + fun isStandard(): Boolean + + /** + * Returns true if the callable's object exists and has a valid method name assigned, or is a custom callable. + */ + fun isValid(): Boolean + + /** + * Perform an RPC (Remote Procedure Call) on all connected peers. + * This is used for multiplayer and is normally not available, unless the function being called has been marked as RPC (using @GDScript.@rpc or Node.rpc_config). + * Calling this method on unsupported functions will result in an error. See Node.rpc. + * */ + fun rpc(vararg args: Any?) + + /** + * Perform an RPC (Remote Procedure Call) on a specific peer ID (see multiplayer documentation for reference). + * This is used for multiplayer and is normally not available unless the function being called has been marked as RPC (using @GDScript.@rpc or Node.rpc_config). + * Calling this method on unsupported functions will result in an error. See Node.rpc_id. + * */ + fun rpcId(peerId: Long, vararg args: Any?) + + /** + * Returns a copy of this Callable with a number of arguments unbound. + * In other words, when the new callable is called the last few arguments supplied by the user are ignored, according to argcount. + * The remaining arguments are passed to the callable. + * This allows to use the original callable in a context that attempts to pass more arguments than this callable can handle, e.g. a signal with a fixed number of arguments. + * See also [bindUnsafe]. + * + * Note: When this method is chained with other similar methods, the order in which the argument list is modified is read from right to left. + * */ + fun unbind(argCount: Int): VariantCallable + + fun toNativeCallable(): VariantCallable + + companion object { + @JvmStatic + @JvmName("create") + operator fun invoke() = VariantCallable() + + @JvmStatic + @JvmName("create") + operator fun invoke(target: Object, methodName: StringName) = MethodCallable(target, methodName) + } + + @Suppress("FunctionName") + object Bridge { + external fun engine_call_constructor(): VoidPtr + external fun engine_call_constructor_object_string_name( + objectPtr: VoidPtr, + methodNamePtr: VoidPtr + ): VoidPtr + external fun engine_call_constructor_lambda_callable( + callable: LambdaContainer<*>, + variantTypeOrdinal: Int, + hashCode: Int, + ): VoidPtr + + external fun engine_call_constructor_cancellable( + callable: LambdaContainer<*>, + variantTypeOrdinal: Int, + hashCode: Int, + ) + + external fun engine_call_copy_constructor(): VoidPtr + + external fun engine_call_bind(handle: VoidPtr) + external fun engine_call_call(handle: VoidPtr) + external fun engine_call_call_deferred(handle: VoidPtr) + external fun engine_call_get_bound_arguments(handle: VoidPtr) + external fun engine_call_get_bound_arguments_count(handle: VoidPtr) + external fun engine_call_get_method(handle: VoidPtr) + external fun engine_call_get_object(handle: VoidPtr) + external fun engine_call_get_object_id(handle: VoidPtr) + external fun engine_call_hash(handle: VoidPtr) + external fun engine_call_is_custom(handle: VoidPtr) + external fun engine_call_is_null(handle: VoidPtr) + external fun engine_call_is_standard(handle: VoidPtr) + external fun engine_call_is_valid(handle: VoidPtr) + external fun engine_call_rpc(handle: VoidPtr) + external fun engine_call_rpc_id(handle: VoidPtr) + external fun engine_call_unbind(handle: VoidPtr) + } +} diff --git a/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/callback/LambdaCallable.kt b/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/callback/LambdaCallable.kt new file mode 100644 index 000000000..bb8449fe0 --- /dev/null +++ b/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/callback/LambdaCallable.kt @@ -0,0 +1,98 @@ +@file:Suppress("UNCHECKED_CAST", "PackageDirectoryMismatch", "unused") + +package godot.core + +import godot.common.interop.ObjectID +import godot.common.interop.VariantConverter +import godot.core.Callable.Bridge +import godot.internal.logging.GodotLogging +import godot.internal.memory.TransferContext + +open class LambdaCallable internal constructor( + protected val container: LambdaContainer, + private var boundArgs: Array = emptyArray() +) : Callable { + + override fun getBoundArguments() = boundArgs.toList() + override fun getBoundArgumentCount() = boundArgs.size + override fun getMethod() = StringName() + override fun getObject() = null + override fun getObjectId() = ObjectID(0) + override fun isCustom() = true + override fun isNull() = false + override fun isStandard() = false + override fun isValid() = true + override fun rpc(vararg args: Any?) = throw UnsupportedOperationException("Can't make a RPC call from a LambdaCallable") + override fun rpcId(peerId: Long, vararg args: Any?) = throw UnsupportedOperationException("Can't make a RPC call from a LambdaCallable") + override fun unbind(argCount: Int) = toNativeCallable().unbind(argCount) + override fun bindUnsafe(vararg args: Any?) = LambdaCallable(container, arrayOf(*args, *boundArgs)) + override fun callUnsafe(vararg args: Any?) = container.invokeUnsafe(*args, *boundArgs) + override fun callDeferredUnsafe(vararg args: Any?) { + val ptr = Bridge.engine_call_constructor_lambda_callable(container, container.returnConverter.id, hashCode()) + // We could use the [toVariantCallable] function, but we want to avoid 1 additional JNI calls in case we have bound arguments. + VariantCallable(ptr).callDeferredUnsafe(*args, *boundArgs) + } + + /** + * Get rid of the lambda contained in this Callable, this instance won't be usable anymore after calling it. + * Custom Callable can create reference cycles between Godot and the JVM which can make part of your objects unable to be freed by the Garbage Collector. + * This method is a last resort that can allow you to break a cycle caused by the Callable keeping its captured instance alive when itself is kept alive by the C++ side. + */ + fun invalidate() = container.invalidate() + override fun toNativeCallable(): VariantCallable { + // We pass all params using jni as we're often in a context of sending parameters to cpp, so we should not rewind buffer. + val ptr = Bridge.engine_call_constructor_lambda_callable(container, container.returnConverter.id, hashCode()) + val unbound = VariantCallable(ptr) + if (boundArgs.isNotEmpty()) { + return unbound.bindUnsafe(*boundArgs) + } + return unbound + } +} + +abstract class LambdaContainer( + val returnConverter: VariantConverter, + val typeConverters: Array, + var function: Function? +) { + var cancelFunction: (() -> Unit)? = null + fun cancel() { + cancelFunction?.invoke() + } + + fun setAsCancellable(signal: Signal, block: () -> Unit) { + cancelFunction = block + TransferContext.writeArguments(VariantParser.SIGNAL to signal) + Bridge.engine_call_constructor_cancellable(this, this.returnConverter.id, hashCode()) + } + + abstract fun invokeUnsafe(vararg args: Any?): R + + fun invoke() = withParameters(typeConverters) { + try { + invokeUnsafe(*paramsArray) + } catch (t: Throwable) { + GodotLogging.error("Error calling a JVM custom Callable from Godot:\n" + t.stackTraceToString()) + } + } + + fun invokeWithReturn(): Any? = withParametersReturn(typeConverters) { + val ret: Any? = null + try { + val ret = invokeUnsafe(*paramsArray) + TransferContext.writeReturnValue(ret, returnConverter) + } catch (t: Throwable) { + GodotLogging.error("Error calling a JVM custom Callable from Godot:\n" + t.stackTraceToString()) + TransferContext.writeReturnValue(null, VariantParser.NIL) + } + ret + } + + fun invalidate(): Unit { + function = null + } + + internal companion object : ParametersReader() +} + +class InvalidJvmLambdaException : Exception("This LambdaCallable has been invalidated, it shouldn't be called. Make sure to disconnect it from any signals") diff --git a/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/callback/MethodCallable.kt b/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/callback/MethodCallable.kt new file mode 100644 index 000000000..9bd2fd6b7 --- /dev/null +++ b/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/callback/MethodCallable.kt @@ -0,0 +1,48 @@ +@file:Suppress("PackageDirectoryMismatch") + +package godot.core + +import godot.api.Object +import godot.core.Callable.Bridge +import godot.internal.memory.MemoryManager + +class MethodCallable internal constructor( + private val target: Object, + private val methodName: StringName, + private var boundArgs: Array = emptyArray() +) : Callable { + + override fun getBoundArguments() = boundArgs.toList() + override fun getBoundArgumentCount() = boundArgs.size + override fun getMethod() = methodName + override fun getObject() = target + override fun getObjectId() = target.objectID + override fun isCustom() = false + override fun isNull() = false + override fun isStandard() = true + override fun isValid() = MemoryManager.isInstanceValid(target) && target.hasMethod(methodName) + override fun rpc(vararg args: Any?) = toNativeCallable().rpc(args) + override fun rpcId(peerId: Long, vararg args: Any?) = toNativeCallable().rpcId(peerId, args) + override fun unbind(argCount: Int) = toNativeCallable().unbind(argCount) + override fun bindUnsafe(vararg args: Any?) = MethodCallable(target, methodName, arrayOf(*args, *boundArgs)) + override fun callUnsafe(vararg args: Any?) = target.call(methodName, *args, *boundArgs) + override fun callDeferredUnsafe(vararg args: Any?) { + target.callDeferred(methodName, *args, *boundArgs) + } + + override fun toNativeCallable(): VariantCallable { + // We pass all params using jni as we're often in a context of sending parameters to cpp, so we should not rewind buffer. + val ptr = Bridge.engine_call_constructor_object_string_name(target.ptr, methodName.ptr) + val unbound = VariantCallable(ptr) + if (boundArgs.isNotEmpty()) { + return unbound.bindUnsafe(*boundArgs) + } + return unbound + } + + companion object { + @JvmStatic + @JvmName("create") + operator fun invoke(target: Object, methodName: StringName) = MethodCallable(target, methodName) + } +} diff --git a/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/Signal.kt b/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/callback/Signal.kt similarity index 69% rename from kt/godot-library/godot-core-library/src/main/kotlin/godot/core/Signal.kt rename to kt/godot-library/godot-core-library/src/main/kotlin/godot/core/callback/Signal.kt index e9ecc58ef..4230fad72 100644 --- a/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/Signal.kt +++ b/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/callback/Signal.kt @@ -1,6 +1,9 @@ +@file:Suppress("PackageDirectoryMismatch") + package godot.core import godot.api.Object +import godot.api.Object.ConnectFlags import godot.common.extensions.convertToSnakeCase import godot.internal.memory.MemoryManager @@ -14,22 +17,24 @@ open class Signal internal constructor( jvmName.convertToSnakeCase().asStringName() ) - fun emitSignal(vararg args: Any?) { + fun emitUnsafe(vararg args: Any?) { godotObject.emitSignal(name, *args) } - fun connect( + fun connectUnsafe( callable: Callable, - flags: Int = 0 - ) = godotObject.connect(name, callable, flags.toLong()) + flags: ConnectFlags = ConnectFlags.DEFAULT + ) = godotObject.connect(name, callable, flags) - fun disconnect(callable: Callable) = godotObject.disconnect(name, callable) + fun disconnectUnsafe(callable: Callable) = godotObject.disconnect(name, callable) fun getConnections() = godotObject.getSignalConnectionList(name) + fun hasConnections() = godotObject.hasConnections(name) + fun isConnected(callable: Callable) = godotObject.isConnected(name, callable) - fun isNull() = !(MemoryManager.isInstanceValid(godotObject) && godotObject.hasSignal(name)) + fun isValid() = MemoryManager.isInstanceValid(godotObject) && godotObject.hasSignal(name) override fun equals(other: Any?): Boolean { if (this === other) return true diff --git a/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/callback/SignalConnector.kt b/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/callback/SignalConnector.kt new file mode 100644 index 000000000..2934955cc --- /dev/null +++ b/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/callback/SignalConnector.kt @@ -0,0 +1,15 @@ +@file:Suppress("PackageDirectoryMismatch") + +package godot.core + +import godot.api.Object.ConnectFlags + +class SignalConnector( + private val signal: Signal, + private val callable: Callable, +) { + fun connect(flags: ConnectFlags = ConnectFlags.DEFAULT): Error = signal.connectUnsafe(callable, flags) + fun disconnect(): Unit = signal.disconnectUnsafe(callable) + fun isConnected(): Boolean = signal.isConnected(callable) + fun isValid(): Boolean = signal.isValid() && callable.isValid() +} diff --git a/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/callback/VariantCallable.kt b/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/callback/VariantCallable.kt new file mode 100644 index 000000000..6aa349175 --- /dev/null +++ b/kt/godot-library/godot-core-library/src/main/kotlin/godot/core/callback/VariantCallable.kt @@ -0,0 +1,123 @@ +@file:Suppress("PackageDirectoryMismatch") + +package godot.core + +import godot.api.Object +import godot.common.interop.ObjectID +import godot.common.interop.VoidPtr +import godot.core.Callable.Bridge +import godot.internal.memory.MemoryManager +import godot.internal.memory.TransferContext +import kotlin.reflect.KCallable + +class VariantCallable : NativeCoreType, Callable { + + internal constructor() { + ptr = Bridge.engine_call_constructor() + MemoryManager.registerNativeCoreType(this, VariantParser.CALLABLE) + } + + internal constructor(callable: VariantCallable) { + TransferContext.writeArguments(VariantParser.CALLABLE to callable) + ptr = Bridge.engine_call_copy_constructor() + MemoryManager.registerNativeCoreType(this, VariantParser.CALLABLE) + } + + internal constructor(handle: VoidPtr) { + this.ptr = handle + MemoryManager.registerNativeCoreType(this, VariantParser.CALLABLE) + } + + override fun bindUnsafe(vararg args: Any?): VariantCallable { + TransferContext.writeArguments(*args.map { VariantCaster.ANY to it }.toTypedArray()) + Bridge.engine_call_bind(ptr) + return TransferContext.readReturnValue(VariantParser.CALLABLE) as VariantCallable + } + + override fun callUnsafe(vararg args: Any?): Any? { + TransferContext.writeArguments(*args.map { VariantCaster.ANY to it }.toTypedArray()) + Bridge.engine_call_call(ptr) + return TransferContext.readReturnValue(VariantCaster.ANY) + } + + override fun callDeferredUnsafe(vararg args: Any?) { + TransferContext.writeArguments(*args.map { VariantCaster.ANY to it }.toTypedArray()) + Bridge.engine_call_call_deferred(ptr) + } + + override fun getBoundArguments(): VariantArray { + Bridge.engine_call_get_bound_arguments(ptr) + @Suppress("UNCHECKED_CAST") + return TransferContext.readReturnValue(VariantParser.ARRAY) as VariantArray + } + + override fun getBoundArgumentCount(): Int { + Bridge.engine_call_get_bound_arguments_count(ptr) + return TransferContext.readReturnValue(VariantCaster.INT) as Int + } + + override fun getMethod(): StringName { + Bridge.engine_call_get_method(ptr) + return TransferContext.readReturnValue(VariantParser.STRING_NAME) as StringName + } + + override fun hashCode(): Int { + Bridge.engine_call_hash(ptr) + return TransferContext.readReturnValue(VariantCaster.INT) as Int + } + + override fun getObject(): Object { + Bridge.engine_call_get_object(ptr) + return TransferContext.readReturnValue(VariantParser.OBJECT) as Object + } + + override fun getObjectId(): ObjectID { + Bridge.engine_call_get_object_id(ptr) + return ObjectID(TransferContext.readReturnValue(VariantParser.LONG) as Long) + } + + override fun isCustom(): Boolean { + Bridge.engine_call_is_custom(ptr) + return TransferContext.readReturnValue(VariantParser.BOOL) as Boolean + } + + override fun isNull(): Boolean { + Bridge.engine_call_is_null(ptr) + return TransferContext.readReturnValue(VariantParser.BOOL) as Boolean + } + + override fun isStandard(): Boolean { + Bridge.engine_call_is_standard(ptr) + return TransferContext.readReturnValue(VariantParser.BOOL) as Boolean + } + + override fun isValid(): Boolean { + Bridge.engine_call_is_valid(ptr) + return TransferContext.readReturnValue(VariantParser.BOOL) as Boolean + } + + override fun rpc(vararg args: Any?) { + TransferContext.writeArguments(*args.map { VariantCaster.ANY to it }.toTypedArray()) + Bridge.engine_call_rpc(ptr) + } + + override fun rpcId(peerId: Long, vararg args: Any?) { + TransferContext.writeArguments(VariantParser.LONG to peerId, *args.map { VariantCaster.ANY to it }.toTypedArray()) + Bridge.engine_call_rpc_id(ptr) + } + + override fun unbind(argCount: Int): VariantCallable { + TransferContext.writeArguments(VariantCaster.INT to argCount) + Bridge.engine_call_unbind(ptr) + return TransferContext.readReturnValue(VariantParser.CALLABLE) as VariantCallable + } + + override fun toNativeCallable() = this + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other !is VariantCallable) return false + if (getObject() != other.getObject() || getMethod() != other.getMethod()) return false + return true + } +} diff --git a/kt/godot-library/godot-coroutine-library/src/main/kotlin/gen/godot/coroutines/Await.kt b/kt/godot-library/godot-coroutine-library/src/main/kotlin/gen/godot/coroutines/Await.kt index df79e0ee5..5d1804073 100644 --- a/kt/godot-library/godot-coroutine-library/src/main/kotlin/gen/godot/coroutines/Await.kt +++ b/kt/godot-library/godot-coroutine-library/src/main/kotlin/gen/godot/coroutines/Await.kt @@ -2,7 +2,6 @@ package godot.coroutines -import godot.api.Object import godot.core.Signal0 import godot.core.Signal1 import godot.core.Signal10 @@ -20,8 +19,7 @@ import godot.core.Signal6 import godot.core.Signal7 import godot.core.Signal8 import godot.core.Signal9 -import godot.core.asCallable -import godot.extension.connectThreadSafe +import godot.core.promise import kotlin.Suppress import kotlin.Unit import kotlin.coroutines.resume @@ -30,25 +28,19 @@ import kotlinx.coroutines.suspendCancellableCoroutine public suspend inline fun Signal0.await(): Unit = suspendCancellableCoroutine { cont: CancellableContinuation -> - connectThreadSafe( { - -> - cont.resume(Unit) - } - .asCallable { - cont.cancel() - } - , Object.ConnectFlags.ONE_SHOT.id.toInt())} + promise( + { -> cont.resume(Unit) }, + { cont.cancel() }, + ) +} public suspend inline fun Signal1.await(): P0 = suspendCancellableCoroutine { cont: CancellableContinuation -> - connectThreadSafe( { - p0: P0 -> - cont.resume(p0) - } - .asCallable { - cont.cancel() - } - , Object.ConnectFlags.ONE_SHOT.id.toInt())} + promise( + { p0: P0 -> cont.resume(p0) }, + { cont.cancel() }, + ) +} public data class SignalArguments2( public val p0: P0, @@ -58,14 +50,11 @@ public data class SignalArguments2( public suspend inline fun Signal2.await(): SignalArguments2 = suspendCancellableCoroutine { cont: CancellableContinuation> -> - connectThreadSafe( { - p0: P0, p1: P1 -> - cont.resume(SignalArguments2(p0, p1)) - } - .asCallable { - cont.cancel() - } - , Object.ConnectFlags.ONE_SHOT.id.toInt())} + promise( + { p0: P0, p1: P1 -> cont.resume(SignalArguments2(p0, p1)) }, + { cont.cancel() }, + ) +} public data class SignalArguments3( public val p0: P0, @@ -76,14 +65,11 @@ public data class SignalArguments3( public suspend inline fun Signal3.await(): SignalArguments3 = suspendCancellableCoroutine { cont: CancellableContinuation> -> - connectThreadSafe( { - p0: P0, p1: P1, p2: P2 -> - cont.resume(SignalArguments3(p0, p1, p2)) - } - .asCallable { - cont.cancel() - } - , Object.ConnectFlags.ONE_SHOT.id.toInt())} + promise( + { p0: P0, p1: P1, p2: P2 -> cont.resume(SignalArguments3(p0, p1, p2)) }, + { cont.cancel() }, + ) +} public data class SignalArguments4( public val p0: P0, @@ -96,14 +82,11 @@ public suspend inline fun Signal4.await(): SignalArguments4 = suspendCancellableCoroutine { cont: CancellableContinuation> -> - connectThreadSafe( { - p0: P0, p1: P1, p2: P2, p3: P3 -> - cont.resume(SignalArguments4(p0, p1, p2, p3)) - } - .asCallable { - cont.cancel() - } - , Object.ConnectFlags.ONE_SHOT.id.toInt())} + promise( + { p0: P0, p1: P1, p2: P2, p3: P3 -> cont.resume(SignalArguments4(p0, p1, p2, p3)) }, + { cont.cancel() }, + ) +} public data class SignalArguments5( public val p0: P0, @@ -117,14 +100,11 @@ public suspend inline fun .await(): SignalArguments5 = suspendCancellableCoroutine { cont: CancellableContinuation> -> - connectThreadSafe( { - p0: P0, p1: P1, p2: P2, p3: P3, p4: P4 -> - cont.resume(SignalArguments5(p0, p1, p2, p3, p4)) - } - .asCallable { - cont.cancel() - } - , Object.ConnectFlags.ONE_SHOT.id.toInt())} + promise( + { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4 -> cont.resume(SignalArguments5(p0, p1, p2, p3, p4)) }, + { cont.cancel() }, + ) +} public data class SignalArguments6( public val p0: P0, @@ -139,14 +119,11 @@ public suspend inline fun .await(): SignalArguments6 = suspendCancellableCoroutine { cont: CancellableContinuation> -> - connectThreadSafe( { - p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5 -> - cont.resume(SignalArguments6(p0, p1, p2, p3, p4, p5)) - } - .asCallable { - cont.cancel() - } - , Object.ConnectFlags.ONE_SHOT.id.toInt())} + promise( + { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5 -> cont.resume(SignalArguments6(p0, p1, p2, p3, p4, p5)) }, + { cont.cancel() }, + ) +} public data class SignalArguments7( public val p0: P0, @@ -162,14 +139,11 @@ public suspend inline fun Signal7.await(): SignalArguments7 = suspendCancellableCoroutine { cont: CancellableContinuation> -> - connectThreadSafe( { - p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6 -> - cont.resume(SignalArguments7(p0, p1, p2, p3, p4, p5, p6)) - } - .asCallable { - cont.cancel() - } - , Object.ConnectFlags.ONE_SHOT.id.toInt())} + promise( + { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6 -> cont.resume(SignalArguments7(p0, p1, p2, p3, p4, p5, p6)) }, + { cont.cancel() }, + ) +} public data class SignalArguments8( public val p0: P0, @@ -186,14 +160,11 @@ public suspend inline fun Signal8.await(): SignalArguments8 = suspendCancellableCoroutine { cont: CancellableContinuation> -> - connectThreadSafe( { - p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7 -> - cont.resume(SignalArguments8(p0, p1, p2, p3, p4, p5, p6, p7)) - } - .asCallable { - cont.cancel() - } - , Object.ConnectFlags.ONE_SHOT.id.toInt())} + promise( + { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7 -> cont.resume(SignalArguments8(p0, p1, p2, p3, p4, p5, p6, p7)) }, + { cont.cancel() }, + ) +} public data class SignalArguments9( public val p0: P0, @@ -211,14 +182,11 @@ public suspend inline fun Signal9.await(): SignalArguments9 = suspendCancellableCoroutine { cont: CancellableContinuation> -> - connectThreadSafe( { - p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8 -> - cont.resume(SignalArguments9(p0, p1, p2, p3, p4, p5, p6, p7, p8)) - } - .asCallable { - cont.cancel() - } - , Object.ConnectFlags.ONE_SHOT.id.toInt())} + promise( + { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8 -> cont.resume(SignalArguments9(p0, p1, p2, p3, p4, p5, p6, p7, p8)) }, + { cont.cancel() }, + ) +} public data class SignalArguments10( public val p0: P0, @@ -238,14 +206,11 @@ public suspend inline fun .await(): SignalArguments10 = suspendCancellableCoroutine { cont: CancellableContinuation> -> - connectThreadSafe( { - p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9 -> - cont.resume(SignalArguments10(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)) - } - .asCallable { - cont.cancel() - } - , Object.ConnectFlags.ONE_SHOT.id.toInt())} + promise( + { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9 -> cont.resume(SignalArguments10(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)) }, + { cont.cancel() }, + ) +} public data class SignalArguments11( public val p0: P0, @@ -267,14 +232,11 @@ public suspend inline fun = suspendCancellableCoroutine { cont: CancellableContinuation> -> - connectThreadSafe( { - p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10 -> - cont.resume(SignalArguments11(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10)) - } - .asCallable { - cont.cancel() - } - , Object.ConnectFlags.ONE_SHOT.id.toInt())} + promise( + { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10 -> cont.resume(SignalArguments11(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10)) }, + { cont.cancel() }, + ) +} public data class SignalArguments12( public val p0: P0, @@ -297,14 +259,11 @@ public suspend inline fun = suspendCancellableCoroutine { cont: CancellableContinuation> -> - connectThreadSafe( { - p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11 -> - cont.resume(SignalArguments12(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11)) - } - .asCallable { - cont.cancel() - } - , Object.ConnectFlags.ONE_SHOT.id.toInt())} + promise( + { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11 -> cont.resume(SignalArguments12(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11)) }, + { cont.cancel() }, + ) +} public data class SignalArguments13( public val p0: P0, @@ -328,14 +287,11 @@ public suspend inline fun = suspendCancellableCoroutine { cont: CancellableContinuation> -> - connectThreadSafe( { - p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12 -> - cont.resume(SignalArguments13(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12)) - } - .asCallable { - cont.cancel() - } - , Object.ConnectFlags.ONE_SHOT.id.toInt())} + promise( + { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12 -> cont.resume(SignalArguments13(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12)) }, + { cont.cancel() }, + ) +} public data class SignalArguments14( public val p0: P0, @@ -360,14 +316,11 @@ public suspend inline fun = suspendCancellableCoroutine { cont: CancellableContinuation> -> - connectThreadSafe( { - p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13 -> - cont.resume(SignalArguments14(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13)) - } - .asCallable { - cont.cancel() - } - , Object.ConnectFlags.ONE_SHOT.id.toInt())} + promise( + { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13 -> cont.resume(SignalArguments14(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13)) }, + { cont.cancel() }, + ) +} public data class SignalArguments15( @@ -395,14 +348,11 @@ public suspend inline fun = suspendCancellableCoroutine { cont: CancellableContinuation> -> - connectThreadSafe( { - p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14 -> - cont.resume(SignalArguments15(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14)) - } - .asCallable { - cont.cancel() - } - , Object.ConnectFlags.ONE_SHOT.id.toInt())} + promise( + { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14 -> cont.resume(SignalArguments15(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14)) }, + { cont.cancel() }, + ) +} public data class SignalArguments16( @@ -431,11 +381,8 @@ public suspend inline fun = suspendCancellableCoroutine { cont: CancellableContinuation> -> - connectThreadSafe( { - p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15 -> - cont.resume(SignalArguments16(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15)) - } - .asCallable { - cont.cancel() - } - , Object.ConnectFlags.ONE_SHOT.id.toInt())} + promise( + { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15 -> cont.resume(SignalArguments16(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15)) }, + { cont.cancel() }, + ) +} diff --git a/kt/godot-library/godot-coroutine-library/src/main/kotlin/godot/coroutines/GodotCoroutine.kt b/kt/godot-library/godot-coroutine-library/src/main/kotlin/godot/coroutines/GodotCoroutine.kt index 5733b0ce8..75a796488 100644 --- a/kt/godot-library/godot-coroutine-library/src/main/kotlin/godot/coroutines/GodotCoroutine.kt +++ b/kt/godot-library/godot-coroutine-library/src/main/kotlin/godot/coroutines/GodotCoroutine.kt @@ -8,7 +8,7 @@ import kotlin.coroutines.CoroutineContext import kotlin.coroutines.EmptyCoroutineContext object GodotCoroutine : CoroutineScope { - override val coroutineContext = GodotDispatchers.ThreadPool + SupervisorJob() + override val coroutineContext = GodotDispatchers.ThreadPool + SupervisorJob() } fun godotCoroutine( diff --git a/kt/godot-library/godot-coroutine-library/src/main/kotlin/godot/coroutines/GodotDispatchers.kt b/kt/godot-library/godot-coroutine-library/src/main/kotlin/godot/coroutines/GodotDispatchers.kt index e7890efce..7c8bc34d1 100644 --- a/kt/godot-library/godot-coroutine-library/src/main/kotlin/godot/coroutines/GodotDispatchers.kt +++ b/kt/godot-library/godot-coroutine-library/src/main/kotlin/godot/coroutines/GodotDispatchers.kt @@ -4,11 +4,12 @@ import godot.api.Engine import godot.api.Object import godot.api.SceneTree import godot.api.WorkerThreadPool -import godot.core.Callable import godot.core.asCallable +import godot.internal.memory.MemoryManager import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.Runnable -import kotlinx.coroutines.cancel +import java.util.concurrent.locks.ReentrantLock +import kotlin.concurrent.withLock import kotlin.coroutines.CoroutineContext object GodotDispatchers { @@ -20,30 +21,77 @@ object GodotDispatchers { private object GodotMainThreadCoroutineDispatcher : CoroutineDispatcher() { override fun dispatch(context: CoroutineContext, block: Runnable) { - Callable({ block.run() }.asCallable { context.cancel() }).callDeferred() + { block.run() }.asCallable().callDeferred() } } private object GodotThreadPoolCoroutineDispatcher : CoroutineDispatcher() { + private const val MIN_SIZE = 64 + + val lock = ReentrantLock() + val currentTasks = HashMap(MIN_SIZE) + val terminatedTasks = ArrayList(MIN_SIZE) + + init { + // Schedule to clear remaining tasks when Godot terminates.. + MemoryManager.registerCallback(true, ::clearCompletedTasks) + } + override fun dispatch(context: CoroutineContext, block: Runnable) { - WorkerThreadPool.addTask({ block.run() }.asCallable { context.cancel() }) + val callable = { + try { + block.run() + } finally { + lock.withLock { + val id = currentTasks.remove(block)!! + terminatedTasks.add(id) + } + } + }.asCallable() + + val taskID = WorkerThreadPool.addTask(callable) + + val tasksToClear = lock.withLock { + currentTasks[block] = taskID + terminatedTasks.toTypedArray().also { + terminatedTasks.clear() + } + } + + tasksToClear.forEach { + /** + * It's mandatory in Godot to call this method at some point after adding a task to clean up memory. + * We cannot wait immediately after adding the task because it would block the thread doing the dispatching, but we can do it after the task has been confirmed completed. + * It would also be wasteful to allocate a separate thread to poll and check task completions so instead we do process the list of complete tasks right after a regular dispatch. + */ + WorkerThreadPool.waitForTaskCompletion(it) + } + } + + + private fun clearCompletedTasks() { + // Warning, this method is only supposed to be called when Godot terminates! + terminatedTasks.forEach { + WorkerThreadPool.waitForTaskCompletion(it) + } + terminatedTasks.clear() } } private object GodotProcessFrameCoroutineDispatcher : CoroutineDispatcher() { override fun dispatch(context: CoroutineContext, block: Runnable) { - sceneTree.processFrame.connect( - { block.run() }.asCallable { context.cancel() }, - Object.ConnectFlags.ONE_SHOT.id.toInt() + sceneTree.processFrame.connectUnsafe( + { block.run() }.asCallable(), + Object.ConnectFlags.ONE_SHOT ) } } private object GodotPhysicsFrameCoroutineDispatcher : CoroutineDispatcher() { override fun dispatch(context: CoroutineContext, block: Runnable) { - sceneTree.physicsFrame.connect( - { block.run() }.asCallable { context.cancel() }, - Object.ConnectFlags.ONE_SHOT.id.toInt() + sceneTree.physicsFrame.connectUnsafe( + { block.run() }.asCallable(), + Object.ConnectFlags.ONE_SHOT ) } } diff --git a/kt/godot-library/godot-coroutine-library/src/main/kotlin/godot/coroutines/awaitResourceLoad.kt b/kt/godot-library/godot-coroutine-library/src/main/kotlin/godot/coroutines/awaitResourceLoad.kt index 783ed0267..443da7ea6 100644 --- a/kt/godot-library/godot-coroutine-library/src/main/kotlin/godot/coroutines/awaitResourceLoad.kt +++ b/kt/godot-library/godot-coroutine-library/src/main/kotlin/godot/coroutines/awaitResourceLoad.kt @@ -1,21 +1,9 @@ package godot.coroutines -import godot.core.Error import godot.api.Resource import godot.api.ResourceLoader import godot.api.ResourceLoader.CacheMode -import godot.core.variantArrayOf -import godot.global.GD -import godot.common.util.RealT -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.Job import kotlinx.coroutines.async -import kotlinx.coroutines.launch -import kotlinx.coroutines.runBlocking -import kotlinx.coroutines.suspendCancellableCoroutine -import kotlin.coroutines.resume -import kotlin.coroutines.resumeWithException /** @@ -23,17 +11,13 @@ import kotlin.coroutines.resumeWithException * * @param path The path of the resource to be loaded. * @param typeHint A hint about the type of resource being loaded. - * @param useSubThreads Specifies whether to use sub-threads for loading the resource. * @param cacheMode The cache mode to be used while loading the resource. - * @param onProgress A callback function to track the progress of resource loading. * @return The loaded resource, or null if there was an error. */ public suspend inline fun ResourceLoader.awaitLoad( path: String, typeHint: String = "", - useSubThreads: Boolean = false, - cacheMode: CacheMode = ResourceLoader.CacheMode.REUSE, - crossinline onProgress: (RealT) -> Unit = {}, + cacheMode: CacheMode = CacheMode.REUSE, ): Resource? { // early return in case the resource is already loaded if (hasCached(path)) { @@ -41,8 +25,8 @@ public suspend inline fun ResourceLoader.awaitLoad( } // Start a new job so we have a suspension point in case the coroutine is currently in the main thread. - val job = GodotCoroutine.async(Dispatchers.Default) { - load(path) + val job = GodotCoroutine.async(GodotDispatchers.ThreadPool) { + load(path, typeHint, cacheMode) } return job.await() @@ -53,18 +37,14 @@ public suspend inline fun ResourceLoader.awaitLoad( * * @param path The path of the resource to be loaded. * @param typeHint A hint about the type of resource being loaded. - * @param useSubThreads Specifies whether to use sub-threads for loading the resource. * @param cacheMode The cache mode to be used while loading the resource. - * @param onProgress A callback function to track the progress of resource loading. * @return The loaded resource, or null if there was an error. */ public suspend inline fun ResourceLoader.awaitLoadAs( path: String, typeHint: String = "", - useSubThreads: Boolean = false, - cacheMode: CacheMode = ResourceLoader.CacheMode.REUSE, - crossinline onProgress: (RealT) -> Unit = {}, + cacheMode: CacheMode = CacheMode.REUSE, ): R? { @Suppress("UNCHECKED_CAST") - return this.awaitLoad(path, typeHint, useSubThreads, cacheMode, onProgress) as? R + return this.awaitLoad(path, typeHint, cacheMode) as? R } diff --git a/kt/godot-library/godot-extension-library/src/main/kotlin/gen/godot/extension/SignalUtils.kt b/kt/godot-library/godot-extension-library/src/main/kotlin/gen/godot/extension/SignalUtils.kt deleted file mode 100644 index 5a938290d..000000000 --- a/kt/godot-library/godot-extension-library/src/main/kotlin/gen/godot/extension/SignalUtils.kt +++ /dev/null @@ -1,512 +0,0 @@ -@file:Suppress( - "PackageDirectoryMismatch", - "NOTHING_TO_INLINE", - "UNUSED_PARAMETER", -) - -package godot.extension - -import godot.api.Object -import godot.core.Callable -import godot.core.Signal0 -import godot.core.Signal1 -import godot.core.Signal10 -import godot.core.Signal11 -import godot.core.Signal12 -import godot.core.Signal13 -import godot.core.Signal14 -import godot.core.Signal15 -import godot.core.Signal16 -import godot.core.Signal2 -import godot.core.Signal3 -import godot.core.Signal4 -import godot.core.Signal5 -import godot.core.Signal6 -import godot.core.Signal7 -import godot.core.Signal8 -import godot.core.Signal9 -import godot.core.asCallable -import godot.core.toGodotName -import godot.extension.connectThreadSafe -import kotlin.Any -import kotlin.Int -import kotlin.Suppress -import kotlin.Unit -import kotlin.reflect.KCallable - -public fun Signal0.connectThreadSafe( - target: T, - method: T.() -> Unit, - flags: Int = 0, -): Any? = connectThreadSafe(Callable(target, (method as KCallable<*>).name.toGodotName()), flags) - -public inline fun Signal0.connectThreadSafe(flags: Int = 0, noinline method: () -> Unit): Any? = - connectThreadSafe(method.asCallable(), flags) - -public fun Signal1.connectThreadSafe( - target: T, - method: T.(p0: P0) -> Unit, - flags: Int = 0, -): Any? = connectThreadSafe(Callable(target, (method as KCallable<*>).name.toGodotName()), flags) - -public inline fun Signal1.connectThreadSafe(flags: Int = 0, noinline - method: (p0: P0) -> Unit): Any? = connectThreadSafe(method.asCallable(), flags) - -public fun Signal2.connectThreadSafe( - target: T, - method: T.(p0: P0, p1: P1) -> Unit, - flags: Int = 0, -): Any? = connectThreadSafe(Callable(target, (method as KCallable<*>).name.toGodotName()), flags) - -public inline fun Signal2.connectThreadSafe(flags: Int = 0, - noinline method: (p0: P0, p1: P1) -> Unit): Any? = - connectThreadSafe(method.asCallable(), flags) - -public fun Signal3.connectThreadSafe( - target: T, - method: T.( - p0: P0, - p1: P1, - p2: P2, - ) -> Unit, - flags: Int = 0, -): Any? = connectThreadSafe(Callable(target, (method as KCallable<*>).name.toGodotName()), flags) - -public inline fun - Signal3.connectThreadSafe(flags: Int = 0, noinline method: ( - p0: P0, - p1: P1, - p2: P2, -) -> Unit): Any? = connectThreadSafe(method.asCallable(), flags) - -public fun Signal4.connectThreadSafe( - target: T, - method: T.( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - ) -> Unit, - flags: Int = 0, -): Any? = connectThreadSafe(Callable(target, (method as KCallable<*>).name.toGodotName()), flags) - -public inline fun - Signal4.connectThreadSafe(flags: Int = 0, noinline method: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, -) -> Unit): Any? = connectThreadSafe(method.asCallable(), flags) - -public fun Signal5.connectThreadSafe( - target: T, - method: T.( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - ) -> Unit, - flags: Int = 0, -): Any? = connectThreadSafe(Callable(target, (method as KCallable<*>).name.toGodotName()), flags) - -public inline fun - Signal5.connectThreadSafe(flags: Int = 0, noinline method: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, -) -> Unit): Any? = connectThreadSafe(method.asCallable(), flags) - -public fun Signal6.connectThreadSafe( - target: T, - method: T.( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - ) -> Unit, - flags: Int = 0, -): Any? = connectThreadSafe(Callable(target, (method as KCallable<*>).name.toGodotName()), flags) - -public inline fun - Signal6.connectThreadSafe(flags: Int = 0, noinline method: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, -) -> Unit): Any? = connectThreadSafe(method.asCallable(), flags) - -public fun - Signal7.connectThreadSafe( - target: T, - method: T.( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - ) -> Unit, - flags: Int = 0, -): Any? = connectThreadSafe(Callable(target, (method as KCallable<*>).name.toGodotName()), flags) - -public inline fun Signal7.connectThreadSafe(flags: Int = 0, noinline method: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, -) -> Unit): Any? = connectThreadSafe(method.asCallable(), flags) - -public fun - Signal8.connectThreadSafe( - target: T, - method: T.( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - ) -> Unit, - flags: Int = 0, -): Any? = connectThreadSafe(Callable(target, (method as KCallable<*>).name.toGodotName()), flags) - -public inline fun Signal8.connectThreadSafe(flags: Int = 0, - noinline method: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, -) -> Unit): Any? = connectThreadSafe(method.asCallable(), flags) - -public fun - Signal9.connectThreadSafe( - target: T, - method: T.( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - ) -> Unit, - flags: Int = 0, -): Any? = connectThreadSafe(Callable(target, (method as KCallable<*>).name.toGodotName()), flags) - -public inline fun - Signal9.connectThreadSafe(flags: Int = 0, noinline - method: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, -) -> Unit): Any? = connectThreadSafe(method.asCallable(), flags) - -public fun - Signal10.connectThreadSafe( - target: T, - method: T.( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - ) -> Unit, - flags: Int = 0, -): Any? = connectThreadSafe(Callable(target, (method as KCallable<*>).name.toGodotName()), flags) - -public inline fun - Signal10.connectThreadSafe(flags: Int = 0, noinline - method: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, -) -> Unit): Any? = connectThreadSafe(method.asCallable(), flags) - -public fun - Signal11.connectThreadSafe( - target: T, - method: T.( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - ) -> Unit, - flags: Int = 0, -): Any? = connectThreadSafe(Callable(target, (method as KCallable<*>).name.toGodotName()), flags) - -public inline fun - Signal11.connectThreadSafe(flags: Int = 0, - noinline method: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, -) -> Unit): Any? = connectThreadSafe(method.asCallable(), flags) - -public fun - Signal12.connectThreadSafe( - target: T, - method: T.( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - ) -> Unit, - flags: Int = 0, -): Any? = connectThreadSafe(Callable(target, (method as KCallable<*>).name.toGodotName()), flags) - -public inline fun - Signal12.connectThreadSafe(flags: Int = 0, - noinline method: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, -) -> Unit): Any? = connectThreadSafe(method.asCallable(), flags) - -public fun - Signal13.connectThreadSafe( - target: T, - method: T.( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - ) -> Unit, - flags: Int = 0, -): Any? = connectThreadSafe(Callable(target, (method as KCallable<*>).name.toGodotName()), flags) - -public inline fun - Signal13.connectThreadSafe(flags: Int - = 0, noinline method: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, -) -> Unit): Any? = connectThreadSafe(method.asCallable(), flags) - -public fun - Signal14.connectThreadSafe( - target: T, - method: T.( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - ) -> Unit, - flags: Int = 0, -): Any? = connectThreadSafe(Callable(target, (method as KCallable<*>).name.toGodotName()), flags) - -public inline fun - Signal14.connectThreadSafe(flags: Int - = 0, noinline method: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, -) -> Unit): Any? = connectThreadSafe(method.asCallable(), flags) - -public fun - Signal15.connectThreadSafe( - target: T, - method: T.( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - p14: P14, - ) -> Unit, - flags: Int = 0, -): Any? = connectThreadSafe(Callable(target, (method as KCallable<*>).name.toGodotName()), flags) - -public inline fun - Signal15.connectThreadSafe(flags: Int - = 0, noinline method: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - p14: P14, -) -> Unit): Any? = connectThreadSafe(method.asCallable(), flags) - -public fun - Signal16.connectThreadSafe( - target: T, - method: T.( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - p14: P14, - p15: P15, - ) -> Unit, - flags: Int = 0, -): Any? = connectThreadSafe(Callable(target, (method as KCallable<*>).name.toGodotName()), flags) - -public inline fun - Signal16.connectThreadSafe(flags: Int - = 0, noinline method: ( - p0: P0, - p1: P1, - p2: P2, - p3: P3, - p4: P4, - p5: P5, - p6: P6, - p7: P7, - p8: P8, - p9: P9, - p10: P10, - p11: P11, - p12: P12, - p13: P13, - p14: P14, - p15: P15, -) -> Unit): Any? = connectThreadSafe(method.asCallable(), flags) diff --git a/kt/godot-library/godot-extension-library/src/main/kotlin/godot/extension/ObjectExt.kt b/kt/godot-library/godot-extension-library/src/main/kotlin/godot/extension/ObjectExt.kt index ab4800fb3..415ab6abe 100644 --- a/kt/godot-library/godot-extension-library/src/main/kotlin/godot/extension/ObjectExt.kt +++ b/kt/godot-library/godot-extension-library/src/main/kotlin/godot/extension/ObjectExt.kt @@ -12,45 +12,6 @@ import godot.core.asCachedStringName import godot.core.toGodotName import kotlin.reflect.KFunction -/** - * **Note:** The function name is converted to snake_case - * Use [Object.callDeferred] to call functions by string or [callDeferredRawName] for an unconverted version of this function - */ -inline fun > Object.callDeferred(function: T, vararg args: Any?) = - callDeferred(function.name.toGodotName(), *args) - -/** - * Same as [callDeferred] but the function name is not converted to snake_case - */ -inline fun > Object.callDeferredRawName(function: T, vararg args: Any?) = - callDeferred(function.name.asCachedStringName(), *args) - -/** - * **Note:** The function name is converted to snake_case - * Use [Object.call] to call functions by string or [callRawName] for an unconverted version of this function - */ -inline fun > Object.call(function: T, vararg args: Any?) = - call(function.name.toGodotName(), *args) - -/** - * Same as [call] but the function name is not converted to snake_case - */ -inline fun > Object.callRawName(function: T, vararg args: Any?) = - call(function.name.asCachedStringName(), *args) - -/** - * **Note:** The function name is converted to snake_case - * Use [Object.callv] to call functions by string or [callvRawName] for an unconverted version of this function - */ -inline fun > Object.callv(function: T, argArray: VariantArray) = - callv(function.name.toGodotName(), argArray) - -/** - * Same as [callv] but the function name is not converted to snake_case - */ -inline fun > Object.callvRawName(function: T, argArray: VariantArray) = - callv(function.name.asCachedStringName(), argArray) - /** * **Note:** The function name is converted to snake_case * Use [Object.hasMethod] to check function existence by string or [hasMethodRawName] for an unconverted version of this function @@ -64,76 +25,6 @@ inline fun > Object.hasMethod(function: T) = inline fun > Object.hasMethodRawName(function: T) = hasMethod(function.name.asCachedStringName()) -/** - * **Note:** The function name is converted to snake_case - * Use [Object.isConnected] to check connections by string or [hasMethodRawName] for an unconverted version of this function - */ -//TODO/4.0: Check if still correct -inline fun > Object.isConnected( - signal: Signal, - target: Object, - function: T -) = isConnected(signal.name, Callable(target, function.name.toGodotName())) - -/** - * Same as [isConnected] but the function name is not converted to snake_case - */ -//TODO/4.0: Check if still correct -inline fun > Object.isConnectedRawName( - signal: Signal, - target: Object, - function: T -) = isConnected(signal.name, Callable(target, function.name.asCachedStringName())) - -/** - * **Note:** The function name is converted to snake_case - * Use [Object.connect] to connect by string or [hasMethodRawName] for an unconverted version of this function - */ -//TODO/4.0: Check if still correct -inline fun > Object.connect( - signal: Signal, - target: Object, - function: T, - flags: Int = 0 -) = connect( - signal.name, - Callable(target, function.name.toGodotName()), - flags.toLong() -) - -/** - * Same as [connect] but the function name is not converted to snake_case - */ -//TODO/4.0: Check if still correct -inline fun > Object.connectRawName( - signal: Signal, - target: Object, - function: T, - flags: Int = 0 -) = connect(signal.name, Callable(target, function.name.asCachedStringName()), flags.toLong()) - -/** - * **Note:** The function name is converted to snake_case - * Use [Object.disconnect] to connect by string or [disconnectRawName] for an unconverted version of this function - */ -//TODO/4.0: Check if still correct -inline fun > Object.disconnect( - signal: Signal, - target: Object, - function: T -) = disconnect(signal.name, Callable(target, function.name.toGodotName())) - -/** - * Same as [disconnect] but the function name is not converted to snake_case - */ -//TODO/4.0: Check if still correct -inline fun > Object.disconnectRawName( - signal: Signal, - target: Object, - function: T -) = disconnect(signal.name, Callable(target, function.name.asCachedStringName())) - - /** * Instance will be automatically freed when the engine closes. */ diff --git a/kt/godot-library/godot-extension-library/src/main/kotlin/godot/extension/SignalExt.kt b/kt/godot-library/godot-extension-library/src/main/kotlin/godot/extension/SignalExt.kt deleted file mode 100644 index b2ba8e08f..000000000 --- a/kt/godot-library/godot-extension-library/src/main/kotlin/godot/extension/SignalExt.kt +++ /dev/null @@ -1,21 +0,0 @@ -package godot.extension - -import godot.core.Callable -import godot.core.Signal -import godot.api.Node -import godot.core.asStringName - -private val connectMethodName = "connect".asStringName() - -fun Signal.connectThreadSafe(callable: Callable, flags: Int = 0) = - (godotObject as? Node)?.callThreadSafe( - connectMethodName, - name, - callable, - flags.toLong() - ) ?: godotObject.connect( - name, - callable, - flags.toLong() - ) - diff --git a/kt/plugins/godot-gradle-plugin/src/main/resources/godot/gradle/godot-kotlin-graal-jni-config.json b/kt/plugins/godot-gradle-plugin/src/main/resources/godot/gradle/godot-kotlin-graal-jni-config.json index 0c528df69..4e1426e79 100644 --- a/kt/plugins/godot-gradle-plugin/src/main/resources/godot/gradle/godot-kotlin-graal-jni-config.json +++ b/kt/plugins/godot-gradle-plugin/src/main/resources/godot/gradle/godot-kotlin-graal-jni-config.json @@ -157,15 +157,16 @@ ] }, { - "name" : "godot.core.NativeCallable$Bridge", + "name" : "godot.core.Callable$Bridge", "fields" : [ { "name" : "INSTANCE" } ], "methods" : [ { "name" : "engine_call_constructor", "parameterTypes" : [] }, - { "name" : "engine_call_constructor_object_string_name", "parameterTypes" : [] }, - { "name" : "engine_call_constructor_kt_custom_callable", "parameterTypes" : ["godot.core.LambdaCallable", "int", "int", "boolean"] }, + { "name" : "engine_call_constructor_object_string_name", "parameterTypes" : ["long", "long"] }, + { "name" : "engine_call_constructor_lambda_callable", "parameterTypes" : ["godot.core.LambdaContainer", "int", "int"] }, + { "name" : "engine_call_constructor_cancellable", "parameterTypes" : ["godot.core.LambdaContainer", "int", "int"] }, { "name" : "engine_call_copy_constructor", "parameterTypes" : [] }, { "name" : "engine_call_bind", "parameterTypes" : ["long"] }, @@ -189,12 +190,11 @@ ] }, { - "name" : "godot.core.LambdaCallable$Bridge", - "fields" : [ - { "name" : "INSTANCE" } - ], - "methods" : [ - { "name" : "wrap_in_custom_callable", "parameterTypes" : ["godot.core.LambdaCallable", "int", "int", "boolean"] } + "name":"godot.core.LambdaContainer", + "methods":[ + {"name":"invoke","parameterTypes":[] }, + {"name":"invokeWithReturn","parameterTypes":[] }, + {"name":"cancel","parameterTypes":[] } ] }, { @@ -331,7 +331,10 @@ { "name" : "engine_call_to_float64_array", "parameterTypes" : ["long"] }, { "name" : "engine_call_to_int32_array", "parameterTypes" : ["long"] }, { "name" : "engine_call_to_int64_array", "parameterTypes" : ["long"] }, - { "name" : "engine_call_size", "parameterTypes" : ["long"] } + { "name" : "engine_call_size", "parameterTypes" : ["long"] }, + + { "name" : "engine_convert_to_godot", "parameterTypes" : ["byte[]"] }, + { "name" : "engine_convert_to_jvm", "parameterTypes" : ["long"] } ] }, { @@ -399,7 +402,10 @@ { "name" : "engine_call_size", "parameterTypes" : ["long"] }, { "name" : "engine_call_slice", "parameterTypes" : ["long"] }, { "name" : "engine_call_sort", "parameterTypes" : ["long"] }, - { "name" : "engine_call_to_byte_array", "parameterTypes" : ["long"] } + { "name" : "engine_call_to_byte_array", "parameterTypes" : ["long"] }, + + { "name" : "engine_convert_to_godot", "parameterTypes" : ["float[]"] }, + { "name" : "engine_convert_to_jvm", "parameterTypes" : ["long"] } ] }, { @@ -433,7 +439,10 @@ { "name" : "engine_call_size", "parameterTypes" : ["long"] }, { "name" : "engine_call_slice", "parameterTypes" : ["long"] }, { "name" : "engine_call_sort", "parameterTypes" : ["long"] }, - { "name" : "engine_call_to_byte_array", "parameterTypes" : ["long"] } + { "name" : "engine_call_to_byte_array", "parameterTypes" : ["long"] }, + + { "name" : "engine_convert_to_godot", "parameterTypes" : ["double[]"] }, + { "name" : "engine_convert_to_jvm", "parameterTypes" : ["long"] } ] }, { @@ -467,7 +476,10 @@ { "name" : "engine_call_size", "parameterTypes" : ["long"] }, { "name" : "engine_call_slice", "parameterTypes" : ["long"] }, { "name" : "engine_call_sort", "parameterTypes" : ["long"] }, - { "name" : "engine_call_to_byte_array", "parameterTypes" : ["long"] } + { "name" : "engine_call_to_byte_array", "parameterTypes" : ["long"] }, + + { "name" : "engine_convert_to_godot", "parameterTypes" : ["int[]"] }, + { "name" : "engine_convert_to_jvm", "parameterTypes" : ["long"] } ] }, { @@ -501,7 +513,10 @@ { "name" : "engine_call_size", "parameterTypes" : ["long"] }, { "name" : "engine_call_slice", "parameterTypes" : ["long"] }, { "name" : "engine_call_sort", "parameterTypes" : ["long"] }, - { "name" : "engine_call_to_byte_array", "parameterTypes" : ["long"] } + { "name" : "engine_call_to_byte_array", "parameterTypes" : ["long"] }, + + { "name" : "engine_convert_to_godot", "parameterTypes" : ["long[]"] }, + { "name" : "engine_convert_to_jvm", "parameterTypes" : ["long"] } ] }, { @@ -569,7 +584,10 @@ { "name" : "engine_call_size", "parameterTypes" : ["long"] }, { "name" : "engine_call_slice", "parameterTypes" : ["long"] }, { "name" : "engine_call_sort", "parameterTypes" : ["long"] }, - { "name" : "engine_call_to_byte_array", "parameterTypes" : ["long"] } + { "name" : "engine_call_to_byte_array", "parameterTypes" : ["long"] }, + + { "name" : "engine_convert_to_godot", "parameterTypes" : ["float[]"] }, + { "name" : "engine_convert_to_jvm", "parameterTypes" : ["long"] } ] }, { @@ -603,7 +621,10 @@ { "name" : "engine_call_size", "parameterTypes" : ["long"] }, { "name" : "engine_call_slice", "parameterTypes" : ["long"] }, { "name" : "engine_call_sort", "parameterTypes" : ["long"] }, - { "name" : "engine_call_to_byte_array", "parameterTypes" : ["long"] } + { "name" : "engine_call_to_byte_array", "parameterTypes" : ["long"] }, + + { "name" : "engine_convert_to_godot", "parameterTypes" : ["float[]"] }, + { "name" : "engine_convert_to_jvm", "parameterTypes" : ["long"] } ] }, { @@ -637,7 +658,10 @@ { "name" : "engine_call_size", "parameterTypes" : ["long"] }, { "name" : "engine_call_slice", "parameterTypes" : ["long"] }, { "name" : "engine_call_sort", "parameterTypes" : ["long"] }, - { "name" : "engine_call_to_byte_array", "parameterTypes" : ["long"] } + { "name" : "engine_call_to_byte_array", "parameterTypes" : ["long"] }, + + { "name" : "engine_convert_to_godot", "parameterTypes" : ["float[]"] }, + { "name" : "engine_convert_to_jvm", "parameterTypes" : ["long"] } ] }, { @@ -710,16 +734,6 @@ {"name": "construct", "parameterTypes": ["long", "long"]} ] }, - { - "name":"godot.core.LambdaCallable", - "methods":[ - {"name":"invokeNoReturn","parameterTypes":[] }, - {"name":"invokeWithReturn","parameterTypes":[] }, - {"name":"getReturnVariantType","parameterTypes":[] }, - {"name":"hashCode","parameterTypes":[] }, - {"name":"onCancel","parameterTypes":[] } - ] - }, { "name":"godot.core.KtFunction", "methods":[ diff --git a/kt/tools-common/src/main/kotlin/godot/tools/common/constants/Classes.kt b/kt/tools-common/src/main/kotlin/godot/tools/common/constants/Classes.kt index dfc673ec6..525397f68 100644 --- a/kt/tools-common/src/main/kotlin/godot/tools/common/constants/Classes.kt +++ b/kt/tools-common/src/main/kotlin/godot/tools/common/constants/Classes.kt @@ -13,9 +13,11 @@ object GodotKotlinJvmTypes { const val stringName = "StringName" const val array = "VariantArray" const val callable = "Callable" - const val callableBase = "Callable" + const val methodCallable = "MethodCallable" + const val lambdaCallable = "LambdaCallable" const val dictionary = "Dictionary" const val error = "Error" + const val connector = "SignalConnector" const val nodePath = "NodePath" const val variant = "Any" const val refCounted = "RefCounted" @@ -244,10 +246,12 @@ object GodotTypes { ) } +val GODOT_SIGNAL_CONNECTOR = ClassName(godotCorePackage, GodotKotlinJvmTypes.connector) val GODOT_ERROR = ClassName(godotCorePackage, GodotKotlinJvmTypes.error) val GODOT_ARRAY = ClassName(godotCorePackage, GodotKotlinJvmTypes.array) val GODOT_CALLABLE = ClassName(godotCorePackage, GodotKotlinJvmTypes.callable) -val GODOT_CALLABLE_BASE = ClassName(godotCorePackage, GodotKotlinJvmTypes.callableBase) +val GODOT_METHOD_CALLABLE = ClassName(godotCorePackage, GodotKotlinJvmTypes.methodCallable) +val GODOT_LAMBDA_CALLABLE = ClassName(godotCorePackage, GodotKotlinJvmTypes.lambdaCallable) val GODOT_DICTIONARY = ClassName(godotCorePackage, GodotKotlinJvmTypes.dictionary) val GODOT_OBJECT = ClassName(godotApiPackage, GodotKotlinJvmTypes.obj) val KT_OBJECT = ClassName(godotCorePackage, GodotKotlinJvmTypes.ktObject) diff --git a/register_types.cpp b/register_types.cpp index c80744783..befdee1ca 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -94,6 +94,4 @@ void uninitialize_kotlin_jvm_module(ModuleInitializationLevel p_level) { JvmLanguage* jvm_language {GdjLanguage::get_instance()}; ScriptServer::unregister_language(jvm_language); memdelete(jvm_language); - - JvmScriptManager::finalize(); } diff --git a/src/gd_kotlin.cpp b/src/gd_kotlin.cpp index 00625d173..11bf97d8d 100644 --- a/src/gd_kotlin.cpp +++ b/src/gd_kotlin.cpp @@ -336,6 +336,7 @@ void GDKotlin::finalize_core_library() { MemoryManager::get_instance().clean_up(env); + JvmScriptManager::finalize(); JvmManager::finalize_jvm_wrappers(env, bootstrap_class_loader); memdelete(callable_middleman); diff --git a/src/jni/types.cpp b/src/jni/types.cpp index 8bc9c2a7e..333cd95b4 100644 --- a/src/jni/types.cpp +++ b/src/jni/types.cpp @@ -60,7 +60,6 @@ namespace jni { return obj == nullptr; } - bool JObject::is_same_object(Env& env, const JObject& other) const { return env.is_same_object(obj, other.obj); } @@ -142,27 +141,27 @@ namespace jni { return JObject(ret); } - JByteArray::JByteArray(Env& env, const jsize size) : JArray() { + JByteArray::JByteArray(Env& env, const jsize size) { // Allocate an Array with reserved size; obj = env.env->NewByteArray(size); } - JIntArray::JIntArray(Env& env, const jsize size) : JArray() { + JIntArray::JIntArray(Env& env, const jsize size) { // Allocate an Array with reserved size; obj = env.env->NewIntArray(size); } - JLongArray::JLongArray(Env& env, const jsize size) : JArray() { + JLongArray::JLongArray(Env& env, const jsize size) { // Allocate an Array with reserved size; obj = env.env->NewLongArray(size); } - JFloatArray::JFloatArray(Env& env, const jsize size) : JArray() { + JFloatArray::JFloatArray(Env& env, const jsize size) { // Allocate an Array with reserved size; obj = env.env->NewFloatArray(size); } - JDoubleArray::JDoubleArray(Env& env, const jsize size) : JArray() { + JDoubleArray::JDoubleArray(Env& env, const jsize size) { // Allocate an Array with reserved size; obj = env.env->NewDoubleArray(size); } diff --git a/src/jni/types.h b/src/jni/types.h index 8339206a5..3130d61fa 100644 --- a/src/jni/types.h +++ b/src/jni/types.h @@ -13,7 +13,7 @@ namespace jni { class JValue { public: - jvalue value; + jvalue value{}; JValue(JObject obj); diff --git a/src/jvm_wrapper/bridge/callable_bridge.cpp b/src/jvm_wrapper/bridge/callable_bridge.cpp index e9b0d1e6d..7137f0d83 100644 --- a/src/jvm_wrapper/bridge/callable_bridge.cpp +++ b/src/jvm_wrapper/bridge/callable_bridge.cpp @@ -4,7 +4,8 @@ #include "constraints.h" #include "jvm_wrapper/kotlin_callable_custom.h" #include "jvm_wrapper/memory/transfer_context.h" -#include "variant_allocator.h" + +#include using namespace bridges; @@ -12,21 +13,36 @@ uintptr_t CallableBridge::engine_call_constructor(JNIEnv* p_raw_env, jobject p_i return reinterpret_cast(VariantAllocator::alloc(Callable())); } -uintptr_t CallableBridge::engine_call_constructor_object_string_name(JNIEnv* p_raw_env, jobject p_instance) { +uintptr_t CallableBridge::engine_call_constructor_object_string_name(JNIEnv * p_raw_env, jobject p_instance, jlong object_ptr, jlong method_name_ptr) { + Object* obj = reinterpret_cast(object_ptr); + StringName* name = reinterpret_cast(method_name_ptr); + return reinterpret_cast(VariantAllocator::alloc(Callable(obj, *name))); +} + +uintptr_t CallableBridge::engine_call_constructor_lambda_callable(JNIEnv* p_raw_env, jobject, jobject p_lambda_container, jint p_variant_type_ordinal, jint p_hash_code) { jni::Env env {p_raw_env}; - Variant args[2] = {}; - TransferContext::get_instance().read_args(env, args); - return reinterpret_cast(VariantAllocator::alloc(Callable(args[0].operator Object*(), args[1].operator StringName()))); + return reinterpret_cast(VariantAllocator::alloc(Callable( + memnew(JvmCallableCustom(env, p_lambda_container, static_cast(p_variant_type_ordinal), p_hash_code, false)) + ))); } -uintptr_t CallableBridge::engine_call_constructor_kt_custom_callable(JNIEnv* p_raw_env, jobject p_instance, - jobject p_kt_custom_callable_instance, - jint p_variant_type_ordinal, jint p_hash_code, - jboolean p_has_on_destroy) { +void CallableBridge::engine_call_constructor_cancellable(JNIEnv* p_raw_env, jobject p_instance, jobject p_kt_custom_callable_instance, jint p_variant_type_ordinal, jint p_hash_code) { jni::Env env {p_raw_env}; - return reinterpret_cast( - VariantAllocator::alloc(Callable(memnew(KotlinCallableCustom(env, p_kt_custom_callable_instance, static_cast(p_variant_type_ordinal), p_hash_code, p_has_on_destroy)))) - ); + + Variant args[1] = {}; + TransferContext::get_instance().read_args(env, args); + Signal signal = args[0].operator Signal(); + Callable callable {memnew( + JvmCallableCustom(env, p_kt_custom_callable_instance, static_cast(p_variant_type_ordinal), p_hash_code, true) + )}; + + Object* object = signal.get_object(); + if(Node* node = Object::cast_to(object)) { + // Nodes can only connect their signal in the main thread. + node->call_thread_safe(SNAME("connect"), callable, Object::CONNECT_ONE_SHOT); + } else { + signal.connect(callable, Object::CONNECT_ONE_SHOT); + } } uintptr_t CallableBridge::engine_call_copy_constructor(JNIEnv* p_raw_env, jobject p_instance) { @@ -51,16 +67,7 @@ void CallableBridge::engine_call_bind(JNIEnv* p_raw_env, jobject p_instance, jlo TransferContext::get_instance().write_return_value(env, result); } -void CallableBridge::engine_call_bindv(JNIEnv* p_raw_env, jobject p_instance, jlong p_raw_ptr) { - jni::Env env {p_raw_env}; - Variant args[1] = {}; - TransferContext::get_instance().read_args(env, args); - - Variant result {from_uint_to_ptr(p_raw_ptr)->bindv(args[0])}; - TransferContext::get_instance().write_return_value(env, result); -} - -void CallableBridge::engine_call_call(JNIEnv* p_raw_env, jobject p_instance, jlong p_raw_ptr) { +void CallableBridge::engine_call_call(JNIEnv* p_raw_env, jobject _, jlong p_raw_ptr) { jni::Env env {p_raw_env}; Variant args[MAX_FUNCTION_ARG_COUNT]; @@ -91,15 +98,6 @@ void CallableBridge::engine_call_call_deferred(JNIEnv* p_raw_env, jobject p_inst from_uint_to_ptr(p_raw_ptr)->call_deferredp(args_ptr, args_size); } -void CallableBridge::engine_call_callv(JNIEnv* p_raw_env, jobject p_instance, jlong p_raw_ptr) { - jni::Env env {p_raw_env}; - Variant args[1] = {}; - TransferContext::get_instance().read_args(env, args); - - Variant result {from_uint_to_ptr(p_raw_ptr)->callv(args[0])}; - TransferContext::get_instance().write_return_value(env, result); -} - void CallableBridge::engine_call_get_bound_arguments(JNIEnv* p_raw_env, jobject p_instance, jlong p_raw_ptr) { jni::Env env {p_raw_env}; @@ -208,4 +206,4 @@ void CallableBridge::engine_call_unbind(JNIEnv* p_raw_env, jobject p_instance, j TransferContext::get_instance().write_return_value(env, result); } -CallableBridge::~CallableBridge() = default; \ No newline at end of file +CallableBridge::~CallableBridge() = default; diff --git a/src/jvm_wrapper/bridge/callable_bridge.h b/src/jvm_wrapper/bridge/callable_bridge.h index 5c38885fb..e1648f3e2 100644 --- a/src/jvm_wrapper/bridge/callable_bridge.h +++ b/src/jvm_wrapper/bridge/callable_bridge.h @@ -4,20 +4,19 @@ #include "jvm_wrapper/jvm_singleton_wrapper.h" namespace bridges { - JVM_SINGLETON_WRAPPER(CallableBridge, "godot.core.NativeCallable$Bridge") { + JVM_SINGLETON_WRAPPER(CallableBridge, "godot.core.Callable$Bridge") { SINGLETON_CLASS(CallableBridge) // clang-format off INIT_JNI_BINDINGS( INIT_NATIVE_METHOD("engine_call_constructor", "()J", CallableBridge::engine_call_constructor) - INIT_NATIVE_METHOD("engine_call_constructor_object_string_name", "()J", CallableBridge::engine_call_constructor_object_string_name) - INIT_NATIVE_METHOD("engine_call_constructor_kt_custom_callable", "(Lgodot/core/LambdaCallable;IIZ)J", CallableBridge::engine_call_constructor_kt_custom_callable) + INIT_NATIVE_METHOD("engine_call_constructor_object_string_name", "(JJ)J", CallableBridge::engine_call_constructor_object_string_name) + INIT_NATIVE_METHOD("engine_call_constructor_lambda_callable", "(Lgodot/core/LambdaContainer;II)J", CallableBridge::engine_call_constructor_lambda_callable) + INIT_NATIVE_METHOD("engine_call_constructor_cancellable", "(Lgodot/core/LambdaContainer;II)V", CallableBridge::engine_call_constructor_cancellable) INIT_NATIVE_METHOD("engine_call_copy_constructor", "()J", CallableBridge::engine_call_copy_constructor) INIT_NATIVE_METHOD("engine_call_bind", "(J)V", CallableBridge::engine_call_bind) - INIT_NATIVE_METHOD("engine_call_bindv", "(J)V", CallableBridge::engine_call_bindv) INIT_NATIVE_METHOD("engine_call_call", "(J)V", CallableBridge::engine_call_call) INIT_NATIVE_METHOD("engine_call_call_deferred", "(J)V", CallableBridge::engine_call_call_deferred) - INIT_NATIVE_METHOD("engine_call_callv", "(J)V", CallableBridge::engine_call_callv) INIT_NATIVE_METHOD("engine_call_get_bound_arguments", "(J)V", CallableBridge::engine_call_get_bound_arguments) INIT_NATIVE_METHOD("engine_call_get_bound_arguments_count", "(J)V", CallableBridge::engine_call_get_bound_arguments_count) INIT_NATIVE_METHOD("engine_call_get_method", "(J)V", CallableBridge::engine_call_get_method) @@ -35,36 +34,41 @@ namespace bridges { // clang-format on public: - static uintptr_t engine_call_constructor(JNIEnv* p_raw_env, jobject p_instance); + static uintptr_t engine_call_constructor(JNIEnv * p_raw_env, jobject p_instance); + static uintptr_t engine_call_constructor_object_string_name(JNIEnv * p_raw_env, jobject p_instance, jlong object_ptr, jlong method_name_ptr); + static uintptr_t engine_call_constructor_lambda_callable( + JNIEnv * p_raw_env, + jobject p_instance, + jobject p_lambda_container, + jint p_variant_type_ordinal, + jint p_hash_code + ); + static void engine_call_constructor_cancellable( + JNIEnv * p_raw_env, + jobject p_instance, + jobject p_kt_custom_callable_instance, + jint p_variant_type_ordinal, + jint p_hash_code + ); + static uintptr_t engine_call_copy_constructor(JNIEnv * p_raw_env, jobject p_instance); - static uintptr_t engine_call_constructor_object_string_name(JNIEnv* p_raw_env, jobject p_instance); - - static uintptr_t engine_call_constructor_kt_custom_callable(JNIEnv* p_raw_env, jobject p_instance, - jobject p_kt_custom_callable_instance, - jint p_variant_type_ordinal, jint p_hash_code, - jboolean p_has_on_destroy); - - static uintptr_t engine_call_copy_constructor(JNIEnv* p_raw_env, jobject p_instance); - - static void engine_call_bind(JNIEnv* p_raw_env, jobject p_instance, jlong p_raw_ptr); - static void engine_call_bindv(JNIEnv* p_raw_env, jobject p_instance, jlong p_raw_ptr); - static void engine_call_call(JNIEnv* p_raw_env, jobject p_instance, jlong p_raw_ptr); - static void engine_call_call_deferred(JNIEnv* p_raw_env, jobject p_instance, jlong p_raw_ptr); - static void engine_call_callv(JNIEnv* p_raw_env, jobject p_instance, jlong p_raw_ptr); - static void engine_call_get_bound_arguments(JNIEnv* p_raw_env, jobject p_instance, jlong p_raw_ptr); - static void engine_call_get_bound_arguments_count(JNIEnv* p_raw_env, jobject p_instance, jlong p_raw_ptr); - static void engine_call_get_method(JNIEnv* p_raw_env, jobject p_instance, jlong p_raw_ptr); - static void engine_call_get_object(JNIEnv* p_raw_env, jobject p_instance, jlong p_raw_ptr); - static void engine_call_get_object_id(JNIEnv* p_raw_env, jobject p_instance, jlong p_raw_ptr); - static void engine_call_hash(JNIEnv* p_raw_env, jobject p_instance, jlong p_raw_ptr); - static void engine_call_is_custom(JNIEnv* p_raw_env, jobject p_instance, jlong p_raw_ptr); - static void engine_call_is_null(JNIEnv* p_raw_env, jobject p_instance, jlong p_raw_ptr); - static void engine_call_is_standard(JNIEnv* p_raw_env, jobject p_instance, jlong p_raw_ptr); - static void engine_call_is_valid(JNIEnv* p_raw_env, jobject p_instance, jlong p_raw_ptr); - static void engine_call_rpc(JNIEnv* p_raw_env, jobject p_instance, jlong p_raw_ptr); - static void engine_call_rpc_id(JNIEnv* p_raw_env, jobject p_instance, jlong p_raw_ptr); - static void engine_call_unbind(JNIEnv* p_raw_env, jobject p_instance, jlong p_raw_ptr); + static void engine_call_bind(JNIEnv * p_raw_env, jobject p_instance, jlong p_raw_ptr); + static void engine_call_call(JNIEnv * p_raw_env, jobject p_instance, jlong p_raw_ptr); + static void engine_call_call_deferred(JNIEnv * p_raw_env, jobject p_instance, jlong p_raw_ptr); + static void engine_call_get_bound_arguments(JNIEnv * p_raw_env, jobject p_instance, jlong p_raw_ptr); + static void engine_call_get_bound_arguments_count(JNIEnv * p_raw_env, jobject p_instance, jlong p_raw_ptr); + static void engine_call_get_method(JNIEnv * p_raw_env, jobject p_instance, jlong p_raw_ptr); + static void engine_call_get_object(JNIEnv * p_raw_env, jobject p_instance, jlong p_raw_ptr); + static void engine_call_get_object_id(JNIEnv * p_raw_env, jobject p_instance, jlong p_raw_ptr); + static void engine_call_hash(JNIEnv * p_raw_env, jobject p_instance, jlong p_raw_ptr); + static void engine_call_is_custom(JNIEnv * p_raw_env, jobject p_instance, jlong p_raw_ptr); + static void engine_call_is_null(JNIEnv * p_raw_env, jobject p_instance, jlong p_raw_ptr); + static void engine_call_is_standard(JNIEnv * p_raw_env, jobject p_instance, jlong p_raw_ptr); + static void engine_call_is_valid(JNIEnv * p_raw_env, jobject p_instance, jlong p_raw_ptr); + static void engine_call_rpc(JNIEnv * p_raw_env, jobject p_instance, jlong p_raw_ptr); + static void engine_call_rpc_id(JNIEnv * p_raw_env, jobject p_instance, jlong p_raw_ptr); + static void engine_call_unbind(JNIEnv * p_raw_env, jobject p_instance, jlong p_raw_ptr); }; -}// namespace bridge +} // namespace bridges -#endif// GODOT_JVM_CALLABLE_BRIDGE_H +#endif // GODOT_JVM_CALLABLE_BRIDGE_H diff --git a/src/jvm_wrapper/bridge/lambda_callable_bridge.cpp b/src/jvm_wrapper/bridge/lambda_callable_bridge.cpp deleted file mode 100644 index 4489954d9..000000000 --- a/src/jvm_wrapper/bridge/lambda_callable_bridge.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "lambda_callable_bridge.h" - -#include "jvm_wrapper/kotlin_callable_custom.h" - -using namespace bridges; - -uintptr_t LambdaCallableBridge::wrap_in_custom_callable(JNIEnv* p_raw_env, jobject p_instance, - jobject p_kt_custom_callable_instance, jint p_variant_type_ordinal, - jint p_hash_code, jboolean p_has_on_destroy) { - jni::Env env {p_raw_env}; - return reinterpret_cast( - memnew(KotlinCallableCustom(env, p_kt_custom_callable_instance, static_cast(p_variant_type_ordinal), p_hash_code, p_has_on_destroy)) - ); -} - -LambdaCallableBridge::~LambdaCallableBridge() = default; diff --git a/src/jvm_wrapper/bridge/lambda_callable_bridge.h b/src/jvm_wrapper/bridge/lambda_callable_bridge.h deleted file mode 100644 index fb95805e1..000000000 --- a/src/jvm_wrapper/bridge/lambda_callable_bridge.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef GODOT_JVM_LAMBDA_CALLABLE_BRIDGE_H -#define GODOT_JVM_LAMBDA_CALLABLE_BRIDGE_H - -#include "jvm_wrapper/jvm_singleton_wrapper.h" - -namespace bridges { - JVM_SINGLETON_WRAPPER(LambdaCallableBridge, "godot.core.LambdaCallable$Bridge") { - SINGLETON_CLASS(LambdaCallableBridge) - - // clang-format off - INIT_JNI_BINDINGS( - INIT_NATIVE_METHOD("wrap_in_custom_callable", "(Lgodot/core/LambdaCallable;IIZ)J", LambdaCallableBridge::wrap_in_custom_callable) - ) - // clang-format on - - public: - static uintptr_t wrap_in_custom_callable(JNIEnv* p_raw_env, jobject p_instance, jobject p_kt_custom_callable_instance, jint p_variant_type_ordinal, jint p_hash_code, jboolean p_has_on_destroy); - }; -} - - -#endif// GODOT_JVM_LAMBDA_CALLABLE_BRIDGE_H diff --git a/src/jvm_wrapper/kotlin_callable_custom.cpp b/src/jvm_wrapper/kotlin_callable_custom.cpp index 7f4b81662..af25552ec 100644 --- a/src/jvm_wrapper/kotlin_callable_custom.cpp +++ b/src/jvm_wrapper/kotlin_callable_custom.cpp @@ -1,13 +1,16 @@ #include "kotlin_callable_custom.h" -#include "jvm_wrapper/memory/transfer_context.h" + #include "gd_kotlin.h" +#include "jvm_wrapper/memory/transfer_context.h" -void LambdaCallable::invoke(jni::Env& p_env, const Variant** p_args, int args_count, Variant& r_ret) const { - TransferContext& transfer_context{TransferContext::get_instance()}; +void LambdaContainer::invoke(jni::Env& p_env, const Variant** p_args, int args_count, Variant& r_ret) const { + TransferContext& transfer_context {TransferContext::get_instance()}; transfer_context.write_args(p_env, p_args, args_count); + has_been_called = true; + if (has_return_value) { - jni::JObject ret{wrapped.call_object_method(p_env, INVOKE_WITH_RETURN)}; + jni::JObject ret {wrapped.call_object_method(p_env, INVOKE_WITH_RETURN)}; transfer_context.read_return_value(p_env, r_ret); ret.delete_local_ref(p_env); @@ -15,88 +18,68 @@ void LambdaCallable::invoke(jni::Env& p_env, const Variant** p_args, int args_co } wrapped.call_void_method(p_env, INVOKE_NO_RETURN); - - has_been_called = true; -} - -void LambdaCallable::on_destroy(jni::Env& p_env) const { - if (!has_on_cancel || has_been_called) { - return; - } - - wrapped.call_void_method(p_env, ON_CANCEL); } -int LambdaCallable::get_hash_code() const { +int LambdaContainer::get_hash_code() const { return hash_code; } -bool LambdaCallable::equals(const LambdaCallable& other) const { - jni::Env env{jni::Jvm::current_env()}; +bool LambdaContainer::equals(const LambdaContainer& other) const { + jni::Env env {jni::Jvm::current_env()}; return wrapped.is_same_object(env, other.wrapped); } -LambdaCallable::LambdaCallable(jni::Env& p_env, jni::JObject p_wrapped, Variant::Type return_type, int p_hash_code, - bool p_has_on_cancel) : JvmInstanceWrapper(p_env, p_wrapped) { - has_return_value = return_type != Variant::NIL; +LambdaContainer::LambdaContainer(jni::Env& p_env, jni::JObject p_wrapped, Variant::Type return_type, int p_hash_code, bool p_has_on_cancel) : + JvmInstanceWrapper(p_env, p_wrapped), + hash_code {p_hash_code}, + has_return_value {return_type != Variant::NIL}, + has_on_cancel {p_has_on_cancel}, + has_been_called {false} {} - hash_code = p_hash_code; - has_on_cancel = p_has_on_cancel; - has_been_called = false; -} +LambdaContainer::~LambdaContainer() { + if (!has_on_cancel || has_been_called) { return; } + jni::Env env {jni::Jvm::current_env()}; + wrapped.call_void_method(env, CANCEL); +} -void KotlinCallableCustom::call(const Variant** p_arguments, int p_argcount, Variant& r_return_value, - Callable::CallError& r_call_error) const { - jni::Env env{jni::Jvm::current_env()}; - kt_callable.invoke(env, p_arguments, p_argcount, r_return_value); +void JvmCallableCustom::call(const Variant** p_arguments, int p_argcount, Variant& r_return_value, Callable::CallError& r_call_error) const { + jni::Env env {jni::Jvm::current_env()}; + lambda.invoke(env, p_arguments, p_argcount, r_return_value); } -uint32_t KotlinCallableCustom::hash() const { - return kt_callable.get_hash_code(); +uint32_t JvmCallableCustom::hash() const { + return lambda.get_hash_code(); } -String KotlinCallableCustom::get_as_text() const { - return "KotlinCallableCustom::invoke"; +String JvmCallableCustom::get_as_text() const { + return "JvmCallableCustom::invoke"; } -ObjectID KotlinCallableCustom::get_object() const { +ObjectID JvmCallableCustom::get_object() const { return GDKotlin::get_instance().get_callable_middleman()->get_instance_id(); } -CallableCustom::CompareEqualFunc KotlinCallableCustom::get_compare_equal_func() const { - return &KotlinCallableCustom::compare_equal; +CallableCustom::CompareEqualFunc JvmCallableCustom::get_compare_equal_func() const { + return &JvmCallableCustom::compare_equal; } -CallableCustom::CompareLessFunc KotlinCallableCustom::get_compare_less_func() const { - return &KotlinCallableCustom::compare_less; +CallableCustom::CompareLessFunc JvmCallableCustom::get_compare_less_func() const { + return &JvmCallableCustom::compare_less; } -bool KotlinCallableCustom::compare_equal(const CallableCustom* p_a, const CallableCustom* p_b) { - auto a{dynamic_cast(p_a)}; - auto b{dynamic_cast(p_b)}; - - if (!a || !b) { - return false; - } +bool JvmCallableCustom::compare_equal(const CallableCustom* p_a, const CallableCustom* p_b) { + // Function only called by Godot when both callable are confirmed to be the same custom type. + // Therefore, those 2 pointers are guaranteed to be instances of this class. + auto a {reinterpret_cast(p_a)}; + auto b {reinterpret_cast(p_b)}; - return a->kt_callable.equals(b->kt_callable); + return a->lambda.equals(b->lambda); } -bool KotlinCallableCustom::compare_less(const CallableCustom* p_a, const CallableCustom* p_b) { +bool JvmCallableCustom::compare_less(const CallableCustom* p_a, const CallableCustom* p_b) { return !compare_equal(p_a, p_b) && p_a < p_b; } -KotlinCallableCustom::KotlinCallableCustom(jni::Env& p_env, jni::JObject p_wrapped, Variant::Type return_type, - int p_hash_code, bool p_has_on_destroy) : CallableCustom(), - kt_callable(p_env, p_wrapped, - return_type, - p_hash_code, - p_has_on_destroy) { - -} - -KotlinCallableCustom::~KotlinCallableCustom() { - jni::Env env{jni::Jvm::current_env()}; - kt_callable.on_destroy(env); -} +JvmCallableCustom::JvmCallableCustom(jni::Env& p_env, jni::JObject p_wrapped, Variant::Type return_type, int p_hash_code, bool p_has_on_destroy) : + lambda(p_env, p_wrapped, return_type, p_hash_code, p_has_on_destroy) {} \ No newline at end of file diff --git a/src/jvm_wrapper/kotlin_callable_custom.h b/src/jvm_wrapper/kotlin_callable_custom.h index e6d32601c..9544ccbe5 100644 --- a/src/jvm_wrapper/kotlin_callable_custom.h +++ b/src/jvm_wrapper/kotlin_callable_custom.h @@ -4,33 +4,28 @@ #include "jvm_wrapper/jvm_instance_wrapper.h" #include "core/variant/callable.h" -JVM_INSTANCE_WRAPPER(LambdaCallable, "godot.core.LambdaCallable") { - JVM_CLASS(LambdaCallable) - // clang-format off +JVM_INSTANCE_WRAPPER(LambdaContainer, "godot.core.LambdaContainer") { + JVM_CLASS(LambdaContainer) + // clang-format off JNI_VOID_METHOD(INVOKE_NO_RETURN) JNI_OBJECT_METHOD(INVOKE_WITH_RETURN) - JNI_INT_METHOD(GET_RETURN_VARIANT_TYPE) - JNI_INT_METHOD(HASH_CODE) - JNI_VOID_METHOD(ON_CANCEL) + JNI_VOID_METHOD(CANCEL) INIT_JNI_BINDINGS( - INIT_JNI_METHOD(INVOKE_NO_RETURN, "invokeNoReturn", "()V") + INIT_JNI_METHOD(INVOKE_NO_RETURN, "invoke", "()V") INIT_JNI_METHOD(INVOKE_WITH_RETURN, "invokeWithReturn", "()Ljava/lang/Object;") - INIT_JNI_METHOD(GET_RETURN_VARIANT_TYPE, "getReturnVariantType", "()I") - INIT_JNI_METHOD(HASH_CODE, "hashCode", "()I") - INIT_JNI_METHOD(ON_CANCEL, "onCancel", "()V") + INIT_JNI_METHOD(CANCEL, "cancel", "()V") ) - // clang-format on public: void invoke(jni::Env& p_env, const Variant** p_args, int args_count, Variant& r_ret) const; - void on_destroy(jni::Env& p_env) const; int get_hash_code() const; - bool equals(const LambdaCallable& other) const; + bool equals(const LambdaContainer& other) const; - LambdaCallable(jni::Env& p_env, jni::JObject p_wrapped, Variant::Type return_type, int p_hash_code, bool p_has_on_cancel); + LambdaContainer(jni::Env& p_env, jni::JObject p_wrapped, Variant::Type return_type, int p_hash_code, bool p_has_on_cancel); + ~LambdaContainer(); private: int hash_code; @@ -39,7 +34,7 @@ JVM_INSTANCE_WRAPPER(LambdaCallable, "godot.core.LambdaCallable") { mutable bool has_been_called; }; -class KotlinCallableCustom : public CallableCustom { +class JvmCallableCustom : public CallableCustom { public: void call(const Variant** p_arguments, int p_argcount, Variant& r_return_value, Callable::CallError& r_call_error) const override; @@ -49,11 +44,11 @@ class KotlinCallableCustom : public CallableCustom { CompareLessFunc get_compare_less_func() const override; ObjectID get_object() const override; - KotlinCallableCustom(jni::Env& p_env, jni::JObject p_wrapped, Variant::Type return_type, int p_hash_code, bool p_has_on_destroy); - ~KotlinCallableCustom(); + JvmCallableCustom(jni::Env& p_env, jni::JObject p_wrapped, Variant::Type return_type, int p_hash_code, bool p_has_on_destroy); + ~JvmCallableCustom() = default; private: - LambdaCallable kt_callable; + LambdaContainer lambda; static bool compare_equal(const CallableCustom* p_a, const CallableCustom* p_b); static bool compare_less(const CallableCustom* p_a, const CallableCustom* p_b); diff --git a/src/jvm_wrapper/memory/transfer_context.cpp b/src/jvm_wrapper/memory/transfer_context.cpp index 6b3db4dee..81523ce55 100644 --- a/src/jvm_wrapper/memory/transfer_context.cpp +++ b/src/jvm_wrapper/memory/transfer_context.cpp @@ -97,8 +97,8 @@ void TransferContext::icall(JNIEnv* rawEnv, jobject instance, jlong j_ptr, jlong } const Variant& ret_value {method_bind->call(ptr, args_ptr, args_size, r_error)}; - buffer->rewind(); + VariantToBuffer::write_variant(ret_value, buffer); } else { Variant* args {variant_args + stack_offset}; diff --git a/src/kt_variant.h b/src/kt_variant.h index ca4ead8fc..1fb491499 100644 --- a/src/kt_variant.h +++ b/src/kt_variant.h @@ -237,14 +237,6 @@ class BufferToVariant { return Variant(Signal(object, name)); } - static Variant read_callable(SharedBuffer* byte_buffer) { - bool is_custom {static_cast(decode_uint32(byte_buffer->get_cursor()))}; - byte_buffer->increment_position(BOOL_SIZE); - - if (is_custom) { return Callable(read_pointer(byte_buffer)); } - - return *read_pointer(byte_buffer); - } public: @@ -281,7 +273,7 @@ class BufferToVariant { &BufferToVariant::read_native_core_type, &BufferToVariant::read_core_type, &BufferToVariant::read_object, - &BufferToVariant::read_callable, + &BufferToVariant::read_native_core_type, &BufferToVariant::read_signal, &BufferToVariant::read_native_core_type, &BufferToVariant::read_native_core_type, diff --git a/src/lifecycle/jvm_manager.cpp b/src/lifecycle/jvm_manager.cpp index dea3def6e..d3b6e547a 100644 --- a/src/lifecycle/jvm_manager.cpp +++ b/src/lifecycle/jvm_manager.cpp @@ -4,7 +4,6 @@ #include "jvm_wrapper/bridge/callable_bridge.h" #include "jvm_wrapper/bridge/dictionary_bridge.h" #include "jvm_wrapper/bridge/godot_print_bridge.h" -#include "jvm_wrapper/bridge/lambda_callable_bridge.h" #include "jvm_wrapper/bridge/node_path_bridge.h" #include "jvm_wrapper/bridge/packed_array_bridge.h" #include "jvm_wrapper/bridge/packed_byte_array_bridge.h" @@ -44,6 +43,7 @@ CreateJavaVM get_create_jvm_function(void* lib_handle) { #else // Sanity check in case we mess up preprocessors JVM_DEV_ASSERT(false, "Current configuration doesn't provide a way to create a JVM!"); + return nullptr; #endif } @@ -105,14 +105,13 @@ bool JvmManager::initialize_jvm_wrappers(jni::Env& p_env, ClassLoader* class_loa && KtFunctionInfo::initialize(p_env, class_loader) && KtFunction::initialize(p_env, class_loader) && KtClass::initialize(p_env, class_loader) - && LambdaCallable::initialize(p_env, class_loader) + && LambdaContainer::initialize(p_env, class_loader) && TransferContext::initialize(p_env, class_loader) && TypeManager::initialize(p_env, class_loader) && LongStringQueue::initialize(p_env, class_loader) && MemoryManager::initialize(p_env, class_loader) && bridges::GodotPrintBridge::initialize(p_env, class_loader) && bridges::CallableBridge::initialize(p_env, class_loader) - && bridges::LambdaCallableBridge::initialize(p_env, class_loader) && bridges::DictionaryBridge::initialize(p_env, class_loader) && bridges::StringNameBridge::initialize(p_env, class_loader) && bridges::NodePathBridge::initialize(p_env, class_loader) @@ -142,7 +141,6 @@ void JvmManager::finalize_jvm_wrappers(jni::Env& p_env, ClassLoader* class_loade MemoryManager::finalize(p_env, class_loader); bridges::GodotPrintBridge::finalize(p_env, class_loader); bridges::CallableBridge::finalize(p_env, class_loader); - bridges::LambdaCallableBridge::finalize(p_env, class_loader); bridges::DictionaryBridge::finalize(p_env, class_loader); bridges::StringNameBridge::finalize(p_env, class_loader); bridges::NodePathBridge::finalize(p_env, class_loader); @@ -157,6 +155,7 @@ void JvmManager::finalize_jvm_wrappers(jni::Env& p_env, ClassLoader* class_loade bridges::PackedVector2ArrayBridge::finalize(p_env, class_loader); bridges::PackedVector3ArrayBridge::finalize(p_env, class_loader); bridges::PackedVector4ArrayBridge::finalize(p_env, class_loader); + LambdaContainer::finalize(p_env, class_loader); KtObject::finalize(p_env, class_loader); KtPropertyInfo::finalize(p_env, class_loader); KtProperty::finalize(p_env, class_loader); @@ -170,8 +169,6 @@ void JvmManager::finalize_jvm_wrappers(jni::Env& p_env, ClassLoader* class_loade void JvmManager::close_jvm() { #if defined DYNAMIC_JVM || defined STATIC_JVM - //TODO: Remove the return jvm when https://github.com/godotengine/godot/issues/95809 is resolved - return; JVM_LOG_VERBOSE("Shutting down JVM ..."); jni::Jvm::destroy(); #endif diff --git a/src/lifecycle/jvm_user_configuration.cpp b/src/lifecycle/jvm_user_configuration.cpp index ed8244df9..03edf7f02 100644 --- a/src/lifecycle/jvm_user_configuration.cpp +++ b/src/lifecycle/jvm_user_configuration.cpp @@ -278,9 +278,11 @@ void JvmUserConfiguration::parse_command_line(const List& args, HashMap< configuration_map[JVM_ARGUMENTS_CMD_IDENTIFIER] = arr; } +#ifdef DEV_ENABLED for (const auto& map_element : configuration_map) { JVM_DEV_VERBOSE("Value for commandline argument: %s -> %s", map_element.key, map_element.value); } +#endif } }