diff --git a/harness/tests/scripts/godot/tests/Invocation.gdj b/harness/tests/scripts/godot/tests/Invocation.gdj index 55a59cb58a..88c84dabf8 100644 --- a/harness/tests/scripts/godot/tests/Invocation.gdj +++ b/harness/tests/scripts/godot/tests/Invocation.gdj @@ -6,20 +6,20 @@ fqName = godot.tests.Invocation relativeSourcePath = src/main/kotlin/godot/tests/Invocation.kt baseType = Node3D supertypes = [ - godot.Node3D, + godot.Node3D, godot.Node, godot.Object, godot.core.KtObject, kotlin.Any ] signals = [ - no_param, + no_param, one_param, two_param, signal_with_multiple_targets ] properties = [ - button, + button, enum_list, vector_list, enum_list_mutable, @@ -78,7 +78,7 @@ properties = [ array ] functions = [ - target_function_one, + target_function_one, target_function_two, int_value, long_value, @@ -171,4 +171,4 @@ functions = [ nullable_string_is_null, nullable_return_type, create_variant_array_of_user_type -] \ No newline at end of file +] diff --git a/harness/tests/scripts/godot/tests/LambdaCallableTest.gdj b/harness/tests/scripts/godot/tests/LambdaCallableTest.gdj new file mode 100644 index 0000000000..4178cad6dc --- /dev/null +++ b/harness/tests/scripts/godot/tests/LambdaCallableTest.gdj @@ -0,0 +1,30 @@ +// THIS FILE IS GENERATED! DO NOT EDIT OR DELETE IT. EDIT OR DELETE THE ASSOCIATED SOURCE CODE FILE INSTEAD +// Note: You can however freely move this file inside your godot project if you want. Keep in mind however, that if you rename the originating source code file, this file will be deleted and regenerated as a new file instead of being updated! Other modifications to the source file however, will result in this file being updated. + +registeredName = LambdaCallableTest +fqName = godot.tests.LambdaCallableTest +relativeSourcePath = src/main/kotlin/godot/tests/LambdaCallableTest.kt +baseType = Node +supertypes = [ + godot.Node, + godot.Object, + godot.core.KtObject, + kotlin.Any +] +signals = [ + signal_no_param, + signal_with_params +] +properties = [ + has_signal_no_param_been_triggered, + signal_string, + signal_long, + signal_node, + kt_callable, + kt_callable_string +] +functions = [ + _ready, + emit_signal_no_param, + emit_signal_with_param +] \ No newline at end of file diff --git a/harness/tests/src/main/java/godot/tests/JavaTestClass.java b/harness/tests/src/main/java/godot/tests/JavaTestClass.java index 010efa31a8..5ed958c066 100644 --- a/harness/tests/src/main/java/godot/tests/JavaTestClass.java +++ b/harness/tests/src/main/java/godot/tests/JavaTestClass.java @@ -3,7 +3,7 @@ import godot.Button; import godot.Node; import godot.annotation.*; -import godot.core.Callable; +import godot.core.NativeCallable; import godot.core.StringNameUtils; import godot.signals.Signal; import godot.signals.Signal2; @@ -70,7 +70,7 @@ public String greeting() { public void connectAndTriggerSignal() { connect( StringNameUtils.asStringName("test_signal"), - new Callable(this, StringNameUtils.asStringName("signal_callback")), + new NativeCallable(this, StringNameUtils.asStringName("signal_callback")), (int) ConnectFlags.CONNECT_ONE_SHOT.getId() ); emitSignal(StringNameUtils.asStringName("test_signal")); diff --git a/harness/tests/src/main/kotlin/godot/tests/Invocation.kt b/harness/tests/src/main/kotlin/godot/tests/Invocation.kt index d8461843e6..d12c362750 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.core.dictionaryOf import godot.core.variantArrayOf import godot.extensions.getNodeAs import godot.registration.Range +import godot.signals.connect import godot.signals.signal import godot.tests.subpackage.OtherScript import godot.util.RealT @@ -407,6 +408,10 @@ class Invocation : Node3D() { oneParam.connect(invocation, OtherScript::hookOneParam) twoParam.connect(invocation, OtherScript::hookTwoParam) + noParam.connect { println("noParam signal emitted") } + oneParam.connect { b -> println("oneParam signal emitted with $b") } + twoParam.connect { p0, p1 -> println("twoParam signal emitted with $p0 and $p1") } + signalWithMultipleTargets.connect(this, Invocation::targetFunctionOne) signalWithMultipleTargets.connect(this, Invocation::targetFunctionTwo) diff --git a/harness/tests/src/main/kotlin/godot/tests/LambdaCallableTest.kt b/harness/tests/src/main/kotlin/godot/tests/LambdaCallableTest.kt new file mode 100644 index 0000000000..897b4998e8 --- /dev/null +++ b/harness/tests/src/main/kotlin/godot/tests/LambdaCallableTest.kt @@ -0,0 +1,61 @@ +package godot.tests + +import godot.Node +import godot.annotation.RegisterClass +import godot.annotation.RegisterFunction +import godot.annotation.RegisterProperty +import godot.annotation.RegisterSignal +import godot.core.callable.asCallable +import godot.signals.connect +import godot.signals.signal + +@RegisterClass +class LambdaCallableTest : Node() { + + @RegisterSignal + val signalNoParam by signal() + + @RegisterProperty + var hasSignalNoParamBeenTriggered = false + + @RegisterSignal + val signalWithParams by signal("str", "long", "node") + + @RegisterProperty + lateinit var signalString: String + + @RegisterProperty + var signalLong: Long = Long.MIN_VALUE + + @RegisterProperty + lateinit var signalNode: Node + + @RegisterProperty + var ktCallable = { str: String -> ktCallableString = str }.asCallable() + + @RegisterProperty + lateinit var ktCallableString: String + + @RegisterFunction + override fun _ready() { + signalNoParam.connect { + hasSignalNoParamBeenTriggered = true + } + + signalWithParams.connect { p0, p1, p2 -> + signalString = p0 + signalLong = p1 + signalNode = p2 + } + } + + @RegisterFunction + fun emitSignalNoParam() { + signalNoParam.emit() + } + + @RegisterFunction + fun emitSignalWithParam(str: String, long: Long, node: Node) { + signalWithParams.emit(str, long, node) + } +} \ No newline at end of file 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 b9b2ef2d81..3c760e7234 100644 --- a/harness/tests/src/main/kotlin/godot/tests/callable/CallableMethodBindTest.kt +++ b/harness/tests/src/main/kotlin/godot/tests/callable/CallableMethodBindTest.kt @@ -4,7 +4,7 @@ import godot.Node import godot.annotation.RegisterClass import godot.annotation.RegisterFunction import godot.annotation.RegisterProperty -import godot.core.Callable +import godot.core.NativeCallable import godot.core.VariantArray import godot.core.variantArrayOf import godot.global.GD @@ -16,22 +16,22 @@ class CallableMethodBindTest: Node() { @RegisterFunction fun callWithMethodWithAllBinds() { - Callable(this, CallableMethodBindTest::readySignalMethodBindTest).bind(1, 2, 3).call() + NativeCallable(this, CallableMethodBindTest::readySignalMethodBindTest).bind(1, 2, 3).call() } @RegisterFunction fun callWithMethodWithTwoBinds() { - Callable(this, CallableMethodBindTest::readySignalMethodBindTest).bind(2, 3).call(0) + NativeCallable(this, CallableMethodBindTest::readySignalMethodBindTest).bind(2, 3).call(0) } @RegisterFunction fun callWithMethodWithOneBind() { - Callable(this, CallableMethodBindTest::readySignalMethodBindTest).bind(3).call(0, 0) + NativeCallable(this, CallableMethodBindTest::readySignalMethodBindTest).bind(3).call(0, 0) } @RegisterFunction fun callWithMethodWithNoBind() { - Callable(this, CallableMethodBindTest::readySignalMethodBindTest).bind().call(0, 0, 0) + NativeCallable(this, CallableMethodBindTest::readySignalMethodBindTest).bind().call(0, 0, 0) } @RegisterFunction diff --git a/harness/tests/test/unit/test_lambda_callable.gd b/harness/tests/test/unit/test_lambda_callable.gd new file mode 100644 index 0000000000..db95058ba0 --- /dev/null +++ b/harness/tests/test/unit/test_lambda_callable.gd @@ -0,0 +1,36 @@ +extends "res://addons/gut/test.gd" + + +func test_signal_without_param(): + var lambda_callable_test_script = LambdaCallableTest.new() + get_tree().root.add_child(lambda_callable_test_script) + lambda_callable_test_script.emit_signal_no_param() + assert_true(lambda_callable_test_script.has_signal_no_param_been_triggered) + get_tree().root.remove_child(lambda_callable_test_script) + lambda_callable_test_script.free() + +func test_signal_with_param(): + var lambda_callable_test_script = LambdaCallableTest.new() + get_tree().root.add_child(lambda_callable_test_script) + + var expected_str = "expected" + var expected_int = randi() + var expected_node = lambda_callable_test_script + + lambda_callable_test_script.emit_signal_with_param(expected_str, expected_int, expected_node) + + assert_eq(lambda_callable_test_script.signal_string, expected_str) + assert_eq(lambda_callable_test_script.signal_long, expected_int) + assert_eq(lambda_callable_test_script.signal_node, expected_node) + get_tree().root.remove_child(lambda_callable_test_script) + lambda_callable_test_script.free() + +func test_kotlin_lambda_call_from_gdscript(): + var lambda_callable_test_script = LambdaCallableTest.new() + + var expected_str = "expected" + + lambda_callable_test_script.kt_callable.call(expected_str) + + assert_eq(lambda_callable_test_script.kt_callable_string, expected_str) + lambda_callable_test_script.free() diff --git a/kt/api-generator/src/main/kotlin/godot/codegen/extensions/TypedExtensions.kt b/kt/api-generator/src/main/kotlin/godot/codegen/extensions/TypedExtensions.kt index 3c4116c667..c5f83d79b5 100644 --- a/kt/api-generator/src/main/kotlin/godot/codegen/extensions/TypedExtensions.kt +++ b/kt/api-generator/src/main/kotlin/godot/codegen/extensions/TypedExtensions.kt @@ -15,34 +15,7 @@ import godot.codegen.traits.CastableTrait import godot.codegen.traits.NullableTrait import godot.codegen.traits.TypedTrait import godot.codegen.traits.WithDefaultValueTrait -import godot.tools.common.constants.GODOT_ARRAY -import godot.tools.common.constants.GODOT_DICTIONARY -import godot.tools.common.constants.GODOT_ERROR -import godot.tools.common.constants.GodotKotlinJvmTypes -import godot.tools.common.constants.GodotTypes -import godot.tools.common.constants.VARIANT_TYPE_ANY -import godot.tools.common.constants.VARIANT_TYPE_ARRAY -import godot.tools.common.constants.VARIANT_TYPE_BOOL -import godot.tools.common.constants.VARIANT_TYPE_DOUBLE -import godot.tools.common.constants.VARIANT_TYPE_LONG -import godot.tools.common.constants.VARIANT_TYPE_NIL -import godot.tools.common.constants.VARIANT_TYPE_NODE_PATH -import godot.tools.common.constants.VARIANT_TYPE_OBJECT -import godot.tools.common.constants.VARIANT_TYPE_PACKED_BYTE_ARRAY -import godot.tools.common.constants.VARIANT_TYPE_PACKED_COLOR_ARRAY -import godot.tools.common.constants.VARIANT_TYPE_PACKED_FLOAT_32_ARRAY -import godot.tools.common.constants.VARIANT_TYPE_PACKED_FLOAT_64_ARRAY -import godot.tools.common.constants.VARIANT_TYPE_PACKED_INT_32_ARRAY -import godot.tools.common.constants.VARIANT_TYPE_PACKED_INT_64_ARRAY -import godot.tools.common.constants.VARIANT_TYPE_PACKED_STRING_ARRAY -import godot.tools.common.constants.VARIANT_TYPE_PACKED_VECTOR2_ARRAY -import godot.tools.common.constants.VARIANT_TYPE_PACKED_VECTOR3_ARRAY -import godot.tools.common.constants.VARIANT_TYPE_STRING_NAME -import godot.tools.common.constants.VARIANT_TYPE__RID -import godot.tools.common.constants.godotApiPackage -import godot.tools.common.constants.godotCorePackage -import godot.tools.common.constants.signalPackage -import godot.tools.common.constants.variantTypePackage +import godot.tools.common.constants.* import java.util.* const val enumPrefix = "enum::" @@ -126,6 +99,7 @@ fun TypedTrait.getTypeClassName(): ClassTypeNameWrapper { type == GodotTypes.dictionary -> ClassTypeNameWrapper(GODOT_DICTIONARY) .parameterizedBy(ANY.copy(nullable = true), ANY.copy(nullable = true)) type == GodotTypes.variant -> ClassTypeNameWrapper(ANY) + type == GodotTypes.callable -> ClassTypeNameWrapper(GODOT_CALLABLE_BASE) isCoreType() -> ClassTypeNameWrapper(ClassName(godotCorePackage, type!!)) else -> ClassTypeNameWrapper(ClassName(godotApiPackage, type!!)) } @@ -167,20 +141,20 @@ val TypedTrait.jvmVariantTypeValue: ClassName } } -fun T.getDefaultValueKotlinString(): String? +fun T.getDefaultValueKotlinString(): Pair>? where T : WithDefaultValueTrait, T : NullableTrait, T : CastableTrait { val defaultValueString = defaultValue ?: return null return when { - nullable && defaultValue == "null" -> defaultValueString - type == GodotTypes.color -> "${GodotKotlinJvmTypes.color}($defaultValueString)" - type == GodotTypes.variant -> defaultValueString - type == GodotTypes.bool -> defaultValueString.lowercase(Locale.US) - type == GodotTypes.float && meta == GodotMeta.Float.float -> "${intToFloat(defaultValueString)}f" - type == GodotTypes.float -> intToFloat(defaultValueString) + nullable && defaultValue == "null" -> defaultValueString to arrayOf() + type == GodotTypes.color -> "${GodotKotlinJvmTypes.color}($defaultValueString)" to arrayOf() + type == GodotTypes.variant -> defaultValueString to arrayOf() + type == GodotTypes.bool -> defaultValueString.lowercase(Locale.US) to arrayOf() + type == GodotTypes.float && meta == GodotMeta.Float.float -> "${intToFloat(defaultValueString)}f" to arrayOf() + type == GodotTypes.float -> intToFloat(defaultValueString) to arrayOf() type == GodotTypes.stringName -> "${GodotKotlinJvmTypes.stringName}(".plus(defaultValueString.replace("&", "")) - .plus(")") + .plus(")") to arrayOf() type == GodotTypes.array || isTypedArray() -> if (defaultValueString.startsWith("Array")) { @@ -192,14 +166,15 @@ fun T.getDefaultValueKotlinString(): String? "$godotCorePackage.variantArrayOf(" .plus(defaultValueString.removePrefix("[").removeSuffix("]")) .plus(")") - } + } to arrayOf() type == GodotTypes.rect2 -> defaultValueString .replace(",", ".0,") - .replace(")", ".0)") + .replace(")", ".0)") to arrayOf() + + type == GodotTypes.callable -> "%T()" to arrayOf(GODOT_CALLABLE) type == GodotTypes.rid || - type == GodotTypes.callable || type == GodotTypes.dictionary || type == GodotTypes.transform2D || type == GodotTypes.transform3D || @@ -212,9 +187,9 @@ fun T.getDefaultValueKotlinString(): String? type == GodotTypes.packedInt64Array || type == GodotTypes.packedVector2Array || type == GodotTypes.packedVector3Array - -> "$type()" + -> "$type()" to arrayOf() - else -> defaultValueString + else -> defaultValueString to arrayOf() } } 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 89e112cec2..937ba2ae52 100644 --- a/kt/api-generator/src/main/kotlin/godot/codegen/generationEntry.kt +++ b/kt/api-generator/src/main/kotlin/godot/codegen/generationEntry.kt @@ -11,6 +11,7 @@ import godot.codegen.repositories.* import godot.codegen.repositories.impl.* import godot.codegen.services.* import godot.codegen.services.impl.* +import godot.tools.common.constants.Constraints import godot.tools.common.constants.GENERATED_COMMENT import java.io.File @@ -78,4 +79,7 @@ fun File.generateApiFrom(jsonSource: File, docsDir: File? = null) { .build() .writeTo(this) } + + KtCallableGenerationService().generate(Constraints.MAX_FUNCTION_ARG_COUNT).writeTo(this) + SignalGenerationService().generate(Constraints.MAX_FUNCTION_ARG_COUNT).writeTo(this) } diff --git a/kt/api-generator/src/main/kotlin/godot/codegen/services/IKtCallableGenerationService.kt b/kt/api-generator/src/main/kotlin/godot/codegen/services/IKtCallableGenerationService.kt new file mode 100644 index 0000000000..6b9fc423ec --- /dev/null +++ b/kt/api-generator/src/main/kotlin/godot/codegen/services/IKtCallableGenerationService.kt @@ -0,0 +1,7 @@ +package godot.codegen.services + +import com.squareup.kotlinpoet.FileSpec + +interface IKtCallableGenerationService { + fun generate(maxArgumentCount: Int): FileSpec +} \ No newline at end of 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 new file mode 100644 index 0000000000..a2bd1ca889 --- /dev/null +++ b/kt/api-generator/src/main/kotlin/godot/codegen/services/ISignalGenerationService.kt @@ -0,0 +1,7 @@ +package godot.codegen.services + +import com.squareup.kotlinpoet.FileSpec + +interface ISignalGenerationService { + fun generate(maxArgumentCount: Int): FileSpec +} \ No newline at end of file diff --git a/kt/api-generator/src/main/kotlin/godot/codegen/services/impl/GenerationService.kt b/kt/api-generator/src/main/kotlin/godot/codegen/services/impl/GenerationService.kt index e32cc1c388..94de547434 100644 --- a/kt/api-generator/src/main/kotlin/godot/codegen/services/impl/GenerationService.kt +++ b/kt/api-generator/src/main/kotlin/godot/codegen/services/impl/GenerationService.kt @@ -25,21 +25,7 @@ import godot.codegen.services.IEnumService import godot.codegen.services.IGenerationService import godot.codegen.traits.CallableTrait import godot.codegen.traits.addKdoc -import godot.tools.common.constants.CORE_TYPE_LOCAL_COPY -import godot.tools.common.constants.CORE_TYPE_HELPER -import godot.tools.common.constants.GENERATED_COMMENT -import godot.tools.common.constants.GODOT_BASE_TYPE -import godot.tools.common.constants.GodotKotlinJvmTypes -import godot.tools.common.constants.GodotTypes -import godot.tools.common.constants.KT_OBJECT -import godot.tools.common.constants.TRANSFER_CONTEXT -import godot.tools.common.constants.TYPE_MANAGER -import godot.tools.common.constants.VARIANT_TYPE_ANY -import godot.tools.common.constants.VARIANT_TYPE_LONG -import godot.tools.common.constants.godotApiPackage -import godot.tools.common.constants.godotCorePackage -import godot.tools.common.constants.godotUtilPackage -import godot.tools.common.constants.signalPackage +import godot.tools.common.constants.* import java.util.* private const val methodBindingsInnerClassName = "MethodBindings" @@ -682,8 +668,6 @@ class GenerationService( .build() private fun TypeSpec.Builder.generateTypesafeRpc() { - val camelToSnakeCaseUtilFunction = MemberName(godotUtilPackage, "camelToSnakeCase") - val asStringNameUtilFunction = MemberName(godotCorePackage, "asStringName") for (i in 0..10) { val kFunctionTypeParameters = mutableListOf() if (i != 0) { @@ -721,7 +705,7 @@ class GenerationService( templateString += ", $argParamName" } templateString += ")" - rpcFunSpec.addStatement(templateString, camelToSnakeCaseUtilFunction, asStringNameUtilFunction) + rpcFunSpec.addStatement(templateString, CAMEL_TO_SNAKE_CASE_UTIL_FUNCTION, AS_STRING_NAME_UTIL_FUNCTION) rpcFunSpec.addTypeVariable(TypeVariableName.invoke("FUNCTION", kFunctionClassName).copy(reified = true)) addFunction(rpcFunSpec.build()) @@ -794,13 +778,13 @@ class GenerationService( val appliedDefault = if ((argument.isEnum() || argument.isBitField()) && defaultValueKotlinCode != null) { enumService.findEnumValue( argumentTypeClassName, - defaultValueKotlinCode.toLong() + defaultValueKotlinCode.first.toLong() ).name } else { - defaultValueKotlinCode + defaultValueKotlinCode?.first } if (appliedDefault != null) { - parameterBuilder.defaultValue(appliedDefault) + parameterBuilder.defaultValue(appliedDefault, *defaultValueKotlinCode!!.second) // add @JvmOverloads annotation for java support if not already present val jvmOverloadAnnotationSpec = AnnotationSpec.builder(JvmOverloads::class.asClassName()).build() diff --git a/kt/api-generator/src/main/kotlin/godot/codegen/services/impl/KtCallableGenerationService.kt b/kt/api-generator/src/main/kotlin/godot/codegen/services/impl/KtCallableGenerationService.kt new file mode 100644 index 0000000000..2d3fe34691 --- /dev/null +++ b/kt/api-generator/src/main/kotlin/godot/codegen/services/impl/KtCallableGenerationService.kt @@ -0,0 +1,329 @@ +package godot.codegen.services.impl + +import com.squareup.kotlinpoet.* +import com.squareup.kotlinpoet.ParameterizedTypeName.Companion.parameterizedBy +import godot.codegen.services.IKtCallableGenerationService +import godot.tools.common.constants.* + +class KtCallableGenerationService : IKtCallableGenerationService { + override fun generate(maxArgumentCount: Int): FileSpec { + val callableFileSpec = FileSpec.builder(callablePackage, "KtCallables") + + for (argCount in 0 .. maxArgumentCount) { + val classBuilder = TypeSpec + .classBuilder(ClassName(callablePackage, "$KT_CALLABLE_NAME$argCount")) + .superclass( + KT_CALLABLE_CLASS_NAME + .parameterizedBy(returnTypeParameter) + ) + + val argumentRange = 0 ..< argCount + + classBuilder + .addSuperclassConstructorParameter( + VARIANT_TYPE_ARGUMENT_NAME + ) + + for (index in argumentRange) { + classBuilder.addSuperclassConstructorParameter("p${index}Type") + } + + val typeVariableNames = argumentRange + .map { + TypeVariableName("P$it") + } + + classBuilder + .addTypeVariables( + typeVariableNames + ) + .addTypeVariable(returnTypeParameter) + + val primaryConstructor = FunSpec.constructorBuilder() + + val lambdaTypeName = LambdaTypeName.get( + receiver = null, + parameters = typeVariableNames + .mapIndexed { index: Int, typeVariableName: TypeVariableName -> + ParameterSpec.builder("p$index", typeVariableName).build() + }, + returnType = returnTypeParameter + ) + + classBuilder + .addProperty( + PropertySpec + .builder( + FUNCTION_PARAMETER_NAME, + lambdaTypeName, + KModifier.PRIVATE + ) + .initializer(FUNCTION_PARAMETER_NAME) + .build() + ) + + val variantTypeClassName = ClassName( + godotCorePackage, + GodotKotlinJvmTypes.variantType + ) + + primaryConstructor + .addParameter( + ParameterSpec + .builder( + VARIANT_TYPE_ARGUMENT_NAME, + variantTypeClassName + ) + .build() + ) + + val variantTypeToBooleanTypeName = Pair::class + .asClassName() + .parameterizedBy( + variantTypeClassName, + BOOLEAN + ) + + for (arg in argumentRange) { + val typeProperty = "p${arg}Type" + + if (arg != argumentRange.last) { + classBuilder + .addProperty( + PropertySpec + .builder( + typeProperty, + variantTypeToBooleanTypeName, + KModifier.PRIVATE + ) + .initializer(typeProperty) + .build() + ) + } + + primaryConstructor + .addParameter( + ParameterSpec + .builder( + typeProperty, + variantTypeToBooleanTypeName + ) + .build() + ) + } + + primaryConstructor + .addParameter( + ParameterSpec + .builder( + FUNCTION_PARAMETER_NAME, + lambdaTypeName + ) + .build() + ) + + 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(callablePackage, "$KT_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 ..< removedTypeVariables)) { + append(",·p${index}Type") + } + + append(")·{·") + + for (index in (0 ..< removedTypeVariables)) { + if (index != 0) append(",·") + + append("p${index}:·%T") + } + + append("·->·$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 + } + + callableFileSpec.addType(classBuilder.build()) + + val variantMapperMember = MemberName(godotCorePackage, "variantMapper") + callableFileSpec.addFunction( + FunSpec.builder(CALLABLE_FUNCTION_NAME) + .addTypeVariables(typeVariableNames.map { it.copy(reified = true) }) + .addTypeVariable(returnTypeParameter.copy(reified = true)) + .addModifiers(KModifier.INLINE) + .addParameter( + ParameterSpec + .builder( + FUNCTION_PARAMETER_NAME, + lambdaTypeName + ) + .addModifiers(KModifier.NOINLINE) + .build() + ) + .addCode( + CodeBlock.of( + buildString { + append("return·$KT_CALLABLE_NAME$argCount(") + append("%M.getOrDefault(%T::class,·%T),·") + for (typeParameter in typeVariableNames) { + append("%M[%T::class]!!·to·%L,·") + } + append(FUNCTION_PARAMETER_NAME) + append(')') + }, + variantMapperMember, + returnTypeParameter, + VARIANT_TYPE_NIL, + *typeVariableNames + .flatMap { + listOf(variantMapperMember, it, true) + } + .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) + .addCode("return·$CALLABLE_FUNCTION_NAME(this)") + .build() + ) + } + + callableFileSpec.addAnnotation( + AnnotationSpec.builder(ClassName("kotlin", "Suppress")) + .addMember("\"PackageDirectoryMismatch\", \"UNCHECKED_CAST\"") + .build() + ) + + return callableFileSpec.build() + } + + companion object { + private const val FUNCTION_PARAMETER_NAME = "function" + private const val KT_CALLABLE_NAME = "KtCallable" + private const val CALLABLE_FUNCTION_NAME = "callable" + private const val VARIANT_TYPE_ARGUMENT_NAME = "variantType" + private val KT_CALLABLE_CLASS_NAME = ClassName(callablePackage, KT_CALLABLE_NAME) + private val returnTypeParameter = TypeVariableName("R", ANY.copy(nullable = true)) + } +} \ No newline at end of file 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 new file mode 100644 index 0000000000..53a24dc122 --- /dev/null +++ b/kt/api-generator/src/main/kotlin/godot/codegen/services/impl/SignalGenerationService.kt @@ -0,0 +1,259 @@ +package godot.codegen.services.impl + +import com.squareup.kotlinpoet.* +import com.squareup.kotlinpoet.ParameterizedTypeName.Companion.parameterizedBy +import godot.codegen.services.ISignalGenerationService +import godot.tools.common.constants.* +import kotlin.reflect.KCallable + +class SignalGenerationService : ISignalGenerationService { + override fun generate(maxArgumentCount: Int): FileSpec { + val signalFileSpec = FileSpec.builder(signalPackage, "Signals") + + val signalProviderObject = TypeSpec + .objectBuilder(ClassName(godotSignalsPackage, "SignalProvider")) + + val godotObjectBoundTypeVariable = TypeVariableName("T", GODOT_OBJECT) + val flagsParameter = ParameterSpec.builder(FLAGS_PARAMETER_NAME, INT) + .defaultValue("%L", 0) + .build() + + for (argCount in 0 .. maxArgumentCount) { + val argumentRange = 0 ..< argCount + + val typeVariableNames = argumentRange + .map { + TypeVariableName("P$it") + } + + val signalClassName = ClassName(signalPackage, "$SIGNAL_CLASS_NAME$argCount") + val signalTypeSpec = TypeSpec + .classBuilder(signalClassName) + .addTypeVariables(typeVariableNames) + .superclass(ClassName(signalPackage, SIGNAL_CLASS_NAME)) + + signalTypeSpec + .primaryConstructor( + FunSpec.constructorBuilder() + .addParameters( + listOf( + ParameterSpec.builder(INSTANCE_PARAMETER, GODOT_OBJECT).build(), + ParameterSpec.builder(NAME_PARAMETER, STRING).build() + ) + ) + .build() + ) + + signalTypeSpec + .addSuperclassConstructorParameter(INSTANCE_PARAMETER) + .addSuperclassConstructorParameter(NAME_PARAMETER) + + val genericParameters = typeVariableNames + .mapIndexed { index: Int, typeVariableName: TypeVariableName -> + ParameterSpec.builder("p$index", typeVariableName).build() + } + val lambdaTypeName = LambdaTypeName.get( + receiver = godotObjectBoundTypeVariable, + parameters = genericParameters, + returnType = UNIT + ) + + signalTypeSpec + .addFunctions( + listOf( + FunSpec.builder("emit") + .returns(UNIT) + .addParameters( + genericParameters + ) + .addCode( + CodeBlock.of( + buildString { + append("emitSignal(") + for (i in argumentRange) { + if (i != 0) append(",·") + + append("p$i") + } + append(')') + } + ) + ) + .build(), + + FunSpec.builder(CONNECT_METHOD_NAME) + .addTypeVariable(godotObjectBoundTypeVariable) + .addParameters( + listOf( + ParameterSpec.builder(TARGET_PARAMETER_NAME, godotObjectBoundTypeVariable).build(), + ParameterSpec.builder(METHOD_PARAMETER_NAME, lambdaTypeName).build(), + flagsParameter + ) + ) + .returns(GODOT_ERROR) + .addCode(generateConnectionCodeBlock()) + .build(), + + FunSpec.builder(DISCONNECT_METHOD_NAME) + .addTypeVariable(godotObjectBoundTypeVariable) + .addParameters( + listOf( + ParameterSpec.builder(TARGET_PARAMETER_NAME, godotObjectBoundTypeVariable).build(), + ParameterSpec.builder(METHOD_PARAMETER_NAME, lambdaTypeName).build() + ) + ) + .returns(UNIT) + .addCode(generateConnectionCodeBlock(true)) + .build() + ) + ) + + signalFileSpec.addType(signalTypeSpec.build()) + + val signalConnectExtensionBuilder = FunSpec.builder(CONNECT_METHOD_NAME) + + val signalConnectExtensionGenericParameters = ParameterSpec + .builder( + METHOD_PARAMETER_NAME, + LambdaTypeName.get( + parameters = genericParameters, + returnType = UNIT + ) + ) + + if (argCount != 0) { + signalConnectExtensionBuilder.addModifiers(KModifier.INLINE) + signalConnectExtensionGenericParameters.addModifiers(KModifier.NOINLINE) + } + + val signalClassNameWithTypeParameters = if (typeVariableNames.isEmpty()) { + signalClassName + } else { + signalClassName.parameterizedBy(*typeVariableNames.toTypedArray()) + } + signalFileSpec.addFunction( + signalConnectExtensionBuilder + .addTypeVariables( + typeVariableNames.map { it.copy(reified = true) } + ) + .receiver( + signalClassNameWithTypeParameters + ) + .addParameters( + listOf( + flagsParameter, + signalConnectExtensionGenericParameters.build() + ) + ) + .returns(GODOT_ERROR) + .addCode( + "return·$CONNECT_METHOD_NAME($METHOD_PARAMETER_NAME.%M(),·$FLAGS_PARAMETER_NAME)", + AS_CALLABLE_UTIL_FUNCTION + ) + .build() + ) + + val signalProviderFunction = FunSpec.builder(SIGNAL_FUNCTION_NAME) + + if (argCount != 0) { + signalProviderFunction.addAnnotation( + AnnotationSpec.builder(Suppress::class) + .addMember("\"UNUSED_PARAMETER\"") + .build() + ) + } + + signalProviderObject + .addFunction( + signalProviderFunction + .addTypeVariables(typeVariableNames) + .addParameters( + listOf( + ParameterSpec.builder(THIS_REF_PARAMETER_NAME, GODOT_OBJECT).build(), + ParameterSpec.builder(NAME_PARAMETER, STRING).build(), + *argumentRange + .map { + ParameterSpec.builder("p$it", STRING).build() + } + .toTypedArray() + ) + ) + .returns(signalClassNameWithTypeParameters) + .addCode( + "return·%T($THIS_REF_PARAMETER_NAME,·$NAME_PARAMETER)", + signalClassNameWithTypeParameters + ) + .addAnnotation(JvmStatic::class) + .build() + ) + + val signalDelegateFunction = FunSpec.builder(SIGNAL_FUNCTION_NAME) + + if (argCount != 0) { + signalDelegateFunction.addAnnotation( + AnnotationSpec.builder(Suppress::class).addMember("\"UNUSED_PARAMETER\"").build() + ) + } + + signalFileSpec + .addFunction( + signalDelegateFunction + .addTypeVariables(typeVariableNames) + .addParameters( + argumentRange + .map { + ParameterSpec.builder("p$it", STRING).build() + } + ) + .returns(signalDelegateProviderClassName.parameterizedBy(signalClassNameWithTypeParameters)) + .addCode( + CodeBlock.of( + "return·%T(::%T)", + signalDelegateProviderClassName, + signalClassName + ) + ) + .build() + ) + } + + signalFileSpec.addAnnotation( + AnnotationSpec.builder(ClassName("kotlin", "Suppress")) + .addMember("\"PackageDirectoryMismatch\"") + .build() + ) + + signalFileSpec.addType(signalProviderObject.build()) + + return signalFileSpec.build() + } + + companion object { + private const val SIGNAL_CLASS_NAME = "Signal" + private const val INSTANCE_PARAMETER = "instance" + private const val NAME_PARAMETER = "name" + 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 CONNECT_METHOD_NAME = "connect" + private const val DISCONNECT_METHOD_NAME = "disconnect" + private const val SIGNAL_FUNCTION_NAME = "signal" + + private val signalDelegateProviderClassName = ClassName(signalPackage, "SignalDelegateProvider") + + private fun generateConnectionCodeBlock(isDisconnect: Boolean = false): CodeBlock { + val methodName = if (isDisconnect) DISCONNECT_METHOD_NAME else CONNECT_METHOD_NAME + val flagsParameters = if (isDisconnect) "" else ",·$FLAGS_PARAMETER_NAME" + + return CodeBlock.of( + "return·$methodName(%T($TARGET_PARAMETER_NAME,·($METHOD_PARAMETER_NAME·as·%T<*>).name.%M().%M())$flagsParameters)", + GODOT_CALLABLE, + KCallable::class.asClassName(), + CAMEL_TO_SNAKE_CASE_UTIL_FUNCTION, + AS_STRING_NAME_UTIL_FUNCTION + ) + } + } +} \ No newline at end of file diff --git a/kt/entry-generation/godot-entry-generator/src/main/kotlin/godot/entrygenerator/ext/TypeExtensions.kt b/kt/entry-generation/godot-entry-generator/src/main/kotlin/godot/entrygenerator/ext/TypeExtensions.kt index 0eaef3eb93..ab8157838f 100644 --- a/kt/entry-generation/godot-entry-generator/src/main/kotlin/godot/entrygenerator/ext/TypeExtensions.kt +++ b/kt/entry-generation/godot-entry-generator/src/main/kotlin/godot/entrygenerator/ext/TypeExtensions.kt @@ -3,38 +3,7 @@ package godot.entrygenerator.ext import com.squareup.kotlinpoet.ClassName import com.squareup.kotlinpoet.TypeName import godot.entrygenerator.model.Type -import godot.tools.common.constants.GodotKotlinJvmTypes -import godot.tools.common.constants.GodotTypes -import godot.tools.common.constants.VARIANT_TYPE_AABB -import godot.tools.common.constants.VARIANT_TYPE_ANY -import godot.tools.common.constants.VARIANT_TYPE_ARRAY -import godot.tools.common.constants.VARIANT_TYPE_BOOL -import godot.tools.common.constants.VARIANT_TYPE_DOUBLE -import godot.tools.common.constants.VARIANT_TYPE_JVM_BYTE -import godot.tools.common.constants.VARIANT_TYPE_JVM_FLOAT -import godot.tools.common.constants.VARIANT_TYPE_JVM_INT -import godot.tools.common.constants.VARIANT_TYPE_LONG -import godot.tools.common.constants.VARIANT_TYPE_NIL -import godot.tools.common.constants.VARIANT_TYPE_NODE_PATH -import godot.tools.common.constants.VARIANT_TYPE_OBJECT -import godot.tools.common.constants.VARIANT_TYPE_PACKED_BYTE_ARRAY -import godot.tools.common.constants.VARIANT_TYPE_PACKED_COLOR_ARRAY -import godot.tools.common.constants.VARIANT_TYPE_PACKED_FLOAT_32_ARRAY -import godot.tools.common.constants.VARIANT_TYPE_PACKED_FLOAT_64_ARRAY -import godot.tools.common.constants.VARIANT_TYPE_PACKED_INT_32_ARRAY -import godot.tools.common.constants.VARIANT_TYPE_PACKED_INT_64_ARRAY -import godot.tools.common.constants.VARIANT_TYPE_PACKED_STRING_ARRAY -import godot.tools.common.constants.VARIANT_TYPE_PACKED_VECTOR2_ARRAY -import godot.tools.common.constants.VARIANT_TYPE_PACKED_VECTOR3_ARRAY -import godot.tools.common.constants.VARIANT_TYPE_STRING -import godot.tools.common.constants.VARIANT_TYPE_STRING_NAME -import godot.tools.common.constants.VARIANT_TYPE_TRANSFORM2D -import godot.tools.common.constants.VARIANT_TYPE_TRANSFORM3D -import godot.tools.common.constants.VARIANT_TYPE__RID -import godot.tools.common.constants.godotApiPackage -import godot.tools.common.constants.godotCorePackage -import godot.tools.common.constants.godotUtilPackage -import godot.tools.common.constants.variantTypePackage +import godot.tools.common.constants.* import godot.tools.common.extensions.convertToCamelCase import java.util.* @@ -66,6 +35,7 @@ fun Type?.toKtVariantType(): ClassName = when { fqName == "$godotCorePackage.${GodotTypes.packedVector2Array}" -> VARIANT_TYPE_PACKED_VECTOR2_ARRAY fqName == "$godotCorePackage.${GodotTypes.packedVector3Array}" -> VARIANT_TYPE_PACKED_VECTOR3_ARRAY fqName == "$godotCorePackage.${GodotTypes.packedColorArray}" -> VARIANT_TYPE_PACKED_COLOR_ARRAY + fqName.startsWith("$godotCallablePackage.${GodotTypes.ktCallable}") -> VARIANT_TYPE_PACKED_CALLABLE isCoreType() -> ClassName( variantTypePackage, fqName.substringAfterLast(".").convertToCamelCase().uppercase(Locale.getDefault()) diff --git a/kt/godot-library/src/main/kotlin/godot/core/Functions.kt b/kt/godot-library/src/main/kotlin/godot/core/Functions.kt index 99a739effb..781e171547 100644 --- a/kt/godot-library/src/main/kotlin/godot/core/Functions.kt +++ b/kt/godot-library/src/main/kotlin/godot/core/Functions.kt @@ -2,8 +2,12 @@ package godot.core -import godot.core.callable.KtCallable +import godot.core.callable.ParametersReader +import godot.core.memory.TransferContext +import godot.global.GD +import godot.tools.common.constants.Constraints import godot.util.camelToSnakeCase +import godot.util.threadLocal enum class PropertyHint { NONE, ///< no hint provided. @@ -65,11 +69,26 @@ data class KtRpcConfig( abstract class KtFunction( val functionInfo: KtFunctionInfo, - parameterCount: Int, - variantType: VariantType, + val parameterCount: Int, + private val variantType: VariantType, vararg parameterTypes: Pair -) : KtCallable(functionInfo.name, parameterCount, variantType, *parameterTypes) { +) { + private val types: Array = parameterTypes.map { it.first }.toTypedArray() + private val isNullables: Array = parameterTypes.map { it.second }.toTypedArray() + val registrationName = functionInfo.name.camelToSnakeCase() + + fun invoke(instance: T): Unit = withParameters(types, isNullables) { + invokeKt(instance) + } + + fun invokeWithReturn(instance: T): Any? = withParametersReturn(types, isNullables, variantType) { + invokeKt(instance) + } + + internal companion object : ParametersReader() + + internal abstract fun invokeKt(instance: T): R } class KtFunction0( diff --git a/kt/godot-library/src/main/kotlin/godot/core/Variant.kt b/kt/godot-library/src/main/kotlin/godot/core/Variant.kt index b74cf92083..0a014849a4 100644 --- a/kt/godot-library/src/main/kotlin/godot/core/Variant.kt +++ b/kt/godot-library/src/main/kotlin/godot/core/Variant.kt @@ -42,6 +42,7 @@ import godot.core.VariantType.VECTOR3I import godot.core.VariantType.VECTOR4 import godot.core.VariantType.VECTOR4I import godot.core.VariantType._RID +import godot.core.callable.KtCallable import godot.core.memory.MemoryManager import godot.signals.Signal import godot.util.toRealT @@ -80,7 +81,8 @@ internal val variantMapper = mutableMapOf( Vector4::class to VECTOR4, Vector4i::class to VECTOR4I, Projection::class to PROJECTION, - Callable::class to CALLABLE, + NativeCallable::class to CALLABLE, + KtCallable::class to CALLABLE, Signal::class to SIGNAL, PackedByteArray::class to PACKED_BYTE_ARRAY, PackedColorArray::class to PACKED_COLOR_ARRAY, @@ -548,10 +550,18 @@ enum class VariantType( 25, { buffer: ByteBuffer, _: Int -> val ptr = buffer.long - Callable(ptr) + NativeCallable(ptr) }, { buffer: ByteBuffer, any: Any -> - CALLABLE.toGodotNativeCoreType(buffer, any) + buffer.variantType = CALLABLE.ordinal + if (any is NativeCallable) { + buffer.bool = false + buffer.putLong(any._handle) + } else { + require(any is KtCallable<*>) + buffer.bool = true + buffer.putLong(any.wrapInCustomCallable()) + } } ), SIGNAL( diff --git a/kt/godot-library/src/main/kotlin/godot/core/bridge/Callable.kt b/kt/godot-library/src/main/kotlin/godot/core/bridge/Callable.kt index f545449da6..2b4614e04c 100644 --- a/kt/godot-library/src/main/kotlin/godot/core/bridge/Callable.kt +++ b/kt/godot-library/src/main/kotlin/godot/core/bridge/Callable.kt @@ -1,491 +1,16 @@ -@file:JvmName("CallableUtils") @file:Suppress("PackageDirectoryMismatch") - package godot.core import godot.Object -import godot.core.memory.MemoryManager -import godot.core.memory.TransferContext -import godot.util.VoidPtr -import godot.util.camelToSnakeCase -import kotlin.reflect.KCallable - -class Callable : NativeCoreType { - - constructor() { - _handle = Bridge.engine_call_constructor() - MemoryManager.registerNativeCoreType(this, VariantType.CALLABLE) - } - - constructor(target: Object, methodName: StringName) { - TransferContext.writeArguments(VariantType.OBJECT to target, VariantType.STRING_NAME to methodName) - _handle = Bridge.engine_call_constructor_object_string_name() - MemoryManager.registerNativeCoreType(this, VariantType.CALLABLE) - } - - constructor(callable: Callable) { - TransferContext.writeArguments(VariantType.CALLABLE to callable) - _handle = Bridge.engine_call_copy_constructor() - MemoryManager.registerNativeCoreType(this, VariantType.CALLABLE) - } - - internal constructor(_handle: VoidPtr){ - this._handle = _handle - MemoryManager.registerNativeCoreType(this, VariantType.CALLABLE) - } - - fun bind(vararg args: Any?): Callable { - TransferContext.writeArguments(*args.map { VariantType.ANY to it }.toTypedArray()) - Bridge.engine_call_bind(_handle) - return TransferContext.readReturnValue(VariantType.CALLABLE, false) as Callable - } - - fun bindv(args: VariantArray): Callable { - TransferContext.writeArguments(VariantType.ARRAY to args) - Bridge.engine_call_bindv(_handle) - return TransferContext.readReturnValue(VariantType.CALLABLE, false) as Callable - } - - fun call(vararg args: Any?): Any? { - TransferContext.writeArguments(*args.map { VariantType.ANY to it }.toTypedArray()) - Bridge.engine_call_call(_handle) - return TransferContext.readReturnValue(VariantType.ANY, true) - } - - fun callDeferred(vararg args: Any?) { - TransferContext.writeArguments(*args.map { VariantType.ANY to it }.toTypedArray()) - Bridge.engine_call_call_deferred(_handle) - } - - fun callv(args: VariantArray): Any? { - TransferContext.writeArguments(VariantType.ARRAY to args) - Bridge.engine_call_callv(_handle) - return TransferContext.readReturnValue(VariantType.ANY, true) - } - - fun getBoundArguments(): VariantArray { - Bridge.engine_call_get_bound_arguments(_handle) - @Suppress("UNCHECKED_CAST") - return TransferContext.readReturnValue(VariantType.ARRAY, false) as VariantArray - } - - fun getBoundArgumentCount(): Int { - Bridge.engine_call_get_bound_arguments_count(_handle) - return TransferContext.readReturnValue(VariantType.JVM_INT, false) as Int - } - - fun getMethod(): StringName { - Bridge.engine_call_get_method(_handle) - return TransferContext.readReturnValue(VariantType.STRING_NAME, false) as StringName - } - - fun getObject(): Object { - Bridge.engine_call_get_object(_handle) - return TransferContext.readReturnValue(VariantType.OBJECT, false) as Object - } - - fun getObjectId(): ObjectID { - Bridge.engine_call_get_object_id(_handle) - return ObjectID(TransferContext.readReturnValue(VariantType.LONG) as Long) - } - - override fun hashCode(): Int { - Bridge.engine_call_hash(_handle) - return TransferContext.readReturnValue(VariantType.JVM_INT) as Int - } - - fun isCustom(): Boolean { - Bridge.engine_call_is_custom(_handle) - return TransferContext.readReturnValue(VariantType.BOOL) as Boolean - } - - fun isNull(): Boolean { - Bridge.engine_call_is_null(_handle) - return TransferContext.readReturnValue(VariantType.BOOL) as Boolean - } - - fun isStandard(): Boolean { - Bridge.engine_call_is_standard(_handle) - return TransferContext.readReturnValue(VariantType.BOOL) as Boolean - } - - fun isValid(): Boolean { - Bridge.engine_call_is_valid(_handle) - return TransferContext.readReturnValue(VariantType.BOOL) as Boolean - } - - fun rpc(vararg args: Any?) { - TransferContext.writeArguments(*args.map { VariantType.ANY to it }.toTypedArray()) - Bridge.engine_call_rpc(_handle) - } - - fun rpcId(peerId: Long, vararg args: Any?) { - TransferContext.writeArguments(VariantType.LONG to peerId, *args.map { VariantType.ANY to it }.toTypedArray()) - Bridge.engine_call_rpc_id(_handle) - } - - fun unbind(argCount: Int): Callable { - TransferContext.writeArguments(VariantType.JVM_INT to argCount) - Bridge.engine_call_unbind(_handle) - return TransferContext.readReturnValue(VariantType.CALLABLE, false) as Callable - } +import godot.core.callable.KtCallable - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other !is Callable) 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: KtCustomCallable): 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) - } +interface Callable { + fun call(vararg args: Any?): Any? companion object { - operator fun invoke( - target: T, - callable: T.() -> Unit - ) = Callable(target, (callable as KCallable<*>).name.camelToSnakeCase().asStringName()) - - operator fun invoke( - target: T, - callable: T.(P) -> Unit - ) = Callable(target, (callable as KCallable<*>).name.camelToSnakeCase().asStringName()) - - operator fun invoke( - target: T, - callable: T.(P1, P2) -> Unit - ) = Callable(target, (callable as KCallable<*>).name.camelToSnakeCase().asStringName()) - - operator fun invoke( - target: T, - callable: T.(P1, P2, P3) -> Unit - ) = Callable(target, (callable as KCallable<*>).name.camelToSnakeCase().asStringName()) - - operator fun invoke( - target: T, - callable: T.(P1, P2, P3, P4) -> Unit - ) = Callable(target, (callable as KCallable<*>).name.camelToSnakeCase().asStringName()) - - operator fun invoke( - target: T, - callable: T.(P1, P2, P3, P4, P5) -> Unit - ) = Callable(target, (callable as KCallable<*>).name.camelToSnakeCase().asStringName()) - - operator fun invoke( - target: T, - callable: T.(P1, P2, P3, P4, P5, P6) -> Unit - ) = Callable(target, (callable as KCallable<*>).name.camelToSnakeCase().asStringName()) - - operator fun invoke( - target: T, - callable: T.(P1, P2, P3, P4, P5, P6, P7) -> Unit - ) = Callable(target, (callable as KCallable<*>).name.camelToSnakeCase().asStringName()) - - operator fun invoke( - target: T, - callable: T.(P1, P2, P3, P4, P5, P6, P7, P8) -> Unit - ) = Callable(target, (callable as KCallable<*>).name.camelToSnakeCase().asStringName()) - - operator fun invoke( - target: T, - callable: T.(P1, P2, P3, P4, P5, P6, P7, P8, P9) -> Unit - ) = Callable(target, (callable as KCallable<*>).name.camelToSnakeCase().asStringName()) - - operator fun invoke( - target: T, - callable: T.(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) -> Unit - ) = Callable(target, (callable as KCallable<*>).name.camelToSnakeCase().asStringName()) + operator fun invoke() = NativeCallable() + operator fun invoke(target: Object, methodName: StringName) = NativeCallable(target, methodName) + operator fun invoke(nativeCallable: NativeCallable) = NativeCallable(nativeCallable) + operator fun invoke(ktCallable: KtCallable<*>) = NativeCallable(ktCallable) } -} - - -//TODO: Enable that code again when KtCustomCallable is back -//@Suppress("UNCHECKED_CAST") -//inline fun callable( -// target: Object, -// noinline function: T.() -> R -//) = Callable( -// target, -// TargetedCall( -// function, -// checkNotNull(variantMapper[R::class]) { -// "Cannot map return type ${R::class} to variant." -// } -// ) as KtCallable -//) -// -//@Suppress("UNCHECKED_CAST") -//inline fun callable( -// target: Object, -// noinline function: T.(P0) -> R -//) = Callable( -// target, -// TargetedCall1( -// function, -// checkNotNull(variantMapper[R::class]) { -// "Cannot map return type ${R::class} to variant type." -// }, -// checkNotNull(variantMapper[P0::class]) { -// "Cannot map parameter type ${P0::class} to variant." -// } to true -// ) as KtCallable -//) -// -//@Suppress("UNCHECKED_CAST") -//inline fun callable( -// target: Object, -// noinline function: T.(P0, P1) -> R -//) = Callable( -// target, -// TargetedCall2( -// function, -// checkNotNull(variantMapper[R::class]) { -// "Cannot map return type ${R::class} to variant." -// }, -// checkNotNull(variantMapper[P0::class]) { -// "Cannot map parameter type ${P0::class} to variant." -// } to true, -// checkNotNull(variantMapper[P1::class]) { -// "Cannot map parameter type ${P1::class} to variant." -// } to true -// ) as KtCallable -//) -// -//@Suppress("UNCHECKED_CAST") -//inline fun callable( -// target: Object, -// noinline function: T.(P0, P1, P2) -> R -//) = Callable( -// target, -// TargetedCall3( -// function, -// checkNotNull(variantMapper[R::class]) { -// "Cannot map return type ${R::class} to variant." -// }, -// checkNotNull(variantMapper[P0::class]) { -// "Cannot map parameter type ${P0::class} to variant." -// } to true, -// checkNotNull(variantMapper[P1::class]) { -// "Cannot map parameter type ${P1::class} to variant." -// } to true, -// checkNotNull(variantMapper[P2::class]) { -// "Cannot map parameter type ${P2::class} to variant." -// } to true -// ) as KtCallable -//) -// -//@Suppress("UNCHECKED_CAST") -//inline fun callable( -// target: Object, -// noinline function: T.(P0, P1, P2, P3) -> R -//) = Callable( -// target, -// TargetedCall4( -// function, -// checkNotNull(variantMapper[R::class]) { -// "Cannot map return type ${R::class} to variant." -// }, -// checkNotNull(variantMapper[P0::class]) { -// "Cannot map parameter type ${P0::class} to variant." -// } to true, -// checkNotNull(variantMapper[P1::class]) { -// "Cannot map parameter type ${P1::class} to variant." -// } to true, -// checkNotNull(variantMapper[P2::class]) { -// "Cannot map parameter type ${P2::class} to variant." -// } to true, -// checkNotNull(variantMapper[P3::class]) { -// "Cannot map parameter type ${P3::class} to variant." -// } to true -// ) as KtCallable -//) -// -//@Suppress("UNCHECKED_CAST") -//inline fun callable( -// target: Object, -// noinline function: T.(P0, P1, P2, P3, P4) -> R -//) = Callable( -// target, -// TargetedCall5( -// function, -// checkNotNull(variantMapper[R::class]) { -// "Cannot map return type ${R::class} to variant." -// }, -// checkNotNull(variantMapper[P0::class]) { -// "Cannot map parameter type ${P0::class} to variant." -// } to true, -// checkNotNull(variantMapper[P1::class]) { -// "Cannot map parameter type ${P1::class} to variant." -// } to true, -// checkNotNull(variantMapper[P2::class]) { -// "Cannot map parameter type ${P2::class} to variant." -// } to true, -// checkNotNull(variantMapper[P3::class]) { -// "Cannot map parameter type ${P3::class} to variant." -// } to true, -// checkNotNull(variantMapper[P4::class]) { -// "Cannot map parameter type ${P4::class} to variant." -// } to true -// ) as KtCallable -//) -// -//@Suppress("UNCHECKED_CAST") -//inline fun < -// T : KtObject, -// reified P0 : Any?, -// reified P1 : Any?, -// reified P2 : Any?, -// reified P3 : Any?, -// reified P4 : Any?, -// reified P5 : Any?, -// reified R : Any?, -// > callable( -// target: Object, -// noinline function: T.(P0, P1, P2, P3, P4, P5) -> R -//) = Callable( -// target, -// TargetedCall6( -// function, -// checkNotNull(variantMapper[R::class]) { -// "Cannot map return type ${R::class} to variant." -// }, -// checkNotNull(variantMapper[P0::class]) { -// "Cannot map parameter type ${P0::class} to variant." -// } to true, -// checkNotNull(variantMapper[P1::class]) { -// "Cannot map parameter type ${P1::class} to variant." -// } to true, -// checkNotNull(variantMapper[P2::class]) { -// "Cannot map parameter type ${P2::class} to variant." -// } to true, -// checkNotNull(variantMapper[P3::class]) { -// "Cannot map parameter type ${P3::class} to variant." -// } to true, -// checkNotNull(variantMapper[P4::class]) { -// "Cannot map parameter type ${P4::class} to variant." -// } to true, -// checkNotNull(variantMapper[P5::class]) { -// "Cannot map parameter type ${P5::class} to variant." -// } to true, -// ) as KtCallable -//) -// -//@Suppress("UNCHECKED_CAST") -//inline fun < -// T : KtObject, -// reified P0 : Any?, -// reified P1 : Any?, -// reified P2 : Any?, -// reified P3 : Any?, -// reified P4 : Any?, -// reified P5 : Any?, -// reified P6 : Any?, -// reified R : Any?, -// > callable( -// target: Object, -// noinline function: T.(P0, P1, P2, P3, P4, P5, P6) -> R -//) = Callable( -// target, -// TargetedCall7( -// function, -// checkNotNull(variantMapper[R::class]) { -// "Cannot map return type ${R::class} to variant." -// }, -// checkNotNull(variantMapper[P0::class]) { -// "Cannot map parameter type ${P0::class} to variant." -// } to true, -// checkNotNull(variantMapper[P1::class]) { -// "Cannot map parameter type ${P1::class} to variant." -// } to true, -// checkNotNull(variantMapper[P2::class]) { -// "Cannot map parameter type ${P2::class} to variant." -// } to true, -// checkNotNull(variantMapper[P3::class]) { -// "Cannot map parameter type ${P3::class} to variant." -// } to true, -// checkNotNull(variantMapper[P4::class]) { -// "Cannot map parameter type ${P4::class} to variant." -// } to true, -// checkNotNull(variantMapper[P5::class]) { -// "Cannot map parameter type ${P5::class} to variant." -// } to true, -// checkNotNull(variantMapper[P6::class]) { -// "Cannot map parameter type ${P6::class} to variant." -// } to true, -// ) as KtCallable -//) -// -//@Suppress("UNCHECKED_CAST") -//inline fun < -// T : KtObject, -// reified P0 : Any?, -// reified P1 : Any?, -// reified P2 : Any?, -// reified P3 : Any?, -// reified P4 : Any?, -// reified P5 : Any?, -// reified P6 : Any?, -// reified P7 : Any?, -// reified R : Any?, -// > callable( -// target: Object, -// noinline function: T.(P0, P1, P2, P3, P4, P5, P6, P7) -> R -//) = Callable( -// target, -// TargetedCall8( -// function, -// checkNotNull(variantMapper[R::class]) { -// "Cannot map return type ${R::class} to variant." -// }, -// checkNotNull(variantMapper[P0::class]) { -// "Cannot map parameter type ${P0::class} to variant." -// } to true, -// checkNotNull(variantMapper[P1::class]) { -// "Cannot map parameter type ${P1::class} to variant." -// } to true, -// checkNotNull(variantMapper[P2::class]) { -// "Cannot map parameter type ${P2::class} to variant." -// } to true, -// checkNotNull(variantMapper[P3::class]) { -// "Cannot map parameter type ${P3::class} to variant." -// } to true, -// checkNotNull(variantMapper[P4::class]) { -// "Cannot map parameter type ${P4::class} to variant." -// } to true, -// checkNotNull(variantMapper[P5::class]) { -// "Cannot map parameter type ${P5::class} to variant." -// } to true, -// checkNotNull(variantMapper[P6::class]) { -// "Cannot map parameter type ${P6::class} to variant." -// } to true, -// checkNotNull(variantMapper[P7::class]) { -// "Cannot map parameter type ${P7::class} to variant." -// } to true, -// ) as KtCallable -//) -// -//fun callable(jvmCall: () -> Unit) = Callable(jvmCall) +} \ No newline at end of file diff --git a/kt/godot-library/src/main/kotlin/godot/core/bridge/NativeCallable.kt b/kt/godot-library/src/main/kotlin/godot/core/bridge/NativeCallable.kt new file mode 100644 index 0000000000..ae4fb71a98 --- /dev/null +++ b/kt/godot-library/src/main/kotlin/godot/core/bridge/NativeCallable.kt @@ -0,0 +1,230 @@ +@file:JvmName("CallableUtils") +@file:Suppress("PackageDirectoryMismatch") + +package godot.core + +import godot.Object +import godot.core.callable.KtCallable +import godot.core.memory.MemoryManager +import godot.core.memory.TransferContext +import godot.util.VoidPtr +import godot.util.camelToSnakeCase +import kotlin.reflect.KCallable + +class NativeCallable : NativeCoreType, Callable { + + internal constructor() { + _handle = Bridge.engine_call_constructor() + MemoryManager.registerNativeCoreType(this, VariantType.CALLABLE) + } + + internal constructor(target: Object, methodName: StringName) { + TransferContext.writeArguments(VariantType.OBJECT to target, VariantType.STRING_NAME to methodName) + _handle = Bridge.engine_call_constructor_object_string_name() + MemoryManager.registerNativeCoreType(this, VariantType.CALLABLE) + } + + internal constructor(callable: NativeCallable) { + TransferContext.writeArguments(VariantType.CALLABLE to callable) + _handle = Bridge.engine_call_copy_constructor() + MemoryManager.registerNativeCoreType(this, VariantType.CALLABLE) + } + + internal constructor(ktCallable: KtCallable<*>) { + // We pass all params using jni as we're often in a context of sending parameters to cpp, so we should not rewind buffer. + _handle = Bridge.engine_call_constructor_kt_custom_callable(ktCallable, ktCallable.variantType.ordinal, ktCallable.hashCode()) + MemoryManager.registerNativeCoreType(this, VariantType.CALLABLE) + } + + internal constructor(_handle: VoidPtr){ + this._handle = _handle + MemoryManager.registerNativeCoreType(this, VariantType.CALLABLE) + } + + fun bind(vararg args: Any?): NativeCallable { + TransferContext.writeArguments(*args.map { VariantType.ANY to it }.toTypedArray()) + Bridge.engine_call_bind(_handle) + return TransferContext.readReturnValue(VariantType.CALLABLE, false) as NativeCallable + } + + fun bindv(args: VariantArray): NativeCallable { + TransferContext.writeArguments(VariantType.ARRAY to args) + Bridge.engine_call_bindv(_handle) + return TransferContext.readReturnValue(VariantType.CALLABLE, false) as NativeCallable + } + + override fun call(vararg args: Any?): Any? { + TransferContext.writeArguments(*args.map { VariantType.ANY to it }.toTypedArray()) + Bridge.engine_call_call(_handle) + return TransferContext.readReturnValue(VariantType.ANY, true) + } + + fun callDeferred(vararg args: Any?) { + TransferContext.writeArguments(*args.map { VariantType.ANY to it }.toTypedArray()) + Bridge.engine_call_call_deferred(_handle) + } + + fun callv(args: VariantArray): Any? { + TransferContext.writeArguments(VariantType.ARRAY to args) + Bridge.engine_call_callv(_handle) + return TransferContext.readReturnValue(VariantType.ANY, true) + } + + fun getBoundArguments(): VariantArray { + Bridge.engine_call_get_bound_arguments(_handle) + @Suppress("UNCHECKED_CAST") + return TransferContext.readReturnValue(VariantType.ARRAY, false) as VariantArray + } + + fun getBoundArgumentCount(): Int { + Bridge.engine_call_get_bound_arguments_count(_handle) + return TransferContext.readReturnValue(VariantType.JVM_INT, false) as Int + } + + fun getMethod(): StringName { + Bridge.engine_call_get_method(_handle) + return TransferContext.readReturnValue(VariantType.STRING_NAME, false) as StringName + } + + fun getObject(): Object { + Bridge.engine_call_get_object(_handle) + return TransferContext.readReturnValue(VariantType.OBJECT, false) as Object + } + + fun getObjectId(): ObjectID { + Bridge.engine_call_get_object_id(_handle) + return ObjectID(TransferContext.readReturnValue(VariantType.LONG) as Long) + } + + override fun hashCode(): Int { + Bridge.engine_call_hash(_handle) + return TransferContext.readReturnValue(VariantType.JVM_INT) as Int + } + + fun isCustom(): Boolean { + Bridge.engine_call_is_custom(_handle) + return TransferContext.readReturnValue(VariantType.BOOL) as Boolean + } + + fun isNull(): Boolean { + Bridge.engine_call_is_null(_handle) + return TransferContext.readReturnValue(VariantType.BOOL) as Boolean + } + + fun isStandard(): Boolean { + Bridge.engine_call_is_standard(_handle) + return TransferContext.readReturnValue(VariantType.BOOL) as Boolean + } + + fun isValid(): Boolean { + Bridge.engine_call_is_valid(_handle) + return TransferContext.readReturnValue(VariantType.BOOL) as Boolean + } + + fun rpc(vararg args: Any?) { + TransferContext.writeArguments(*args.map { VariantType.ANY to it }.toTypedArray()) + Bridge.engine_call_rpc(_handle) + } + + fun rpcId(peerId: Long, vararg args: Any?) { + TransferContext.writeArguments(VariantType.LONG to peerId, *args.map { VariantType.ANY to it }.toTypedArray()) + Bridge.engine_call_rpc_id(_handle) + } + + fun unbind(argCount: Int): NativeCallable { + TransferContext.writeArguments(VariantType.JVM_INT to argCount) + Bridge.engine_call_unbind(_handle) + return TransferContext.readReturnValue(VariantType.CALLABLE, false) 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: KtCallable<*>, variantTypeOrdinal: Int, hashCode: Int): 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.camelToSnakeCase().asStringName()) + + operator fun invoke( + target: T, + callable: T.(P) -> Unit + ) = NativeCallable(target, (callable as KCallable<*>).name.camelToSnakeCase().asStringName()) + + operator fun invoke( + target: T, + callable: T.(P1, P2) -> Unit + ) = NativeCallable(target, (callable as KCallable<*>).name.camelToSnakeCase().asStringName()) + + operator fun invoke( + target: T, + callable: T.(P1, P2, P3) -> Unit + ) = NativeCallable(target, (callable as KCallable<*>).name.camelToSnakeCase().asStringName()) + + operator fun invoke( + target: T, + callable: T.(P1, P2, P3, P4) -> Unit + ) = NativeCallable(target, (callable as KCallable<*>).name.camelToSnakeCase().asStringName()) + + operator fun invoke( + target: T, + callable: T.(P1, P2, P3, P4, P5) -> Unit + ) = NativeCallable(target, (callable as KCallable<*>).name.camelToSnakeCase().asStringName()) + + operator fun invoke( + target: T, + callable: T.(P1, P2, P3, P4, P5, P6) -> Unit + ) = NativeCallable(target, (callable as KCallable<*>).name.camelToSnakeCase().asStringName()) + + operator fun invoke( + target: T, + callable: T.(P1, P2, P3, P4, P5, P6, P7) -> Unit + ) = NativeCallable(target, (callable as KCallable<*>).name.camelToSnakeCase().asStringName()) + + operator fun invoke( + target: T, + callable: T.(P1, P2, P3, P4, P5, P6, P7, P8) -> Unit + ) = NativeCallable(target, (callable as KCallable<*>).name.camelToSnakeCase().asStringName()) + + operator fun invoke( + target: T, + callable: T.(P1, P2, P3, P4, P5, P6, P7, P8, P9) -> Unit + ) = NativeCallable(target, (callable as KCallable<*>).name.camelToSnakeCase().asStringName()) + + operator fun invoke( + target: T, + callable: T.(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) -> Unit + ) = NativeCallable(target, (callable as KCallable<*>).name.camelToSnakeCase().asStringName()) + } +} \ No newline at end of file diff --git a/kt/godot-library/src/main/kotlin/godot/core/callable/KtCallable.kt b/kt/godot-library/src/main/kotlin/godot/core/callable/KtCallable.kt index 4c0822cdf6..544118b10b 100644 --- a/kt/godot-library/src/main/kotlin/godot/core/callable/KtCallable.kt +++ b/kt/godot-library/src/main/kotlin/godot/core/callable/KtCallable.kt @@ -1,57 +1,37 @@ +@file:Suppress("UNCHECKED_CAST") + package godot.core.callable -import godot.core.KtObject import godot.core.VariantType -import godot.core.memory.TransferContext -import godot.global.GD -import godot.tools.common.constants.Constraints -import godot.util.threadLocal - -abstract class KtCallable( - private val name: String, - val parameterCount: Int, - val variantType: VariantType, +import godot.core.Callable +import godot.util.VoidPtr + +abstract class KtCallable( + internal val variantType: VariantType, vararg parameterTypes: Pair -) { +) : Callable { private val types: Array = parameterTypes.map { it.first }.toTypedArray() private val isNullables: Array = parameterTypes.map { it.second }.toTypedArray() - fun invoke(instance: T) { - TransferContext.readArguments(types, isNullables, paramsArray) - try { - invokeKt(instance) - } catch (t: Throwable) { - GD.printErr("Error calling a JVM method from Godot:", t.stackTrace) - } - resetParamsArray() + val returnVariantType: Int + get() = variantType.ordinal + + fun invokeNoReturn(): Unit = withParameters(types, isNullables) { + invokeKt() } - fun invokeWithReturn(instance: T): Any? { - TransferContext.readArguments(types, isNullables, paramsArray) - - var ret: Any? = Unit - try { - ret = invokeKt(instance) - TransferContext.writeReturnValue(ret, variantType) - } catch (t: Throwable) { - GD.printErr("Error calling a JVM method from Godot:", t.stackTrace) - TransferContext.writeReturnValue(null, VariantType.NIL) - } - resetParamsArray() - return ret + fun invokeWithReturn(): Any? = withParametersReturn(types, isNullables, variantType) { + invokeKt() } - companion object { - val paramsArray by threadLocal { - Array(Constraints.MAX_FUNCTION_ARG_COUNT) { - null - } - } + internal abstract fun invokeKt(): R - fun resetParamsArray() { - paramsArray.fill(null) - } - } + internal companion object : ParametersReader() + + internal fun wrapInCustomCallable(): VoidPtr = Bridge.wrap_in_custom_callable(this, variantType.ordinal, hashCode()) - internal abstract fun invokeKt(instance: T): R -} + @Suppress("FunctionName") + private object Bridge { + external fun wrap_in_custom_callable(instance: KtCallable<*>,variantTypeOrdinal: Int, hashCode: Int): VoidPtr + } +} \ No newline at end of file diff --git a/kt/godot-library/src/main/kotlin/godot/core/callable/KtCallables.kt b/kt/godot-library/src/main/kotlin/godot/core/callable/KtCallables.kt deleted file mode 100644 index 8d03556080..0000000000 --- a/kt/godot-library/src/main/kotlin/godot/core/callable/KtCallables.kt +++ /dev/null @@ -1,443 +0,0 @@ -@file:Suppress("UNCHECKED_CAST") - -package godot.core.callable - -import godot.core.KtObject -import godot.core.VariantType - -class TargetedCall( - private val function: T.() -> R, - variantType: VariantType -) : KtCallable(this.toString(), 0, variantType) { - override fun invokeKt(instance: T) = instance.function() -} - -class TargetedCall1( - private val function: T.(P0) -> R, - variantType: VariantType, - p0Type: Pair -) : KtCallable(this.toString(), 1, variantType, p0Type) { - override fun invokeKt(instance: T): R = instance.function(paramsArray[0] as P0) -} - -class TargetedCall2( - private val function: T.(P0, P1) -> R, - variantType: VariantType, - p0Type: Pair, - p1Type: Pair -) : KtCallable(this.toString(), 1, variantType, p0Type, p1Type) { - override fun invokeKt(instance: T): R = instance.function( - paramsArray[0] as P0, - paramsArray[1] as P1 - ) -} - -class TargetedCall3( - private val function: T.(P0, P1, P2) -> R, - variantType: VariantType, - p0Type: Pair, - p1Type: Pair, - p2Type: Pair -) : KtCallable(this.toString(), 1, variantType, p0Type, p1Type, p2Type) { - override fun invokeKt(instance: T): R = instance.function( - paramsArray[0] as P0, - paramsArray[1] as P1, - paramsArray[2] as P2 - ) -} - -class TargetedCall4( - private val function: T.(P0, P1, P2, P3) -> R, - variantType: VariantType, - p0Type: Pair, - p1Type: Pair, - p2Type: Pair, - p3Type: Pair -) : KtCallable(this.toString(), 1, variantType, p0Type, p1Type, p2Type, p3Type) { - override fun invokeKt(instance: T): R = instance.function( - paramsArray[0] as P0, - paramsArray[1] as P1, - paramsArray[2] as P2, - paramsArray[3] as P3 - ) -} - -class TargetedCall5( - private val function: T.(P0, P1, P2, P3, P4) -> R, - variantType: VariantType, - p0Type: Pair, - p1Type: Pair, - p2Type: Pair, - p3Type: Pair, - p4Type: Pair -) : KtCallable(this.toString(), 1, variantType, p0Type, p1Type, p2Type, p3Type, p4Type) { - override fun invokeKt(instance: T): R = instance.function( - paramsArray[0] as P0, - paramsArray[1] as P1, - paramsArray[2] as P2, - paramsArray[3] as P3, - paramsArray[4] as P4 - ) -} - -class TargetedCall6< - T : KtObject, - P0 : Any?, - P1 : Any?, - P2 : Any?, - P3 : Any?, - P4 : Any?, - P5 : Any?, - R : Any?, - >( - private val function: T.(P0, P1, P2, P3, P4, P5) -> R, - variantType: VariantType, - p0Type: Pair, - p1Type: Pair, - p2Type: Pair, - p3Type: Pair, - p4Type: Pair, - p5Type: Pair, -) : KtCallable(this.toString(), 1, variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type) { - override fun invokeKt(instance: T): R = instance.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, - ) -} - -class TargetedCall7< - T : KtObject, - P0 : Any?, - P1 : Any?, - P2 : Any?, - P3 : Any?, - P4 : Any?, - P5 : Any?, - P6 : Any?, - R : Any?, - >( - private val function: T.(P0, P1, P2, P3, P4, P5, P6) -> R, - variantType: VariantType, - p0Type: Pair, - p1Type: Pair, - p2Type: Pair, - p3Type: Pair, - p4Type: Pair, - p5Type: Pair, - p6Type: Pair, -) : KtCallable(this.toString(), 1, variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type) { - override fun invokeKt(instance: T): R = instance.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, - ) -} - -class TargetedCall8< - T : KtObject, - P0 : Any?, - P1 : Any?, - P2 : Any?, - P3 : Any?, - P4 : Any?, - P5 : Any?, - P6 : Any?, - P7 : Any?, - R : Any?, - >( - private val function: T.(P0, P1, P2, P3, P4, P5, P6, P7) -> R, - variantType: VariantType, - p0Type: Pair, - p1Type: Pair, - p2Type: Pair, - p3Type: Pair, - p4Type: Pair, - p5Type: Pair, - p6Type: Pair, - p7Type: Pair, -) : KtCallable(this.toString(), 1, variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type) { - override fun invokeKt(instance: T): R = instance.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, - ) -} - -class TargetedCall9( - private val function: T.(P0, P1, P2, P3, P4, P5, P6, P7, P8) -> R, - variantType: VariantType, - p0Type: Pair, - p1Type: Pair, - p2Type: Pair, - p3Type: Pair, - p4Type: Pair, - p5Type: Pair, - p6Type: Pair, - p7Type: Pair, - p8Type: Pair -) : KtCallable(this.toString(), 9, variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type) { - override fun invokeKt(instance: T): R = instance.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 - ) -} - -class TargetedCall10( - private val function: T.(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) -> R, - variantType: VariantType, - p0Type: Pair, - p1Type: Pair, - p2Type: Pair, - p3Type: Pair, - p4Type: Pair, - p5Type: Pair, - p6Type: Pair, - p7Type: Pair, - p8Type: Pair, - p9Type: Pair -) : KtCallable(this.toString(), 10, variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type) { - override fun invokeKt(instance: T): R = instance.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 - ) -} - -class TargetedCall11( - private val function: T.(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) -> R, - variantType: VariantType, - p0Type: Pair, - p1Type: Pair, - p2Type: Pair, - p3Type: Pair, - p4Type: Pair, - p5Type: Pair, - p6Type: Pair, - p7Type: Pair, - p8Type: Pair, - p9Type: Pair, - p10Type: Pair -) : KtCallable(this.toString(), 11, variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type, p10Type) { - override fun invokeKt(instance: T): R = instance.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 - ) -} - -class TargetedCall12( - private val function: T.(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11) -> R, - variantType: VariantType, - p0Type: Pair, - p1Type: Pair, - p2Type: Pair, - p3Type: Pair, - p4Type: Pair, - p5Type: Pair, - p6Type: Pair, - p7Type: Pair, - p8Type: Pair, - p9Type: Pair, - p10Type: Pair, - p11Type: Pair -) : KtCallable(this.toString(), 12, variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type, p10Type, p11Type) { - override fun invokeKt(instance: T): R = instance.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 - ) -} - -class TargetedCall13( - private val function: T.(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12) -> R, - variantType: VariantType, - p0Type: Pair, - p1Type: Pair, - p2Type: Pair, - p3Type: Pair, - p4Type: Pair, - p5Type: Pair, - p6Type: Pair, - p7Type: Pair, - p8Type: Pair, - p9Type: Pair, - p10Type: Pair, - p11Type: Pair, - p12Type: Pair -) : KtCallable(this.toString(), 13, variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type, p10Type, p11Type, p12Type) { - override fun invokeKt(instance: T): R = instance.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 - ) -} - -class TargetedCall14( - private val function: T.(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13) -> R, - variantType: VariantType, - p0Type: Pair, - p1Type: Pair, - p2Type: Pair, - p3Type: Pair, - p4Type: Pair, - p5Type: Pair, - p6Type: Pair, - p7Type: Pair, - p8Type: Pair, - p9Type: Pair, - p10Type: Pair, - p11Type: Pair, - p12Type: Pair, - p13Type: Pair -) : KtCallable(this.toString(), 14, variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type, p10Type, p11Type, p12Type, p13Type) { - override fun invokeKt(instance: T): R = instance.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 - ) -} - -class TargetedCall15( - private val function: T.(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14) -> R, - variantType: VariantType, - p0Type: Pair, - p1Type: Pair, - p2Type: Pair, - p3Type: Pair, - p4Type: Pair, - p5Type: Pair, - p6Type: Pair, - p7Type: Pair, - p8Type: Pair, - p9Type: Pair, - p10Type: Pair, - p11Type: Pair, - p12Type: Pair, - p13Type: Pair, - p14Type: Pair -) : KtCallable(this.toString(), 15, variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type, p10Type, p11Type, p12Type, p13Type, p14Type) { - override fun invokeKt(instance: T): R = instance.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 - ) -} - -class TargetedCall16( - private val function: T.(P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15) -> R, - variantType: VariantType, - p0Type: Pair, - p1Type: Pair, - p2Type: Pair, - p3Type: Pair, - p4Type: Pair, - p5Type: Pair, - p6Type: Pair, - p7Type: Pair, - p8Type: Pair, - p9Type: Pair, - p10Type: Pair, - p11Type: Pair, - p12Type: Pair, - p13Type: Pair, - p14Type: Pair, - p15Type: Pair -) : KtCallable(this.toString(), 16, variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type, p10Type, p11Type, p12Type, p13Type, p14Type, p15Type) { - override fun invokeKt(instance: T): R = instance.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 - ) -} - - diff --git a/kt/godot-library/src/main/kotlin/godot/core/callable/ParametersReader.kt b/kt/godot-library/src/main/kotlin/godot/core/callable/ParametersReader.kt new file mode 100644 index 0000000000..71e7fc6195 --- /dev/null +++ b/kt/godot-library/src/main/kotlin/godot/core/callable/ParametersReader.kt @@ -0,0 +1,50 @@ +package godot.core.callable + +import godot.core.VariantType +import godot.core.memory.TransferContext +import godot.global.GD +import godot.tools.common.constants.Constraints +import godot.util.threadLocal + +internal open class ParametersReader { + val paramsArray by threadLocal { + Array(Constraints.MAX_FUNCTION_ARG_COUNT) { + null + } + } + + private fun resetParamsArray() { + paramsArray.fill(null) + } + + internal inline fun withParameters(types: Array, isNullables: Array, code: () -> Unit) { + TransferContext.readArguments(types, isNullables, paramsArray) + try { + code() + } catch (t: Throwable) { + GD.printErr("Error calling a JVM method from Godot:", t.stackTraceToString()) + } + resetParamsArray() + } + + internal inline fun withParametersReturn( + types: Array, + isNullables: Array, + variantType: VariantType, + code: () -> R + ): Any? { + TransferContext.readArguments(types, isNullables, paramsArray) + + var ret: Any? = Unit + try { + ret = code() + TransferContext.writeReturnValue(ret, variantType) + } catch (t: Throwable) { + GD.printErr("Error calling a JVM method from Godot:", t.stackTraceToString()) + TransferContext.writeReturnValue(null, VariantType.NIL) + } + + resetParamsArray() + return ret + } +} \ No newline at end of file diff --git a/kt/godot-library/src/main/kotlin/godot/gen/godot/core/callable/KtCallables.kt b/kt/godot-library/src/main/kotlin/godot/gen/godot/core/callable/KtCallables.kt new file mode 100644 index 0000000000..5016bf628e --- /dev/null +++ b/kt/godot-library/src/main/kotlin/godot/gen/godot/core/callable/KtCallables.kt @@ -0,0 +1,2340 @@ +@file:Suppress("PackageDirectoryMismatch", "UNCHECKED_CAST") + +package godot.core.callable + +import godot.core.VariantType +import godot.core.VariantType.NIL +import godot.core.variantMapper +import kotlin.Any +import kotlin.Boolean +import kotlin.Pair +import kotlin.Suppress + +public class KtCallable0( + variantType: VariantType, + private val function: () -> R, +) : KtCallable(variantType) { + public override fun invokeKt(): R = function() + + public operator fun invoke(): R = function() + + public override fun call(vararg args: Any?): Any? = function() +} + +public inline fun callable(noinline function: () -> R) = + KtCallable0(variantMapper.getOrDefault(R::class, NIL), function) + +public inline fun (() -> R).asCallable() = callable(this) + +public class KtCallable1( + variantType: VariantType, + p0Type: Pair, + private val function: (p0: P0) -> R, +) : KtCallable(variantType, 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) = KtCallable0(variantType) { -> function(p0) } +} + +public inline fun callable(noinline function: (p0: P0) -> R) = + KtCallable1(variantMapper.getOrDefault(R::class, NIL), variantMapper[P0::class]!! to true, function) + +public inline fun ((p0: P0) -> R).asCallable() = callable(this) + +public class KtCallable2( + variantType: VariantType, + private val p0Type: Pair, + p1Type: Pair, + private val function: (p0: P0, p1: P1) -> R, +) : KtCallable(variantType, 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) = KtCallable0(variantType) { -> function(p0, p1) } + + public fun bind(p1: P1) = KtCallable1(variantType, p0Type) { p0: P0 -> function(p0, p1) } +} + +public inline fun callable(noinline function: (p0: P0, + p1: P1) -> R) = + KtCallable2(variantMapper.getOrDefault(R::class, NIL), variantMapper[P0::class]!! to true, variantMapper[P1::class]!! to true, function) + +public inline fun ((p0: P0, p1: P1) -> R).asCallable() = + callable(this) + +public class KtCallable3( + variantType: VariantType, + private val p0Type: Pair, + private val p1Type: Pair, + p2Type: Pair, + private val function: ( + p0: P0, + p1: P1, + p2: P2, + ) -> R, +) : KtCallable(variantType, 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, + ) = KtCallable0(variantType) { -> function(p0, p1, p2) } + + public fun bind(p1: P1, p2: P2) = + KtCallable1(variantType, p0Type) { p0: P0 -> function(p0, p1, p2) } + + public fun bind(p2: P2) = + KtCallable2(variantType, p0Type, p1Type) { p0: P0, p1: P1 -> function(p0, p1, p2) } +} + +public inline fun callable(noinline function: ( + p0: P0, + p1: P1, + p2: P2, +) -> R) = + KtCallable3(variantMapper.getOrDefault(R::class, NIL), variantMapper[P0::class]!! to true, variantMapper[P1::class]!! to true, variantMapper[P2::class]!! to true, function) + +public inline fun (( + p0: P0, + p1: P1, + p2: P2, +) -> R).asCallable() = callable(this) + +public class KtCallable4( + variantType: VariantType, + private val p0Type: Pair, + private val p1Type: Pair, + private val p2Type: Pair, + p3Type: Pair, + private val function: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + ) -> R, +) : KtCallable(variantType, 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, + ) = KtCallable0(variantType) { -> function(p0, p1, p2, p3) } + + public fun bind( + p1: P1, + p2: P2, + p3: P3, + ) = KtCallable1(variantType, p0Type) { p0: P0 -> function(p0, p1, p2, p3) } + + public fun bind(p2: P2, p3: P3) = + KtCallable2(variantType, p0Type, p1Type) { p0: P0, p1: P1 -> function(p0, p1, p2, p3) } + + public fun bind(p3: P3) = + KtCallable3(variantType, p0Type, p1Type, p2Type) { p0: P0, p1: P1, p2: P2 -> function(p0, p1, p2, p3) } +} + +public inline fun callable(noinline + function: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, +) -> R) = + KtCallable4(variantMapper.getOrDefault(R::class, NIL), variantMapper[P0::class]!! to true, variantMapper[P1::class]!! to true, variantMapper[P2::class]!! to true, variantMapper[P3::class]!! to true, function) + +public inline fun (( + p0: P0, + p1: P1, + p2: P2, + p3: P3, +) -> R).asCallable() = callable(this) + +public class KtCallable5( + variantType: VariantType, + private val p0Type: Pair, + private val p1Type: Pair, + private val p2Type: Pair, + private val p3Type: Pair, + p4Type: Pair, + private val function: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + ) -> R, +) : KtCallable(variantType, 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, + ) = KtCallable0(variantType) { -> function(p0, p1, p2, p3, p4) } + + public fun bind( + p1: P1, + p2: P2, + p3: P3, + p4: P4, + ) = KtCallable1(variantType, p0Type) { p0: P0 -> function(p0, p1, p2, p3, p4) } + + public fun bind( + p2: P2, + p3: P3, + p4: P4, + ) = KtCallable2(variantType, p0Type, p1Type) { p0: P0, p1: P1 -> function(p0, p1, p2, p3, p4) } + + public fun bind(p3: P3, p4: P4) = + KtCallable3(variantType, p0Type, p1Type, p2Type) { p0: P0, p1: P1, p2: P2 -> function(p0, p1, p2, p3, p4) } + + public fun bind(p4: P4) = + KtCallable4(variantType, p0Type, p1Type, p2Type, p3Type) { p0: P0, p1: P1, p2: P2, p3: P3 -> function(p0, p1, p2, p3, p4) } +} + +public inline fun + callable(noinline function: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, +) -> R) = + KtCallable5(variantMapper.getOrDefault(R::class, NIL), variantMapper[P0::class]!! to true, variantMapper[P1::class]!! to true, variantMapper[P2::class]!! to true, variantMapper[P3::class]!! to true, variantMapper[P4::class]!! to true, function) + +public inline fun (( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, +) -> R).asCallable() = callable(this) + +public class KtCallable6( + variantType: VariantType, + private val p0Type: Pair, + private val p1Type: Pair, + private val p2Type: Pair, + private val p3Type: Pair, + private val p4Type: Pair, + p5Type: Pair, + private val function: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + ) -> R, +) : KtCallable(variantType, 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, + ) = KtCallable0(variantType) { -> function(p0, p1, p2, p3, p4, p5) } + + public fun bind( + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + ) = KtCallable1(variantType, p0Type) { p0: P0 -> function(p0, p1, p2, p3, p4, p5) } + + public fun bind( + p2: P2, + p3: P3, + p4: P4, + p5: P5, + ) = + KtCallable2(variantType, p0Type, p1Type) { p0: P0, p1: P1 -> function(p0, p1, p2, p3, p4, p5) } + + public fun bind( + p3: P3, + p4: P4, + p5: P5, + ) = + KtCallable3(variantType, p0Type, p1Type, p2Type) { p0: P0, p1: P1, p2: P2 -> function(p0, p1, p2, p3, p4, p5) } + + public fun bind(p4: P4, p5: P5) = + KtCallable4(variantType, p0Type, p1Type, p2Type, p3Type) { p0: P0, p1: P1, p2: P2, p3: P3 -> function(p0, p1, p2, p3, p4, p5) } + + public fun bind(p5: P5) = + KtCallable5(variantType, p0Type, p1Type, p2Type, p3Type, p4Type) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4 -> function(p0, p1, p2, p3, p4, p5) } +} + +public inline fun callable(noinline function: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, +) -> R) = + KtCallable6(variantMapper.getOrDefault(R::class, NIL), variantMapper[P0::class]!! to true, variantMapper[P1::class]!! to true, variantMapper[P2::class]!! to true, variantMapper[P3::class]!! to true, variantMapper[P4::class]!! to true, variantMapper[P5::class]!! to true, function) + +public inline fun (( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, +) -> R).asCallable() = callable(this) + +public class KtCallable7( + variantType: VariantType, + private val p0Type: Pair, + private val p1Type: Pair, + private val p2Type: Pair, + private val p3Type: Pair, + private val p4Type: Pair, + private val p5Type: Pair, + p6Type: Pair, + private val function: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + ) -> R, +) : KtCallable(variantType, 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, + ) = KtCallable0(variantType) { -> function(p0, p1, p2, p3, p4, p5, p6) } + + public fun bind( + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + ) = KtCallable1(variantType, p0Type) { p0: P0 -> function(p0, p1, p2, p3, p4, p5, p6) } + + public fun bind( + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + ) = + KtCallable2(variantType, p0Type, p1Type) { p0: P0, p1: P1 -> function(p0, p1, p2, p3, p4, p5, p6) } + + public fun bind( + p3: P3, + p4: P4, + p5: P5, + p6: P6, + ) = + KtCallable3(variantType, p0Type, p1Type, p2Type) { p0: P0, p1: P1, p2: P2 -> function(p0, p1, p2, p3, p4, p5, p6) } + + public fun bind( + p4: P4, + p5: P5, + p6: P6, + ) = + KtCallable4(variantType, p0Type, p1Type, p2Type, p3Type) { p0: P0, p1: P1, p2: P2, p3: P3 -> function(p0, p1, p2, p3, p4, p5, p6) } + + public fun bind(p5: P5, p6: P6) = + KtCallable5(variantType, p0Type, p1Type, p2Type, p3Type, p4Type) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4 -> function(p0, p1, p2, p3, p4, p5, p6) } + + public fun bind(p6: P6) = + KtCallable6(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5 -> function(p0, p1, p2, p3, p4, p5, p6) } +} + +public inline fun callable(noinline function: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, +) -> R) = + KtCallable7(variantMapper.getOrDefault(R::class, NIL), variantMapper[P0::class]!! to true, variantMapper[P1::class]!! to true, variantMapper[P2::class]!! to true, variantMapper[P3::class]!! to true, variantMapper[P4::class]!! to true, variantMapper[P5::class]!! to true, variantMapper[P6::class]!! to true, function) + +public inline fun (( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, +) -> R).asCallable() = callable(this) + +public class KtCallable8( + variantType: VariantType, + private val p0Type: Pair, + private val p1Type: Pair, + private val p2Type: Pair, + private val p3Type: Pair, + private val p4Type: Pair, + private val p5Type: Pair, + private val p6Type: Pair, + p7Type: Pair, + private val function: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + ) -> R, +) : KtCallable(variantType, 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, + ) = KtCallable0(variantType) { -> 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, + ) = KtCallable1(variantType, p0Type) { 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, + ) = + KtCallable2(variantType, p0Type, p1Type) { 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, + ) = + KtCallable3(variantType, p0Type, p1Type, p2Type) { 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, + ) = + KtCallable4(variantType, p0Type, p1Type, p2Type, p3Type) { 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, + ) = + KtCallable5(variantType, p0Type, p1Type, p2Type, p3Type, p4Type) { 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) = + KtCallable6(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type) { 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) = + KtCallable7(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type) { p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6 -> function(p0, p1, p2, p3, p4, p5, p6, p7) } +} + +public inline fun callable(noinline function: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, +) -> R) = + KtCallable8(variantMapper.getOrDefault(R::class, NIL), variantMapper[P0::class]!! to true, variantMapper[P1::class]!! to true, variantMapper[P2::class]!! to true, variantMapper[P3::class]!! to true, variantMapper[P4::class]!! to true, variantMapper[P5::class]!! to true, variantMapper[P6::class]!! to true, variantMapper[P7::class]!! to true, function) + +public inline fun (( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, +) -> R).asCallable() = callable(this) + +public class KtCallable9( + variantType: VariantType, + private val p0Type: Pair, + private val p1Type: Pair, + private val p2Type: Pair, + private val p3Type: Pair, + private val p4Type: Pair, + private val p5Type: Pair, + private val p6Type: Pair, + private val p7Type: Pair, + p8Type: Pair, + private val function: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + ) -> R, +) : KtCallable(variantType, 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, + ) = KtCallable0(variantType) { -> 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, + ) = KtCallable1(variantType, p0Type) { 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, + ) = + KtCallable2(variantType, p0Type, p1Type) { 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, + ) = + KtCallable3(variantType, p0Type, p1Type, p2Type) { 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, + ) = + KtCallable4(variantType, p0Type, p1Type, p2Type, p3Type) { 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, + ) = + KtCallable5(variantType, p0Type, p1Type, p2Type, p3Type, p4Type) { 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, + ) = + KtCallable6(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type) { 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) = + KtCallable7(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type) { 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) = + KtCallable8(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type) { 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 inline fun callable(noinline function: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, +) -> R) = + KtCallable9(variantMapper.getOrDefault(R::class, NIL), variantMapper[P0::class]!! to true, variantMapper[P1::class]!! to true, variantMapper[P2::class]!! to true, variantMapper[P3::class]!! to true, variantMapper[P4::class]!! to true, variantMapper[P5::class]!! to true, variantMapper[P6::class]!! to true, variantMapper[P7::class]!! to true, variantMapper[P8::class]!! to true, function) + +public inline fun (( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, +) -> R).asCallable() = callable(this) + +public class KtCallable10( + variantType: VariantType, + private val p0Type: Pair, + private val p1Type: Pair, + private val p2Type: Pair, + private val p3Type: Pair, + private val p4Type: Pair, + private val p5Type: Pair, + private val p6Type: Pair, + private val p7Type: Pair, + private val p8Type: Pair, + p9Type: Pair, + private val function: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + ) -> R, +) : KtCallable(variantType, 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, + ) = KtCallable0(variantType) { -> 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, + ) = + KtCallable1(variantType, p0Type) { 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, + ) = + KtCallable2(variantType, p0Type, p1Type) { 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, + ) = + KtCallable3(variantType, p0Type, p1Type, p2Type) { 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, + ) = + KtCallable4(variantType, p0Type, p1Type, p2Type, p3Type) { 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, + ) = + KtCallable5(variantType, p0Type, p1Type, p2Type, p3Type, p4Type) { 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, + ) = + KtCallable6(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type) { 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, + ) = + KtCallable7(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type) { 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) = + KtCallable8(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type) { 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) = + KtCallable9(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type) { 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 inline fun callable(noinline function: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, +) -> R) = + KtCallable10(variantMapper.getOrDefault(R::class, NIL), variantMapper[P0::class]!! to true, variantMapper[P1::class]!! to true, variantMapper[P2::class]!! to true, variantMapper[P3::class]!! to true, variantMapper[P4::class]!! to true, variantMapper[P5::class]!! to true, variantMapper[P6::class]!! to true, variantMapper[P7::class]!! to true, variantMapper[P8::class]!! to true, variantMapper[P9::class]!! to true, 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() = callable(this) + +public class KtCallable11( + variantType: VariantType, + private val p0Type: Pair, + private val p1Type: Pair, + private val p2Type: Pair, + private val p3Type: Pair, + private val p4Type: Pair, + private val p5Type: Pair, + private val p6Type: Pair, + private val p7Type: Pair, + private val p8Type: Pair, + private val p9Type: Pair, + p10Type: Pair, + 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, +) : KtCallable(variantType, 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, + ) = KtCallable0(variantType) { -> 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, + ) = + KtCallable1(variantType, p0Type) { 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, + ) = + KtCallable2(variantType, p0Type, p1Type) { 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, + ) = + KtCallable3(variantType, p0Type, p1Type, p2Type) { 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, + ) = + KtCallable4(variantType, p0Type, p1Type, p2Type, p3Type) { 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, + ) = + KtCallable5(variantType, p0Type, p1Type, p2Type, p3Type, p4Type) { 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, + ) = + KtCallable6(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type) { 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, + ) = + KtCallable7(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type) { 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, + ) = + KtCallable8(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type) { 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) = + KtCallable9(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type) { 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) = + KtCallable10(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type) { 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 inline fun callable(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) = + KtCallable11(variantMapper.getOrDefault(R::class, NIL), variantMapper[P0::class]!! to true, variantMapper[P1::class]!! to true, variantMapper[P2::class]!! to true, variantMapper[P3::class]!! to true, variantMapper[P4::class]!! to true, variantMapper[P5::class]!! to true, variantMapper[P6::class]!! to true, variantMapper[P7::class]!! to true, variantMapper[P8::class]!! to true, variantMapper[P9::class]!! to true, variantMapper[P10::class]!! to true, 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() = callable(this) + +public class KtCallable12( + variantType: VariantType, + private val p0Type: Pair, + private val p1Type: Pair, + private val p2Type: Pair, + private val p3Type: Pair, + private val p4Type: Pair, + private val p5Type: Pair, + private val p6Type: Pair, + private val p7Type: Pair, + private val p8Type: Pair, + private val p9Type: Pair, + private val p10Type: Pair, + p11Type: Pair, + 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, +) : KtCallable(variantType, 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, + ) = KtCallable0(variantType) { -> 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, + ) = + KtCallable1(variantType, p0Type) { 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, + ) = + KtCallable2(variantType, p0Type, p1Type) { 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, + ) = + KtCallable3(variantType, p0Type, p1Type, p2Type) { 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, + ) = + KtCallable4(variantType, p0Type, p1Type, p2Type, p3Type) { 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, + ) = + KtCallable5(variantType, p0Type, p1Type, p2Type, p3Type, p4Type) { 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, + ) = + KtCallable6(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type) { 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, + ) = + KtCallable7(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type) { 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, + ) = + KtCallable8(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type) { 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, + ) = + KtCallable9(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type) { 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) = + KtCallable10(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type) { 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) = + KtCallable11(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type, p10Type) { 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 inline fun callable(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) = + KtCallable12(variantMapper.getOrDefault(R::class, NIL), variantMapper[P0::class]!! to true, variantMapper[P1::class]!! to true, variantMapper[P2::class]!! to true, variantMapper[P3::class]!! to true, variantMapper[P4::class]!! to true, variantMapper[P5::class]!! to true, variantMapper[P6::class]!! to true, variantMapper[P7::class]!! to true, variantMapper[P8::class]!! to true, variantMapper[P9::class]!! to true, variantMapper[P10::class]!! to true, variantMapper[P11::class]!! to true, 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() = callable(this) + +public class KtCallable13( + variantType: VariantType, + private val p0Type: Pair, + private val p1Type: Pair, + private val p2Type: Pair, + private val p3Type: Pair, + private val p4Type: Pair, + private val p5Type: Pair, + private val p6Type: Pair, + private val p7Type: Pair, + private val p8Type: Pair, + private val p9Type: Pair, + private val p10Type: Pair, + private val p11Type: Pair, + p12Type: Pair, + 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, +) : KtCallable(variantType, 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, + ) = + KtCallable0(variantType) { -> 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, + ) = + KtCallable1(variantType, p0Type) { 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, + ) = + KtCallable2(variantType, p0Type, p1Type) { 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, + ) = + KtCallable3(variantType, p0Type, p1Type, p2Type) { 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, + ) = + KtCallable4(variantType, p0Type, p1Type, p2Type, p3Type) { 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, + ) = + KtCallable5(variantType, p0Type, p1Type, p2Type, p3Type, p4Type) { 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, + ) = + KtCallable6(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type) { 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, + ) = + KtCallable7(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type) { 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, + ) = + KtCallable8(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type) { 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, + ) = + KtCallable9(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type) { 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, + ) = + KtCallable10(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type) { 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) = + KtCallable11(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type, p10Type) { 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) = + KtCallable12(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type, p10Type, p11Type) { 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 inline fun + callable(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) = + KtCallable13(variantMapper.getOrDefault(R::class, NIL), variantMapper[P0::class]!! to true, variantMapper[P1::class]!! to true, variantMapper[P2::class]!! to true, variantMapper[P3::class]!! to true, variantMapper[P4::class]!! to true, variantMapper[P5::class]!! to true, variantMapper[P6::class]!! to true, variantMapper[P7::class]!! to true, variantMapper[P8::class]!! to true, variantMapper[P9::class]!! to true, variantMapper[P10::class]!! to true, variantMapper[P11::class]!! to true, variantMapper[P12::class]!! to true, 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() = callable(this) + +public class KtCallable14( + variantType: VariantType, + private val p0Type: Pair, + private val p1Type: Pair, + private val p2Type: Pair, + private val p3Type: Pair, + private val p4Type: Pair, + private val p5Type: Pair, + private val p6Type: Pair, + private val p7Type: Pair, + private val p8Type: Pair, + private val p9Type: Pair, + private val p10Type: Pair, + private val p11Type: Pair, + private val p12Type: Pair, + p13Type: Pair, + 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, +) : KtCallable(variantType, 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, + ) = + KtCallable0(variantType) { -> 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, + ) = + KtCallable1(variantType, p0Type) { 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, + ) = + KtCallable2(variantType, p0Type, p1Type) { 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, + ) = + KtCallable3(variantType, p0Type, p1Type, p2Type) { 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, + ) = + KtCallable4(variantType, p0Type, p1Type, p2Type, p3Type) { 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, + ) = + KtCallable5(variantType, p0Type, p1Type, p2Type, p3Type, p4Type) { 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, + ) = + KtCallable6(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type) { 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, + ) = + KtCallable7(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type) { 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, + ) = + KtCallable8(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type) { 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, + ) = + KtCallable9(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type) { 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, + ) = + KtCallable10(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type) { 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, + ) = + KtCallable11(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type, p10Type) { 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) = + KtCallable12(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type, p10Type, p11Type) { 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) = + KtCallable13(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type, p10Type, p11Type, p12Type) { 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 inline fun callable(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) = + KtCallable14(variantMapper.getOrDefault(R::class, NIL), variantMapper[P0::class]!! to true, variantMapper[P1::class]!! to true, variantMapper[P2::class]!! to true, variantMapper[P3::class]!! to true, variantMapper[P4::class]!! to true, variantMapper[P5::class]!! to true, variantMapper[P6::class]!! to true, variantMapper[P7::class]!! to true, variantMapper[P8::class]!! to true, variantMapper[P9::class]!! to true, variantMapper[P10::class]!! to true, variantMapper[P11::class]!! to true, variantMapper[P12::class]!! to true, variantMapper[P13::class]!! to true, 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() = callable(this) + +public class KtCallable15( + variantType: VariantType, + private val p0Type: Pair, + private val p1Type: Pair, + private val p2Type: Pair, + private val p3Type: Pair, + private val p4Type: Pair, + private val p5Type: Pair, + private val p6Type: Pair, + private val p7Type: Pair, + private val p8Type: Pair, + private val p9Type: Pair, + private val p10Type: Pair, + private val p11Type: Pair, + private val p12Type: Pair, + private val p13Type: Pair, + p14Type: Pair, + 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, +) : KtCallable(variantType, 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, + ) = + KtCallable0(variantType) { -> 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, + ) = + KtCallable1(variantType, p0Type) { 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, + ) = + KtCallable2(variantType, p0Type, p1Type) { 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, + ) = + KtCallable3(variantType, p0Type, p1Type, p2Type) { 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, + ) = + KtCallable4(variantType, p0Type, p1Type, p2Type, p3Type) { 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, + ) = + KtCallable5(variantType, p0Type, p1Type, p2Type, p3Type, p4Type) { 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, + ) = + KtCallable6(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type) { 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, + ) = + KtCallable7(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type) { 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, + ) = + KtCallable8(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type) { 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, + ) = + KtCallable9(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type) { 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, + ) = + KtCallable10(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type) { 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, + ) = + KtCallable11(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type, p10Type) { 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, + ) = + KtCallable12(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type, p10Type, p11Type) { 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) = + KtCallable13(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type, p10Type, p11Type, p12Type) { 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) = + KtCallable14(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type, p10Type, p11Type, p12Type, p13Type) { 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 inline fun callable(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) = + KtCallable15(variantMapper.getOrDefault(R::class, NIL), variantMapper[P0::class]!! to true, variantMapper[P1::class]!! to true, variantMapper[P2::class]!! to true, variantMapper[P3::class]!! to true, variantMapper[P4::class]!! to true, variantMapper[P5::class]!! to true, variantMapper[P6::class]!! to true, variantMapper[P7::class]!! to true, variantMapper[P8::class]!! to true, variantMapper[P9::class]!! to true, variantMapper[P10::class]!! to true, variantMapper[P11::class]!! to true, variantMapper[P12::class]!! to true, variantMapper[P13::class]!! to true, variantMapper[P14::class]!! to true, 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() = callable(this) + +public class KtCallable16( + variantType: VariantType, + private val p0Type: Pair, + private val p1Type: Pair, + private val p2Type: Pair, + private val p3Type: Pair, + private val p4Type: Pair, + private val p5Type: Pair, + private val p6Type: Pair, + private val p7Type: Pair, + private val p8Type: Pair, + private val p9Type: Pair, + private val p10Type: Pair, + private val p11Type: Pair, + private val p12Type: Pair, + private val p13Type: Pair, + private val p14Type: Pair, + p15Type: Pair, + 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, +) : KtCallable(variantType, 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, + ) = + KtCallable0(variantType) { -> 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, + ) = + KtCallable1(variantType, p0Type) { 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, + ) = + KtCallable2(variantType, p0Type, p1Type) { 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, + ) = + KtCallable3(variantType, p0Type, p1Type, p2Type) { 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, + ) = + KtCallable4(variantType, p0Type, p1Type, p2Type, p3Type) { 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, + ) = + KtCallable5(variantType, p0Type, p1Type, p2Type, p3Type, p4Type) { 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, + ) = + KtCallable6(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type) { 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, + ) = + KtCallable7(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type) { 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, + ) = + KtCallable8(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type) { 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, + ) = + KtCallable9(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type) { 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, + ) = + KtCallable10(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type) { 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, + ) = + KtCallable11(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type, p10Type) { 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, + ) = + KtCallable12(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type, p10Type, p11Type) { 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, + ) = + KtCallable13(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type, p10Type, p11Type, p12Type) { 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) = + KtCallable14(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type, p10Type, p11Type, p12Type, p13Type) { 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) = + KtCallable15(variantType, p0Type, p1Type, p2Type, p3Type, p4Type, p5Type, p6Type, p7Type, p8Type, p9Type, p10Type, p11Type, p12Type, p13Type, p14Type) { 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 inline fun callable(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) = + KtCallable16(variantMapper.getOrDefault(R::class, NIL), variantMapper[P0::class]!! to true, variantMapper[P1::class]!! to true, variantMapper[P2::class]!! to true, variantMapper[P3::class]!! to true, variantMapper[P4::class]!! to true, variantMapper[P5::class]!! to true, variantMapper[P6::class]!! to true, variantMapper[P7::class]!! to true, variantMapper[P8::class]!! to true, variantMapper[P9::class]!! to true, variantMapper[P10::class]!! to true, variantMapper[P11::class]!! to true, variantMapper[P12::class]!! to true, variantMapper[P13::class]!! to true, variantMapper[P14::class]!! to true, variantMapper[P15::class]!! to true, 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() = callable(this) diff --git a/kt/godot-library/src/main/kotlin/godot/gen/godot/signals/Signals.kt b/kt/godot-library/src/main/kotlin/godot/gen/godot/signals/Signals.kt new file mode 100644 index 0000000000..89cbf12eac --- /dev/null +++ b/kt/godot-library/src/main/kotlin/godot/gen/godot/signals/Signals.kt @@ -0,0 +1,1465 @@ +@file:Suppress("PackageDirectoryMismatch") + +package godot.signals + +import godot.Object +import godot.core.Callable +import godot.core.GodotError +import godot.core.asStringName +import godot.core.callable.asCallable +import godot.util.camelToSnakeCase +import kotlin.Int +import kotlin.String +import kotlin.Suppress +import kotlin.Unit +import kotlin.jvm.JvmStatic +import kotlin.reflect.KCallable + +public class Signal0( + instance: Object, + name: String, +) : Signal(instance, name) { + public fun emit(): Unit { + emitSignal() + } + + public fun connect( + target: T, + method: T.() -> Unit, + flags: Int = 0, + ): GodotError = + connect(Callable(target, (method as KCallable<*>).name.camelToSnakeCase().asStringName()), flags) + + public fun disconnect(target: T, method: T.() -> Unit): Unit = + disconnect(Callable(target, (method as KCallable<*>).name.camelToSnakeCase().asStringName())) +} + +public fun Signal0.connect(flags: Int = 0, method: () -> Unit): GodotError = + connect(method.asCallable(), flags) + +public fun signal(): SignalDelegateProvider = SignalDelegateProvider(::Signal0) + +public class Signal1( + instance: Object, + name: String, +) : Signal(instance, name) { + public fun emit(p0: P0): Unit { + emitSignal(p0) + } + + public fun connect( + target: T, + method: T.(p0: P0) -> Unit, + flags: Int = 0, + ): GodotError = + connect(Callable(target, (method as KCallable<*>).name.camelToSnakeCase().asStringName()), flags) + + public fun disconnect(target: T, method: T.(p0: P0) -> Unit): Unit = + disconnect(Callable(target, (method as KCallable<*>).name.camelToSnakeCase().asStringName())) +} + +public inline fun Signal1.connect(flags: Int = 0, noinline + method: (p0: P0) -> Unit): GodotError = connect(method.asCallable(), flags) + +@Suppress("UNUSED_PARAMETER") +public fun signal(p0: String): SignalDelegateProvider> = + SignalDelegateProvider(::Signal1) + +public class Signal2( + instance: Object, + name: String, +) : Signal(instance, name) { + public fun emit(p0: P0, p1: P1): Unit { + emitSignal(p0, p1) + } + + public fun connect( + target: T, + method: T.(p0: P0, p1: P1) -> Unit, + flags: Int = 0, + ): GodotError = + connect(Callable(target, (method as KCallable<*>).name.camelToSnakeCase().asStringName()), flags) + + public fun disconnect(target: T, method: T.(p0: P0, p1: P1) -> Unit): Unit = + disconnect(Callable(target, (method as KCallable<*>).name.camelToSnakeCase().asStringName())) +} + +public inline fun Signal2.connect(flags: Int = 0, noinline + method: (p0: P0, p1: P1) -> Unit): GodotError = connect(method.asCallable(), flags) + +@Suppress("UNUSED_PARAMETER") +public fun signal(p0: String, p1: String): SignalDelegateProvider> = + SignalDelegateProvider(::Signal2) + +public class Signal3( + instance: Object, + name: String, +) : Signal(instance, name) { + public fun emit( + p0: P0, + p1: P1, + p2: P2, + ): Unit { + emitSignal(p0, p1, p2) + } + + public fun connect( + target: T, + method: T.( + p0: P0, + p1: P1, + p2: P2, + ) -> Unit, + flags: Int = 0, + ): GodotError = + connect(Callable(target, (method as KCallable<*>).name.camelToSnakeCase().asStringName()), flags) + + public fun disconnect(target: T, method: T.( + p0: P0, + p1: P1, + p2: P2, + ) -> Unit): Unit = + disconnect(Callable(target, (method as KCallable<*>).name.camelToSnakeCase().asStringName())) +} + +public inline fun Signal3.connect(flags: Int = 0, + noinline method: ( + p0: P0, + p1: P1, + p2: P2, +) -> Unit): GodotError = connect(method.asCallable(), flags) + +@Suppress("UNUSED_PARAMETER") +public fun signal( + p0: String, + p1: String, + p2: String, +): SignalDelegateProvider> = SignalDelegateProvider(::Signal3) + +public class Signal4( + instance: Object, + name: String, +) : Signal(instance, name) { + public fun emit( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + ): Unit { + emitSignal(p0, p1, p2, p3) + } + + public fun connect( + target: T, + method: T.( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + ) -> Unit, + flags: Int = 0, + ): GodotError = + connect(Callable(target, (method as KCallable<*>).name.camelToSnakeCase().asStringName()), 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.camelToSnakeCase().asStringName())) +} + +public inline fun + Signal4.connect(flags: Int = 0, noinline method: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, +) -> Unit): GodotError = connect(method.asCallable(), flags) + +@Suppress("UNUSED_PARAMETER") +public fun signal( + p0: String, + p1: String, + p2: String, + p3: String, +): SignalDelegateProvider> = SignalDelegateProvider(::Signal4) + +public class Signal5( + instance: Object, + name: String, +) : Signal(instance, name) { + public fun emit( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + ): Unit { + emitSignal(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, + ): GodotError = + connect(Callable(target, (method as KCallable<*>).name.camelToSnakeCase().asStringName()), 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.camelToSnakeCase().asStringName())) +} + +public inline fun + Signal5.connect(flags: Int = 0, noinline method: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, +) -> Unit): GodotError = connect(method.asCallable(), flags) + +@Suppress("UNUSED_PARAMETER") +public fun signal( + p0: String, + p1: String, + p2: String, + p3: String, + p4: String, +): SignalDelegateProvider> = SignalDelegateProvider(::Signal5) + +public class Signal6( + instance: Object, + name: String, +) : Signal(instance, name) { + public fun emit( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + ): Unit { + emitSignal(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, + ): GodotError = + connect(Callable(target, (method as KCallable<*>).name.camelToSnakeCase().asStringName()), 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.camelToSnakeCase().asStringName())) +} + +public inline fun + Signal6.connect(flags: Int = 0, noinline method: ( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, +) -> Unit): GodotError = connect(method.asCallable(), flags) + +@Suppress("UNUSED_PARAMETER") +public fun signal( + p0: String, + p1: String, + p2: String, + p3: String, + p4: String, + p5: String, +): SignalDelegateProvider> = SignalDelegateProvider(::Signal6) + +public class Signal7( + instance: Object, + name: String, +) : Signal(instance, name) { + public fun emit( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + ): Unit { + emitSignal(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, + ): GodotError = + connect(Callable(target, (method as KCallable<*>).name.camelToSnakeCase().asStringName()), 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.camelToSnakeCase().asStringName())) +} + +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): GodotError = connect(method.asCallable(), flags) + +@Suppress("UNUSED_PARAMETER") +public fun signal( + p0: String, + p1: String, + p2: String, + p3: String, + p4: String, + p5: String, + p6: String, +): SignalDelegateProvider> = SignalDelegateProvider(::Signal7) + +public class Signal8( + instance: Object, + name: String, +) : Signal(instance, name) { + public fun emit( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + ): Unit { + emitSignal(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, + ): GodotError = + connect(Callable(target, (method as KCallable<*>).name.camelToSnakeCase().asStringName()), 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.camelToSnakeCase().asStringName())) +} + +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): GodotError = connect(method.asCallable(), flags) + +@Suppress("UNUSED_PARAMETER") +public fun signal( + p0: String, + p1: String, + p2: String, + p3: String, + p4: String, + p5: String, + p6: String, + p7: String, +): SignalDelegateProvider> = + SignalDelegateProvider(::Signal8) + +public class Signal9( + instance: Object, + name: String, +) : Signal(instance, name) { + public fun emit( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + ): Unit { + emitSignal(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, + ): GodotError = + connect(Callable(target, (method as KCallable<*>).name.camelToSnakeCase().asStringName()), 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.camelToSnakeCase().asStringName())) +} + +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): GodotError = connect(method.asCallable(), flags) + +@Suppress("UNUSED_PARAMETER") +public fun signal( + p0: String, + p1: String, + p2: String, + p3: String, + p4: String, + p5: String, + p6: String, + p7: String, + p8: String, +): SignalDelegateProvider> = + SignalDelegateProvider(::Signal9) + +public class Signal10( + instance: Object, + name: String, +) : Signal(instance, name) { + public fun emit( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + ): Unit { + emitSignal(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, + ): GodotError = + connect(Callable(target, (method as KCallable<*>).name.camelToSnakeCase().asStringName()), 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.camelToSnakeCase().asStringName())) +} + +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): GodotError = connect(method.asCallable(), flags) + +@Suppress("UNUSED_PARAMETER") +public fun signal( + p0: String, + p1: String, + p2: String, + p3: String, + p4: String, + p5: String, + p6: String, + p7: String, + p8: String, + p9: String, +): SignalDelegateProvider> = + SignalDelegateProvider(::Signal10) + +public class Signal11( + instance: Object, + name: String, +) : Signal(instance, name) { + public fun emit( + p0: P0, + p1: P1, + p2: P2, + p3: P3, + p4: P4, + p5: P5, + p6: P6, + p7: P7, + p8: P8, + p9: P9, + p10: P10, + ): Unit { + emitSignal(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, + ): GodotError = + connect(Callable(target, (method as KCallable<*>).name.camelToSnakeCase().asStringName()), 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.camelToSnakeCase().asStringName())) +} + +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): GodotError = connect(method.asCallable(), flags) + +@Suppress("UNUSED_PARAMETER") +public fun signal( + p0: String, + p1: String, + p2: String, + p3: String, + p4: String, + p5: String, + p6: String, + p7: String, + p8: String, + p9: String, + p10: String, +): SignalDelegateProvider> = + SignalDelegateProvider(::Signal11) + +public class Signal12( + instance: Object, + name: String, +) : Signal(instance, name) { + public fun emit( + 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 { + emitSignal(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, + ): GodotError = + connect(Callable(target, (method as KCallable<*>).name.camelToSnakeCase().asStringName()), 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.camelToSnakeCase().asStringName())) +} + +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): GodotError = connect(method.asCallable(), flags) + +@Suppress("UNUSED_PARAMETER") +public fun signal( + p0: String, + p1: String, + p2: String, + p3: String, + p4: String, + p5: String, + p6: String, + p7: String, + p8: String, + p9: String, + p10: String, + p11: String, +): SignalDelegateProvider> = + SignalDelegateProvider(::Signal12) + +public class Signal13( + instance: Object, + name: String, +) : Signal(instance, name) { + public fun emit( + 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 { + emitSignal(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, + ): GodotError = + connect(Callable(target, (method as KCallable<*>).name.camelToSnakeCase().asStringName()), 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.camelToSnakeCase().asStringName())) +} + +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): GodotError = connect(method.asCallable(), flags) + +@Suppress("UNUSED_PARAMETER") +public fun signal( + p0: String, + p1: String, + p2: String, + p3: String, + p4: String, + p5: String, + p6: String, + p7: String, + p8: String, + p9: String, + p10: String, + p11: String, + p12: String, +): SignalDelegateProvider> = + SignalDelegateProvider(::Signal13) + +public class Signal14( + instance: Object, + name: String, +) : Signal(instance, name) { + public fun emit( + 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 { + emitSignal(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13) + } + + 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, + p13: P13, + ) -> Unit, + flags: Int = 0, + ): GodotError = + connect(Callable(target, (method as KCallable<*>).name.camelToSnakeCase().asStringName()), 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.camelToSnakeCase().asStringName())) +} + +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): GodotError = connect(method.asCallable(), flags) + +@Suppress("UNUSED_PARAMETER") +public fun signal( + p0: String, + p1: String, + p2: String, + p3: String, + p4: String, + p5: String, + p6: String, + p7: String, + p8: String, + p9: String, + p10: String, + p11: String, + p12: String, + p13: String, +): SignalDelegateProvider> = + SignalDelegateProvider(::Signal14) + +public class Signal15( + instance: Object, + name: String, +) : Signal(instance, name) { + public fun emit( + 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 { + emitSignal(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14) + } + + 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, + p13: P13, + p14: P14, + ) -> Unit, + flags: Int = 0, + ): GodotError = + connect(Callable(target, (method as KCallable<*>).name.camelToSnakeCase().asStringName()), 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.camelToSnakeCase().asStringName())) +} + +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): GodotError = connect(method.asCallable(), flags) + +@Suppress("UNUSED_PARAMETER") +public fun signal( + p0: String, + p1: String, + p2: String, + p3: String, + p4: String, + p5: String, + p6: String, + p7: String, + p8: String, + p9: String, + p10: String, + p11: String, + p12: String, + p13: String, + p14: String, +): SignalDelegateProvider> + = SignalDelegateProvider(::Signal15) + +public class Signal16( + instance: Object, + name: String, +) : Signal(instance, name) { + public fun emit( + 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 { + emitSignal(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15) + } + + 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, + p13: P13, + p14: P14, + p15: P15, + ) -> Unit, + flags: Int = 0, + ): GodotError = + connect(Callable(target, (method as KCallable<*>).name.camelToSnakeCase().asStringName()), 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.camelToSnakeCase().asStringName())) +} + +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): GodotError = connect(method.asCallable(), flags) + +@Suppress("UNUSED_PARAMETER") +public fun signal( + p0: String, + p1: String, + p2: String, + p3: String, + p4: String, + p5: String, + p6: String, + p7: String, + p8: String, + p9: String, + p10: String, + p11: String, + p12: String, + p13: String, + p14: String, + p15: String, +): + SignalDelegateProvider> + = SignalDelegateProvider(::Signal16) + +public object SignalProvider { + @JvmStatic + public fun signal(thisRef: Object, name: String): Signal0 = Signal0(thisRef, name) + + @Suppress("UNUSED_PARAMETER") + @JvmStatic + public fun signal( + thisRef: Object, + name: String, + p0: String, + ): Signal1 = Signal1(thisRef, name) + + @Suppress("UNUSED_PARAMETER") + @JvmStatic + public fun signal( + thisRef: Object, + name: String, + p0: String, + p1: String, + ): Signal2 = Signal2(thisRef, name) + + @Suppress("UNUSED_PARAMETER") + @JvmStatic + public fun signal( + thisRef: Object, + name: String, + p0: String, + p1: String, + p2: String, + ): Signal3 = Signal3(thisRef, name) + + @Suppress("UNUSED_PARAMETER") + @JvmStatic + public fun signal( + thisRef: Object, + name: String, + p0: String, + p1: String, + p2: String, + p3: String, + ): Signal4 = Signal4(thisRef, name) + + @Suppress("UNUSED_PARAMETER") + @JvmStatic + public fun signal( + thisRef: Object, + name: String, + p0: String, + p1: String, + p2: String, + p3: String, + p4: String, + ): Signal5 = Signal5(thisRef, name) + + @Suppress("UNUSED_PARAMETER") + @JvmStatic + public fun signal( + thisRef: Object, + name: String, + p0: String, + p1: String, + p2: String, + p3: String, + p4: String, + p5: String, + ): Signal6 = Signal6(thisRef, name) + + @Suppress("UNUSED_PARAMETER") + @JvmStatic + public fun signal( + thisRef: Object, + name: String, + p0: String, + p1: String, + p2: String, + p3: String, + p4: String, + p5: String, + p6: String, + ): Signal7 = Signal7(thisRef, name) + + @Suppress("UNUSED_PARAMETER") + @JvmStatic + public fun signal( + thisRef: Object, + name: String, + p0: String, + p1: String, + p2: String, + p3: String, + p4: String, + p5: String, + p6: String, + p7: String, + ): Signal8 = + Signal8(thisRef, name) + + @Suppress("UNUSED_PARAMETER") + @JvmStatic + public fun signal( + thisRef: Object, + name: String, + p0: String, + p1: String, + p2: String, + p3: String, + p4: String, + p5: String, + p6: String, + p7: String, + p8: String, + ): Signal9 = + Signal9(thisRef, name) + + @Suppress("UNUSED_PARAMETER") + @JvmStatic + public fun signal( + thisRef: Object, + name: String, + p0: String, + p1: String, + p2: String, + p3: String, + p4: String, + p5: String, + p6: String, + p7: String, + p8: String, + p9: String, + ): Signal10 = + Signal10(thisRef, name) + + @Suppress("UNUSED_PARAMETER") + @JvmStatic + public fun signal( + thisRef: Object, + name: String, + p0: String, + p1: String, + p2: String, + p3: String, + p4: String, + p5: String, + p6: String, + p7: String, + p8: String, + p9: String, + p10: String, + ): Signal11 = + Signal11(thisRef, name) + + @Suppress("UNUSED_PARAMETER") + @JvmStatic + public fun signal( + thisRef: Object, + name: String, + p0: String, + p1: String, + p2: String, + p3: String, + p4: String, + p5: String, + p6: String, + p7: String, + p8: String, + p9: String, + p10: String, + p11: String, + ): Signal12 = + Signal12(thisRef, name) + + @Suppress("UNUSED_PARAMETER") + @JvmStatic + public fun signal( + thisRef: Object, + name: String, + p0: String, + p1: String, + p2: String, + p3: String, + p4: String, + p5: String, + p6: String, + p7: String, + p8: String, + p9: String, + p10: String, + p11: String, + p12: String, + ): Signal13 = + Signal13(thisRef, name) + + @Suppress("UNUSED_PARAMETER") + @JvmStatic + public fun signal( + thisRef: Object, + name: String, + p0: String, + p1: String, + p2: String, + p3: String, + p4: String, + p5: String, + p6: String, + p7: String, + p8: String, + p9: String, + p10: String, + p11: String, + p12: String, + p13: String, + ): Signal14 = + Signal14(thisRef, name) + + @Suppress("UNUSED_PARAMETER") + @JvmStatic + public fun signal( + thisRef: Object, + name: String, + p0: String, + p1: String, + p2: String, + p3: String, + p4: String, + p5: String, + p6: String, + p7: String, + p8: String, + p9: String, + p10: String, + p11: String, + p12: String, + p13: String, + p14: String, + ): Signal15 = + Signal15(thisRef, name) + + @Suppress("UNUSED_PARAMETER") + @JvmStatic + public fun signal( + thisRef: Object, + name: String, + p0: String, + p1: String, + p2: String, + p3: String, + p4: String, + p5: String, + p6: String, + p7: String, + p8: String, + p9: String, + p10: String, + p11: String, + p12: String, + p13: String, + p14: String, + p15: String, + ): Signal16 = + Signal16(thisRef, name) +} diff --git a/kt/godot-library/src/main/kotlin/godot/signals/Signal.kt b/kt/godot-library/src/main/kotlin/godot/signals/Signal.kt new file mode 100644 index 0000000000..7eb3862f08 --- /dev/null +++ b/kt/godot-library/src/main/kotlin/godot/signals/Signal.kt @@ -0,0 +1,55 @@ +package godot.signals + +import godot.Object +import godot.core.Callable +import godot.core.CoreType +import godot.core.StringName +import godot.core.asStringName +import godot.global.GD +import godot.util.camelToSnakeCase + +open class Signal internal constructor( + val godotObject: Object, + val name: StringName +) : CoreType { + + constructor(instance: Object, jvmName: String) : this( + instance, + jvmName.camelToSnakeCase().removePrefix("_").asStringName() + ) + + fun emitSignal(vararg args: Any?) { + godotObject.emitSignal(name, *args) + } + + fun connect( + callable: Callable, + flags: Int = 0 + ) = godotObject.connect(name, callable, flags.toLong()) + + fun disconnect(callable: Callable) = godotObject.disconnect(name, callable) + + fun getConnections() = godotObject.getSignalConnectionList(name) + + fun isConnected(callable: Callable) = godotObject.isConnected(name, callable) + + fun isNull() = !(GD.isInstanceValid(godotObject) && godotObject.hasSignal(name)) + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as Signal + + if (godotObject != other.godotObject) return false + if (name != other.name) return false + + return true + } + + override fun hashCode(): Int { + var result = godotObject.hashCode() + result = 31 * result + name.hashCode() + return result + } +} \ No newline at end of file diff --git a/kt/godot-library/src/main/kotlin/godot/signals/SignalProvider.kt b/kt/godot-library/src/main/kotlin/godot/signals/SignalProvider.kt index 413bb064a7..737b850a20 100644 --- a/kt/godot-library/src/main/kotlin/godot/signals/SignalProvider.kt +++ b/kt/godot-library/src/main/kotlin/godot/signals/SignalProvider.kt @@ -3,38 +3,6 @@ package godot.signals import godot.Object import kotlin.reflect.KProperty -/** - * For java convenience usage - */ -object SignalProvider { - @JvmStatic - fun signal(thisRef: Object, name: String): Signal0 = Signal0(thisRef, name) - @JvmStatic - @Suppress("UNUSED_PARAMETER") - fun signal(thisRef: Object, name: String, p0: String) = Signal1(thisRef, name) - @JvmStatic - @Suppress("UNUSED_PARAMETER") - fun signal(thisRef: Object, name: String, p0: String, p1: String) = Signal2(thisRef, name) - @JvmStatic - @Suppress("UNUSED_PARAMETER") - fun signal(thisRef: Object, name: String, p0: String, p1: String, p2: String) = Signal3(thisRef, name) - @JvmStatic - @Suppress("UNUSED_PARAMETER") - fun signal(thisRef: Object, name: String, p0: String, p1: String, p2: String, p3: String) = Signal4(thisRef, name) - @JvmStatic - @Suppress("UNUSED_PARAMETER") - fun signal(thisRef: Object, name: String, p0: String, p1: String, p2: String, p3: String, p4: String) = Signal5(thisRef, name) - @JvmStatic - @Suppress("UNUSED_PARAMETER") - fun signal(thisRef: Object, name: String, p0: String, p1: String, p2: String, p3: String, p4: String, p5: String) = Signal6(thisRef, name) - @JvmStatic - @Suppress("UNUSED_PARAMETER") - fun signal(thisRef: Object, name: String, p0: String, p1: String, p2: String, p3: String, p4: String, p5: String, p6: String) = Signal7(thisRef, name) - @JvmStatic - @Suppress("UNUSED_PARAMETER") - fun signal(thisRef: Object, name: String, p0: String, p1: String, p2: String, p3: String, p4: String, p5: String, p6: String, p7: String) = Signal8(thisRef, name) -} - class SignalDelegate(val factory: () -> T) { @PublishedApi internal var signal: T? = null @@ -51,83 +19,4 @@ class SignalDelegateProvider(private val factory: (Object, String) - operator fun provideDelegate(thisRef: Object, property: KProperty<*>): SignalDelegate { return SignalDelegate { factory(thisRef, property.name) } } -} - -fun signal(): SignalDelegateProvider { - return SignalDelegateProvider(::Signal0) -} - -@Suppress("UNUSED_PARAMETER") -fun signal(p0: String): SignalDelegateProvider> { - return SignalDelegateProvider(::Signal1) -} - -@Suppress("UNUSED_PARAMETER") -fun signal(p0: String, p1: String): SignalDelegateProvider> { - return SignalDelegateProvider(::Signal2) -} - -@Suppress("UNUSED_PARAMETER") -fun signal(p0: String, p1: String, p2: String): SignalDelegateProvider> { - return SignalDelegateProvider(::Signal3) -} - -@Suppress("UNUSED_PARAMETER") -fun signal( - p0: String, - p1: String, - p2: String, - p3: String -): SignalDelegateProvider> { - return SignalDelegateProvider(::Signal4) -} - -@Suppress("UNUSED_PARAMETER") -fun signal( - p0: String, - p1: String, - p2: String, - p3: String, - p4: String -): SignalDelegateProvider> { - return SignalDelegateProvider(::Signal5) -} - -@Suppress("UNUSED_PARAMETER") -fun signal( - p0: String, - p1: String, - p2: String, - p3: String, - p4: String, - p5: String -): SignalDelegateProvider> { - return SignalDelegateProvider(::Signal6) -} - -@Suppress("UNUSED_PARAMETER") -fun signal( - p0: String, - p1: String, - p2: String, - p3: String, - p4: String, - p5: String, - p6: String -): SignalDelegateProvider> { - return SignalDelegateProvider(::Signal7) -} - -@Suppress("UNUSED_PARAMETER") -fun signal( - p0: String, - p1: String, - p2: String, - p3: String, - p4: String, - p5: String, - p6: String, - p7: String -): SignalDelegateProvider> { - return SignalDelegateProvider(::Signal8) -} +} \ No newline at end of file diff --git a/kt/godot-library/src/main/kotlin/godot/signals/Signals.kt b/kt/godot-library/src/main/kotlin/godot/signals/Signals.kt deleted file mode 100644 index 8561455b27..0000000000 --- a/kt/godot-library/src/main/kotlin/godot/signals/Signals.kt +++ /dev/null @@ -1,308 +0,0 @@ -package godot.signals - -import godot.Object -import godot.core.Callable -import godot.core.CoreType -import godot.core.GodotError -import godot.core.StringName -import godot.core.asStringName -import godot.global.GD -import godot.util.camelToSnakeCase -import kotlin.reflect.KCallable - -open class Signal internal constructor( - val godotObject: Object, - val name: StringName -) : CoreType { - - constructor(instance: Object, jvmName: String) : this( - instance, - jvmName.camelToSnakeCase().removePrefix("_").asStringName() - ) - - fun emitSignal(vararg args: Any?) { - godotObject.emitSignal(name, *args) - } - - fun connect( - callable: Callable, - flags: Int = 0 - ) = godotObject.connect(name, callable, flags.toLong()) - - fun disconnect(callable: Callable) = godotObject.disconnect(name, callable) - - fun getConnections() = godotObject.getSignalConnectionList(name) - - fun isConnected(callable: Callable) = godotObject.isConnected(name, callable) - - fun isNull() = !(GD.isInstanceValid(godotObject) && godotObject.hasSignal(name)) - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (javaClass != other?.javaClass) return false - - other as Signal - - if (godotObject != other.godotObject) return false - if (name != other.name) return false - - return true - } - - override fun hashCode(): Int { - var result = godotObject.hashCode() - result = 31 * result + name.hashCode() - return result - } -} - -class Signal0(instance: Object, name: String) : Signal(instance, name) { - fun emit() { - emitSignal() - } - - fun connect( - target: T, - method: T.() -> Unit, - flags: Int = 0, - ): GodotError { - val methodName = (method as KCallable<*>).name.camelToSnakeCase().asStringName() - return connect(Callable(target, methodName), flags) - } - - fun disconnect( - target: T, - method: T.() -> Unit - ) { - val methodName = (method as KCallable<*>).name.camelToSnakeCase().asStringName() - return disconnect(Callable(target, methodName)) - } -} - -class Signal1(instance: Object, name: String) : Signal(instance, name) { - fun emit(p0: P0) { - emitSignal( - p0 - ) - } - - fun connect( - target: T, - method: T.(P0) -> Unit, - flags: Int = 0, - ): GodotError { - val methodName = (method as KCallable<*>).name.camelToSnakeCase().asStringName() - return connect(Callable(target, methodName), flags) - } - - fun disconnect( - target: T, - method: T.(P0) -> Unit - ) { - val methodName = (method as KCallable<*>).name.camelToSnakeCase().asStringName() - return disconnect(Callable(target, methodName)) - } -} - -class Signal2(instance: Object, name: String) : Signal(instance, name) { - fun emit(p0: P0, p1: P1) { - emitSignal( - p0, - p1 - ) - } - - fun connect( - target: T, - method: T.(P0, P1) -> Unit, - flags: Int = 0, - ): GodotError { - val methodName = (method as KCallable<*>).name.camelToSnakeCase().asStringName() - return connect(Callable(target, methodName), flags) - } - - fun disconnect( - target: T, - method: T.(P0, P1) -> Unit - ) { - val methodName = (method as KCallable<*>).name.camelToSnakeCase().asStringName() - return disconnect(Callable(target, methodName)) - } -} - -class Signal3(instance: Object, name: String) : Signal(instance, name) { - fun emit(p0: P0, p1: P1, p2: P2) { - emitSignal( - p0, - p1, - p2 - ) - } - - fun connect( - target: T, - method: T.(P0, P1, P2) -> Unit, - flags: Int = 0, - ): GodotError { - val methodName = (method as KCallable<*>).name.camelToSnakeCase().asStringName() - return connect(Callable(target, methodName), flags) - } - - fun disconnect( - target: T, - method: T.(P0, P1, P2) -> Unit - ) { - val methodName = (method as KCallable<*>).name.camelToSnakeCase().asStringName() - return disconnect(Callable(target, methodName)) - } -} - -class Signal4(instance: Object, name: String) : Signal(instance, name) { - fun emit(p0: P0, p1: P1, p2: P2, p3: P3) { - emitSignal( - p0, - p1, - p2, - p3 - ) - } - - fun connect( - target: T, - method: T.(P0, P1, P2, P3) -> Unit, - flags: Int = 0, - ): GodotError { - val methodName = (method as KCallable<*>).name.camelToSnakeCase().asStringName() - return connect(Callable(target, methodName), flags) - } - - fun disconnect( - target: T, - method: T.(P0, P1, P2, P3) -> Unit - ) { - val methodName = (method as KCallable<*>).name.camelToSnakeCase().asStringName() - return disconnect(Callable(target, methodName)) - } -} - -class Signal5(instance: Object, name: String) : Signal(instance, name) { - fun emit(p0: P0, p1: P1, p2: P2, p3: P3, p4: P4) { - emitSignal( - p0, - p1, - p2, - p3, - p4 - ) - } - - fun connect( - target: T, - method: T.(P0, P1, P2, P3, P4) -> Unit, - flags: Int = 0, - ): GodotError { - val methodName = (method as KCallable<*>).name.camelToSnakeCase().asStringName() - return connect(Callable(target, methodName), flags) - } - - fun disconnect( - target: T, - method: T.(P0, P1, P2, P3, P4) -> Unit - ) { - val methodName = (method as KCallable<*>).name.camelToSnakeCase().asStringName() - return disconnect(Callable(target, methodName)) - } -} - -class Signal6(instance: Object, name: String) : Signal(instance, name) { - fun emit(p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5) { - emitSignal( - p0, - p1, - p2, - p3, - p4, - p5 - ) - } - - fun connect( - target: T, - method: T.(P0, P1, P2, P3, P4, P5) -> Unit, - flags: Int = 0, - ): GodotError { - val methodName = (method as KCallable<*>).name.camelToSnakeCase().asStringName() - return connect(Callable(target, methodName), flags) - } - - fun disconnect( - target: T, - method: T.(P0, P1, P2, P3, P4, P5) -> Unit - ) { - val methodName = (method as KCallable<*>).name.camelToSnakeCase().asStringName() - return disconnect(Callable(target, methodName)) - } -} - -class Signal7(instance: Object, name: String) : Signal(instance, name) { - fun emit(p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6) { - emitSignal( - p0, - p1, - p2, - p3, - p4, - p5, - p6 - ) - } - - fun connect( - target: T, - method: T.(P0, P1, P2, P3, P4, P5, P6) -> Unit, - flags: Int = 0, - ): GodotError { - val methodName = (method as KCallable<*>).name.camelToSnakeCase().asStringName() - return connect(Callable(target, methodName), flags) - } - - fun disconnect( - target: T, - method: T.(P0, P1, P2, P3, P4, P5, P6) -> Unit - ) { - val methodName = (method as KCallable<*>).name.camelToSnakeCase().asStringName() - return disconnect(Callable(target, methodName)) - } -} - -class Signal8(instance: Object, name: String) : Signal(instance, name) { - fun emit(p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7) { - emitSignal( - p0, - p1, - p2, - p3, - p4, - p5, - p6, - p7 - ) - } - - fun connect( - target: T, - method: T.(P0, P1, P2, P3, P4, P5, P6, P7) -> Unit, - flags: Int = 0, - ): GodotError { - val methodName = (method as KCallable<*>).name.camelToSnakeCase().asStringName() - return connect(Callable(target, methodName), flags) - } - - fun disconnect( - target: T, - method: T.(P0, P1, P2, P3, P4, P5, P6, P7) -> Unit - ) { - val methodName = (method as KCallable<*>).name.camelToSnakeCase().asStringName() - return disconnect(Callable(target, methodName)) - } -} 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 e8a35a29de..69f42b697d 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 @@ -7,6 +7,7 @@ object GodotKotlinJvmTypes{ const val stringName = "StringName" const val array = "VariantArray" const val callable = "Callable" + const val callableBase = "Callable" const val dictionary = "Dictionary" const val error = "GodotError" const val nodePath = "NodePath" @@ -109,6 +110,7 @@ object GodotTypes { const val vector4 = "Vector4" const val vector4i = "Vector4i" const val projection = "Projection" + const val ktCallable = "KtCallable" const val callable = "Callable" const val signal = "Signal" const val variant = "Variant" @@ -198,6 +200,7 @@ object GodotTypes { 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_DICTIONARY = ClassName(godotCorePackage, GodotKotlinJvmTypes.dictionary) val GODOT_OBJECT = ClassName(godotApiPackage, GodotKotlinJvmTypes.obj) val KT_OBJECT = ClassName(godotCorePackage, GodotKotlinJvmTypes.ktObject) @@ -223,6 +226,7 @@ val VARIANT_TYPE_PACKED_STRING_ARRAY = ClassName(variantTypePackage, "PACKED_STR val VARIANT_TYPE_PACKED_VECTOR2_ARRAY = ClassName(variantTypePackage, "PACKED_VECTOR2_ARRAY") val VARIANT_TYPE_PACKED_VECTOR3_ARRAY = ClassName(variantTypePackage, "PACKED_VECTOR3_ARRAY") val VARIANT_TYPE_PACKED_COLOR_ARRAY = ClassName(variantTypePackage, "PACKED_COLOR_ARRAY") +val VARIANT_TYPE_PACKED_CALLABLE = ClassName(variantTypePackage, "CALLABLE") val VARIANT_TYPE_OBJECT = ClassName(variantTypePackage, "OBJECT") val VARIANT_TYPE_JVM_INT = ClassName(variantTypePackage, "JVM_INT") val VARIANT_TYPE_JVM_FLOAT = ClassName(variantTypePackage, "JVM_FLOAT") diff --git a/kt/tools-common/src/main/kotlin/godot/tools/common/constants/Functions.kt b/kt/tools-common/src/main/kotlin/godot/tools/common/constants/Functions.kt index 8b603d3c2a..1f88d49c7b 100644 --- a/kt/tools-common/src/main/kotlin/godot/tools/common/constants/Functions.kt +++ b/kt/tools-common/src/main/kotlin/godot/tools/common/constants/Functions.kt @@ -9,6 +9,12 @@ object KotlinFunctions { object GodotFunctions { const val notification = "_notification" + const val camelToSnakeCase = "camelToSnakeCase" + const val asStringName = "asStringName" + const val asCallable = "asCallable" } val KOTLIN_LIST_OF = MemberName(kotlinCollectionsPackage, KotlinFunctions.listOf) +val CAMEL_TO_SNAKE_CASE_UTIL_FUNCTION = MemberName(godotUtilPackage, GodotFunctions.camelToSnakeCase) +val AS_STRING_NAME_UTIL_FUNCTION = MemberName(godotCorePackage, GodotFunctions.asStringName) +val AS_CALLABLE_UTIL_FUNCTION = MemberName(callablePackage, GodotFunctions.asCallable) \ No newline at end of file diff --git a/kt/tools-common/src/main/kotlin/godot/tools/common/constants/Packages.kt b/kt/tools-common/src/main/kotlin/godot/tools/common/constants/Packages.kt index 9e6307d83c..1f7499ed76 100644 --- a/kt/tools-common/src/main/kotlin/godot/tools/common/constants/Packages.kt +++ b/kt/tools-common/src/main/kotlin/godot/tools/common/constants/Packages.kt @@ -4,8 +4,10 @@ const val signalPackage = "godot.signals" const val godotApiPackage = "godot" const val godotCorePackage = "godot.core" const val godotMemoryPackage = "godot.core.memory" +const val godotCallablePackage = "godot.core.callable" const val godotAnnotationPackage = "godot.annotation" const val godotUtilPackage = "godot.util" +const val callablePackage = "$godotCorePackage.callable" const val godotRegistrationPackage = "godot.registration" const val godotSignalsPackage = "godot.signals" diff --git a/src/gd_kotlin.cpp b/src/gd_kotlin.cpp index 4144296c98..c103346625 100644 --- a/src/gd_kotlin.cpp +++ b/src/gd_kotlin.cpp @@ -209,6 +209,8 @@ void GDKotlin::load_user_code() { } void GDKotlin::init() { + callable_middleman = memnew(Object); + fetch_user_configuration(); set_jvm_options(); @@ -258,6 +260,9 @@ void GDKotlin::finish() { #endif state = State::NOT_STARTED; + + memdelete(callable_middleman); + callable_middleman = nullptr; } const JvmUserConfiguration& GDKotlin::get_configuration() { @@ -363,6 +368,10 @@ void GDKotlin::unload_dynamic_lib() { } #endif +Object* GDKotlin::get_callable_middleman() const { + return callable_middleman; +} + #ifdef DEBUG_ENABLED void GDKotlin::validate_state() { bool invalid {false}; diff --git a/src/gd_kotlin.h b/src/gd_kotlin.h index adeaad8283..78b6e2ab09 100644 --- a/src/gd_kotlin.h +++ b/src/gd_kotlin.h @@ -28,6 +28,7 @@ class GDKotlin { ClassLoader* bootstrap_class_loader {nullptr}; Bootstrap* bootstrap {nullptr}; + Object* callable_middleman; //TODO: delete when https://github.com/godotengine/godot/issues/95231 is resolved void fetch_user_configuration(); void set_jvm_options(); @@ -64,6 +65,9 @@ class GDKotlin { void load_user_code(); void finish(); + //TODO: delete when https://github.com/godotengine/godot/issues/95231 is resolved + Object* get_callable_middleman() const; + #ifdef DEBUG_ENABLED void validate_state(); #endif diff --git a/src/jni/types.cpp b/src/jni/types.cpp index e67c7652f1..8018dc5151 100644 --- a/src/jni/types.cpp +++ b/src/jni/types.cpp @@ -84,6 +84,10 @@ namespace jni { return ret; } + bool JObject::is_same_object(Env& env, const JObject& other) const { + return env.is_same_object(obj, other.obj); + } + MethodId JClass::get_method_id(Env& env, const char* name, const char* signature) { auto id = env.env->GetMethodID((jclass) obj, name, signature); JVM_CRASH_COND_MSG(id == nullptr, vformat("Method not found: %s with signature: %s", name, signature)); diff --git a/src/jni/types.h b/src/jni/types.h index 88b7bafbd3..7b63d1f15c 100644 --- a/src/jni/types.h +++ b/src/jni/types.h @@ -78,6 +78,8 @@ namespace jni { jboolean call_boolean_method(Env& env, MethodId method, jvalue* args = {}) const; bool is_null(); + + bool is_same_object(Env& env, const JObject& other) const; }; template diff --git a/src/jvm_wrapper/bridge/callable_bridge.cpp b/src/jvm_wrapper/bridge/callable_bridge.cpp index a797f2e9c0..503adb9d1b 100644 --- a/src/jvm_wrapper/bridge/callable_bridge.cpp +++ b/src/jvm_wrapper/bridge/callable_bridge.cpp @@ -3,6 +3,7 @@ #include "bridges_utils.h" #include "constraints.h" #include "jvm_wrapper/memory/transfer_context.h" +#include "kotlin_callable_custom.h" using namespace bridges; @@ -17,12 +18,12 @@ uintptr_t CallableBridge::engine_call_constructor_object_string_name(JNIEnv* p_r return reinterpret_cast(memnew(Callable(args[0].operator Object*(), args[1].operator StringName()))); } -// TODO: Enable that code again when KtCustomCallable is back -// uintptr_t CallableBridge::engine_call_constructor_kt_custom_callable(JNIEnv* p_raw_env, jobject p_instance, jobject p_kt_custom_callable_instance) { -// return reinterpret_cast( -// memnew(Callable(memnew(KtCustomCallable(p_kt_custom_callable_instance)))) -// ); -// } +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) { + jni::Env env {p_raw_env}; + return reinterpret_cast( + memnew(Callable(memnew(KotlinCallableCustom(env, p_kt_custom_callable_instance, static_cast(p_variant_type_ordinal), p_hash_code)))) + ); +} uintptr_t CallableBridge::engine_call_copy_constructor(JNIEnv* p_raw_env, jobject p_instance) { jni::Env env {p_raw_env}; diff --git a/src/jvm_wrapper/bridge/callable_bridge.h b/src/jvm_wrapper/bridge/callable_bridge.h index 787b1b581a..cbb7e262f4 100644 --- a/src/jvm_wrapper/bridge/callable_bridge.h +++ b/src/jvm_wrapper/bridge/callable_bridge.h @@ -4,14 +4,14 @@ #include "jvm_wrapper/jvm_singleton_wrapper.h" namespace bridges { - JVM_SINGLETON_WRAPPER(CallableBridge, "godot.core.Callable$Bridge") { + JVM_SINGLETON_WRAPPER(CallableBridge, "godot.core.NativeCallable$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/KtCustomCallable;)J", CallableBridge::engine_call_constructor_kt_custom_callable) + INIT_NATIVE_METHOD("engine_call_constructor_kt_custom_callable", "(Lgodot/core/callable/KtCallable;II)J", CallableBridge::engine_call_constructor_kt_custom_callable) 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) @@ -39,8 +39,7 @@ namespace bridges { static uintptr_t engine_call_constructor_object_string_name(JNIEnv* p_raw_env, jobject p_instance); - //TODO: Enable that code again when KtCustomCallable is back - //static uintptr_t engine_call_constructor_kt_custom_callable(JNIEnv* p_raw_env, jobject p_instance, jobject p_kt_custom_callable_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); static uintptr_t engine_call_copy_constructor(JNIEnv* p_raw_env, jobject p_instance); diff --git a/src/jvm_wrapper/bridge/kt_callable_bridge.cpp b/src/jvm_wrapper/bridge/kt_callable_bridge.cpp new file mode 100644 index 0000000000..d2f9aaaff0 --- /dev/null +++ b/src/jvm_wrapper/bridge/kt_callable_bridge.cpp @@ -0,0 +1,13 @@ +#include "kt_callable_bridge.h" +#include "kotlin_callable_custom.h" + +using namespace bridges; + +uintptr_t KtCallableBridge::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) { + 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)) + ); +} diff --git a/src/jvm_wrapper/bridge/kt_callable_bridge.h b/src/jvm_wrapper/bridge/kt_callable_bridge.h new file mode 100644 index 0000000000..774e81ac54 --- /dev/null +++ b/src/jvm_wrapper/bridge/kt_callable_bridge.h @@ -0,0 +1,23 @@ +#ifndef GODOT_JVM_KT_CALLABLE_BRIDGE_H +#define GODOT_JVM_KT_CALLABLE_BRIDGE_H + + +#include "jvm_wrapper/jvm_singleton_wrapper.h" + +namespace bridges { + JVM_SINGLETON_WRAPPER(KtCallableBridge, "godot.core.callable.KtCallable$Bridge") { + SINGLETON_CLASS(KtCallableBridge) + + // clang-format off + INIT_JNI_BINDINGS( + INIT_NATIVE_METHOD("wrap_in_custom_callable", "(Lgodot/core/callable/KtCallable;II)J", KtCallableBridge::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); + }; +} + + +#endif //GODOT_JVM_KT_CALLABLE_BRIDGE_H diff --git a/src/kotlin_callable_custom.cpp b/src/kotlin_callable_custom.cpp new file mode 100644 index 0000000000..d1f1db2824 --- /dev/null +++ b/src/kotlin_callable_custom.cpp @@ -0,0 +1,81 @@ +#include "kotlin_callable_custom.h" +#include "jvm_wrapper/memory/transfer_context.h" +#include "gd_kotlin.h" + +void KtCallable::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); + + if (has_return_value) { + 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); + + return; + } + + wrapped.call_void_method(p_env, INVOKE_NO_RETURN); +} + +int KtCallable::get_hash_code() const { + return hash_code; +} + +bool KtCallable::equals(const KtCallable& other) const { + jni::Env env {jni::Jvm::current_env()}; + return wrapped.is_same_object(env, other.wrapped); +} + +KtCallable::KtCallable(jni::Env& p_env, jni::JObject p_wrapped, Variant::Type return_type, int p_hash_code) : JvmInstanceWrapper(p_env, p_wrapped) { + has_return_value = return_type != Variant::NIL; + + hash_code = p_hash_code; +} + + +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); +} + +uint32_t KotlinCallableCustom::hash() const { + return kt_callable.get_hash_code(); +} + +String KotlinCallableCustom::get_as_text() const { + return "KotlinCallableCustom::invoke"; +} + +ObjectID KotlinCallableCustom::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::CompareLessFunc KotlinCallableCustom::get_compare_less_func() const { + return &KotlinCallableCustom::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; + } + + return a->kt_callable.equals(b->kt_callable); +} + +bool KotlinCallableCustom::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) : CallableCustom(), + kt_callable(p_env, p_wrapped, return_type, p_hash_code) { + +} \ No newline at end of file diff --git a/src/kotlin_callable_custom.h b/src/kotlin_callable_custom.h new file mode 100644 index 0000000000..dd69ddd0a4 --- /dev/null +++ b/src/kotlin_callable_custom.h @@ -0,0 +1,57 @@ +#ifndef GODOT_JVM_KOTLIN_CALLABLE_CUSTOM_H +#define GODOT_JVM_KOTLIN_CALLABLE_CUSTOM_H + + +#include "jvm_wrapper/jvm_instance_wrapper.h" +#include "core/variant/callable.h" + +JVM_INSTANCE_WRAPPER(KtCallable, "godot.core.callable.KtCallable") { + // clang-format off + + JNI_METHOD(INVOKE_NO_RETURN) + JNI_METHOD(INVOKE_WITH_RETURN) + JNI_METHOD(GET_RETURN_VARIANT_TYPE) + JNI_METHOD(HASH_CODE) + + INIT_JNI_BINDINGS( + INIT_JNI_METHOD(INVOKE_NO_RETURN, "invokeNoReturn", "()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") + ) + + // clang-format on + +public: + void invoke(jni::Env& p_env, const Variant** p_args, int args_count, Variant& r_ret) const; + int get_hash_code() const; + bool equals(const KtCallable& other) const; + + KtCallable(jni::Env& p_env, jni::JObject p_wrapped, Variant::Type return_type, int p_hash_code); + +private: + int hash_code; + bool has_return_value; +}; + +class KotlinCallableCustom : public CallableCustom { +public: + void call(const Variant** p_arguments, int p_argcount, Variant& r_return_value, Callable::CallError& r_call_error) const override; + + uint32_t hash() const override; + String get_as_text() const override; + CompareEqualFunc get_compare_equal_func() const override; + 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); + +private: + KtCallable kt_callable; + + static bool compare_equal(const CallableCustom* p_a, const CallableCustom* p_b); + static bool compare_less(const CallableCustom* p_a, const CallableCustom* p_b); +}; + + +#endif //GODOT_JVM_KOTLIN_CALLABLE_CUSTOM_H diff --git a/src/kt_variant.h b/src/kt_variant.h index 02b71394b6..8b1ab6a704 100644 --- a/src/kt_variant.h +++ b/src/kt_variant.h @@ -232,6 +232,17 @@ namespace ktvariant { return Variant(*to_native_core_type(byte_buffer)); } + static Variant from_kvariant_tKCallableValue(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(to_native_core_type(byte_buffer)); + } + + return from_kvariant_tokVariantNativeCoreTypeValue(byte_buffer); + } + static Variant from_kvariant_toKObjectValue(SharedBuffer* byte_buffer) { return Variant(to_godot_object(byte_buffer)); } @@ -258,7 +269,7 @@ namespace ktvariant { to_gd_array[Variant::TRANSFORM3D] = from_kvariant_to_kVariantCoreTypeValue; to_gd_array[Variant::PROJECTION] = from_kvariant_to_kVariantCoreTypeValue; to_gd_array[Variant::COLOR] = from_kvariant_to_kVariantCoreTypeValue; - to_gd_array[Variant::CALLABLE] = from_kvariant_tokVariantNativeCoreTypeValue; + to_gd_array[Variant::CALLABLE] = from_kvariant_tKCallableValue; to_gd_array[Variant::SIGNAL] = from_kvariant_toKSignalValue; to_gd_array[Variant::DICTIONARY] = from_kvariant_tokVariantNativeCoreTypeValue; to_gd_array[Variant::ARRAY] = from_kvariant_tokVariantNativeCoreTypeValue; diff --git a/src/lifecycle/jvm_manager.cpp b/src/lifecycle/jvm_manager.cpp index d31e2b8061..1fb542cee8 100644 --- a/src/lifecycle/jvm_manager.cpp +++ b/src/lifecycle/jvm_manager.cpp @@ -20,6 +20,8 @@ #include "jvm_wrapper/memory/memory_manager.h" #include "jvm_wrapper/memory/transfer_context.h" #include "jvm_wrapper/registration/kt_class.h" +#include "kotlin_callable_custom.h" +#include "jvm_wrapper/bridge/kt_callable_bridge.h" #include #include @@ -103,6 +105,7 @@ bool JvmManager::initialize_jni_classes(jni::Env& p_env, ClassLoader* class_load KtFunctionInfo::initialize_jni_binding(p_env, class_loader); KtFunction::initialize_jni_binding(p_env, class_loader); KtClass::initialize_jni_binding(p_env, class_loader); + KtCallable::initialize_jni_binding(p_env, class_loader); return TransferContext::initialize(p_env, class_loader) && TypeManager::initialize(p_env, class_loader) @@ -110,6 +113,7 @@ bool JvmManager::initialize_jni_classes(jni::Env& p_env, ClassLoader* class_load && MemoryManager::initialize(p_env, class_loader) && bridges::GDPrintBridge::initialize(p_env, class_loader) && bridges::CallableBridge::initialize(p_env, class_loader) + && bridges::KtCallableBridge::initialize(p_env, class_loader) && bridges::DictionaryBridge::initialize(p_env, class_loader) && bridges::RidBridge::initialize(p_env, class_loader) && bridges::StringNameBridge::initialize(p_env, class_loader)