-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(entry-gen): Manage type parameters with classgraph
- Loading branch information
Showing
13 changed files
with
211 additions
and
98 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
...symbol-processor/src/main/kotlin/godot/annotation/processor/classgraph/constants/Types.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package godot.annotation.processor.classgraph.constants | ||
|
||
const val BOOLEAN = "boolean" | ||
const val INT = "int" | ||
const val LONG = "long" | ||
const val FLOAT = "float" | ||
const val DOUBLE = "double" | ||
const val BYTE = "byte" | ||
const val SHORT = "short" | ||
|
||
val jvmPrimitives = listOf( | ||
BOOLEAN, | ||
INT, | ||
LONG, | ||
FLOAT, | ||
DOUBLE, | ||
BYTE, | ||
SHORT | ||
) | ||
|
||
const val VOID = "void" | ||
|
||
const val STRING = "java.lang.String" | ||
|
||
const val JVM_OBJECT = "java.lang.Object" | ||
|
||
const val SET = "java.util.Set" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...rc/main/kotlin/godot/annotation/processor/classgraph/extensions/TypeArgumentExtensions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package godot.annotation.processor.classgraph.extensions | ||
|
||
import godot.annotation.processor.classgraph.Settings | ||
import godot.annotation.processor.classgraph.constants.JVM_OBJECT | ||
import godot.entrygenerator.model.Type | ||
import io.github.classgraph.ClassRefTypeSignature | ||
import io.github.classgraph.ScanResult | ||
import io.github.classgraph.TypeArgument | ||
|
||
context(ScanResult) | ||
fun TypeArgument.getType(settings: Settings): Type { | ||
val typeSignature = typeSignature as ClassRefTypeSignature | ||
return typeSignature.getMappedType(settings) | ||
} | ||
|
||
context(ScanResult) | ||
private fun ClassRefTypeSignature.getMappedType(settings: Settings): Type { | ||
return if (fullyQualifiedClassName == JVM_OBJECT) { | ||
getJavaLangObjectType(settings) | ||
} else { | ||
this@ScanResult.getClassInfo(fullyQualifiedClassName).mapToType( | ||
typeArguments, | ||
settings | ||
) | ||
} | ||
} |
Oops, something went wrong.