-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for indexed properties in api-generator #312
Add support for indexed properties in api-generator #312
Conversation
Hello ! That’s a good catch ! Thanks a lot ! |
@piiertho The generated code changes are now included. The error I had been running into with Long was with the buffer writing where code was expecting a Long but receiving an Int. At the time I had though there must be some lower level API expecting an Int, but on further inspection the mismatch was with my own added code, which was using Int literals when it should have been using Long literals. I updated my changes to consistently use Longs and that is working now. After further testing, it turns out that I must have mixed up which builds I was testing when I thought the indexed getters were originally working, and after more testing can now confirm that the indexing problem does also apply to the getters so the changes in this PR are needed for both getters and setters. For the record, here's a link to the code that is generating the code that is raising the error this PR is addressing: https://github.com/godotengine/godot/blob/3.4.2-stable/core/make_binders.py#L48-L53. As a side note, when I peruse the affected properties, it looks like mostly less common Godot properties use this indexing mechanism. I've been using Godot Kotlin JVM for over six months and only recently ran into this issue. |
Build errors on windows are not from your side. I asked on an existing godot issue why this is happening: godotengine/godot#58595 Linux check is error we have because gpg key is repo private :/ Anyway, everything looks good to me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx a lot for the fix!
@silentorb can you rebase branch on master ? |
…nges to the generated API files.
ad10b72
to
2b1bd44
Compare
@piiertho: The PR is rebased with the latest build changes. |
Thx for contribution ! |
Some of Godot's property getter/setters have an additional index parameter, specified with the
index
field of the property metadata.For those properties the
api-generator
withingodot-kotlin-jvm
is not including the index arguments in the generated property code, causing the setters for indexed properties to throw exceptions.The indexed getters seem to be working without the extra index property. I'm not sure how that is.
This PR adds code to
api-generator
'sProperty::generate
so that the generated code includes the indexed arguments for properties that need them.For example, the code generated for
SpatialMaterial::albedoTexture
(which has a hard-coded index of 0) looks like this after the PR:Where before those two
writeArguments
lines were:TransferContext.writeArguments()
and
Even though only the setters were throwing exceptions, I also added the index parameter to the getter because that seems like the more accurate call. I haven't been able to verify yet but maybe there is some additional code on the C++ side that is filling in the gaps for the indexed getter calls?
My understanding is that
godot-kotlin-jvm
is usingLong
instead ofInt
for interop, though in this case usingLong
for the indexed properties was failing while usingInt
is working. I'm guessing maybe that's because the index parameter is not a formally exposed element of the Godot API and is instead a lower-level implementation detail.For the current version of the API this PR affects 32 generated files. I left the generated files out of the PR to keep the PR minimal but can add them if needed.
I've tested some of the indexed property cases and everything I have tested is working. I have not comprehensively tested every property affected by this PR.