Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement new rpc related functionality #341

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 4 additions & 4 deletions .github/workflows/check-pr-engine-editor-debug-and-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on: [pull_request]

env:
SCONS_CACHE_MSVC_CONFIG: true
GODOT_BASE_VERSION: 3.4.4
GODOT_BASE_VERSION: 4.0.0

jobs:
build-godot-bootstrap:
Expand All @@ -19,7 +19,7 @@ jobs:
uses: actions/checkout@v2
with:
repository: godotengine/godot
ref: 3.4.4-stable
ref: master
- name: Clone Godot JVM module.
uses: actions/checkout@v2
with:
Expand Down Expand Up @@ -72,7 +72,7 @@ jobs:
uses: actions/checkout@v2
with:
repository: godotengine/godot
ref: 3.4.4-stable
ref: master
- name: Clone Godot JVM module.
uses: actions/checkout@v2
with:
Expand Down Expand Up @@ -152,7 +152,7 @@ jobs:
uses: actions/checkout@v2
with:
repository: godotengine/godot
ref: 3.4.4-stable
ref: master
- name: Clone Godot JVM module.
uses: actions/checkout@v2
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/check-pr-engine-editor-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on: [pull_request]

env:
SCONS_CACHE_MSVC_CONFIG: true
GODOT_BASE_VERSION: 3.4.4
GODOT_BASE_VERSION: 4.0.0

jobs:
build-editor-release:
Expand Down Expand Up @@ -39,7 +39,7 @@ jobs:
uses: actions/checkout@v2
with:
repository: godotengine/godot
ref: 3.4.4-stable
ref: master
- name: Clone Godot JVM module.
uses: actions/checkout@v2
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/check-pr-engine-export-template-debug.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on: [pull_request]

env:
SCONS_CACHE_MSVC_CONFIG: true
GODOT_BASE_VERSION: 3.4.4
GODOT_BASE_VERSION: master

jobs:
build-export-debug:
Expand Down Expand Up @@ -43,7 +43,7 @@ jobs:
uses: actions/checkout@v2
with:
repository: godotengine/godot
ref: 3.4.4-stable
ref: master
- name: Clone Godot JVM module.
uses: actions/checkout@v2
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on: [pull_request]

env:
SCONS_CACHE_MSVC_CONFIG: true
GODOT_BASE_VERSION: 3.4.4
GODOT_BASE_VERSION: 4.0.0

jobs:
build-export-release:
Expand Down Expand Up @@ -43,7 +43,7 @@ jobs:
uses: actions/checkout@v2
with:
repository: godotengine/godot
ref: 3.4.4-stable
ref: master
- name: Clone Godot JVM module.
uses: actions/checkout@v2
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
uses: actions/checkout@v2
with:
repository: godotengine/godot
ref: 3.4.4-stable
ref: master
- name: Clone Godot JVM module.
uses: actions/checkout@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-export-template-debug.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
uses: actions/checkout@v2
with:
repository: godotengine/godot
ref: 3.4.4-stable
ref: master

- name: Clone Godot JVM module.
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-export-template-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
uses: actions/checkout@v2
with:
repository: godotengine/godot
ref: 3.4.4-stable
ref: master

- name: Clone Godot JVM module.
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-godot-editor-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
uses: actions/checkout@v2
with:
repository: godotengine/godot
ref: 3.4.4-stable
ref: master

- name: Clone Godot JVM module.
uses: actions/checkout@v2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
uses: actions/checkout@v2
with:
repository: godotengine/godot
ref: 3.4.4-stable
ref: master
- name: Clone Godot JVM module.
uses: actions/checkout@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-godot-library.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
uses: actions/checkout@v2
with:
repository: godotengine/godot
ref: 3.4.4-stable
ref: master
- name: Clone Godot JVM module.
uses: actions/checkout@v2
with:
Expand Down
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ set(GODOT_ROOT_DIR ../../)
# Get sources
file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS src/*.cpp)

add_library(${PROJECT_NAME} SHARED register_types.cpp ${SOURCES} src/gd_kotlin.cpp src/gd_kotlin.h src/godotkotlin_defs.h src/jni/wrapper.h src/kt_function.cpp src/kt_function.h src/kt_property.cpp src/kt_property.h src/jni/local_frame.cpp src/jni/local_frame.h src/kt_signal_info.cpp src/kt_signal_info.h src/bridges/memory_bridge.cpp src/bridges/memory_bridge.h src/jni/java_method_signature.cpp src/jni/java_method_signature.h src/java_instance_wrapper.h src/shared_buffer.h src/shared_buffer.cpp src/type_manager.cpp src/type_manager.h src/bridges_manager.cpp src/bridges_manager.h src/bridges/variant_array_bridge.cpp src/bridges/variant_array_bridge.h src/bridges/constants.h src/bridges/dictionary_bridge.cpp src/bridges/dictionary_bridge.h src/bridges/bridges_utils.h src/bridges/rid_bridge.cpp src/bridges/rid_bridge.h src/bridges/node_path_bridge.cpp src/bridges/node_path_bridge.h src/bridges/pool_byte_array_bridge.h src/bridges/pool_byte_array_bridge.cpp src/bridges/pool_color_array_bridge.h src/bridges/pool_color_array_bridge.cpp src/bridges/pool_int_array_bridge.h src/bridges/pool_int_array_bridge.cpp src/bridges/pool_real_array_bridge.h src/bridges/pool_real_array_bridge.cpp src/bridges/pool_string_array_bridge.h src/bridges/pool_string_array_bridge.cpp src/bridges/pool_vector2_array_bridge.h src/bridges/pool_vector2_array_bridge.cpp src/bridges/pool_vector3_array_bridge.h src/bridges/pool_vector3_array_bridge.cpp src/logging.h src/kt_constructor.cpp src/kt_constructor.h src/bridges/gd_print_bridge.cpp src/bridges/gd_print_bridge.h src/kotlin_editor_export_plugin.cpp src/kotlin_editor_export_plugin.h src/jni/platforms/jvm_desktop.cpp src/jni/platforms/jvm_android.cpp src/jni/platforms/init_args_desktop.cpp src/jni/platforms/init_args_android.cpp src/ref_db.h src/ref_db.cpp src/editor/godot_kotlin_jvm_editor.cpp src/editor/godot_kotlin_jvm_editor.h src/editor/menu_option.h src/editor/build/build_manager.cpp src/editor/build/build_manager.h src/editor/panel/bottom_panel.cpp src/editor/panel/bottom_panel.h src/editor/dialog/build_dialog.cpp src/editor/dialog/build_dialog.h src/editor/dialog/about_dialog.cpp src/editor/dialog/about_dialog.h src/long_string_queue.h src/long_string_queue.cpp src/jni/class_loader.h src/jni/class_loader.cpp src/java_singleton_wrapper.h src/editor/dialog/error_dialog.cpp src/editor/dialog/error_dialog.h)
add_library(${PROJECT_NAME} SHARED register_types.cpp ${SOURCES} src/gd_kotlin.cpp src/gd_kotlin.h src/godotkotlin_defs.h src/jni/wrapper.h src/kt_function.cpp src/kt_function.h src/kt_property.cpp src/kt_property.h src/jni/local_frame.cpp src/jni/local_frame.h src/kt_signal_info.cpp src/kt_signal_info.h src/bridges/memory_bridge.cpp src/bridges/memory_bridge.h src/jni/java_method_signature.cpp src/jni/java_method_signature.h src/java_instance_wrapper.h src/shared_buffer.h src/shared_buffer.cpp src/type_manager.cpp src/type_manager.h src/bridges_manager.cpp src/bridges_manager.h src/bridges/variant_array_bridge.cpp src/bridges/variant_array_bridge.h src/bridges/constants.h src/bridges/dictionary_bridge.cpp src/bridges/dictionary_bridge.h src/bridges/bridges_utils.h src/bridges/rid_bridge.cpp src/bridges/rid_bridge.h src/bridges/node_path_bridge.cpp src/bridges/node_path_bridge.h src/bridges/packed_byte_array_bridge.h src/bridges/packed_byte_array_bridge.cpp src/bridges/packed_color_array_bridge.h src/bridges/packed_color_array_bridge.cpp src/bridges/packed_int_32_array_bridge.h src/bridges/packed_int_32_array_bridge.cpp src/bridges/packed_float_32_array_bridge.h src/bridges/packed_float_32_array_bridge.cpp src/bridges/packed_string_array_bridge.h src/bridges/packed_string_array_bridge.cpp src/bridges/packed_vector2_array_bridge.h src/bridges/packed_vector2_array_bridge.cpp src/bridges/packed_vector3_array_bridge.h src/bridges/packed_vector3_array_bridge.cpp src/logging.h src/kt_constructor.cpp src/kt_constructor.h src/bridges/gd_print_bridge.cpp src/bridges/gd_print_bridge.h src/kotlin_editor_export_plugin.cpp src/kotlin_editor_export_plugin.h src/jni/platforms/jvm_desktop.cpp src/jni/platforms/jvm_android.cpp src/jni/platforms/init_args_desktop.cpp src/jni/platforms/init_args_android.cpp src/ref_db.h src/ref_db.cpp src/editor/godot_kotlin_jvm_editor.cpp src/editor/godot_kotlin_jvm_editor.h src/editor/menu_option.h src/editor/build/build_manager.cpp src/editor/build/build_manager.h src/editor/panel/bottom_panel.cpp src/editor/panel/bottom_panel.h src/editor/dialog/build_dialog.cpp src/editor/dialog/build_dialog.h src/editor/dialog/about_dialog.cpp src/editor/dialog/about_dialog.h src/long_string_queue.h src/long_string_queue.cpp src/jni/class_loader.h src/jni/class_loader.cpp src/java_singleton_wrapper.h src/editor/dialog/error_dialog.cpp src/editor/dialog/error_dialog.h src/bridges/packed_int_64_array_bridge.h src/bridges/packed_int_64_array_bridge.cpp src/bridges/packed_float_64_array_bridge.h src/bridges/packed_float_64_array_bridge.cpp src/bridges/string_name_bridge.cpp src/bridges/string_name_bridge.h src/kt_custom_callable.cpp src/kt_custom_callable.h src/bridges/callable_bridge.cpp src/bridges/callable_bridge.h src/kt_custom_callable_middleman.h)

# JNI
find_package(JNI REQUIRED)
Expand All @@ -21,6 +21,7 @@ target_include_directories(${PROJECT_NAME}
)

# Uncomment to pass auto completion in TOOLS mode
#add_compile_definitions(MONO_GLUE_ENABLED)
add_compile_definitions(TOOLS_ENABLED)
add_compile_definitions(DEBUG_ENABLED)

Expand Down
2 changes: 1 addition & 1 deletion docs/src/doc/contribution/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ To build our module, you need to same dependencies as the ones described in the

Make sure that Java is installed and its PATH set in your system as well (at least Java 9 is needed!).

1. Clone godot repo with the stable tag you want do deveop for (3.4.4-stable in this example). `git clone [email protected]:godotengine/godot.git 3.4.4-stable --recursive`
1. Clone godot repo with the stable tag you want do develop for (master in this example). `git clone [email protected]:godotengine/godot.git 3.x --recursive`

2. In the `godot-root` dir, run the following command: `git submodule add [email protected]:utopia-rise/godot-kotlin-jvm.git modules/kotlin_jvm`

Expand Down
4 changes: 2 additions & 2 deletions docs/src/doc/user-guide/versioning.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
The module uses semantic versioning for its own versions but adds a suffix for the supported godot version:

Full version: `0.4.0-3.4.4`
Full version: `0.4.0-4.0.0`

Module Version: `0.4.0`

Supported Godot Version: `3.4.4`
Supported Godot Version: `4.0.0`
52 changes: 27 additions & 25 deletions harness/tests/scripts/CopyModificationCheckTestClass.kt
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import godot.Spatial
import godot.Node3D
import godot.annotation.RegisterClass
import godot.annotation.RegisterProperty
import godot.core.Dictionary
import godot.core.Transform
import godot.core.Transform3D
import godot.core.Vector3
import godot.core.variantArrayOf
import godot.tests.Invocation
import godot.tests.TestEnum

@RegisterClass
class CopyModificationCheckTestClass: Spatial() {
class CopyModificationCheckTestClass: Node3D() {

@RegisterProperty
var spatial = Spatial()
var node3D = Node3D()
var vectorList = variantArrayOf(Vector3.FORWARD)
var dictionary = Dictionary<Int, Vector3>().apply {
set(0, Vector3.FORWARD)
Expand All @@ -22,8 +22,8 @@ class CopyModificationCheckTestClass: Spatial() {
fun directCopyModification() {
rotation.x = 5.0
rotation[0] = 5.0
spatial.rotation.x = 5.0
spatial.rotation[0] = 5.0
node3D.rotation.x = 5.0
node3D.rotation[0] = 5.0
vectorList[0].x = 5.0
vectorList[0][0] = 5.0
dictionary[0].x = 5.0
Expand Down Expand Up @@ -74,7 +74,7 @@ class CopyModificationCheckTestClass: Spatial() {
vector--
println(vector)

Spatial().transform = Transform().apply {
Node3D().transform = Transform3D().apply {
basis.x = Vector3().apply {
x = vector
}
Expand Down Expand Up @@ -117,7 +117,7 @@ class CopyModificationCheckTestClass: Spatial() {

// Not allowed as it's a copy modification through some refs
fun copyModificationThroughReferenceAndFunctionCallWithBody() {
val vector = spatial.rotation
val vector = node3D.rotation
fun vectorProvider(): Vector3 {
return vector
}
Expand All @@ -142,7 +142,7 @@ class CopyModificationCheckTestClass: Spatial() {

// Not allowed as one branch might return a copy of a vector
fun copyModificationThroughDifferentReturnBranches(decision: TestEnum) {
val vector = spatial.rotation
val vector = node3D.rotation
fun vectorProvider(): Vector3 {
if (decision == TestEnum.ENUM_1) {
return Vector3()
Expand All @@ -156,27 +156,28 @@ class CopyModificationCheckTestClass: Spatial() {

// Allowed as `vectorCopy` is assigned later so the change of `x` actually has a use
fun copyButAssignedLater() {
val vectorCopy = spatial.rotation
val vectorCopy = node3D.rotation
vectorCopy[0] = 5.0
vectorCopy.x = 5.0

val anotherSpatial = Spatial()
anotherSpatial.rotation = vectorCopy
val anotherNode3D = Node3D()
anotherNode3D.rotation = vectorCopy
}

// Not allowed as modifying a local copy without using the modified local copy later.
// We have to assume that the modification was done by "accident"
fun copyModificationThroughReference() {
val vectorCopy = spatial.rotation
val vectorCopy = node3D.rotation
vectorCopy[0] = 5.0
vectorCopy.x = 5.0
}

// allowed as convenience function
fun objectHelperFunction() {
spatial.rotation {
x += 5.0
}
//TODO/4.0: reenable
// node3D.rotation {
// x += 5.0
// }
}

// not allowed as globalTransform is a copy and it would not be set correctly to this (Spatial) again
Expand All @@ -188,14 +189,15 @@ class CopyModificationCheckTestClass: Spatial() {

// both allowed as both are equivalent in functionality and are setting the correct value back to this (Spatial)
fun correctlyNestedHelperFunction() {
globalTransform {
origin.x += 3
}
globalTransform {
origin {
x += 3
}
}
//TODO/4.0: reenable
// globalTransform {
// origin.x += 3
// }
// globalTransform {
// origin {
// x += 3
// }
// }
}

fun collectionHelperFunction() {
Expand All @@ -212,7 +214,7 @@ class CopyModificationCheckTestClass: Spatial() {
fun poolArrayFunctions() {
Invocation().vectorList.pushBack(Vector3.FORWARD)
Invocation().vectorList[0].x += 5
Invocation().vectorList.get(0).x += 5
Invocation().vectorList.get(0).x += 5
//TODO: once helper functions are merged
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ class CoreTypesIdentityTest : Node() {
var plane = Plane(1, 2, 3, 4)

@RegisterProperty
var quat = Quat(1, 2, 3, 4)
var quaternion = Quaternion(1, 2, 3, 4)

@RegisterProperty
var rect2 = Rect2(1.0, 2.0, 3.0, 4.0)

@RegisterProperty
var transform =
Transform(Vector3(0, 1, 2), Vector3(3, 4, 5), Vector3(6, 7, 8), Vector3(9, 10, 11))
var transform3D =
Transform3D(Vector3(0, 1, 2), Vector3(3, 4, 5), Vector3(6, 7, 8), Vector3(9, 10, 11))

@RegisterProperty
var transform2D = Transform2D(0, 1, 2, 3, 4, 5)
Expand All @@ -53,13 +53,13 @@ class CoreTypesIdentityTest : Node() {
fun plane(plane: Plane) = plane

@RegisterFunction
fun quat(quat: Quat) = quat
fun quat(quaternion: Quaternion) = quaternion

@RegisterFunction
fun rect2(rect2: Rect2) = rect2

@RegisterFunction
fun transform(transform: Transform) = transform
fun transform(transform3D: Transform3D) = transform3D

@RegisterFunction
fun transform2D(transform2D: Transform2D) = transform2D
Expand Down
7 changes: 4 additions & 3 deletions harness/tests/src/main/kotlin/godot/tests/FuncRefTest.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package godot.tests

import godot.MultiplayerAPI
import godot.Node
import godot.annotation.RegisterClass
import godot.annotation.RegisterFunction
import godot.annotation.RegisterProperty
import godot.annotation.RegisterSignal
import godot.annotation.Rpc
import godot.extensions.call
import godot.extensions.callDeferred
import godot.signals.signal
Expand All @@ -16,7 +16,7 @@ class FuncRefTest : Node() {
@RegisterSignal
val signalTest by signal()

@RegisterProperty(rpcMode = MultiplayerAPI.RPCMode.REMOTE)
@RegisterProperty
var blubb: Boolean = false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it missing @Rpc annotation ?


@RegisterProperty
Expand All @@ -37,7 +37,8 @@ class FuncRefTest : Node() {
// rset(::blubb, false)
}

@RegisterFunction(MultiplayerAPI.RPCMode.REMOTE)
@Rpc
@RegisterFunction
fun testSignalCallback() {
signalCallFlag = true
}
Expand Down
Loading