diff --git a/harness/tests/scripts/godot/tests/Invocation.gdj b/harness/tests/scripts/godot/tests/Invocation.gdj index ad8ec0b91..5dd455bb1 100644 --- a/harness/tests/scripts/godot/tests/Invocation.gdj +++ b/harness/tests/scripts/godot/tests/Invocation.gdj @@ -7,159 +7,159 @@ relativeSourcePath = src/main/kotlin/godot/tests/Invocation.kt baseType = Node3D supertypes = [ godot.Node3D, - godot.Node, - godot.Object, - godot.core.KtObject, - kotlin.Any + godot.Node, + godot.Object, + godot.core.KtObject, + kotlin.Any ] signals = [ ] properties = [ button, - enum_list, - vector_list, - enum_list_mutable, - register_object, - register_object_nullable, - register_object_nullable_pre_init, - register_object_non_nullable_pre_init, - vector, - x, - y, - z, - custom_name, - invocation, - enum_test, - resource_test, - jvm_id, - test_array_any, - nav_meshes, - nullable_array, - any_to_any_dictionary, - nav_meshes_dictionary, - nullable_dictionary, - color, - rid, - packed_byte_array, - packed_int32_array, - packed_float64_array, - packed_color_array, - packed_string_array, - packed_vector2_array, - packed_vector3_array, - p1, - p1_1, - p2, - p3, - p4, - p5, - p6, - p7, - p8, - p9, - p10, - p11, - p12, - p13, - p14, - p15, - p16, - p17, - stringtemplation, - test_string, - ascii_string, - utf8_string + enum_list, + vector_list, + enum_list_mutable, + register_object, + register_object_nullable, + register_object_nullable_pre_init, + register_object_non_nullable_pre_init, + vector, + x, + y, + z, + custom_name, + invocation, + enum_test, + resource_test, + jvm_id, + test_array_any, + nav_meshes, + nullable_array, + any_to_any_dictionary, + nav_meshes_dictionary, + nullable_dictionary, + color, + rid, + packed_byte_array, + packed_int32_array, + packed_float64_array, + packed_color_array, + packed_string_array, + packed_vector2_array, + packed_vector3_array, + p1, + p1_1, + p2, + p3, + p4, + p5, + p6, + p7, + p8, + p9, + p10, + p11, + p12, + p13, + p14, + p15, + p16, + p17, + stringtemplation, + test_string, + ascii_string, + utf8_string ] functions = [ int_value, - long_value, - float_value, - double_value, - boolean_value, - string_value, - int_addition, - init_nullables, - _enter_tree, - _ready, - _on_destroy, - get_rid_id, - get_nav_mesh_rid, - append_to_any_dict, - remove_from_any_dict, - get_from_any_dict, - any_dict_size, - append_to_string_nav_mesh_dict, - remove_from_string_nav_mesh_dict, - get_from_string_nav_mesh_dict, - string_nav_mesh_dict_size, - append_to_string_nav_mesh_nullable_dict, - remove_from_string_nav_mesh_nullable_dict, - string_nav_mesh_nullable_dict_size, - append_nullable_standard_nav_mesh, - append_nullable_nav_mesh, - remove_nullable_nav_mesh, - remove_nullable_nav_mesh_with_index, - nullable_nav_meshes_size, - append_standard_nav_mesh, - append_nav_mesh, - remove_nav_mesh, - remove_nav_mesh_with_index, - get_nav_mesh_from_array, - nav_meshes_size, - append_any_to_array, - remove_any_from_array, - get_any_from_array, - array_any_size, - count_namesh_instance, - get_nav_mesh_count, - parent_is_node3_d, - is_object_node3_d, - other_jvm_id, - has_camera_node, - add_byte_to_packed_array, - add_byte_array_to_packed_array, - delete_byte_from_packed_array, - get_byte_from_packed_array, - set_byte_in_packed_array, - resize_byte_packed_array, - add_color_to_packed_array, - add_color_array_to_packed_array, - delete_color_from_packed_array, - get_color_from_packed_array, - set_color_in_packed_array, - resize_color_packed_array, - add_int_to_packed_array, - add_int_array_to_packed_array, - delete_int_from_packed_array, - get_int_from_packed_array, - set_int_in_packed_array, - resize_int_packed_array, - add_real_to_packed_array, - add_real_array_to_packed_array, - read_string_from_byte_array, - delete_real_from_packed_array, - get_real_from_packed_array, - set_real_in_packed_array, - resize_real_packed_array, - add_string_to_packed_array, - add_string_array_to_packed_array, - delete_string_from_packed_array, - get_string_from_packed_array, - set_string_in_packed_array, - resize_string_packed_array, - add_vector2_to_packed_array, - add_vector2_array_to_packed_array, - delete_vector2_from_packed_array, - get_vector2_from_packed_array, - set_vector2_in_packed_array, - resize_vector2_packed_array, - add_vector3_to_packed_array, - add_vector3_array_to_packed_array, - delete_vector3_from_packed_array, - get_vector3_from_packed_array, - set_vector3_in_packed_array, - resize_vector3_packed_array, - is_sent_xr_same_instance_as_jvm_singleton, - create_variant_array_of_user_type -] + long_value, + float_value, + double_value, + boolean_value, + string_value, + int_addition, + init_nullables, + _enter_tree, + _ready, + _on_destroy, + get_rid_id, + get_nav_mesh_rid, + append_to_any_dict, + remove_from_any_dict, + get_from_any_dict, + any_dict_size, + append_to_string_nav_mesh_dict, + remove_from_string_nav_mesh_dict, + get_from_string_nav_mesh_dict, + string_nav_mesh_dict_size, + append_to_string_nav_mesh_nullable_dict, + remove_from_string_nav_mesh_nullable_dict, + string_nav_mesh_nullable_dict_size, + append_nullable_standard_nav_mesh, + append_nullable_nav_mesh, + remove_nullable_nav_mesh, + remove_nullable_nav_mesh_with_index, + nullable_nav_meshes_size, + append_standard_nav_mesh, + append_nav_mesh, + remove_nav_mesh, + remove_nav_mesh_with_index, + get_nav_mesh_from_array, + nav_meshes_size, + append_any_to_array, + remove_any_from_array, + get_any_from_array, + array_any_size, + count_namesh_instance, + get_nav_mesh_count, + parent_is_node3_d, + is_object_node3_d, + other_jvm_id, + has_camera_node, + add_byte_to_packed_array, + add_byte_array_to_packed_array, + delete_byte_from_packed_array, + get_byte_from_packed_array, + set_byte_in_packed_array, + resize_byte_packed_array, + add_color_to_packed_array, + add_color_array_to_packed_array, + delete_color_from_packed_array, + get_color_from_packed_array, + set_color_in_packed_array, + resize_color_packed_array, + add_int_to_packed_array, + add_int_array_to_packed_array, + delete_int_from_packed_array, + get_int_from_packed_array, + set_int_in_packed_array, + resize_int_packed_array, + add_real_to_packed_array, + add_real_array_to_packed_array, + read_string_from_byte_array, + delete_real_from_packed_array, + get_real_from_packed_array, + set_real_in_packed_array, + resize_real_packed_array, + add_string_to_packed_array, + add_string_array_to_packed_array, + delete_string_from_packed_array, + get_string_from_packed_array, + set_string_in_packed_array, + resize_string_packed_array, + add_vector2_to_packed_array, + add_vector2_array_to_packed_array, + delete_vector2_from_packed_array, + get_vector2_from_packed_array, + set_vector2_in_packed_array, + resize_vector2_packed_array, + add_vector3_to_packed_array, + add_vector3_array_to_packed_array, + delete_vector3_from_packed_array, + get_vector3_from_packed_array, + set_vector3_in_packed_array, + resize_vector3_packed_array, + is_sent_xr_same_instance_as_jvm_singleton, + create_variant_array_of_user_type +] \ No newline at end of file diff --git a/kt/entry-generation/godot-kotlin-symbol-processor/src/main/kotlin/godot/annotation/processor/ext/ksAnnotatedExt.kt b/kt/entry-generation/godot-kotlin-symbol-processor/src/main/kotlin/godot/annotation/processor/ext/ksAnnotatedExt.kt index 259cc15d9..0500d29e0 100644 --- a/kt/entry-generation/godot-kotlin-symbol-processor/src/main/kotlin/godot/annotation/processor/ext/ksAnnotatedExt.kt +++ b/kt/entry-generation/godot-kotlin-symbol-processor/src/main/kotlin/godot/annotation/processor/ext/ksAnnotatedExt.kt @@ -19,12 +19,16 @@ fun KSAnnotated.hasAnnotation(annotationClass: KClass): Bool } } -fun KSAnnotation.hasAnnotation(annotationClass: KClass): Boolean { - return this.fqNameUnsafe == annotationClass.qualifiedName || this +fun KSAnnotation.hasAnnotation(annotationClass: KClass, alreadyEvaluated: MutableList = mutableListOf()): Boolean { + val annotationsOnAnnotation = this .annotationType + .resolve() + .declaration .annotations + .filterNot { alreadyEvaluated.contains(it) } .toList() - .any { it.hasAnnotation(annotationClass) } + + return this.fqNameUnsafe == annotationClass.qualifiedName || annotationsOnAnnotation.any { it.hasAnnotation(annotationClass, alreadyEvaluated.apply { add(this@hasAnnotation) }) } } fun KSAnnotated.hasRegistrationAnnotation(): Boolean { diff --git a/kt/entry-generation/godot-kotlin-symbol-processor/src/main/kotlin/godot/annotation/processor/ext/ksClassDeclarationExt.kt b/kt/entry-generation/godot-kotlin-symbol-processor/src/main/kotlin/godot/annotation/processor/ext/ksClassDeclarationExt.kt index c213cdaf5..5a6aa384d 100644 --- a/kt/entry-generation/godot-kotlin-symbol-processor/src/main/kotlin/godot/annotation/processor/ext/ksClassDeclarationExt.kt +++ b/kt/entry-generation/godot-kotlin-symbol-processor/src/main/kotlin/godot/annotation/processor/ext/ksClassDeclarationExt.kt @@ -5,6 +5,7 @@ import com.google.devtools.ksp.getConstructors import com.google.devtools.ksp.getDeclaredProperties import com.google.devtools.ksp.isAbstract import com.google.devtools.ksp.isPublic +import com.google.devtools.ksp.symbol.ClassKind import com.google.devtools.ksp.symbol.KSClassDeclaration import com.google.devtools.ksp.symbol.KSFunctionDeclaration import com.google.devtools.ksp.symbol.KSPropertyDeclaration @@ -38,7 +39,7 @@ internal fun KSClassDeclaration.mapToClazz( val registeredFunctions = getAllFunctions() .filter { function -> - function.hasAnnotation(GodotMember::class) || function.overridesApiFunction() + function.hasAnnotation(GodotMember::class) || function.overridesApiFunction() || function.overridesRegisteredFunction() } .mapNotNull { it.mapToRegisteredFunction(this, settings) } .toList() @@ -67,7 +68,7 @@ internal fun KSClassDeclaration.mapToClazz( .map { it.mapToRegisteredSignal(declaredProperties.toList(), settings) } .toList() - val shouldBeRegistered = hasRegistrationAnnotation() || + val shouldBeRegistered = (classKind != ClassKind.ANNOTATION_CLASS && hasRegistrationAnnotation()) || isAbstractAndContainsRegisteredMembers(registeredFunctions, registeredProperties, registeredSignals) || isAbstractAndInheritsGodotBaseClass() @@ -152,6 +153,10 @@ private fun KSFunctionDeclaration.overridesApiFunction(isOveridee: Boolean = fal } } +private fun KSFunctionDeclaration.overridesRegisteredFunction(): Boolean { + return hasAnnotation(GodotMember::class) || (findOverridee() as? KSFunctionDeclaration)?.overridesRegisteredFunction() == true +} + private fun KSPropertyDeclaration.overridesRegisteredProperty(): Boolean { return hasAnnotation(GodotMember::class) || findOverridee()?.overridesRegisteredProperty() == true }