Skip to content

Commit

Permalink
change ReatT to Double in generated api (#194)
Browse files Browse the repository at this point in the history
Co-authored-by: Pierre-Thomas Meisels <[email protected]>
  • Loading branch information
piiertho and Pierre-Thomas Meisels authored Aug 2, 2020
1 parent 1dcde78 commit 9b62844
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/godot/codegen/Argument.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Argument @JsonCreator constructor(
when (type) {
"Color", "Variant" -> "$type($defaultValue)"
"Boolean" -> defaultValue.toLowerCase()
"RealT" -> intToFloat(defaultValue)
"Double" -> intToFloat(defaultValue)
"Vector2", "Vector3", "Rect2" -> "$type${defaultValue.replace(",", ".0,")
.replace(")", ".0)")}"
"Dictionary", "Transform", "Transform2D", "VariantArray", "RID", "PoolVector2Array", "PoolStringArray",
Expand Down
5 changes: 1 addition & 4 deletions buildSrc/src/main/kotlin/godot/codegen/ICall.kt
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,7 @@ class ICall(
codeBlockBuilder.add(
" val retVar = %M<%T>()\n",
MemberName("kotlinx.cinterop", "alloc"),
ClassName(
if (returnType == "RealT") "godot.internal.type" else "kotlinx.cinterop",
"${returnType}Var"
)
ClassName("kotlinx.cinterop", "${returnType}Var")
)
} else {
codeBlockBuilder.add(
Expand Down
8 changes: 3 additions & 5 deletions buildSrc/src/main/kotlin/godot/codegen/TypeCast.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private val kotlinReservedNames = listOf(
"object"
)

private val primitives = listOf("Long", "RealT", "Boolean", "Unit")
private val primitives = listOf("Long", "Double", "Boolean", "Unit")

fun String.escapeUnderscore(): String {
if (this == "") return this
Expand Down Expand Up @@ -88,14 +88,12 @@ fun String.getPackage() =
} else {
thisString = thisString.replace("::", ".").split(".")[0]
when {
this == "RealT" -> "godot.internal.type"
thisString.isPrimitive() || thisString == "String" -> "kotlin"
thisString.isCoreType() -> "godot.core"
else -> "godot"
}
}
}
this == "RealT" -> "godot.internal.type"
isPrimitive() || this == "String" -> "kotlin"
isCoreType() -> "godot.core"
else -> "godot"
Expand Down Expand Up @@ -145,7 +143,7 @@ fun String.convertToSnakeCase(): String =
fun String.convertTypeToKotlin(): String {
return when {
this == "int" -> "Long"
this == "float" -> "RealT"
this == "float" -> "Double"
this == "bool" -> "Boolean"
this == "void" -> "Unit"
this == "Array" -> "VariantArray"
Expand All @@ -166,7 +164,7 @@ fun String.convertTypeForICalls(): String {

fun String.defaultValue(): String = when (this) {
"Long" -> "0"
"RealT" -> "0.0"
"Double" -> "0.0"
"Boolean" -> "false"
else -> throw Exception("$this is not a primitive type.")
}
Expand Down

0 comments on commit 9b62844

Please sign in to comment.