diff --git a/.github/workflows/trigger_dev.yml b/.github/workflows/trigger_dev.yml index 228c7fc29e..6c9dc03621 100644 --- a/.github/workflows/trigger_dev.yml +++ b/.github/workflows/trigger_dev.yml @@ -108,4 +108,5 @@ jobs: - build-linux with: godot-version: ${{ needs.setup-build-variables.outputs['godot-version'] }} - jvm-version: ${{ needs.setup-build-variables.outputs['jvm-version'] }} \ No newline at end of file + jvm-version: ${{ needs.setup-build-variables.outputs['jvm-version'] }} + build-version: ${{ needs.setup-build-variables.outputs['build-version'] }} \ No newline at end of file diff --git a/docs/src/doc/getting-started/your-first-class.md b/docs/src/doc/getting-started/your-first-class.md index 6a96520cb7..a328f9f30b 100644 --- a/docs/src/doc/getting-started/your-first-class.md +++ b/docs/src/doc/getting-started/your-first-class.md @@ -4,21 +4,19 @@ Let's create a file `src/main/kotlin/com/yourcompany/game/Simple.kt` with the fo package com.yourcompany.game import godot.Node3D -import godot.annotation.RegisterClass -import godot.annotation.RegisterFunction +import godot.annotation.GodotScript import godot.global.GD -@RegisterClass +@GodotScript class Simple: Node3D() { - @RegisterFunction override fun _ready() { GD.print("Hello world!") } } ``` -The [classes](../user-guide/classes.md) section covers in details what we did here, but for now `@RegisterClass` will register the class to Godot. Now we can trigger a build. +The [classes](../user-guide/classes.md) section covers in details what we did here, but for now `@GodotScript` will register the class to Godot. Now we can trigger a build. ```shell ./gradlew build diff --git a/docs/src/doc/index.md b/docs/src/doc/index.md index 405986f440..f26369a6e0 100644 --- a/docs/src/doc/index.md +++ b/docs/src/doc/index.md @@ -37,7 +37,7 @@ Also consider the [API Differences](user-guide/api-differences.md) section for g and limitations which will not be or cannot be adressed in the near forseable future or ever. - Each registered constructor must have a unique number of arguments, constructor overloading is not yet supported. -- No tool mode (you can set it already in the `@RegisterClass` annotation but it has no effect yet). +- No tool mode (you can already use the `@Tool` annotation, but it has no effect yet). - No addon support, you cannot use Godot Kotlin/JVM to write plugins and addons yet (you can however [write libraries](develop-libraries/introduction.md) with godot specific code). - Web is currently not supported. See [Supported platforms](#supported-platforms) to see what platforms we currently support diff --git a/docs/src/doc/user-guide/advanced/abstract-classes.md b/docs/src/doc/user-guide/advanced/abstract-classes.md index 16fa2c276a..ececd06b02 100644 --- a/docs/src/doc/user-guide/advanced/abstract-classes.md +++ b/docs/src/doc/user-guide/advanced/abstract-classes.md @@ -7,7 +7,7 @@ You can define a abstract class and register it's members the same way as you do Under the hood, we only register your normal classes, and let them register all members your abstract class defines. !!! info - For this reason, the `@RegisterClass` annotation is optional for abstract classes. + For this reason, the `@GodotScript` annotation is optional for abstract classes. !!! warning As in Kotlin, you cannot instantiate abstract classes directly from any other scripting language like GDScript! In fact, godot does not even know (or care) that your abstract class exists. @@ -17,22 +17,20 @@ Under the hood, we only register your normal classes, and let them register all Abstract class definition: ```kotlin -// register class annotation is optional for abstract classes +// @GodotScript annotation is optional for abstract classes abstract class AbstractClassInheritanceParent: Node() { @Export - @RegisterProperty var registeredExportedPropertyInAbstractClass = false - @RegisterSignal val signalInAbstractClass by signal("blubb") - @RegisterFunction + @GodotMember fun functionInAbstractClassWithDefaultImplementation() { // some implementation } - @RegisterFunction + @GodotMember abstract fun abstractFunction() } ``` @@ -40,14 +38,11 @@ abstract class AbstractClassInheritanceParent: Node() { Child class definition: ```kotlin -@RegisterClass +@GodotScript class AbstractClassInheritanceChild: AbstractClassInheritanceParent() { - @RegisterFunction + // registered automatically as the abstract class already defines the annotation override fun abstractFunction() { // some implementation } } ``` - -!!! warning "Registration of overridden members" - As you can see in the example; you need to explicitly register any member in the child class which you override from the abstract parent class. Otherwise they will not be registered and thus are not known to godot. \ No newline at end of file diff --git a/docs/src/doc/user-guide/api-differences.md b/docs/src/doc/user-guide/api-differences.md index c3147f20b7..644b7e7e33 100644 --- a/docs/src/doc/user-guide/api-differences.md +++ b/docs/src/doc/user-guide/api-differences.md @@ -152,12 +152,11 @@ You can implement [_notification](https://docs.godotengine.org/en/stable/classes and have class hierarchy notification call without using `super` call, as in GDScript and C++. However, the syntax is a bit different: ```kotlin -@RegisterFunction override fun _notification() = godotNotification { // ... } ``` -Currently this feature except abstract classes. +Currently, this feature does not work for abstract classes. ## StringName and NodePath diff --git a/docs/src/doc/user-guide/classes.md b/docs/src/doc/user-guide/classes.md index 9d2d393387..08b78ea0a4 100644 --- a/docs/src/doc/user-guide/classes.md +++ b/docs/src/doc/user-guide/classes.md @@ -1,7 +1,7 @@ -To expose a class written in Kotlin it needs to extend `godot.Object` (or any of its subtype) and must be annotated with `@RegisterClass`. +To expose a class written in Kotlin it needs to extend `godot.Object` (or any of its subtype) and must be annotated with `@GodotScript`. ```kt -@RegisterClass +@GodotScript class RotatingCube: Node3D() { // ... } @@ -13,7 +13,7 @@ Each registered classes will generate its own .gdj files. For more information, Classes need to be registered with a unique name as Godot does not support namespaces (or packages in this case) for script classes. -By default, we register your classes with the name you give them. While beign a simple approach and enough in most cases, +By default, we register your classes with the name you give them. While being a simple approach and enough in most cases, this can lead to naming conflicts if you have classes in different packages with the same name. For example: - `com.package.a.MyClass` @@ -25,7 +25,7 @@ So you are responsible for making sure that classes have a unique name. We do however provide you with some assistance: - We have compile time checks in place which should let the *build fail* if classes would end up having the same name. -- The `@RegisterClass` annotation lets you define a custom registration name: `@RegisterClass("CustomRegistrationName")`. +- The `@GodotScript` annotation lets you define a custom registration name: `@GodotScript("CustomRegistrationName")`. - Register the class names with the fully qualified name: `com.mygame.MyClass` will be registered as: `com_mygame_MyClass`. This can be configured with: ```kotlin godot { @@ -93,7 +93,7 @@ If you want to be notified when initialization and destruction of your class' in and override the `_onDestroy` function respectively. ```kt -@RegisterClass +@GodotScript class RotatingCube: Node3D() { init { println("Initializing RotatingCube!") @@ -110,7 +110,6 @@ class RotatingCube: Node3D() { Checking if an object is an instance of a particular type can be done via the `is` operator. ```kt -@RegisterFunction override fun _ready() { val parent = getParent() if (parent is CollisionShape) { @@ -128,7 +127,6 @@ This also works for any type you define. If you are sure that an object is always an instance of some type, then you can take advantage of Kotlin's [contracts](https://kotlinlang.org/docs/reference/whatsnew13.html#contracts) feature. This allows you to avoid having nested `if`s. ```kt - @RegisterFunction override fun _ready() { val parent = getParent() require(parent is CollisionShape) @@ -140,7 +138,7 @@ This also works for any type you define. ## Constructors Godot requires you to have a default constructor on your classes. -You can define additional constructors but you have to register them by annothing them with `@RegisterConstructor`. +You can define additional constructors, but you have to register them by annotating them with `@GodotMember`. Default constructors, on the other hand, are always registered automatically. Constructors can also have **a maximum of 8 arguments** and must have a unique argument count as constructor overloading is not yet supported. @@ -148,7 +146,7 @@ This limitation is only for registered constructors. ### Instantiate Kotlin script classes in GDScript -From GDScript it is possible to create an instance of a Kotlin class using the default constructor: +From GDScript, it is possible to create an instance of a Kotlin class using the default constructor: ```kt var instance := YourKotlinClass.new() @@ -161,24 +159,24 @@ var instance := load("res://gdj/YourClass.gdj").new(oneArg, anotherArg) ``` !!! info - The limitation of max 16 arguments for constructors is arbitrary. We decided to introduce this limitation to prevent performance bottlenecks for creating objects as each argument passed to a constructor needs to be unpacked by the binding. The more arguments, the more unpacking is needed which means more overhead. + The limitation of max 8 arguments for constructors is arbitrary. We decided to introduce this limitation to prevent performance bottlenecks for creating objects as each argument passed to a constructor needs to be unpacked by the binding. The more arguments, the more unpacking is needed which means more overhead. ## Customization You can customize to some extent how your class should be registered in Godot. -The `@RegisterClass` annotation takes only one argument: +The `@GodotScript` annotation takes only one argument: -- **className**: If set, the class will be registered with the provided name. +- **customName**: If set, the class will be registered with the provided name. !!! warning "Unique class names" - If you specify the `className` in the annotation, you have to make sure that this name is unique! We implemented compilation checks to make sure the compilation fails if more than two classes are registered with the same name, but we cannot check class names from other scripting languages like GDScript or C#! It is also recommended installing our intellij plugin as it shows duplicated registered class names in the editor as an error. + If you specify the `customName` in the annotation, you have to make sure that this name is unique! We implemented compilation checks to make sure the compilation fails if more than two classes are registered with the same name, but we cannot check class names from other scripting languages like GDScript or C#! It is also recommended installing our intellij plugin as it shows duplicated registered class names in the editor as an error. ## Tool Mode -Annotate your class with `@Tool` to make it a tool class (note that `@RegisterClass` is required for this annotation to take effect). +Annotate your class with `@Tool` to make it a tool class. !!! Caution This is currently not implemented. \ No newline at end of file diff --git a/docs/src/doc/user-guide/functions.md b/docs/src/doc/user-guide/functions.md index aa5e8c4a04..3104510075 100644 --- a/docs/src/doc/user-guide/functions.md +++ b/docs/src/doc/user-guide/functions.md @@ -1,12 +1,12 @@ Any Kotlin function can be registered as long as its parameters and return type can be converted to a `Variant`. -To register a function annotate it with `@RegisterFunction`. +To register a function annotate it with `@GodotMember`. ```kotlin -@RegisterClass +@GodotScript class RotatingCube: Node3D() { - @RegisterFunction - override fun _ready() { - println("I am ready!") + @GodotMember + fun myFunction() { + println("Hello") } } ``` @@ -21,17 +21,11 @@ Therefore, a function called `doSomething()` in Kotlin is usable in GDScript as Virtual functions (like `_ready`, `_process` and `_physics_process`) are declared as overridable functions. The default implementation throws a `NotImplementedException`, so you have to override it if you plan to expose -a virtual function to Godot. Remember, just overriding is not enough to use that function - you have to explicitly -register it as well with `@RegisterFunction`. +a virtual function to Godot. Virtual functions are registered automatically and do not require an explicit `@GodotMember` +annotation. ## Arguments count Godot limits the allowed argument count of functions to `16`. Thus, this binding also has this limitation. If you want to pass more than 16 parameters in a function, you need to wrap them in a container (like a custom container class or a `VariantArray` or `Dictionary`). - -## Customization - -You can customize to some extent how your functions should be registered in Godot. The `@RegisterFunction` annotation takes one argument: - -- **rpcMode**: Default: `RPCMode.DISABLED` diff --git a/docs/src/doc/user-guide/properties.md b/docs/src/doc/user-guide/properties.md index 701221ab6a..37961acbf2 100644 --- a/docs/src/doc/user-guide/properties.md +++ b/docs/src/doc/user-guide/properties.md @@ -1,13 +1,13 @@ Any property of a registered class can be registered as long as it is public, mutable and can be converted to a `Variant`. -To register a property annotate it with `@RegisterProperty`. +To register a property annotate it with `@GodotMember`. ```kotlin -@RegisterClass +@GodotScript class RotatingCube: Node3D() { - @RegisterProperty + @GodotMember var someString: String = "Hello there :-)" - @RegisterProperty + @GodotMember var propertyWithDefaultValue: Float = 2f } ``` @@ -19,24 +19,22 @@ your properties are actually registered as `snake_case`. So a property `someFlag ## Core type specifics -Godot core type always need to have a value. Hence you cannot register properties of core types (like `Vector3`) with lateinit. +Godot core type always need to have a value. Hence, you cannot register properties of core types (like `Vector3`) with lateinit. ## Exporting properties -A registered property can be exported (a.k.a make it visible in the Godot editor) by annotating it with `@Export`. +A property can be exported (a.k.a. make it visible in the Godot editor) by annotating it with `@Export`. A property can be exported if it is a core type, a primitive or inherits from `godot.RefCounted`. ```kotlin -@RegisterClass +@GodotMember class RotatingCube: Node3D() { @Export - @RegisterProperty var speed: Float = 2f } ``` Exported properties can have default values (`2f` in the example above) which will be used as a default value by the `inspector`. -A default value can **only** contain compile time constants and only references to compile time constants. !!! danger If you set a default value in code and a different value in the `inspector` the value of the latter will override the value in code after `init` and before `_enter_tree`. @@ -44,7 +42,7 @@ A default value can **only** contain compile time constants and only references ## Type hint registration This module provides a plethora of annotations for defining property type hints. -These annotations controls how Godot display the property in the inspector. +These annotations control how Godot display the property in the inspector. Each property hint annotation can only be added to certain types of properties. Using the wrong annotation will make the compilation fail. These will only take effect if the property is exported. diff --git a/docs/src/doc/user-guide/signals_and_callables.md b/docs/src/doc/user-guide/signals_and_callables.md index e4e65809d1..2af3ad1e50 100644 --- a/docs/src/doc/user-guide/signals_and_callables.md +++ b/docs/src/doc/user-guide/signals_and_callables.md @@ -14,12 +14,10 @@ In both case, you have to provide the name of the signal parameters as strings f /// tab | Kotlin ```kotlin -@RegisterClass +@GodotScript class MyScript: Node() { - @RegisterSignal val mySignal by signal1("reverse") - @RegisterSignal val mySignal = Signal1("mySignal", "reverse") } ``` @@ -27,9 +25,8 @@ class MyScript: Node() { /// tab | Java ```java -@RegisterClass +@GodotScript public MyScript extends Node { - @RegisterSignal public Signal1 mySignal = Signal1.create(this, "mySignal", "reverse"); // Only one way to do it in Java. } ``` @@ -90,17 +87,16 @@ Note that the connected method has to be a registered to Godot. /// tab | Kotlin ```kotlin -@RegisterClass +@GodotScript class SomeObject: Object() { - @RegisterFunction + @GodotMember fun onReverseChanged(reverse: Boolean) { println("Value of reverse has changed: $reverse") } } -@RegisterClass +@GodotScript class AnotherObject: Object() { - @RegisterSignal val mySignal by signal1("reverse") private val targetObject = SomeObject() @@ -118,17 +114,16 @@ class AnotherObject: Object() { /// tab | Java ```java -@RegisterClass +@GodotScript public class SomeObject extends Object { - @RegisterFunction + @GodotMember public void onReverseChanged(boolean reverse) { System.out.println("Value of reverse has changed: " + reverse); } } -@RegisterClass +@GodotScript public class AnotherObject extends Object { - @RegisterSignal public Signal1 mySignal = Signal1.create(this, "mySignal", "reverse"); private SomeObject targetObject = new SomeObject(); diff --git a/harness/benchmarks/src/main/kotlin/godot/benchmark/Memory.kt b/harness/benchmarks/src/main/kotlin/godot/benchmark/Memory.kt index 17ff83091c..2ca82d8146 100644 --- a/harness/benchmarks/src/main/kotlin/godot/benchmark/Memory.kt +++ b/harness/benchmarks/src/main/kotlin/godot/benchmark/Memory.kt @@ -3,12 +3,12 @@ package godot.benchmark import godot.Node import godot.Object import godot.RefCounted -import godot.annotation.RegisterClass -import godot.annotation.RegisterFunction +import godot.annotation.GodotScript +import godot.annotation.GodotMember import godot.core.RID import godot.core.VariantArray -@RegisterClass +@GodotScript class Memory : Object() { private val objs = VariantArray() @@ -33,7 +33,7 @@ class Memory : Object() { cores.clear() } - @RegisterFunction + @GodotMember fun benchmarkAccessObj() { var obj: Node for (i in 0 until accessSize) { @@ -41,7 +41,7 @@ class Memory : Object() { } } - @RegisterFunction + @GodotMember fun benchmarkAccessRef() { var ref: RefCounted for (i in 0 until accessSize) { @@ -49,7 +49,7 @@ class Memory : Object() { } } - @RegisterFunction + @GodotMember fun benchmarkAccessCore() { var core: RID for (i in 0 until accessSize) { @@ -57,7 +57,7 @@ class Memory : Object() { } } - @RegisterFunction + @GodotMember fun benchmarkStressObject() { var obj: Node for (i in 0 until stressSize) { @@ -66,7 +66,7 @@ class Memory : Object() { } } - @RegisterFunction + @GodotMember fun benchmarkStressReference() { var ref: RefCounted for (i in 0 until stressSize) { @@ -74,7 +74,7 @@ class Memory : Object() { } } - @RegisterFunction + @GodotMember fun benchmarkStressCore() { var core: RID? for (i in 0 until stressSize) { @@ -82,7 +82,7 @@ class Memory : Object() { } } - @RegisterFunction + @GodotMember fun benchmarkStressZMix() { var core: RID? var obj: Node diff --git a/harness/benchmarks/src/main/kotlin/godot/benchmark/Simple.kt b/harness/benchmarks/src/main/kotlin/godot/benchmark/Simple.kt index 8de6f70387..a25d283b11 100644 --- a/harness/benchmarks/src/main/kotlin/godot/benchmark/Simple.kt +++ b/harness/benchmarks/src/main/kotlin/godot/benchmark/Simple.kt @@ -2,23 +2,23 @@ package godot.benchmark import godot.Node import godot.Object -import godot.annotation.RegisterClass -import godot.annotation.RegisterFunction +import godot.annotation.GodotScript +import godot.annotation.GodotMember import godot.core.Transform3D import godot.core.Vector2 import godot.core.Vector3 -@RegisterClass +@GodotScript class Simple : Object() { - @RegisterFunction + @GodotMember fun benchmarkSimpleAdd(): Int { val a = 1 val b = 2 return a + b } - @RegisterFunction + @GodotMember fun benchmarkAvg(): Int { val size = 10000 var total = 0 @@ -28,7 +28,7 @@ class Simple : Object() { return total / size } - @RegisterFunction + @GodotMember fun benchmarkVectors(): Vector3 { var b = Transform3D() b = b.rotated(Vector3.UP, Math.toRadians(60.0)) @@ -44,7 +44,7 @@ class Simple : Object() { return s } - @RegisterFunction + @GodotMember fun benchmarkVectors2Only(): Vector2 { var s = Vector2() for(i in 0 until 1000) { @@ -55,14 +55,14 @@ class Simple : Object() { return s } - @RegisterFunction + @GodotMember fun benchmarkIcall() { val node = Node() node.getInstanceId() node.free() } - @RegisterFunction + @GodotMember fun benchmarkIcallWithLoop() { val node = Node() for (i in 0 until 100) { @@ -74,7 +74,7 @@ class Simple : Object() { node.free() } - @RegisterFunction + @GodotMember fun benchmarkMethodCall() { } } diff --git a/harness/bunnymark/src/main/kotlin/godot/benchmark/bunnymark/BunnymarkV1DrawTexture.kt b/harness/bunnymark/src/main/kotlin/godot/benchmark/bunnymark/BunnymarkV1DrawTexture.kt index 3122b0b837..4d8328b510 100644 --- a/harness/bunnymark/src/main/kotlin/godot/benchmark/bunnymark/BunnymarkV1DrawTexture.kt +++ b/harness/bunnymark/src/main/kotlin/godot/benchmark/bunnymark/BunnymarkV1DrawTexture.kt @@ -4,17 +4,15 @@ import godot.Node2D import godot.RandomNumberGenerator import godot.ResourceLoader import godot.Texture2D -import godot.annotation.RegisterClass -import godot.annotation.RegisterFunction -import godot.annotation.RegisterSignal +import godot.annotation.GodotMember +import godot.annotation.GodotScript import godot.core.Vector2 -import godot.signals.signal +import godot.core.signal1 -@RegisterClass("BunnymarkV1DrawTexture") +@GodotScript("BunnymarkV1DrawTexture") class BunnymarkV1DrawTexture : Node2D() { - @RegisterSignal - val benchmarkFinished by signal("bunnyCount") + val benchmarkFinished by signal1("bunnyCount") data class Bunny(var position: Vector2, var speed: Vector2) @@ -25,19 +23,16 @@ class BunnymarkV1DrawTexture : Node2D() { private lateinit var screenSize: Vector2 - @RegisterFunction override fun _ready() { randomNumberGenerator.randomize() } - @RegisterFunction override fun _draw() { for (bunny in bunnies) { drawTexture(bunnyTexture, bunny.position) } } - @RegisterFunction override fun _process(delta: Double) { screenSize = getViewportRect().size @@ -80,7 +75,7 @@ class BunnymarkV1DrawTexture : Node2D() { queueRedraw() } - @RegisterFunction + @GodotMember fun addBunny() { bunnies.add( Bunny( @@ -90,13 +85,13 @@ class BunnymarkV1DrawTexture : Node2D() { ) } - @RegisterFunction + @GodotMember fun removeBunny() { if (bunnies.size == 0) return bunnies.removeAt(bunnies.size - 1) } - @RegisterFunction + @GodotMember fun finish() { benchmarkFinished.emit(bunnies.size) } diff --git a/harness/bunnymark/src/main/kotlin/godot/benchmark/bunnymark/BunnymarkV1Sprites.kt b/harness/bunnymark/src/main/kotlin/godot/benchmark/bunnymark/BunnymarkV1Sprites.kt index 8845872151..cda7e451bb 100644 --- a/harness/bunnymark/src/main/kotlin/godot/benchmark/bunnymark/BunnymarkV1Sprites.kt +++ b/harness/bunnymark/src/main/kotlin/godot/benchmark/bunnymark/BunnymarkV1Sprites.kt @@ -1,17 +1,20 @@ package godot.benchmark.bunnymark -import godot.core.* -import godot.* -import godot.annotation.RegisterClass -import godot.annotation.RegisterFunction -import godot.annotation.RegisterSignal -import godot.signals.signal - -@RegisterClass("BunnymarkV1Sprites") +import godot.Node2D +import godot.RandomNumberGenerator +import godot.ResourceLoader +import godot.Sprite2D +import godot.Texture2D +import godot.annotation.GodotMember +import godot.annotation.GodotScript +import godot.core.Vector2 +import godot.core.signal1 + + +@GodotScript("BunnymarkV1Sprites") class BunnymarkV1Sprites : Node2D() { - @RegisterSignal - val benchmarkFinished by signal("bunnyCount") + val benchmarkFinished by signal1("bunnyCount") private data class Bunny(var sprite: Sprite2D, var speed: Vector2) @@ -22,12 +25,10 @@ class BunnymarkV1Sprites : Node2D() { private lateinit var screenSize: Vector2 - @RegisterFunction override fun _ready() { randomNumberGenerator.randomize() } - @RegisterFunction override fun _process(delta: Double) { screenSize = getViewportRect().size @@ -69,7 +70,7 @@ class BunnymarkV1Sprites : Node2D() { } } - @RegisterFunction + @GodotMember fun addBunny() { val bunny = Sprite2D() bunny.texture = bunnyTexture @@ -83,7 +84,7 @@ class BunnymarkV1Sprites : Node2D() { ) } - @RegisterFunction + @GodotMember fun removeBunny() { if (bunnies.size == 0) return val bunny = bunnies[bunnies.size - 1] @@ -92,7 +93,7 @@ class BunnymarkV1Sprites : Node2D() { bunny.sprite.queueFree() } - @RegisterFunction + @GodotMember fun finish() { benchmarkFinished.emit(bunnies.size) } diff --git a/harness/bunnymark/src/main/kotlin/godot/benchmark/bunnymark/BunnymarkV2.kt b/harness/bunnymark/src/main/kotlin/godot/benchmark/bunnymark/BunnymarkV2.kt index 392b881356..85e6fa370b 100644 --- a/harness/bunnymark/src/main/kotlin/godot/benchmark/bunnymark/BunnymarkV2.kt +++ b/harness/bunnymark/src/main/kotlin/godot/benchmark/bunnymark/BunnymarkV2.kt @@ -1,17 +1,20 @@ package godot.benchmark.bunnymark -import godot.core.* -import godot.* -import godot.annotation.RegisterClass -import godot.annotation.RegisterFunction -import godot.annotation.RegisterSignal -import godot.signals.signal - -@RegisterClass("BunnymarkV2") +import godot.Label +import godot.Node2D +import godot.RandomNumberGenerator +import godot.ResourceLoader +import godot.Sprite2D +import godot.Texture2D +import godot.annotation.GodotMember +import godot.annotation.GodotScript +import godot.core.Vector2 +import godot.core.signal1 + +@GodotScript("BunnymarkV2") class BunnymarkV2 : Node2D() { - @RegisterSignal - val benchmarkFinished by signal("bunnyCount") + val benchmarkFinished by signal1("bunnyCount") private val gravity = 500 private val bunnySpeeds = mutableListOf() @@ -22,7 +25,6 @@ class BunnymarkV2 : Node2D() { private lateinit var screenSize: Vector2 - @RegisterFunction override fun _ready() { randomNumberGenerator.randomize() addChild(bunnies) @@ -30,7 +32,6 @@ class BunnymarkV2 : Node2D() { addChild(label) } - @RegisterFunction override fun _process(delta: Double) { screenSize = getViewportRect().size label.text = "Bunnies: " + bunnies.getChildCount().toString() @@ -75,7 +76,7 @@ class BunnymarkV2 : Node2D() { } } - @RegisterFunction + @GodotMember fun addBunny() { val bunny = Sprite2D() bunny.texture = bunnyTexture @@ -86,7 +87,7 @@ class BunnymarkV2 : Node2D() { ) } - @RegisterFunction + @GodotMember fun removeBunny() { val childCount = bunnies.getChildCount() if (childCount == 0) return @@ -99,7 +100,7 @@ class BunnymarkV2 : Node2D() { bunnySpeeds.removeAt(childCount.toInt() - 1) } - @RegisterFunction + @GodotMember fun finish() { benchmarkFinished.emit(bunnySpeeds.size) } diff --git a/harness/bunnymark/src/main/kotlin/godot/benchmark/bunnymark/BunnymarkV3.kt b/harness/bunnymark/src/main/kotlin/godot/benchmark/bunnymark/BunnymarkV3.kt index 70eca09c41..0f00923941 100644 --- a/harness/bunnymark/src/main/kotlin/godot/benchmark/bunnymark/BunnymarkV3.kt +++ b/harness/bunnymark/src/main/kotlin/godot/benchmark/bunnymark/BunnymarkV3.kt @@ -1,18 +1,20 @@ package godot.benchmark.bunnymark -import godot.* -import godot.annotation.RegisterClass -import godot.annotation.RegisterFunction -import godot.annotation.RegisterSignal +import godot.Label +import godot.Node2D +import godot.RandomNumberGenerator +import godot.ResourceLoader +import godot.Texture2D +import godot.annotation.GodotMember +import godot.annotation.GodotScript import godot.benchmark.bunnymark.v3.Bunny import godot.core.Vector2 -import godot.signals.signal +import godot.core.signal1 -@RegisterClass("BunnymarkV3") +@GodotScript("BunnymarkV3") class BunnymarkV3 : Node2D() { - @RegisterSignal - val benchmarkFinished by signal("bunnyCount") + val benchmarkFinished by signal1("bunnyCount") private val randomNumberGenerator = RandomNumberGenerator() private val bunnyTexture = ResourceLoader.load("res://images/godot_bunny.png") as Texture2D @@ -21,7 +23,6 @@ class BunnymarkV3 : Node2D() { private lateinit var screenSize: Vector2 - @RegisterFunction override fun _ready() { randomNumberGenerator.randomize() addChild(bunnies) @@ -30,13 +31,12 @@ class BunnymarkV3 : Node2D() { addChild(label) } - @RegisterFunction override fun _process(delta: Double) { screenSize = getViewportRect().size label.text = "Bunnies ${bunnies.getChildCount()}" } - @RegisterFunction + @GodotMember fun addBunny() { val bunny = Bunny() bunny.texture = bunnyTexture @@ -45,7 +45,7 @@ class BunnymarkV3 : Node2D() { bunny.speed = Vector2(randomNumberGenerator.randi() % 200 + 50, randomNumberGenerator.randi() % 200 + 50) } - @RegisterFunction + @GodotMember fun removeBunny() { val childCount = bunnies.getChildCount() if (childCount != 0) { @@ -55,7 +55,7 @@ class BunnymarkV3 : Node2D() { } } - @RegisterFunction + @GodotMember fun finish() { benchmarkFinished.emit(bunnies.getChildCount()) } diff --git a/harness/bunnymark/src/main/kotlin/godot/benchmark/bunnymark/v3/Bunny.kt b/harness/bunnymark/src/main/kotlin/godot/benchmark/bunnymark/v3/Bunny.kt index 33c491e58d..aa14b31391 100644 --- a/harness/bunnymark/src/main/kotlin/godot/benchmark/bunnymark/v3/Bunny.kt +++ b/harness/bunnymark/src/main/kotlin/godot/benchmark/bunnymark/v3/Bunny.kt @@ -2,11 +2,10 @@ package godot.benchmark.bunnymark.v3 import godot.RandomNumberGenerator import godot.Sprite2D -import godot.annotation.RegisterClass -import godot.annotation.RegisterFunction +import godot.annotation.GodotScript import godot.core.Vector2 -@RegisterClass +@GodotScript class Bunny : Sprite2D() { var speed = Vector2() @@ -15,12 +14,10 @@ class Bunny : Sprite2D() { private lateinit var screenSize: Vector2 private val randomNumberGenerator = RandomNumberGenerator() - @RegisterFunction override fun _ready() { randomNumberGenerator.randomize() } - @RegisterFunction override fun _process(delta: Double) { screenSize = getViewportRect().size val pos = position diff --git a/harness/flattened-library-tests/src/main/kotlin/godot/tests/library/flattened/Simple.kt b/harness/flattened-library-tests/src/main/kotlin/godot/tests/library/flattened/Simple.kt index 653d1f3939..c905ae2cef 100644 --- a/harness/flattened-library-tests/src/main/kotlin/godot/tests/library/flattened/Simple.kt +++ b/harness/flattened-library-tests/src/main/kotlin/godot/tests/library/flattened/Simple.kt @@ -2,16 +2,15 @@ package godot.tests.library.flattened import godot.Node3D import godot.annotation.Export -import godot.annotation.RegisterClass -import godot.annotation.RegisterFunction -import godot.annotation.RegisterProperty +import godot.annotation.Member +import godot.annotation.GodotScript -@RegisterClass +@GodotScript class Simple: Node3D() { @Export - @RegisterProperty var testProperty = "Hello from flattened-library-test!" - @RegisterFunction + + @Member fun provideGreeting(): String = testProperty } diff --git a/harness/fqname-library-tests/src/main/kotlin/godot/tests/library/fqname/Simple.kt b/harness/fqname-library-tests/src/main/kotlin/godot/tests/library/fqname/Simple.kt index 60402862b1..d1f2544f3d 100644 --- a/harness/fqname-library-tests/src/main/kotlin/godot/tests/library/fqname/Simple.kt +++ b/harness/fqname-library-tests/src/main/kotlin/godot/tests/library/fqname/Simple.kt @@ -2,16 +2,15 @@ package godot.tests.library.fqname import godot.Node3D import godot.annotation.Export -import godot.annotation.RegisterClass -import godot.annotation.RegisterFunction -import godot.annotation.RegisterProperty +import godot.annotation.Member +import godot.annotation.GodotScript -@RegisterClass +@GodotScript open class Simple: Node3D() { @Export - @RegisterProperty var testProperty = "Hello from fqname-library-test!" - @RegisterFunction + + @Member fun provideGreeting(): String = testProperty } diff --git a/harness/fqname-library-tests/src/main/kotlin/godot/tests/library/fqname/SimpleChild.kt b/harness/fqname-library-tests/src/main/kotlin/godot/tests/library/fqname/SimpleChild.kt index 34242e4913..2ed4aab047 100644 --- a/harness/fqname-library-tests/src/main/kotlin/godot/tests/library/fqname/SimpleChild.kt +++ b/harness/fqname-library-tests/src/main/kotlin/godot/tests/library/fqname/SimpleChild.kt @@ -1,7 +1,7 @@ package godot.tests.library.fqname -import godot.annotation.RegisterClass +import godot.annotation.GodotScript -@RegisterClass +@GodotScript class SimpleChild: Simple() {} diff --git a/harness/hierarchical-library-tests/src/main/kotlin/godot/tests/library/hierarchical/Simple.kt b/harness/hierarchical-library-tests/src/main/kotlin/godot/tests/library/hierarchical/Simple.kt index 1bf6462241..b85e8d1734 100644 --- a/harness/hierarchical-library-tests/src/main/kotlin/godot/tests/library/hierarchical/Simple.kt +++ b/harness/hierarchical-library-tests/src/main/kotlin/godot/tests/library/hierarchical/Simple.kt @@ -2,16 +2,15 @@ package godot.tests.library.hierarchical import godot.Node3D import godot.annotation.Export -import godot.annotation.RegisterClass -import godot.annotation.RegisterFunction -import godot.annotation.RegisterProperty +import godot.annotation.Member +import godot.annotation.GodotScript -@RegisterClass +@GodotScript class Simple: Node3D() { @Export - @RegisterProperty var testProperty = "Hello from hierarchical-library-test!" - @RegisterFunction + + @Member fun provideGreeting(): String = testProperty } diff --git a/harness/tests/.run/Debug EntryGenerator.run.xml b/harness/tests/.run/Debug EntryGenerator.run.xml index 71032a1d75..9aa97ccf15 100644 --- a/harness/tests/.run/Debug EntryGenerator.run.xml +++ b/harness/tests/.run/Debug EntryGenerator.run.xml @@ -1,15 +1,15 @@ - - - + + + \ No newline at end of file diff --git a/harness/tests/addons/gut/fonts/AnonymousPro-Bold.ttf.import b/harness/tests/addons/gut/fonts/AnonymousPro-Bold.ttf.import index a3eb4791fb..de1351f60d 100644 --- a/harness/tests/addons/gut/fonts/AnonymousPro-Bold.ttf.import +++ b/harness/tests/addons/gut/fonts/AnonymousPro-Bold.ttf.import @@ -15,6 +15,7 @@ dest_files=["res://.godot/imported/AnonymousPro-Bold.ttf-9d8fef4d357af5b52cd60af Rendering=null antialiasing=1 generate_mipmaps=false +disable_embedded_bitmaps=true multichannel_signed_distance_field=false msdf_pixel_range=8 msdf_size=48 diff --git a/harness/tests/addons/gut/fonts/AnonymousPro-BoldItalic.ttf.import b/harness/tests/addons/gut/fonts/AnonymousPro-BoldItalic.ttf.import index ef28dd8056..bdde20728a 100644 --- a/harness/tests/addons/gut/fonts/AnonymousPro-BoldItalic.ttf.import +++ b/harness/tests/addons/gut/fonts/AnonymousPro-BoldItalic.ttf.import @@ -15,6 +15,7 @@ dest_files=["res://.godot/imported/AnonymousPro-BoldItalic.ttf-4274bf704d3d6b9cd Rendering=null antialiasing=1 generate_mipmaps=false +disable_embedded_bitmaps=true multichannel_signed_distance_field=false msdf_pixel_range=8 msdf_size=48 diff --git a/harness/tests/addons/gut/fonts/AnonymousPro-Italic.ttf.import b/harness/tests/addons/gut/fonts/AnonymousPro-Italic.ttf.import index 1779af1720..ce3e5b918b 100644 --- a/harness/tests/addons/gut/fonts/AnonymousPro-Italic.ttf.import +++ b/harness/tests/addons/gut/fonts/AnonymousPro-Italic.ttf.import @@ -15,6 +15,7 @@ dest_files=["res://.godot/imported/AnonymousPro-Italic.ttf-9989590b02137b799e13d Rendering=null antialiasing=1 generate_mipmaps=false +disable_embedded_bitmaps=true multichannel_signed_distance_field=false msdf_pixel_range=8 msdf_size=48 diff --git a/harness/tests/addons/gut/fonts/AnonymousPro-Regular.ttf.import b/harness/tests/addons/gut/fonts/AnonymousPro-Regular.ttf.import index 1e2975b155..a567498cda 100644 --- a/harness/tests/addons/gut/fonts/AnonymousPro-Regular.ttf.import +++ b/harness/tests/addons/gut/fonts/AnonymousPro-Regular.ttf.import @@ -15,6 +15,7 @@ dest_files=["res://.godot/imported/AnonymousPro-Regular.ttf-856c843fd6f89964d2ca Rendering=null antialiasing=1 generate_mipmaps=false +disable_embedded_bitmaps=true multichannel_signed_distance_field=false msdf_pixel_range=8 msdf_size=48 diff --git a/harness/tests/addons/gut/fonts/CourierPrime-Bold.ttf.import b/harness/tests/addons/gut/fonts/CourierPrime-Bold.ttf.import index 7d60fb0a2c..cb05171da6 100644 --- a/harness/tests/addons/gut/fonts/CourierPrime-Bold.ttf.import +++ b/harness/tests/addons/gut/fonts/CourierPrime-Bold.ttf.import @@ -15,6 +15,7 @@ dest_files=["res://.godot/imported/CourierPrime-Bold.ttf-1f003c66d63ebed70964e77 Rendering=null antialiasing=1 generate_mipmaps=false +disable_embedded_bitmaps=true multichannel_signed_distance_field=false msdf_pixel_range=8 msdf_size=48 diff --git a/harness/tests/addons/gut/fonts/CourierPrime-BoldItalic.ttf.import b/harness/tests/addons/gut/fonts/CourierPrime-BoldItalic.ttf.import index 4678c9ebb2..0a9a7b770f 100644 --- a/harness/tests/addons/gut/fonts/CourierPrime-BoldItalic.ttf.import +++ b/harness/tests/addons/gut/fonts/CourierPrime-BoldItalic.ttf.import @@ -15,6 +15,7 @@ dest_files=["res://.godot/imported/CourierPrime-BoldItalic.ttf-65ebcc61dd5e1dfa8 Rendering=null antialiasing=1 generate_mipmaps=false +disable_embedded_bitmaps=true multichannel_signed_distance_field=false msdf_pixel_range=8 msdf_size=48 diff --git a/harness/tests/addons/gut/fonts/CourierPrime-Italic.ttf.import b/harness/tests/addons/gut/fonts/CourierPrime-Italic.ttf.import index 522e2950ce..89412fc98c 100644 --- a/harness/tests/addons/gut/fonts/CourierPrime-Italic.ttf.import +++ b/harness/tests/addons/gut/fonts/CourierPrime-Italic.ttf.import @@ -15,6 +15,7 @@ dest_files=["res://.godot/imported/CourierPrime-Italic.ttf-baa9156a73770735a0f72 Rendering=null antialiasing=1 generate_mipmaps=false +disable_embedded_bitmaps=true multichannel_signed_distance_field=false msdf_pixel_range=8 msdf_size=48 diff --git a/harness/tests/addons/gut/fonts/CourierPrime-Regular.ttf.import b/harness/tests/addons/gut/fonts/CourierPrime-Regular.ttf.import index 38174660fb..9fde40b1be 100644 --- a/harness/tests/addons/gut/fonts/CourierPrime-Regular.ttf.import +++ b/harness/tests/addons/gut/fonts/CourierPrime-Regular.ttf.import @@ -15,6 +15,7 @@ dest_files=["res://.godot/imported/CourierPrime-Regular.ttf-3babe7e4a7a588dfc9a8 Rendering=null antialiasing=1 generate_mipmaps=false +disable_embedded_bitmaps=true multichannel_signed_distance_field=false msdf_pixel_range=8 msdf_size=48 diff --git a/harness/tests/addons/gut/fonts/LobsterTwo-Bold.ttf.import b/harness/tests/addons/gut/fonts/LobsterTwo-Bold.ttf.import index 7548ad04dc..673d15155e 100644 --- a/harness/tests/addons/gut/fonts/LobsterTwo-Bold.ttf.import +++ b/harness/tests/addons/gut/fonts/LobsterTwo-Bold.ttf.import @@ -15,6 +15,7 @@ dest_files=["res://.godot/imported/LobsterTwo-Bold.ttf-7c7f734103b58a32491a47881 Rendering=null antialiasing=1 generate_mipmaps=false +disable_embedded_bitmaps=true multichannel_signed_distance_field=false msdf_pixel_range=8 msdf_size=48 diff --git a/harness/tests/addons/gut/fonts/LobsterTwo-BoldItalic.ttf.import b/harness/tests/addons/gut/fonts/LobsterTwo-BoldItalic.ttf.import index 4b609e80bd..62048b0efd 100644 --- a/harness/tests/addons/gut/fonts/LobsterTwo-BoldItalic.ttf.import +++ b/harness/tests/addons/gut/fonts/LobsterTwo-BoldItalic.ttf.import @@ -15,6 +15,7 @@ dest_files=["res://.godot/imported/LobsterTwo-BoldItalic.ttf-227406a33e84448e6aa Rendering=null antialiasing=1 generate_mipmaps=false +disable_embedded_bitmaps=true multichannel_signed_distance_field=false msdf_pixel_range=8 msdf_size=48 diff --git a/harness/tests/addons/gut/fonts/LobsterTwo-Italic.ttf.import b/harness/tests/addons/gut/fonts/LobsterTwo-Italic.ttf.import index 5899b79770..d3ca272819 100644 --- a/harness/tests/addons/gut/fonts/LobsterTwo-Italic.ttf.import +++ b/harness/tests/addons/gut/fonts/LobsterTwo-Italic.ttf.import @@ -15,6 +15,7 @@ dest_files=["res://.godot/imported/LobsterTwo-Italic.ttf-f93abf6c25390c85ad5fb6c Rendering=null antialiasing=1 generate_mipmaps=false +disable_embedded_bitmaps=true multichannel_signed_distance_field=false msdf_pixel_range=8 msdf_size=48 diff --git a/harness/tests/addons/gut/fonts/LobsterTwo-Regular.ttf.import b/harness/tests/addons/gut/fonts/LobsterTwo-Regular.ttf.import index 45a12c8a53..9cc754218b 100644 --- a/harness/tests/addons/gut/fonts/LobsterTwo-Regular.ttf.import +++ b/harness/tests/addons/gut/fonts/LobsterTwo-Regular.ttf.import @@ -15,6 +15,7 @@ dest_files=["res://.godot/imported/LobsterTwo-Regular.ttf-f3fcfa01cd671c8da433dd Rendering=null antialiasing=1 generate_mipmaps=false +disable_embedded_bitmaps=true multichannel_signed_distance_field=false msdf_pixel_range=8 msdf_size=48 diff --git a/harness/tests/addons/gut/strutils.gd b/harness/tests/addons/gut/strutils.gd index 51e45ccea4..b5b1eff5a0 100644 --- a/harness/tests/addons/gut/strutils.gd +++ b/harness/tests/addons/gut/strutils.gd @@ -7,139 +7,139 @@ var _utils = load('res://addons/gut/utils.gd').get_instance() var types = {} func _init_types_dictionary(): - types[TYPE_AABB] = 'AABB' - types[TYPE_ARRAY] = 'ARRAY' - types[TYPE_BASIS] = 'BASIS' - types[TYPE_BOOL] = 'BOOL' - types[TYPE_CALLABLE] = 'CALLABLE' - types[TYPE_COLOR] = 'COLOR' - types[TYPE_DICTIONARY] = 'DICTIONARY' - types[TYPE_FLOAT] = 'FLOAT' - types[TYPE_INT] = 'INT' - types[TYPE_MAX] = 'MAX' - types[TYPE_NODE_PATH] = 'NODE_PATH' - types[TYPE_OBJECT] = 'OBJECT' - types[TYPE_PACKED_BYTE_ARRAY] = 'PACKED_BYTE_ARRAY' - types[TYPE_PACKED_COLOR_ARRAY] = 'PACKED_COLOR_ARRAY' - types[TYPE_PACKED_FLOAT32_ARRAY] = 'PACKED_FLOAT32_ARRAY' - types[TYPE_PACKED_FLOAT64_ARRAY] = 'PACKED_FLOAT64_ARRAY' - types[TYPE_PACKED_INT32_ARRAY] = 'PACKED_INT32_ARRAY' - types[TYPE_PACKED_INT64_ARRAY] = 'PACKED_INT64_ARRAY' - types[TYPE_PACKED_STRING_ARRAY] = 'PACKED_STRING_ARRAY' - types[TYPE_PACKED_VECTOR2_ARRAY] = 'PACKED_VECTOR2_ARRAY' - types[TYPE_PACKED_VECTOR3_ARRAY] = 'PACKED_VECTOR3_ARRAY' - types[TYPE_PLANE] = 'PLANE' - types[TYPE_PROJECTION] = 'PROJECTION' - types[TYPE_QUATERNION] = 'QUATERNION' - types[TYPE_RECT2] = 'RECT2' - types[TYPE_RECT2I] = 'RECT2I' - types[TYPE_RID] = 'RID' - types[TYPE_SIGNAL] = 'SIGNAL' - types[TYPE_STRING_NAME] = 'STRING_NAME' - types[TYPE_STRING] = 'STRING' - types[TYPE_TRANSFORM2D] = 'TRANSFORM2D' - types[TYPE_TRANSFORM3D] = 'TRANSFORM3D' - types[TYPE_VECTOR2] = 'VECTOR2' - types[TYPE_VECTOR2I] = 'VECTOR2I' - types[TYPE_VECTOR3] = 'VECTOR3' - types[TYPE_VECTOR3I] = 'VECTOR3I' - types[TYPE_VECTOR4] = 'VECTOR4' - types[TYPE_VECTOR4I] = 'VECTOR4I' + types[TYPE_AABB] = 'AABB' + types[TYPE_ARRAY] = 'ARRAY' + types[TYPE_BASIS] = 'BASIS' + types[TYPE_BOOL] = 'BOOL' + types[TYPE_CALLABLE] = 'CALLABLE' + types[TYPE_COLOR] = 'COLOR' + types[TYPE_DICTIONARY] = 'DICTIONARY' + types[TYPE_FLOAT] = 'FLOAT' + types[TYPE_INT] = 'INT' + types[TYPE_MAX] = 'MAX' + types[TYPE_NODE_PATH] = 'NODE_PATH' + types[TYPE_OBJECT] = 'OBJECT' + types[TYPE_PACKED_BYTE_ARRAY] = 'PACKED_BYTE_ARRAY' + types[TYPE_PACKED_COLOR_ARRAY] = 'PACKED_COLOR_ARRAY' + types[TYPE_PACKED_FLOAT32_ARRAY] = 'PACKED_FLOAT32_ARRAY' + types[TYPE_PACKED_FLOAT64_ARRAY] = 'PACKED_FLOAT64_ARRAY' + types[TYPE_PACKED_INT32_ARRAY] = 'PACKED_INT32_ARRAY' + types[TYPE_PACKED_INT64_ARRAY] = 'PACKED_INT64_ARRAY' + types[TYPE_PACKED_STRING_ARRAY] = 'PACKED_STRING_ARRAY' + types[TYPE_PACKED_VECTOR2_ARRAY] = 'PACKED_VECTOR2_ARRAY' + types[TYPE_PACKED_VECTOR3_ARRAY] = 'PACKED_VECTOR3_ARRAY' + types[TYPE_PLANE] = 'PLANE' + types[TYPE_PROJECTION] = 'PROJECTION' + types[TYPE_QUATERNION] = 'QUATERNION' + types[TYPE_RECT2] = 'RECT2' + types[TYPE_RECT2I] = 'RECT2I' + types[TYPE_RID] = 'RID' + types[TYPE_SIGNAL] = 'SIGNAL' + types[TYPE_STRING_NAME] = 'STRING_NAME' + types[TYPE_STRING] = 'STRING' + types[TYPE_TRANSFORM2D] = 'TRANSFORM2D' + types[TYPE_TRANSFORM3D] = 'TRANSFORM3D' + types[TYPE_VECTOR2] = 'VECTOR2' + types[TYPE_VECTOR2I] = 'VECTOR2I' + types[TYPE_VECTOR3] = 'VECTOR3' + types[TYPE_VECTOR3I] = 'VECTOR3I' + types[TYPE_VECTOR4] = 'VECTOR4' + types[TYPE_VECTOR4I] = 'VECTOR4I' # Types to not be formatted when using _str var _str_ignore_types = [ - TYPE_INT, TYPE_FLOAT, TYPE_STRING, - TYPE_NIL, TYPE_BOOL + TYPE_INT, TYPE_FLOAT, TYPE_STRING, + TYPE_NIL, TYPE_BOOL ] func _init(): - _init_types_dictionary() + _init_types_dictionary() # ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------ func _get_filename(path): - return path.split('/')[-1] + return path.split('/')[-1] # ------------------------------------------------------------------------------ # Gets the filename of an object passed in. This does not return the # full path to the object, just the filename. # ------------------------------------------------------------------------------ func _get_obj_filename(thing): - var filename = null - - if(thing == null or - _utils.is_native_class(thing) or - !is_instance_valid(thing) or - str(thing) == '' or - typeof(thing) != TYPE_OBJECT or - _utils.is_double(thing)): - return - - if(thing.get_script() == null): - if(thing is PackedScene): - filename = _get_filename(thing.resource_path) - else: - # If it isn't a packed scene and it doesn't have a script then - # we do nothing. This just reads better. - pass - elif(!_utils.is_native_class(thing)): - var dict = inst_to_dict(thing) - filename = _get_filename(dict['@path']) - if(str(dict['@subpath']) != ''): - filename += str('/', dict['@subpath']) - - return filename + var filename = null + + if(thing == null or + _utils.is_native_class(thing) or + !is_instance_valid(thing) or + str(thing) == '' or + typeof(thing) != TYPE_OBJECT or + _utils.is_double(thing)): + return + + if(thing.get_script() == null): + if(thing is PackedScene): + filename = _get_filename(thing.resource_path) + else: + # If it isn't a packed scene and it doesn't have a script then + # we do nothing. This just reads better. + pass + elif(!_utils.is_native_class(thing)): + var dict = inst_to_dict(thing) + filename = _get_filename(dict['@path']) + if(str(dict['@subpath']) != ''): + filename += str('/', dict['@subpath']) + + return filename # ------------------------------------------------------------------------------ # Better object/thing to string conversion. Includes extra details about # whatever is passed in when it can/should. # ------------------------------------------------------------------------------ func type2str(thing): - var filename = _get_obj_filename(thing) - var str_thing = str(thing) - - if(thing == null): - # According to str there is a difference between null and an Object - # that is somehow null. To avoid getting '[Object:null]' as output - # always set it to str(null) instead of str(thing). A null object - # will pass typeof(thing) == TYPE_OBJECT check so this has to be - # before that. - str_thing = str(null) - elif(typeof(thing) == TYPE_FLOAT): - if(!'.' in str_thing): - str_thing += '.0' - elif(typeof(thing) == TYPE_STRING): - str_thing = str('"', thing, '"') - elif(typeof(thing) in _str_ignore_types): - # do nothing b/c we already have str(thing) in - # to_return. I think this just reads a little - # better this way. - pass - elif(typeof(thing) == TYPE_OBJECT): - if(_utils.is_native_class(thing)): - str_thing = _utils.get_native_class_name(thing) - elif(_utils.is_double(thing)): - var double_path = _get_filename(thing.__gutdbl.thepath) - if(thing.__gutdbl.subpath != ''): - double_path += str('/', thing.__gutdbl.subpath) - elif(thing.__gutdbl.from_singleton != ''): - double_path = thing.__gutdbl.from_singleton + " Singleton" - - var double_type = "double" - if(thing.__gutdbl.is_partial): - double_type = "partial-double" - - str_thing += str("(", double_type, " of ", double_path, ")") - - filename = null - elif(types.has(typeof(thing))): - if(!str_thing.begins_with('(')): - str_thing = '(' + str_thing + ')' - str_thing = str(types[typeof(thing)], str_thing) - - if(filename != null): - str_thing += str('(', filename, ')') - return str_thing + var filename = _get_obj_filename(thing) + var str_thing = str(thing) + + if(thing == null): + # According to str there is a difference between null and an Object + # that is somehow null. To avoid getting '[Object:null]' as output + # always set it to str(null) instead of str(thing). A null object + # will pass typeof(thing) == TYPE_OBJECT check so this has to be + # before that. + str_thing = str(null) + elif(typeof(thing) == TYPE_FLOAT): + if(!'.' in str_thing): + str_thing += '.0' + elif(typeof(thing) == TYPE_STRING): + str_thing = str('"', thing, '"') + elif(typeof(thing) in _str_ignore_types): + # do nothing b/c we already have str(thing) in + # to_return. I think this just reads a little + # better this way. + pass + elif(typeof(thing) == TYPE_OBJECT): + if(_utils.is_native_class(thing)): + str_thing = _utils.get_native_class_name(thing) + elif(_utils.is_double(thing)): + var double_path = _get_filename(thing.__gutdbl.thepath) + if(thing.__gutdbl.subpath != ''): + double_path += str('/', thing.__gutdbl.subpath) + elif(thing.__gutdbl.from_singleton != ''): + double_path = thing.__gutdbl.from_singleton + " Singleton" + + var double_type = "double" + if(thing.__gutdbl.is_partial): + double_type = "partial-double" + + str_thing += str("(", double_type, " of ", double_path, ")") + + filename = null + elif(types.has(typeof(thing))): + if(!str_thing.begins_with('(')): + str_thing = '(' + str_thing + ')' + str_thing = str(types[typeof(thing)], str_thing) + + if(filename != null): + str_thing += str('(', filename, ')') + return str_thing # ------------------------------------------------------------------------------ # Returns the string truncated with an '...' in it. Shows the start and last @@ -147,32 +147,32 @@ func type2str(thing): # returned. If max_size is -1 then truncation is skipped. # ------------------------------------------------------------------------------ func truncate_string(src, max_size): - var to_return = src - if(src.length() > max_size - 10 and max_size != -1): - to_return = str(src.substr(0, max_size - 10), '...', src.substr(src.length() - 10, src.length())) - return to_return + var to_return = src + if(src.length() > max_size - 10 and max_size != -1): + to_return = str(src.substr(0, max_size - 10), '...', src.substr(src.length() - 10, src.length())) + return to_return func _get_indent_text(times, pad): - var to_return = '' - for i in range(times): - to_return += pad + var to_return = '' + for i in range(times): + to_return += pad - return to_return + return to_return func indent_text(text, times, pad): - if(times == 0): - return text + if(times == 0): + return text - var to_return = text - var ending_newline = '' + var to_return = text + var ending_newline = '' - if(text.ends_with("\n")): - ending_newline = "\n" - to_return = to_return.left(to_return.length() -1) + if(text.ends_with("\n")): + ending_newline = "\n" + to_return = to_return.left(to_return.length() -1) - var padding = _get_indent_text(times, pad) - to_return = to_return.replace("\n", "\n" + padding) - to_return += ending_newline + var padding = _get_indent_text(times, pad) + to_return = to_return.replace("\n", "\n" + padding) + to_return += ending_newline - return padding + to_return + return padding + to_return diff --git a/harness/tests/otherSourceDir/CopyModificationCheckTestClass.kt b/harness/tests/otherSourceDir/CopyModificationCheckTestClass.kt index f1594721a5..70a885c4d3 100644 --- a/harness/tests/otherSourceDir/CopyModificationCheckTestClass.kt +++ b/harness/tests/otherSourceDir/CopyModificationCheckTestClass.kt @@ -1,14 +1,14 @@ import godot.Node3D import godot.annotation.Export -import godot.annotation.RegisterClass -import godot.annotation.RegisterProperty -import godot.core.* +import godot.annotation.GodotScript +import godot.core.Basis +import godot.core.Transform3D +import godot.core.Vector3 -@RegisterClass +@GodotScript class CopyModificationCheckTestClass: Node3D() { @Export - @RegisterProperty lateinit var node3D: Node3D class Blubb { diff --git a/harness/tests/otherSourceDir/CoreTypePropertyChecks.kt b/harness/tests/otherSourceDir/CoreTypePropertyChecks.kt index 621ba9992f..b79481cad6 100644 --- a/harness/tests/otherSourceDir/CoreTypePropertyChecks.kt +++ b/harness/tests/otherSourceDir/CoreTypePropertyChecks.kt @@ -1,29 +1,27 @@ import godot.Node import godot.annotation.Export -import godot.annotation.RegisterClass -import godot.annotation.RegisterProperty +import godot.annotation.Member +import godot.annotation.GodotScript import godot.core.Vector3 -@RegisterClass +@GodotScript class CoreTypePropertyChecks: Node() { // not allowed cases are commented out so that the compilation runs. Otherwise, our compiler checks trigger a build failure // to test out these checks, uncomment the cases // not allowed // @Export -// @RegisterProperty // lateinit var exportedLateinitCoreType: Vector3 // allowed @Export - @RegisterProperty var exportedNormalCoreType: Vector3 = Vector3.ZERO // not allowed -// @RegisterProperty +// @Member // lateinit var lateinitCoreType: Vector3 // allowed - @RegisterProperty + @Member var normalCoreType: Vector3 = Vector3.ZERO } diff --git a/harness/tests/otherSourceDir/ScriptInOtherSourceDir.kt b/harness/tests/otherSourceDir/ScriptInOtherSourceDir.kt index 6a49ac654a..174d1080cb 100644 --- a/harness/tests/otherSourceDir/ScriptInOtherSourceDir.kt +++ b/harness/tests/otherSourceDir/ScriptInOtherSourceDir.kt @@ -1,10 +1,10 @@ import godot.Node -import godot.annotation.RegisterClass -import godot.annotation.RegisterFunction +import godot.annotation.Member +import godot.annotation.GodotScript -@RegisterClass +@GodotScript class ScriptInOtherSourceDir: Node() { - @RegisterFunction + @Member fun greeting() = "HelloWorld" } diff --git a/harness/tests/scripts/godot/tests/Invocation.gdj b/harness/tests/scripts/godot/tests/Invocation.gdj index 1de7614948..5dd455bb1c 100644 --- a/harness/tests/scripts/godot/tests/Invocation.gdj +++ b/harness/tests/scripts/godot/tests/Invocation.gdj @@ -40,6 +40,7 @@ properties = [ nav_meshes_dictionary, nullable_dictionary, color, + rid, packed_byte_array, packed_int32_array, packed_float64_array, @@ -81,6 +82,7 @@ functions = [ init_nullables, _enter_tree, _ready, + _on_destroy, get_rid_id, get_nav_mesh_rid, append_to_any_dict, diff --git a/harness/tests/scripts/godot/tests/JavaTestClass.gdj b/harness/tests/scripts/godot/tests/JavaTestClass.gdj index 2ac65467a3..8f5e99a539 100644 --- a/harness/tests/scripts/godot/tests/JavaTestClass.gdj +++ b/harness/tests/scripts/godot/tests/JavaTestClass.gdj @@ -30,7 +30,8 @@ properties = [ dictionary ] functions = [ - greeting, + _ready, + greeting, connect_and_trigger_signal, signal_callback ] \ No newline at end of file diff --git a/harness/tests/src/main/java/godot/tests/JavaTestClass.java b/harness/tests/src/main/java/godot/tests/JavaTestClass.java index 144b9c5f63..b113a00e1b 100644 --- a/harness/tests/src/main/java/godot/tests/JavaTestClass.java +++ b/harness/tests/src/main/java/godot/tests/JavaTestClass.java @@ -3,71 +3,62 @@ import godot.Button; import godot.Node; import godot.RenderingServer; -import godot.annotation.*; +import godot.annotation.EnumTypeHint; +import godot.annotation.Export; +import godot.annotation.Member; +import godot.annotation.GodotScript; import godot.core.*; import org.jetbrains.annotations.NotNull; -@RegisterClass +@GodotScript public class JavaTestClass extends Node { - @RegisterSignal public Signal0 testSignal = Signal0.create(this, "test_signal"); - @RegisterSignal public Signal2 testSignal2 = Signal2.create(this, "test_signal_2", "param1", "param2"); // The following should NOT work as we cannot extract parameter names. The compiler checks should catch that and throw a build error -// @RegisterSignal // public Signal testSignal3 = new Signal2<>(this, "name"); @Export - @RegisterProperty @EnumTypeHint public JavaEnum javaEnum = JavaEnum.JAVA_ENUM_1; @Export - @RegisterProperty public int exportedInt = 1; @Export - @RegisterProperty public long exportedLong = 1L; @Export - @RegisterProperty public float exportedFloat = 1f; @Export - @RegisterProperty public double exportedDouble = 1.0; @Export - @RegisterProperty public boolean exportedBoolean = true; @Export - @RegisterProperty public String exportedString = "blubb"; @Export - @RegisterProperty public byte exportedByte = 1; @Export - @RegisterProperty public Button exportedButton; - @RegisterFunction + @Member public String greeting() { return "Hello from java"; } - @RegisterProperty + @Member public boolean signalEmitted = false; - @RegisterProperty + @Member public VariantArray variantArray = new VariantArray<>(Integer.class); - @RegisterProperty + @Member public Dictionary dictionary = new Dictionary<>(Float.class, String.class); public LambdaCallable lambdaCallable = LambdaCallable0.create( @@ -80,7 +71,6 @@ public String greeting() { public NativeCallable methodCallable = Callable.create(this, StringNames.asStringName("DummyName")); - @RegisterFunction @Override public void _ready() { // Check if Singletons have the correct syntax, without Single.INSTANCE @@ -89,7 +79,7 @@ public void _ready() { RenderingServer.getDefaultClearColor(); } - @RegisterFunction + @Member public void connectAndTriggerSignal() { connect( StringNames.asStringName("test_signal"), @@ -110,7 +100,7 @@ public GodotNotification _notification() { ); } - @RegisterFunction + @Member public void signalCallback() { signalEmitted = true; } diff --git a/harness/tests/src/main/kotlin/godot/tests/CoreTypesIdentityTest.kt b/harness/tests/src/main/kotlin/godot/tests/CoreTypesIdentityTest.kt index 669638f17c..e408d2895a 100644 --- a/harness/tests/src/main/kotlin/godot/tests/CoreTypesIdentityTest.kt +++ b/harness/tests/src/main/kotlin/godot/tests/CoreTypesIdentityTest.kt @@ -1,72 +1,80 @@ package godot.tests import godot.Node -import godot.annotation.RegisterClass -import godot.annotation.RegisterFunction -import godot.annotation.RegisterProperty -import godot.core.* - -@RegisterClass +import godot.annotation.Member +import godot.annotation.GodotScript +import godot.core.AABB +import godot.core.Basis +import godot.core.Color +import godot.core.Plane +import godot.core.Quaternion +import godot.core.Rect2 +import godot.core.Transform2D +import godot.core.Transform3D +import godot.core.Vector2 +import godot.core.Vector3 + +@GodotScript class CoreTypesIdentityTest : Node() { - @RegisterProperty + @Member var aabb = AABB(Vector3(1, 1, 1), Vector3(2, 2, 2)) - @RegisterProperty + @Member var basis = Basis(Vector3(0, 1, 2), Vector3(3, 4, 5), Vector3(6, 7, 8)) - @RegisterProperty + @Member var color = Color(0.1, 0.2, 0.3, 0.4) - @RegisterProperty + @Member var plane = Plane(1, 2, 3, 4) - @RegisterProperty + @Member var quaternion = Quaternion(1, 2, 3, 4) - @RegisterProperty + @Member var rect2 = Rect2(1.0, 2.0, 3.0, 4.0) - @RegisterProperty + @Member var transform3D = Transform3D(Vector3(0, 1, 2), Vector3(3, 4, 5), Vector3(6, 7, 8), Vector3(9, 10, 11)) - @RegisterProperty + @Member var transform2D = Transform2D(0, 1, 2, 3, 4, 5) - @RegisterProperty + @Member var vector2 = Vector2(1, 2) - @RegisterProperty + @Member var vector3 = Vector3(1, 2, 3) - @RegisterFunction + @Member fun aabb(aabb: AABB) = aabb - @RegisterFunction + @Member fun basis(basis: Basis) = basis - @RegisterFunction + @Member fun color(color: Color) = color - @RegisterFunction + @Member fun plane(plane: Plane) = plane - @RegisterFunction + @Member fun quat(quaternion: Quaternion) = quaternion - @RegisterFunction + @Member fun rect2(rect2: Rect2) = rect2 - @RegisterFunction + @Member fun transform(transform3D: Transform3D) = transform3D - @RegisterFunction + @Member fun transform2D(transform2D: Transform2D) = transform2D - @RegisterFunction + @Member fun vector2(vector2: Vector2) = vector2 - @RegisterFunction + @Member fun vector3(vector3: Vector3) = vector3 } diff --git a/harness/tests/src/main/kotlin/godot/tests/FuncRefTest.kt b/harness/tests/src/main/kotlin/godot/tests/FuncRefTest.kt index 9cd92c7d4d..2a1b89e57a 100644 --- a/harness/tests/src/main/kotlin/godot/tests/FuncRefTest.kt +++ b/harness/tests/src/main/kotlin/godot/tests/FuncRefTest.kt @@ -1,75 +1,72 @@ package godot.tests import godot.Node -import godot.annotation.RegisterClass -import godot.annotation.RegisterFunction -import godot.annotation.RegisterProperty -import godot.annotation.RegisterSignal +import godot.annotation.Member +import godot.annotation.GodotScript import godot.annotation.Rpc import godot.core.signal0 import godot.extensions.call import godot.extensions.callDeferred -@RegisterClass +@GodotScript class FuncRefTest : Node() { - @RegisterSignal val test by signal0() - @RegisterProperty + @Member var blubb: Boolean = false - @RegisterProperty + @Member var callFlag = false - @RegisterProperty + @Member var callWithParamFlag = false - @RegisterProperty + @Member var signalCallFlag = false - @RegisterFunction + @Member override fun _ready() { test.connect(this, FuncRefTest::testSignalCallback) } @Rpc - @RegisterFunction + @Member fun testSignalCallback() { signalCallFlag = true } - @RegisterFunction + @Member fun testSignalCall() { test.emit() } - @RegisterFunction + @Member fun withoutParamCallback() { callFlag = true } - @RegisterFunction + @Member fun testCallWithoutParam() { call(this::withoutParamCallback) } - @RegisterFunction + @Member fun testCallDeferredWithoutParam() { callDeferred(this::withoutParamCallback) } - @RegisterFunction + @Member fun withParamCallback(flag: Boolean) { callWithParamFlag = flag } - @RegisterFunction + @Member fun testCallWithParam() { call(this::withParamCallback, true) } - @RegisterFunction + @Member fun testCallDeferredWithParam() { callDeferred(this::withParamCallback, true) } diff --git a/harness/tests/src/main/kotlin/godot/tests/Invocation.kt b/harness/tests/src/main/kotlin/godot/tests/Invocation.kt index 7dd7855132..6a09e47178 100644 --- a/harness/tests/src/main/kotlin/godot/tests/Invocation.kt +++ b/harness/tests/src/main/kotlin/godot/tests/Invocation.kt @@ -14,14 +14,13 @@ import godot.annotation.ExpEasing import godot.annotation.Export import godot.annotation.File import godot.annotation.FloatRange +import godot.annotation.Member +import godot.annotation.GodotScript import godot.annotation.IntFlag import godot.annotation.IntRange import godot.annotation.LongRange import godot.annotation.MultilineText import godot.annotation.PlaceHolderText -import godot.annotation.RegisterClass -import godot.annotation.RegisterFunction -import godot.annotation.RegisterProperty import godot.core.Color import godot.core.Dictionary import godot.core.NodePath @@ -49,91 +48,79 @@ enum class TestEnum { ENUM_2 } -@RegisterClass +@GodotScript class Invocation : Node3D() { @Export - @RegisterProperty lateinit var button: Button @Export - @RegisterProperty var enumList = listOf(TestEnum.ENUM_1) - @RegisterProperty + @Member var vectorList = PackedVector3Array() @Export - @RegisterProperty var enumListMutable = mutableListOf(TestEnum.ENUM_1, TestEnum.ENUM_2) // Can't export nullable coretypes //@Export - //@RegisterProperty //var nullableLong: Long? = null private var hasInitializedLateInits = false // Can't export nullable coretypes //@Export - //@RegisterProperty //var lateinitString: String? = null - @RegisterProperty + @Member lateinit var registerObject: OtherScript - @RegisterProperty + @Member var registerObjectNullable: OtherScript? = null - @RegisterProperty + @Member var registerObjectNullablePreInit: OtherScript? = OtherScript() set(value) { field?.free() field = value } - @RegisterProperty + @Member var registerObjectNonNullablePreInit: OtherScript = OtherScript() set(value) { field.free() field = value } - @RegisterProperty + @Member var vector = Vector3() @Export - @RegisterProperty var x = 0 @Export - @RegisterProperty var y = 0.0 @Export - @RegisterProperty var z = 0.0f @Export - @RegisterProperty var customName = "Idonthaveanyidea" //references in default values are allowed if the property is NOT exported private val otherScriptReference = OtherScript() private fun provideOtherScriptReference() = otherScriptReference - @RegisterProperty + @Member var invocation = provideOtherScriptReference() @Export - @RegisterProperty var enumTest = TestEnum.ENUM_1 @Export - @RegisterProperty var resourceTest = NavigationMesh() @Export - @RegisterProperty var jvmId: Int = 0 get() = hashCode() set(value) { @@ -141,145 +128,99 @@ class Invocation : Node3D() { } @Export - @RegisterProperty var testArrayAny = VariantArray() @Export - @RegisterProperty var navMeshes = variantArrayOf(NavigationMesh()) @Export - @RegisterProperty var nullableArray = variantArrayOf(NavigationMesh(), null) @Export - @RegisterProperty var anyToAnyDictionary = Dictionary() @Export - @RegisterProperty var navMeshesDictionary = dictionaryOf("AwesomeNavmesh" to NavigationMesh()) @Export - @RegisterProperty var nullableDictionary = dictionaryOf( "notnull" to NavigationMesh(), "null" to null ) @Export - @RegisterProperty var color = Color() @Export - @RegisterProperty var rid = RID() @Export - @RegisterProperty var packedByteArray = PackedByteArray() @Export - @RegisterProperty var packedInt32Array = PackedInt32Array() @Export - @RegisterProperty var packedFloat64Array = PackedFloat64Array() @Export - @RegisterProperty var packedColorArray = PackedColorArray() @Export - @RegisterProperty var packedStringArray = PackedStringArray() @Export - @RegisterProperty var packedVector2Array = PackedVector2Array() @Export - @RegisterProperty var packedVector3Array = PackedVector3Array() - @Export - @RegisterProperty @IntRange(1, 2) var p1 = 1 - @Export - @RegisterProperty @LongRange(1L, 2L) var p1_1 = 1L - @Export - @RegisterProperty @FloatRange(1f, 2f) var p2 = 1f - @Export - @RegisterProperty @DoubleRange(1.0, 2.0) var p3 = 1.0 - @Export - @RegisterProperty @DoubleRange(min = 1.0, max = 2.0, step = 0.1, or = Range.OR_GREATER, hideSlider = true, isDegrees = true, suffix = "MyCoolSuffix") var p4 = 1.0 - @Export - @RegisterProperty @FloatRange(1f, 2f) var p5 = 1f - @Export - @RegisterProperty @EnumTypeHint var p6 = TestEnum.ENUM_1 - @Export - @RegisterProperty @ExpEasing var p7 = 1f - @Export - @RegisterProperty @ExpEasing var p8 = 1.0 @Export - @RegisterProperty @EnumFlag var p9 = setOf(TestEnum.ENUM_1) - @Export - @RegisterProperty @EnumFlag var p10 = mutableSetOf(TestEnum.ENUM_1) - @Export - @RegisterProperty @EnumFlag var p11 = mutableSetOf() - @Export - @RegisterProperty @IntFlag var p12 = 1 or 2 and 3 - @Export - @RegisterProperty @File var p13 = "someFile" - @Export - @RegisterProperty @Dir var p14 = "someDir" - @Export - @RegisterProperty @MultilineText var p15 = """ some @@ -287,61 +228,52 @@ class Invocation : Node3D() { text """.trimIndent() - @Export - @RegisterProperty @PlaceHolderText var p16 = "some placeholderText" - @Export - @RegisterProperty @ColorNoAlpha var p17 = Color() @Export - @RegisterProperty var stringtemplation = "blubb ${17 + 25}" @Export - @RegisterProperty var testString = "Two eggs in a boiler. One says: it's hot here, isn't ? The other: oh my god, an egg talking!" @Export - @RegisterProperty var asciiString = "" @Export - @RegisterProperty var utf8String = "" - @RegisterFunction + @Member fun intValue(value: Int) = value - @RegisterFunction + @Member fun longValue(value: Long) = value - @RegisterFunction + @Member fun floatValue(value: Float) = value - @RegisterFunction + @Member fun doubleValue(value: Double) = value - @RegisterFunction + @Member fun booleanValue(value: Boolean) = value - @RegisterFunction + @Member fun stringValue(value: String) = value - @RegisterFunction + @Member fun intAddition(a: Int, b: Int) = a + b - @RegisterFunction + @Member fun initNullables() { registerObject = OtherScript() registerObjectNullable = OtherScript() hasInitializedLateInits = true } - @RegisterFunction override fun _enterTree() { //TODO: uncomment once https://github.com/utopia-rise/godot-kotlin-jvm/issues/86 is fixed // GD.print("Hello", "Hello") @@ -355,7 +287,7 @@ class Invocation : Node3D() { println("CustomName is $customName") } - @RegisterFunction + override fun _ready() { val formerName = name println("Name is: $name") @@ -400,202 +332,202 @@ class Invocation : Node3D() { registerObjectNonNullablePreInit.free() } - @RegisterFunction + @Member fun getRidId() = rid.id - @RegisterFunction + @Member fun getNavMeshRid() = resourceTest.getRid() - @RegisterFunction + @Member fun appendToAnyDict(key: Any, value: Any) { anyToAnyDictionary[key] = value } - @RegisterFunction + @Member fun removeFromAnyDict(key: Any) { anyToAnyDictionary.remove(key) } - @RegisterFunction + @Member fun getFromAnyDict(key: Any) = anyToAnyDictionary[key] - @RegisterFunction + @Member fun anyDictSize() = anyToAnyDictionary.size - @RegisterFunction + @Member fun appendToStringNavMeshDict(key: String, value: NavigationMesh) { navMeshesDictionary[key] = value } - @RegisterFunction + @Member fun removeFromStringNavMeshDict(key: String) { navMeshesDictionary.remove(key) } - @RegisterFunction + @Member fun getFromStringNavMeshDict(key: String) = navMeshesDictionary[key] - @RegisterFunction + @Member fun stringNavMeshDictSize() = navMeshesDictionary.size - @RegisterFunction + @Member fun appendToStringNavMeshNullableDict(key: String, value: NavigationMesh) { nullableDictionary[key] = value } - @RegisterFunction + @Member fun removeFromStringNavMeshNullableDict(key: String) { nullableDictionary.remove(key) } // TODO: This will fail to register as we cannot register nullable return type -// @RegisterFunction +// @Member // fun getFromStringNavMeshNullableDict(key: String) = nullableDictionary[key] - @RegisterFunction + @Member fun stringNavMeshNullableDictSize() = nullableDictionary.size - @RegisterFunction + @Member fun appendNullableStandardNavMesh() = nullableArray.append(NavigationMesh()) - @RegisterFunction + @Member fun appendNullableNavMesh(navigationMesh: NavigationMesh?) = nullableArray.append(navigationMesh) - @RegisterFunction + @Member fun removeNullableNavMesh(navigationMesh: NavigationMesh?) = nullableArray.remove(navigationMesh) - @RegisterFunction + @Member fun removeNullableNavMeshWithIndex(index: Int) = nullableArray.removeAt(index) // TODO: This will fail to register as we cannot register nullable return type -// @RegisterFunction +// @Member // fun getNullableNavMeshFromArray(index: Int) = nullableArray[index] - @RegisterFunction + @Member fun nullableNavMeshesSize() = nullableArray.size - @RegisterFunction + @Member fun appendStandardNavMesh() = navMeshes.append(NavigationMesh()) - @RegisterFunction + @Member fun appendNavMesh(navigationMesh: NavigationMesh) = navMeshes.append(navigationMesh) - @RegisterFunction + @Member fun removeNavMesh(navigationMesh: NavigationMesh) = navMeshes.remove(navigationMesh) - @RegisterFunction + @Member fun removeNavMeshWithIndex(index: Int) = navMeshes.removeAt(index) - @RegisterFunction + @Member fun getNavMeshFromArray(index: Int) = navMeshes[index] - @RegisterFunction + @Member fun navMeshesSize() = navMeshes.size - @RegisterFunction + @Member fun appendAnyToArray(any: Any) = testArrayAny.append(any) - @RegisterFunction + @Member fun removeAnyFromArray(any: Any) = testArrayAny.remove(any) - @RegisterFunction + @Member fun getAnyFromArray(index: Int) = testArrayAny[index] - @RegisterFunction + @Member fun arrayAnySize() = testArrayAny.size - @RegisterFunction + @Member fun countNameshInstance(navigationMesh: NavigationMesh) = navMeshes.count(navigationMesh) - @RegisterFunction + @Member fun getNavMeshCount() = navMeshes.count() //Type cast checks - @RegisterFunction + @Member fun parentIsNode3D() = getParent() is Node3D - @RegisterFunction + @Member fun isObjectNode3D(obj: Object) = obj is Node3D - @RegisterFunction + @Member fun otherJvmId(invocation: Invocation) = invocation.jvmId - @RegisterFunction + @Member fun hasCameraNode() = getNodeOrNull(NodePath("Camera")) != null - @RegisterFunction + @Member fun addByteToPackedArray(byte: Byte) = packedByteArray.append(byte) - @RegisterFunction + @Member fun addByteArrayToPackedArray(array: PackedByteArray) = packedByteArray.appendArray(array) - @RegisterFunction + @Member fun deleteByteFromPackedArray(index: Int) = packedByteArray.removeAt(index) - @RegisterFunction + @Member fun getByteFromPackedArray(index: Int) = packedByteArray[index] - @RegisterFunction + @Member fun setByteInPackedArray(index: Int, value: Byte) { packedByteArray[index] = value } - @RegisterFunction + @Member fun resizeBytePackedArray(newSize: Int) { packedByteArray.resize(newSize) } - @RegisterFunction + @Member fun addColorToPackedArray(color: Color) = packedColorArray.append(color) - @RegisterFunction + @Member fun addColorArrayToPackedArray(colorArray: PackedColorArray) = packedColorArray.appendArray(colorArray) - @RegisterFunction + @Member fun deleteColorFromPackedArray(index: Int) = packedColorArray.removeAt(index) - @RegisterFunction + @Member fun getColorFromPackedArray(index: Int) = packedColorArray[index] - @RegisterFunction + @Member fun setColorInPackedArray(index: Int, color: Color) { packedColorArray[index] = color } - @RegisterFunction + @Member fun resizeColorPackedArray(newSize: Int) { packedColorArray.resize(newSize) } - @RegisterFunction + @Member fun addIntToPackedArray(int: Int) = packedInt32Array.append(int) - @RegisterFunction + @Member fun addIntArrayToPackedArray(intArray: PackedInt32Array) = this.packedInt32Array.appendArray(intArray) - @RegisterFunction + @Member fun deleteIntFromPackedArray(index: Int) = packedInt32Array.removeAt(index) - @RegisterFunction + @Member fun getIntFromPackedArray(index: Int) = packedInt32Array[index] - @RegisterFunction + @Member fun setIntInPackedArray(index: Int, value: Int) { packedInt32Array[index] = value } - @RegisterFunction + @Member fun resizeIntPackedArray(newSize: Int) { packedInt32Array.resize(newSize) } - @RegisterFunction + @Member fun addRealToPackedArray(realT: RealT) = packedFloat64Array.append(realT) - @RegisterFunction + @Member fun addRealArrayToPackedArray(realArray: PackedFloat64Array) = packedFloat64Array.appendArray(realArray) - @RegisterFunction + @Member fun readStringFromByteArray() { val asciiArray = testString.toByteArray(Charsets.US_ASCII) @@ -613,94 +545,94 @@ class Invocation : Node3D() { utf8String = packed2.getStringFromUtf8() } - @RegisterFunction + @Member fun deleteRealFromPackedArray(index: Int) = packedFloat64Array.removeAt(index) - @RegisterFunction + @Member fun getRealFromPackedArray(index: Int) = packedFloat64Array[index] - @RegisterFunction + @Member fun setRealInPackedArray(index: Int, value: Double) { packedFloat64Array[index] = value } - @RegisterFunction + @Member fun resizeRealPackedArray(newSize: Int) { packedFloat64Array.resize(newSize) } - @RegisterFunction + @Member fun addStringToPackedArray(string: String) = packedStringArray.append(string) - @RegisterFunction + @Member fun addStringArrayToPackedArray(stringArray: PackedStringArray) = packedStringArray.appendArray(stringArray) - @RegisterFunction + @Member fun deleteStringFromPackedArray(index: Int) = packedStringArray.removeAt(index) - @RegisterFunction + @Member fun getStringFromPackedArray(index: Int) = packedStringArray[index] - @RegisterFunction + @Member fun setStringInPackedArray(index: Int, value: String) { packedStringArray[index] = value } - @RegisterFunction + @Member fun resizeStringPackedArray(newSize: Int) { packedStringArray.resize(newSize) } - @RegisterFunction + @Member fun addVector2ToPackedArray(vector2: Vector2) = packedVector2Array.append(vector2) - @RegisterFunction + @Member fun addVector2ArrayToPackedArray(vector2Array: PackedVector2Array) = packedVector2Array.appendArray(vector2Array) - @RegisterFunction + @Member fun deleteVector2FromPackedArray(index: Int) = packedVector2Array.removeAt(index) - @RegisterFunction + @Member fun getVector2FromPackedArray(index: Int) = packedVector2Array[index] - @RegisterFunction + @Member fun setVector2InPackedArray(index: Int, vector2: Vector2) { packedVector2Array[index] = vector2 } - @RegisterFunction + @Member fun resizeVector2PackedArray(newSize: Int) { packedVector2Array.resize(newSize) } - @RegisterFunction + @Member fun addVector3ToPackedArray(vector3: Vector3) = packedVector3Array.append(vector3) - @RegisterFunction + @Member fun addVector3ArrayToPackedArray(vector3Array: PackedVector3Array) = packedVector3Array.appendArray(vector3Array) - @RegisterFunction + @Member fun deleteVector3FromPackedArray(index: Int) = packedVector3Array.removeAt(index) - @RegisterFunction + @Member fun getVector3FromPackedArray(index: Int) = packedVector3Array[index] - @RegisterFunction + @Member fun setVector3InPackedArray(index: Int, vector3: Vector3) { packedVector3Array[index] = vector3 } - @RegisterFunction + @Member fun resizeVector3PackedArray(newSize: Int) { packedVector3Array.resize(newSize) } // Singleton tests - @RegisterFunction + @Member fun isSentXrSameInstanceAsJvmSingleton(arvrServer: XRServer) = XRServer.getInstanceId() == arvrServer.getInstanceId() - @RegisterFunction + @Member fun createVariantArrayOfUserType() = variantArrayOf() } diff --git a/harness/tests/src/main/kotlin/godot/tests/LambdaCallableTest.kt b/harness/tests/src/main/kotlin/godot/tests/LambdaCallableTest.kt index b84f50b000..86cbde8571 100644 --- a/harness/tests/src/main/kotlin/godot/tests/LambdaCallableTest.kt +++ b/harness/tests/src/main/kotlin/godot/tests/LambdaCallableTest.kt @@ -1,44 +1,40 @@ package godot.tests import godot.Node -import godot.annotation.RegisterClass -import godot.annotation.RegisterFunction -import godot.annotation.RegisterProperty -import godot.annotation.RegisterSignal +import godot.annotation.Member +import godot.annotation.GodotScript import godot.core.Signal3 import godot.core.asCallable import godot.core.connect import godot.core.signal0 import godot.core.signal3 -@RegisterClass +@GodotScript class LambdaCallableTest : Node() { - @RegisterSignal val signalNoParam by signal0() - @RegisterProperty + @Member var hasSignalNoParamBeenTriggered = false - @RegisterSignal val signalWithParams: Signal3 by signal3("str", "long", "node") - @RegisterProperty + @Member var signalString: String = "" - @RegisterProperty + @Member var signalLong: Long = Long.MIN_VALUE - @RegisterProperty + @Member lateinit var signalNode: Node - @RegisterProperty + @Member var ktCallable = { str: String -> ktCallableString = str }.asCallable() - @RegisterProperty + @Member var ktCallableString: String = "" - @RegisterFunction + @Member override fun _ready() { signalNoParam.connect { hasSignalNoParamBeenTriggered = true @@ -51,12 +47,12 @@ class LambdaCallableTest : Node() { } } - @RegisterFunction + @Member fun emitSignalNoParam() { signalNoParam.emit() } - @RegisterFunction + @Member fun emitSignalWithParam(str: String, long: Long, node: Node) { signalWithParams.emit(str, long, node) } diff --git a/harness/tests/src/main/kotlin/godot/tests/MultiArgsConstructorTest.kt b/harness/tests/src/main/kotlin/godot/tests/MultiArgsConstructorTest.kt index 060c5e4f6b..2a6841df93 100644 --- a/harness/tests/src/main/kotlin/godot/tests/MultiArgsConstructorTest.kt +++ b/harness/tests/src/main/kotlin/godot/tests/MultiArgsConstructorTest.kt @@ -3,45 +3,44 @@ package godot.tests import godot.NavigationMesh import godot.Node import godot.Object -import godot.annotation.RegisterClass -import godot.annotation.RegisterConstructor -import godot.annotation.RegisterProperty +import godot.annotation.Member +import godot.annotation.GodotScript import godot.core.VariantArray -@RegisterClass +@GodotScript class MultiArgsConstructorTest : Node { - @RegisterProperty + @Member var defaultConstructorHasBeenCalled = false - @RegisterProperty + @Member var oneArgConstructorHasBeenCalled = false - @RegisterProperty + @Member var threeArgsConstructorHasBeenCalled = false - @RegisterConstructor + @Member constructor() : super() { defaultConstructorHasBeenCalled = true } - @RegisterConstructor + @Member constructor(i: Int) : this() { oneArgConstructorHasBeenCalled = true } - @RegisterConstructor + @Member constructor(i: Int, s: String) : this() { threeArgsConstructorHasBeenCalled = true } - @RegisterConstructor + @Member constructor(i: Int, s: String, obj: Object?) : this() - @RegisterConstructor + @Member constructor(i: Int, s: String, obj: Object?, variantArray: VariantArray) : this() - @RegisterConstructor + @Member constructor(i: Int, s: String, obj: Object?, variantArray: VariantArray?, navMesh: NavigationMesh) : this() constructor( @@ -62,8 +61,8 @@ class MultiArgsConstructorTest : Node { ) : this() // constructors which should fail: -// @RegisterConstructor +// @Member // constructor(iShouldFailAsOverloadingIsNotSupported: String, s: String, obj: Object?, variantArray: VariantArray?, navMesh: NavigationMesh) : this() -// @RegisterConstructor +// @Member // constructor(i: Int, s: Int, obj: Object?, variantArray: VariantArray?, navMesh: NavigationMesh, tooManyArgs: String) : this() } diff --git a/harness/tests/src/main/kotlin/godot/tests/args/ConstructorArgSizeTest.kt b/harness/tests/src/main/kotlin/godot/tests/args/ConstructorArgSizeTest.kt index 6d3d810c4b..e932883c38 100644 --- a/harness/tests/src/main/kotlin/godot/tests/args/ConstructorArgSizeTest.kt +++ b/harness/tests/src/main/kotlin/godot/tests/args/ConstructorArgSizeTest.kt @@ -1,26 +1,23 @@ package godot.tests.args import godot.Node -import godot.Resource -import godot.annotation.RegisterClass -import godot.annotation.RegisterConstructor -import godot.annotation.RegisterFunction -import godot.core.Dictionary +import godot.annotation.Member +import godot.annotation.GodotScript import godot.core.VariantArray import godot.core.variantArrayOf -@RegisterClass +@GodotScript class ConstructorArgSizeTest(): Node() { private val receivedConstructorArgs: VariantArray = variantArrayOf() - @RegisterConstructor + @Member constructor( p1: String, ): this() { receivedConstructorArgs.add(p1) } - @RegisterConstructor + @Member constructor( p1: String, p2: String, @@ -31,7 +28,7 @@ class ConstructorArgSizeTest(): Node() { } } - @RegisterConstructor + @Member constructor( p1: String, p2: String, @@ -44,7 +41,7 @@ class ConstructorArgSizeTest(): Node() { } } - @RegisterConstructor + @Member constructor( p1: String, p2: String, @@ -59,7 +56,7 @@ class ConstructorArgSizeTest(): Node() { } } - @RegisterConstructor + @Member constructor( p1: String, p2: String, @@ -76,7 +73,7 @@ class ConstructorArgSizeTest(): Node() { } } - @RegisterConstructor + @Member constructor( p1: String, p2: String, @@ -95,7 +92,7 @@ class ConstructorArgSizeTest(): Node() { } } - @RegisterConstructor + @Member constructor( p1: String, p2: String, @@ -116,7 +113,7 @@ class ConstructorArgSizeTest(): Node() { } } - @RegisterConstructor + @Member constructor( p1: String, p2: String, @@ -139,7 +136,7 @@ class ConstructorArgSizeTest(): Node() { } } - @RegisterFunction + @Member fun getReceivedConstructorArgs(): VariantArray { return receivedConstructorArgs } diff --git a/harness/tests/src/main/kotlin/godot/tests/args/FunctionArgSizeTest.kt b/harness/tests/src/main/kotlin/godot/tests/args/FunctionArgSizeTest.kt index e196fd781d..38d2e070d5 100644 --- a/harness/tests/src/main/kotlin/godot/tests/args/FunctionArgSizeTest.kt +++ b/harness/tests/src/main/kotlin/godot/tests/args/FunctionArgSizeTest.kt @@ -1,22 +1,20 @@ package godot.tests.args import godot.Node -import godot.Resource -import godot.annotation.RegisterClass -import godot.annotation.RegisterFunction -import godot.core.Dictionary +import godot.annotation.Member +import godot.annotation.GodotScript import godot.core.VariantArray import godot.core.variantArrayOf -@RegisterClass +@GodotScript class FunctionArgSizeTest : Node() { - @RegisterFunction + @Member fun arg0(): VariantArray { return variantArrayOf() } - @RegisterFunction + @Member fun arg1( p1: String, ): VariantArray { @@ -25,7 +23,7 @@ class FunctionArgSizeTest : Node() { ) } - @RegisterFunction + @Member fun arg2( p1: String, p2: String, @@ -36,7 +34,7 @@ class FunctionArgSizeTest : Node() { ) } - @RegisterFunction + @Member fun arg3( p1: String, p2: String, @@ -49,7 +47,7 @@ class FunctionArgSizeTest : Node() { ) } - @RegisterFunction + @Member fun arg4( p1: String, p2: String, @@ -64,7 +62,7 @@ class FunctionArgSizeTest : Node() { ) } - @RegisterFunction + @Member fun arg5( p1: String, p2: String, @@ -81,7 +79,7 @@ class FunctionArgSizeTest : Node() { ) } - @RegisterFunction + @Member fun arg6( p1: String, p2: String, @@ -100,7 +98,7 @@ class FunctionArgSizeTest : Node() { ) } - @RegisterFunction + @Member fun arg7( p1: String, p2: String, @@ -121,7 +119,7 @@ class FunctionArgSizeTest : Node() { ) } - @RegisterFunction + @Member fun arg8( p1: String, p2: String, @@ -144,7 +142,7 @@ class FunctionArgSizeTest : Node() { ) } - @RegisterFunction + @Member fun arg9( p1: String, p2: String, @@ -169,7 +167,7 @@ class FunctionArgSizeTest : Node() { ) } - @RegisterFunction + @Member fun arg10( p1: String, p2: String, @@ -196,7 +194,7 @@ class FunctionArgSizeTest : Node() { ) } - @RegisterFunction + @Member fun arg11( p1: String, p2: String, @@ -225,7 +223,7 @@ class FunctionArgSizeTest : Node() { ) } - @RegisterFunction + @Member fun arg12( p1: String, p2: String, @@ -256,7 +254,7 @@ class FunctionArgSizeTest : Node() { ) } - @RegisterFunction + @Member fun arg13( p1: String, p2: String, @@ -289,7 +287,7 @@ class FunctionArgSizeTest : Node() { ) } - @RegisterFunction + @Member fun arg14( p1: String, p2: String, @@ -324,7 +322,7 @@ class FunctionArgSizeTest : Node() { ) } - @RegisterFunction + @Member fun arg15( p1: String, p2: String, @@ -361,7 +359,7 @@ class FunctionArgSizeTest : Node() { ) } - @RegisterFunction + @Member fun arg16( p1: String, p2: String, diff --git a/harness/tests/src/main/kotlin/godot/tests/binding/BindingA.kt b/harness/tests/src/main/kotlin/godot/tests/binding/BindingA.kt index 68312354cb..b4fedeb422 100644 --- a/harness/tests/src/main/kotlin/godot/tests/binding/BindingA.kt +++ b/harness/tests/src/main/kotlin/godot/tests/binding/BindingA.kt @@ -2,8 +2,8 @@ package godot.tests.binding import godot.Node -import godot.annotation.RegisterClass +import godot.annotation.GodotScript -@RegisterClass +@GodotScript class BindingA : Node() { } diff --git a/harness/tests/src/main/kotlin/godot/tests/binding/BindingB.kt b/harness/tests/src/main/kotlin/godot/tests/binding/BindingB.kt index 31a6ad5717..fdd842890e 100644 --- a/harness/tests/src/main/kotlin/godot/tests/binding/BindingB.kt +++ b/harness/tests/src/main/kotlin/godot/tests/binding/BindingB.kt @@ -1,8 +1,8 @@ package godot.tests.binding import godot.Node -import godot.annotation.RegisterClass +import godot.annotation.GodotScript -@RegisterClass +@GodotScript class BindingB : Node() { } diff --git a/harness/tests/src/main/kotlin/godot/tests/binding/BindingTest.kt b/harness/tests/src/main/kotlin/godot/tests/binding/BindingTest.kt index d01bb631db..2ca349f97f 100644 --- a/harness/tests/src/main/kotlin/godot/tests/binding/BindingTest.kt +++ b/harness/tests/src/main/kotlin/godot/tests/binding/BindingTest.kt @@ -1,12 +1,12 @@ package godot.tests.binding import godot.Object -import godot.annotation.RegisterClass -import godot.annotation.RegisterFunction +import godot.annotation.Member +import godot.annotation.GodotScript -@RegisterClass +@GodotScript class BindingTest : Object() { - @RegisterFunction + @Member fun getClassName(obj: Object) = obj::class.simpleName } diff --git a/harness/tests/src/main/kotlin/godot/tests/callable/CallableMethodBindTest.kt b/harness/tests/src/main/kotlin/godot/tests/callable/CallableMethodBindTest.kt index 3c760e7234..cf8b767f05 100644 --- a/harness/tests/src/main/kotlin/godot/tests/callable/CallableMethodBindTest.kt +++ b/harness/tests/src/main/kotlin/godot/tests/callable/CallableMethodBindTest.kt @@ -1,40 +1,39 @@ package godot.tests.callable import godot.Node -import godot.annotation.RegisterClass -import godot.annotation.RegisterFunction -import godot.annotation.RegisterProperty +import godot.annotation.Member +import godot.annotation.GodotScript import godot.core.NativeCallable import godot.core.VariantArray import godot.core.variantArrayOf import godot.global.GD -@RegisterClass +@GodotScript class CallableMethodBindTest: Node() { - @RegisterProperty + @Member var methodBinds: VariantArray = variantArrayOf(-1, -1, -1) - @RegisterFunction + @Member fun callWithMethodWithAllBinds() { NativeCallable(this, CallableMethodBindTest::readySignalMethodBindTest).bind(1, 2, 3).call() } - @RegisterFunction + @Member fun callWithMethodWithTwoBinds() { NativeCallable(this, CallableMethodBindTest::readySignalMethodBindTest).bind(2, 3).call(0) } - @RegisterFunction + @Member fun callWithMethodWithOneBind() { NativeCallable(this, CallableMethodBindTest::readySignalMethodBindTest).bind(3).call(0, 0) } - @RegisterFunction + @Member fun callWithMethodWithNoBind() { NativeCallable(this, CallableMethodBindTest::readySignalMethodBindTest).bind().call(0, 0, 0) } - @RegisterFunction + @Member fun readySignalMethodBindTest(a: Int, b: Int, c: Int) { GD.print("Called with args: $a, $b, $c") methodBinds = variantArrayOf(a, b, c) diff --git a/harness/tests/src/main/kotlin/godot/tests/constructor/ConstructorRegistrationTest.kt b/harness/tests/src/main/kotlin/godot/tests/constructor/ConstructorRegistrationTest.kt index f956afddec..e848f11dc3 100644 --- a/harness/tests/src/main/kotlin/godot/tests/constructor/ConstructorRegistrationTest.kt +++ b/harness/tests/src/main/kotlin/godot/tests/constructor/ConstructorRegistrationTest.kt @@ -1,14 +1,14 @@ package godot.tests.constructor import godot.Node -import godot.annotation.RegisterClass -import godot.annotation.RegisterConstructor +import godot.annotation.Member +import godot.annotation.GodotScript import godot.core.Dictionary import godot.core.VariantArray -@RegisterClass +@GodotScript class ConstructorRegistrationTest(): Node() { - @RegisterConstructor + @Member constructor(param1: Dictionary, param2: VariantArray): this() } diff --git a/harness/tests/src/main/kotlin/godot/tests/coretypes/BasisTest.kt b/harness/tests/src/main/kotlin/godot/tests/coretypes/BasisTest.kt index bf3395df34..3415aff11f 100644 --- a/harness/tests/src/main/kotlin/godot/tests/coretypes/BasisTest.kt +++ b/harness/tests/src/main/kotlin/godot/tests/coretypes/BasisTest.kt @@ -1,35 +1,35 @@ package godot.tests.coretypes import godot.Node -import godot.annotation.RegisterClass -import godot.annotation.RegisterFunction +import godot.annotation.Member +import godot.annotation.GodotScript import godot.core.Basis import godot.core.Quaternion import godot.core.Vector3 -@RegisterClass +@GodotScript class BasisTest : Node() { - @RegisterFunction + @Member fun getFromBasis(basis: Basis, index: Int) = basis[index] - @RegisterFunction + @Member fun setInBasis(basis: Basis, index: Int, vector3: Vector3): Basis { basis[index] = vector3 return basis } - @RegisterFunction + @Member fun getRotationQuat(basis: Basis): Quaternion { return basis.getRotationQuaternion() } - @RegisterFunction + @Member fun newJvmBasis(): Basis { return Basis() } - @RegisterFunction + @Member fun isEqualApproxJvm(a: Basis, b: Basis): Boolean { return a.isEqualApprox(b) } diff --git a/harness/tests/src/main/kotlin/godot/tests/coretypes/StringTest.kt b/harness/tests/src/main/kotlin/godot/tests/coretypes/StringTest.kt index 51543b3925..8e097f81f1 100644 --- a/harness/tests/src/main/kotlin/godot/tests/coretypes/StringTest.kt +++ b/harness/tests/src/main/kotlin/godot/tests/coretypes/StringTest.kt @@ -1,13 +1,12 @@ package godot.tests.coretypes import godot.Node -import godot.annotation.RegisterClass -import godot.annotation.RegisterFunction -import godot.core.StringName -import godot.core.asStringName +import godot.annotation.Member +import godot.annotation.GodotScript import godot.core.Vector2 +import godot.core.asStringName -@RegisterClass +@GodotScript class StringTest : Node() { private val _shortString = "Short String" @@ -46,35 +45,35 @@ class StringTest : Node() { """.trimIndent() - @RegisterFunction + @Member fun identity(str: String) = str - @RegisterFunction + @Member fun fillTheBuffer(str1: String, str2: String, str3: String, str4: String, str5: String): Boolean { return true } - @RegisterFunction + @Member fun mixStringAndVariant(i1: Int, str1: String, vec: Vector2, str2: String, f1: Float): Boolean { return true } - @RegisterFunction + @Member fun getShortString() = _shortString - @RegisterFunction + @Member fun getLongestShortString() = _longestShortString - @RegisterFunction + @Member fun getShortestLongString() = _shortestLongString - @RegisterFunction + @Member fun getLongString() = _longString - @RegisterFunction + @Member fun getLength(str: String) = str.length - @RegisterFunction + @Member fun getAsStringName(str: String) = str.asStringName() } diff --git a/harness/tests/src/main/kotlin/godot/tests/coretypes/Vector3Test.kt b/harness/tests/src/main/kotlin/godot/tests/coretypes/Vector3Test.kt index 6b13eac73b..d2a3f61f6e 100644 --- a/harness/tests/src/main/kotlin/godot/tests/coretypes/Vector3Test.kt +++ b/harness/tests/src/main/kotlin/godot/tests/coretypes/Vector3Test.kt @@ -1,18 +1,18 @@ package godot.tests.coretypes import godot.Node -import godot.annotation.RegisterClass -import godot.annotation.RegisterFunction +import godot.annotation.Member +import godot.annotation.GodotScript import godot.core.Vector3 import godot.common.util.RealT -@RegisterClass +@GodotScript class Vector3Test : Node() { - @RegisterFunction + @Member fun getFromVector3(vector3: Vector3, index: Int) = vector3[index] - @RegisterFunction + @Member fun setInVector3(vector3: Vector3, index: Int, realT: RealT): Vector3 { vector3[index] = realT return vector3 diff --git a/harness/tests/src/main/kotlin/godot/tests/coroutine/CoroutineTest.kt b/harness/tests/src/main/kotlin/godot/tests/coroutine/CoroutineTest.kt index e279554dbc..cd0aa008fc 100644 --- a/harness/tests/src/main/kotlin/godot/tests/coroutine/CoroutineTest.kt +++ b/harness/tests/src/main/kotlin/godot/tests/coroutine/CoroutineTest.kt @@ -4,10 +4,8 @@ package godot.tests.coroutine import godot.Object import godot.PackedScene import godot.ResourceLoader -import godot.annotation.RegisterClass -import godot.annotation.RegisterFunction -import godot.annotation.RegisterProperty -import godot.annotation.RegisterSignal +import godot.annotation.Member +import godot.annotation.GodotScript import godot.core.Vector2 import godot.core.signal0 import godot.core.signal1 @@ -15,55 +13,53 @@ import godot.core.signal4 import godot.coroutines.await import godot.coroutines.awaitLoadAs import godot.coroutines.awaitMainThread +import godot.coroutines.godotCoroutine import godot.coroutines.awaitPhysicsFrame import godot.coroutines.awaitProcessFrame import godot.coroutines.godotCoroutine import godot.global.GD import kotlinx.coroutines.CoroutineStart -@RegisterClass +@GodotScript class CoroutineTest : Object() { - @RegisterSignal val signalWithoutParameter by signal0() - @RegisterSignal val signalWithOneParameter by signal1("int") - @RegisterSignal val signalWithManyParameters by signal4("int", "float", "vector2", "string") - @RegisterProperty + @Member var step: Int = 0 - @RegisterFunction + @Member fun startCoroutineWithoutParameter() = godotCoroutine { step = 1 signalWithoutParameter.await() step = 2 } - @RegisterFunction + @Member fun startCoroutineWithOneParameter() = godotCoroutine { step = 3 step = signalWithOneParameter.await() } - @RegisterFunction + @Member fun startCoroutineWithManyParameters() = godotCoroutine { step = 5 val (int, _, _, _) = signalWithManyParameters.await() step = int } - @RegisterFunction + @Member fun startCoroutineUndispatched() = godotCoroutine(start = CoroutineStart.UNDISPATCHED) { step = 7 signalWithoutParameter.await() step = 8 } - @RegisterFunction + @Member fun startCoroutineWithPhysicsFrame() = godotCoroutine(start = CoroutineStart.UNDISPATCHED) { step = 9 awaitPhysicsFrame { @@ -71,7 +67,7 @@ class CoroutineTest : Object() { } } - @RegisterFunction + @Member fun startCoroutineWithProcessFrame() = godotCoroutine(start = CoroutineStart.UNDISPATCHED) { step = 11 awaitProcessFrame { @@ -79,10 +75,10 @@ class CoroutineTest : Object() { } } - @RegisterSignal + @Member val runOnMainThreadFromBackgroundThreadFinished by signal1("is_test_successful") - @RegisterFunction + @Member fun runOnMainThreadFromBackgroundThread() { val thread = Thread.currentThread().name @@ -109,10 +105,9 @@ class CoroutineTest : Object() { } } - @RegisterSignal val asyncLoadResourceFinished by signal1("is_test_successful") - @RegisterFunction + @Member fun asyncLoadResource() { godotCoroutine { val resource = ResourceLoader.awaitLoadAs("res://Spatial.tscn") { progress -> diff --git a/harness/tests/src/main/kotlin/godot/tests/exception/ExceptionTest.kt b/harness/tests/src/main/kotlin/godot/tests/exception/ExceptionTest.kt index b79bad523c..d3c401f4ee 100644 --- a/harness/tests/src/main/kotlin/godot/tests/exception/ExceptionTest.kt +++ b/harness/tests/src/main/kotlin/godot/tests/exception/ExceptionTest.kt @@ -1,13 +1,13 @@ package godot.tests.exception import godot.Node -import godot.annotation.RegisterClass -import godot.annotation.RegisterFunction +import godot.annotation.Member +import godot.annotation.GodotScript -@RegisterClass +@GodotScript class ExceptionTest: Node() { - @RegisterFunction + @Member fun throwException() { throw RuntimeException("Test exception") } diff --git a/harness/tests/src/main/kotlin/godot/tests/freeform/FreeformRegistrationFileTestClass.kt b/harness/tests/src/main/kotlin/godot/tests/freeform/FreeformRegistrationFileTestClass.kt index a808079ce8..74247c9117 100644 --- a/harness/tests/src/main/kotlin/godot/tests/freeform/FreeformRegistrationFileTestClass.kt +++ b/harness/tests/src/main/kotlin/godot/tests/freeform/FreeformRegistrationFileTestClass.kt @@ -1,11 +1,11 @@ package godot.tests.freeform import godot.Node -import godot.annotation.RegisterClass -import godot.annotation.RegisterFunction +import godot.annotation.Member +import godot.annotation.GodotScript -@RegisterClass +@GodotScript class FreeformRegistrationFileTestClass: Node() { - @RegisterFunction + @Member fun greeting(): String = "Hello from class with freely moved registration file" } diff --git a/harness/tests/src/main/kotlin/godot/tests/inheritance/AbstractClassInheritanceChild.kt b/harness/tests/src/main/kotlin/godot/tests/inheritance/AbstractClassInheritanceChild.kt index 480e9a89ee..8dcbe63d1d 100644 --- a/harness/tests/src/main/kotlin/godot/tests/inheritance/AbstractClassInheritanceChild.kt +++ b/harness/tests/src/main/kotlin/godot/tests/inheritance/AbstractClassInheritanceChild.kt @@ -1,27 +1,24 @@ package godot.tests.inheritance -import godot.annotation.RegisterClass -import godot.annotation.RegisterFunction -import godot.annotation.RegisterProperty -import godot.annotation.RegisterSignal +import godot.annotation.Member +import godot.annotation.GodotScript import godot.core.signal2 -@RegisterClass +@GodotScript class AbstractClassInheritanceChild : AbstractClassInheritanceParent() { - @RegisterSignal override val testOverridden by signal2("blubb", "habbalubbb") //---------------- Here to check ------------------ - @RegisterProperty + @Member var childOpenFunctionHasBeenCalled = false //------------------------------------------------- override var openVar: Int = 100 - @RegisterFunction + @Member override fun openFunction() { childOpenFunctionHasBeenCalled = true } diff --git a/harness/tests/src/main/kotlin/godot/tests/inheritance/AbstractClassInheritanceEmptyChild.kt b/harness/tests/src/main/kotlin/godot/tests/inheritance/AbstractClassInheritanceEmptyChild.kt index dc1c6c2313..05f0a808de 100644 --- a/harness/tests/src/main/kotlin/godot/tests/inheritance/AbstractClassInheritanceEmptyChild.kt +++ b/harness/tests/src/main/kotlin/godot/tests/inheritance/AbstractClassInheritanceEmptyChild.kt @@ -1,7 +1,7 @@ package godot.tests.inheritance -import godot.annotation.RegisterClass +import godot.annotation.GodotScript // issue: https://github.com/utopia-rise/godot-kotlin-jvm/issues/365 -@RegisterClass +@GodotScript class AbstractClassInheritanceEmptyChild: AbstractClassInheritanceEmptyParent() diff --git a/harness/tests/src/main/kotlin/godot/tests/inheritance/AbstractClassInheritanceParent.kt b/harness/tests/src/main/kotlin/godot/tests/inheritance/AbstractClassInheritanceParent.kt index 114310e7ce..782e8edaf7 100644 --- a/harness/tests/src/main/kotlin/godot/tests/inheritance/AbstractClassInheritanceParent.kt +++ b/harness/tests/src/main/kotlin/godot/tests/inheritance/AbstractClassInheritanceParent.kt @@ -2,9 +2,7 @@ package godot.tests.inheritance import godot.Node import godot.annotation.Export -import godot.annotation.RegisterFunction -import godot.annotation.RegisterProperty -import godot.annotation.RegisterSignal +import godot.annotation.Member import godot.core.signal1 import godot.core.signal2 @@ -12,33 +10,30 @@ import godot.core.signal2 abstract class AbstractClassInheritanceParent : Node() { @Export - @RegisterProperty var registeredExportedPropertyInParent = false - @RegisterSignal val testNotOverridden by signal1("blubb") - @RegisterSignal open val testOverridden by signal2("blubb", "habbalubb") //---------------- Here to check ------------------ - @RegisterProperty + @Member var closedFunctionHasBeenCalled = false //------------------------------------------------- - @RegisterProperty + @Member var closedVar = 0 - @RegisterProperty + @Member open var openVar = 0 - @RegisterFunction + @Member fun closedFunction() { closedFunctionHasBeenCalled = true } - @RegisterFunction + @Member abstract fun openFunction() } diff --git a/harness/tests/src/main/kotlin/godot/tests/inheritance/ClassInheritanceChild.kt b/harness/tests/src/main/kotlin/godot/tests/inheritance/ClassInheritanceChild.kt index c7822adfcc..cdb9aaa347 100644 --- a/harness/tests/src/main/kotlin/godot/tests/inheritance/ClassInheritanceChild.kt +++ b/harness/tests/src/main/kotlin/godot/tests/inheritance/ClassInheritanceChild.kt @@ -1,33 +1,29 @@ package godot.tests.inheritance -import godot.annotation.RegisterClass -import godot.annotation.RegisterFunction -import godot.annotation.RegisterProperty -import godot.annotation.RegisterSignal +import godot.annotation.Member +import godot.annotation.GodotScript import godot.core.signal2 import godot.global.GD -@RegisterClass +@GodotScript class ClassInheritanceChild : ClassInheritanceParent() { - @RegisterSignal override val testOverridden by signal2("blubb", "habbalubbb") //---------------- Here to check ------------------ - @RegisterProperty + @Member var childOpenFunctionHasBeenCalled = false //------------------------------------------------- override var openVar: Int = 100 - @RegisterFunction + @Member override fun openFunction() { childOpenFunctionHasBeenCalled = true } - @RegisterFunction override fun _notification() = godotNotification { GD.print("Called ClassInheritanceChild::_notification on $this with $it") notificationCallBitFlag += notificationCallBitFlag or 2 diff --git a/harness/tests/src/main/kotlin/godot/tests/inheritance/ClassInheritanceParent.kt b/harness/tests/src/main/kotlin/godot/tests/inheritance/ClassInheritanceParent.kt index 0480fd4506..a8be5e2966 100644 --- a/harness/tests/src/main/kotlin/godot/tests/inheritance/ClassInheritanceParent.kt +++ b/harness/tests/src/main/kotlin/godot/tests/inheritance/ClassInheritanceParent.kt @@ -1,54 +1,49 @@ package godot.tests.inheritance import godot.Node -import godot.annotation.RegisterClass -import godot.annotation.RegisterFunction -import godot.annotation.RegisterProperty -import godot.annotation.RegisterSignal +import godot.annotation.Member +import godot.annotation.GodotScript import godot.core.GodotNotification import godot.core.signal1 import godot.core.signal2 import godot.global.GD -@RegisterClass +@GodotScript open class ClassInheritanceParent : Node() { - @RegisterSignal val testNotOverridden by signal1("blubb") - @RegisterSignal open val testOverridden by signal2("blubb", "habbalubb") //---------------- Here to check ------------------ - @RegisterProperty + @Member var closedFunctionHasBeenCalled = false - @RegisterProperty + @Member var parentOpenFunctionHasBeenCalled = false //------------------------------------------------- - @RegisterProperty + @Member var closedVar = 0 - @RegisterProperty + @Member open var openVar = 0 - @RegisterFunction + @Member fun closedFunction() { closedFunctionHasBeenCalled = true } - @RegisterFunction + @Member open fun openFunction() { parentOpenFunctionHasBeenCalled = true } - @RegisterProperty + @Member var notificationCallBitFlag = 0 - @RegisterFunction override fun _notification(): GodotNotification = godotNotification { GD.print("Called ClassInheritanceParent::_notification on $this with $it") notificationCallBitFlag = notificationCallBitFlag or 1 diff --git a/harness/tests/src/main/kotlin/godot/tests/instance/NodeInstance.kt b/harness/tests/src/main/kotlin/godot/tests/instance/NodeInstance.kt index 7e3ffc8b08..67301deff0 100644 --- a/harness/tests/src/main/kotlin/godot/tests/instance/NodeInstance.kt +++ b/harness/tests/src/main/kotlin/godot/tests/instance/NodeInstance.kt @@ -1,8 +1,8 @@ package godot.tests.instance import godot.Node -import godot.annotation.RegisterClass +import godot.annotation.GodotScript -@RegisterClass +@GodotScript class NodeInstance : Node() { } diff --git a/harness/tests/src/main/kotlin/godot/tests/instance/ObjectInstance.kt b/harness/tests/src/main/kotlin/godot/tests/instance/ObjectInstance.kt index 7763a1e3d1..b4cfdf9626 100644 --- a/harness/tests/src/main/kotlin/godot/tests/instance/ObjectInstance.kt +++ b/harness/tests/src/main/kotlin/godot/tests/instance/ObjectInstance.kt @@ -1,9 +1,9 @@ package godot.tests.instance import godot.Object -import godot.annotation.RegisterClass +import godot.annotation.GodotScript -@RegisterClass +@GodotScript class ObjectInstance : Object() { } diff --git a/harness/tests/src/main/kotlin/godot/tests/instance/RefCountedInstance.kt b/harness/tests/src/main/kotlin/godot/tests/instance/RefCountedInstance.kt index cf7c480ed9..bb054328a7 100644 --- a/harness/tests/src/main/kotlin/godot/tests/instance/RefCountedInstance.kt +++ b/harness/tests/src/main/kotlin/godot/tests/instance/RefCountedInstance.kt @@ -1,8 +1,8 @@ package godot.tests.instance import godot.RefCounted -import godot.annotation.RegisterClass +import godot.annotation.GodotScript -@RegisterClass +@GodotScript class RefCountedInstance : RefCounted() { } diff --git a/harness/tests/src/main/kotlin/godot/tests/packedarray/PackedArrayTest.kt b/harness/tests/src/main/kotlin/godot/tests/packedarray/PackedArrayTest.kt index 2989c29763..4249ae3b42 100644 --- a/harness/tests/src/main/kotlin/godot/tests/packedarray/PackedArrayTest.kt +++ b/harness/tests/src/main/kotlin/godot/tests/packedarray/PackedArrayTest.kt @@ -1,72 +1,72 @@ package godot.tests.packedarray import godot.Node -import godot.annotation.RegisterClass -import godot.annotation.RegisterFunction +import godot.annotation.Member +import godot.annotation.GodotScript import godot.core.PackedByteArray import godot.core.PackedFloat32Array import godot.core.PackedFloat64Array import godot.core.PackedInt32Array import godot.core.PackedInt64Array -@RegisterClass +@GodotScript class PackedArrayTest : Node() { - @RegisterFunction + @Member fun convertByteArray() : PackedByteArray { val arr = byteArrayOf(0, 1, 2, 4, 8, 16, 32, 64, 127) return PackedByteArray(arr); } - @RegisterFunction + @Member fun convertIntArray() : PackedInt32Array { val arr = intArrayOf(0, 1, 2, 4, 8, 16, 32, 64, 127) return PackedInt32Array(arr); } - @RegisterFunction + @Member fun convertLongArray() : PackedInt64Array { val arr = longArrayOf(0L, 1L, 2L, 4L, 8L, 16L, 32L, 64L, 127L) return PackedInt64Array(arr); } - @RegisterFunction + @Member fun convertFloatArray() : PackedFloat32Array { val arr = floatArrayOf(0f, 1f, 2f, 4f, 8f, 16f, 32f, 64f, 127f) return PackedFloat32Array(arr); } - @RegisterFunction + @Member fun convertDoubleArray() : PackedFloat64Array { val arr = doubleArrayOf(0.0, 1.0, 2.0, 4.0, 8.0, 16.0, 32.0, 64.0, 127.0) return PackedFloat64Array(arr); } - @RegisterFunction + @Member fun getByteArrayValue(arr: PackedByteArray, index: Int) : Byte { val kotlinArr = arr.toByteArray() return kotlinArr[index]; } - @RegisterFunction + @Member fun getIntArrayValue(arr: PackedInt32Array, index: Int) : Int { val kotlinArr = arr.toIntArray() return kotlinArr[index]; } - @RegisterFunction + @Member fun getLongArrayValue(arr: PackedInt64Array, index: Int) : Long { val kotlinArr = arr.toLongArray() return kotlinArr[index]; } - @RegisterFunction + @Member fun getFloatArrayValue(arr: PackedFloat32Array, index: Int) : Float { val kotlinArr = arr.toFloatArray() return kotlinArr[index]; } - @RegisterFunction + @Member fun getDoubleArrayValue(arr: PackedFloat64Array, index: Int) : Double { val kotlinArr = arr.toDoubleArray() return kotlinArr[index]; diff --git a/harness/tests/src/main/kotlin/godot/tests/reflection/BaseReflectionTest.kt b/harness/tests/src/main/kotlin/godot/tests/reflection/BaseReflectionTest.kt index df5ff0436c..b75038d46e 100644 --- a/harness/tests/src/main/kotlin/godot/tests/reflection/BaseReflectionTest.kt +++ b/harness/tests/src/main/kotlin/godot/tests/reflection/BaseReflectionTest.kt @@ -1,15 +1,15 @@ package godot.tests.reflection import godot.Node -import godot.annotation.RegisterClass -import godot.annotation.RegisterFunction +import godot.annotation.Member +import godot.annotation.GodotScript import kotlin.reflect.full.hasAnnotation -@RegisterClass +@GodotScript class BaseReflectionTest: Node() { - @RegisterFunction + @Member fun hasRegisterClassAnnotation(): Boolean { - return BaseReflectionTest::class.hasAnnotation() + return BaseReflectionTest::class.hasAnnotation() } } diff --git a/harness/tests/src/main/kotlin/godot/tests/reflection/GH571_ReflectionTest.kt b/harness/tests/src/main/kotlin/godot/tests/reflection/GH571_ReflectionTest.kt index dd090823b1..f93fc2a14f 100644 --- a/harness/tests/src/main/kotlin/godot/tests/reflection/GH571_ReflectionTest.kt +++ b/harness/tests/src/main/kotlin/godot/tests/reflection/GH571_ReflectionTest.kt @@ -3,12 +3,12 @@ package godot.tests.reflection import com.fasterxml.jackson.core.type.TypeReference import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import godot.Node -import godot.annotation.RegisterClass -import godot.annotation.RegisterFunction +import godot.annotation.Member +import godot.annotation.GodotScript @Suppress("ClassName") -@RegisterClass +@GodotScript class GH571_ReflectionTest: Node() { private val testJsonString = """ @@ -23,7 +23,7 @@ class GH571_ReflectionTest: Node() { val data: String, ) - @RegisterFunction + @Member fun deserializeJson(): String { val mapper = jacksonObjectMapper() val testClass = mapper.readValue(testJsonString, object : TypeReference() {}) diff --git a/harness/tests/src/main/kotlin/godot/tests/registration/TypedVariantArrayRegistration.kt b/harness/tests/src/main/kotlin/godot/tests/registration/TypedVariantArrayRegistration.kt index 9451fcceb7..467ea15d59 100644 --- a/harness/tests/src/main/kotlin/godot/tests/registration/TypedVariantArrayRegistration.kt +++ b/harness/tests/src/main/kotlin/godot/tests/registration/TypedVariantArrayRegistration.kt @@ -4,23 +4,19 @@ import godot.Button import godot.Node import godot.Texture import godot.annotation.Export -import godot.annotation.RegisterClass -import godot.annotation.RegisterProperty +import godot.annotation.GodotScript import godot.core.VariantArray import godot.core.variantArrayOf -@RegisterClass +@GodotScript class TypedVariantArrayRegistration: Node() { @Export - @RegisterProperty var intVariantArray: VariantArray = variantArrayOf() @Export - @RegisterProperty var buttonVariantArray: VariantArray