-
Notifications
You must be signed in to change notification settings - Fork 45
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
Conversation
* Update godot version ref in code * generate api for godot 3.x branch * Fix compilation errors for call methods with changed arg counts * regenerate api for 101cbe5d5b on 3.x Co-authored-by: Cedric Hippmann <[email protected]>
* Create POD to deserialize new godot 4.0's api.json * Rework api generator structure for maintainability and generate using extension api json * Add some shortcut to Kotlin classes to avoid repetitions * fix singleton to class association * Fix KtObject class name in api generator * Rename PoolArrays to PackedArrays * Fix type names usage in core * fix StringName compilation error in generated api by creating empty StringName class in core with TODO * Add RedundantVisibilityModifier suppress warning to generated classes * Rename Transform to Transform3D and Quat to Quaternion in kotlin code * fix variantArray generated default value * Add Rect2i, Vector2i, Vector3i classes with TODO to make generated code compile * Fix Variant generated default values * Make non instantiable classes abstract * Remove generation of classes inheriting singleton * Renamed Reference to RefCounted in generated code, cpp engine compile error fixes * Add callable to core types in api generator * Adapt cpp code to VARIANT_ARG macro deletion from godot repo * Fix generation of enum default parameter, and add id to reimplemented core type enums * apigenerator: set non instantiable classes as open class with internal primary constructor * Avoid generation of method using native structures as we do not have value types for now * Generate default value for callable using default constructor * api-generator: generate default value for RID using default constructor * api-generator: avoid line return because of space in generated code * Add dummy Callable to make code compile * Remove helpers for rpc unreliable and rset as methods does not exists anymore * Make use of Callable in Object's signals extensions * fix GD.load method in godot-library * api-generator: Fix NodePath default value generation, api.json and open methods and properties only if virtual * api-generator: fix generation of indexed properties * Adapt to FileAccess and DirAccess changes from d2ebac3 of godot main repo * fix android build error because of usage of tools translate * fix: add function pointer as template parameter to to_kvariant_fromNATIVECORETYPE to add conversion function and make linux happy * Fix RID operator call on variant in rid_bridge.cpp * comment RPCMode related code in ksAnnotationExt in godot-kotlin-symbol-processor with TODO, in order to compile * Remove REF in favor of Ref<Reference> * adapt kt_variant.h to basis and transform method rename * fix: replace /* by /* in generated kdoc to avoid wrong comment termination * Adapt to new module initialization with init levels * Implement Vector2i and Vector3i types. Readapt Vector2 and Vector3 to new api * 4.0/implement new types protocol (#329) * Implement protocol for Vector2i, Vector3i and Rect2i * Add StringName protocol and start writing its bridge * Implement Callable, its protocol, and its bridge * chore: remove last references to Map and Set in favor of HashMap and HashSet * Seperate constructor methods in StringNameBridge
10a2942
to
661eba3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work !
I have some questions, and new commit on godot master invalidate cpp code.
@@ -16,7 +16,7 @@ class FuncRefTest : Node() { | |||
@RegisterSignal | |||
val signalTest by signal() | |||
|
|||
@RegisterProperty(rpcMode = MultiplayerAPI.RPCMode.REMOTE) | |||
@RegisterProperty | |||
var blubb: Boolean = false |
There was a problem hiding this comment.
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 ?
@@ -332,7 +332,7 @@ class Invocation : Spatial() { | |||
override fun _ready() { | |||
val formerName = name | |||
println("Name is: $name") | |||
name = "TestName" | |||
name = StringName("TestName") //TODO/4.0: provide convenience wrapper for StringName properties and parameters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should have an extension method to convert String
to StringName
|
||
@RegisterClass("RPCTests") | ||
class RpcTests : Node() { | ||
|
||
@RegisterProperty | ||
var remoteSyncCalled: Boolean = false | ||
|
||
@RegisterProperty(rpcMode = MultiplayerAPI.RPCMode.REMOTESYNC) | ||
@RegisterProperty | ||
var remoteSyncProperty: Boolean = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing @Rpc
annotation ?
@@ -25,7 +25,6 @@ fun Type?.toKtVariantType(): ClassName = when { | |||
"godot.core.VariantType", | |||
fqName.substringAfterLast(".").camelToSnakeCase().uppercase(Locale.getDefault()) | |||
) | |||
fqName == "kotlin.Unit" -> ClassName("godot.core.VariantType", "NIL") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why this is removed
@@ -99,6 +99,15 @@ void KtClass::fetch_methods(jni::Env& env) { | |||
} | |||
} | |||
|
|||
void KtClass::fetch_rpc_methods() { | |||
HashMap<StringName, KtFunction*>::Iterator current = methods.begin(); | |||
while (current) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With 4.0 you can now use classic for each, like here :
godot-kotlin-jvm/src/gd_kotlin.cpp
Line 456 in d108e23
for (const KeyValue<StringName, KtClass*>& item : classes) { |
@@ -205,8 +205,7 @@ void KotlinScript::set_path(const String& p_path, bool p_take_over) { | |||
} | |||
|
|||
const Vector<Multiplayer::RPCConfig> KotlinScript::get_rpc_methods() const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems method changed recently: godotengine/godot@ca7d572
91a3123
to
108a673
Compare
Superseeded by #369 |
This changes our rpc related code to support the changes made in godot.
Namely;
This also updates the registration code, code generation and the IDE checks.