Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Registering properties of custom interfaces breaks code generation #371

Closed
exigow opened this issue Nov 1, 2022 · 2 comments · Fixed by #376
Closed

Registering properties of custom interfaces breaks code generation #371

exigow opened this issue Nov 1, 2022 · 2 comments · Fixed by #376
Assignees
Labels
bug Something isn't working topic:entry-gen

Comments

@exigow
Copy link

exigow commented Nov 1, 2022

Hi,

this combination produces invalid code:

  1. class extending Node
  2. such class implementing interface with var property
  3. such property with @Export annotation

I think this scenario should be supported. You often want to create abstraction with common property across different implementations (for example, "game object" and "health" value). Changing this value in editor should be also available.

Steps to reproduce

Version: 0.5.1-3.5.1

interface TestInterface {
	var testProperty: String
}
@RegisterClass
class TestNode : Node(), TestInterface {
	@Export
	@RegisterProperty
	override var testProperty: String = ""
}

Result

Compilation fails. Class in build/generated/ contains redundant override keyword. Removing override manually seems to work but code is replaced on next build task.

public open class TestNodeRegistrar : ClassRegistrar {
	public open override val testPropertyDefaultValueProvider: () -> String = { """""" }
	public override fun register(registry: ClassRegistry): Unit {
		with(registry) {
			registerClass<TestNode>("res://src/main/kotlin/test/TestNode.kt", "godot.Node", TestNode::class, false, "Node", "test_TestNode") {
				constructor(KtConstructor0(::TestNode))
				function(TestNode::_ready, NIL, KtFunctionArgument(NIL, "kotlin.Unit"), DISABLED.id.toInt())
				property(TestNode::testProperty, STRING, STRING, "kotlin.String", NONE, "", testPropertyDefaultValueProvider, true, DISABLED.id.toInt())
			}
		}
	}
}

PS: Thanks for working on this binding. It makes me happy by allowing me to use Godot with Kotlin.

@chippmann chippmann added bug Something isn't working topic:entry-gen labels Nov 2, 2022
@chippmann chippmann self-assigned this Nov 2, 2022
@chippmann chippmann changed the title Overriding @Export properties produces invalid code Registering properties of custom interfaces breaks code generation Nov 15, 2022
@chippmann
Copy link
Contributor

Changed the title to the "real" problem.
Reason for the problem: I handle interfaces as abstract classes in the entry generation by mistake.
Will fix it asap.

chippmann added a commit that referenced this issue Nov 15, 2022
Sub sequentially this also increases the amount of data the entry generator receives in order to do its job. Previously it only received registered classes, functions, properties and constructors. Now it receives every class, function and property from the symbol processor. This allows for additional checks on not registered members or not explicitly registered members.
chippmann added a commit that referenced this issue Nov 25, 2022
Sub sequentially this also increases the amount of data the entry generator receives in order to do its job. Previously it only received registered classes, functions, properties and constructors. Now it receives every class, function and property from the symbol processor. This allows for additional checks on not registered members or not explicitly registered members.
chippmann added a commit that referenced this issue Nov 28, 2022
…registered members (#376)

* Fix #371 by checking if the overridden property is from an interface

Sub sequentially this also increases the amount of data the entry generator receives in order to do its job. Previously it only received registered classes, functions, properties and constructors. Now it receives every class, function and property from the symbol processor. This allows for additional checks on not registered members or not explicitly registered members.

* Implement check if overridden registered property is registered

* Make overridden registered member check a warning and not an error

* Remove implicit registration of overriding property if the overridden property is registered

* Fix compiler overridee check

* Update test classes for new enforced explicit registration
@exigow
Copy link
Author

exigow commented Nov 28, 2022

Thanks, @chippmann.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working topic:entry-gen
Projects
None yet
2 participants