Skip to content

Commit

Permalink
fix: Getter now calls method from parent even if getter stats with is
Browse files Browse the repository at this point in the history
  • Loading branch information
piiertho committed Jun 10, 2021
1 parent 88ad27e commit 8bd2d00
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package godot.codegen
import com.fasterxml.jackson.core.type.TypeReference
import com.fasterxml.jackson.databind.ObjectMapper
import com.squareup.kotlinpoet.*
import godot.codegen.utils.convertToSnakeCase
import godot.codegen.utils.getPackage
import godot.codegen.utils.jvmVariantTypeValue
import godot.docgen.ClassDoc
Expand Down Expand Up @@ -35,17 +36,18 @@ fun File.generateApiFrom(jsonSource: File, docsDir: File? = null) {
classes.forEach { clazz ->
clazz.properties.forEach { property ->
val method = Method(
"get_${property.oldName}",
property.getter.convertToSnakeCase(),
property.type,
isVirtual = false,
hasVarargs = false,
arguments = listOf()
)
val parentClassAndMethod = tree.getMethodFromAncestor(clazz, method)
if (parentClassAndMethod != null && !property.hasValidGetter) {
val parentMethodName = "get${parentClassAndMethod.first.newName}${property.newName.capitalize()}"
val isBoolGetter = property.getter.startsWith("is")
val parentMethodName = "${if (isBoolGetter) "is" else "get"}${parentClassAndMethod.first.newName}${property.newName.capitalize()}"
property.parentMethodToCall = parentMethodName
val find = parentClassAndMethod.first.methods.find { it.newName == "get${property.newName.capitalize()}" }
val find = parentClassAndMethod.first.methods.find { it.newName == property.getter }
if (find != null) {
methodsToRename[find] = parentMethodName
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion kt/godot-library/src/main/kotlin/godot/gen/godot/Font.kt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8bd2d00

Please sign in to comment.