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

Reworked signal system, added support for Callable and Signal #36368

Merged
merged 1 commit into from
Feb 20, 2020

Conversation

reduz
Copy link
Member

@reduz reduz commented Feb 19, 2020

Both add a more abstract way to access callable and signal data, and both are added to the type system (and Variant).

Signal connections are now made by passing a Callable instead of object and method, this opens the door to a lot more custom and efficient ways to get the callbacks. Likewise, signals can be accessed from variants, and methods are now first class (only as a getter though).

Existing within-engine calls to connect and disconnect were renamed to connect_compat and disconnect_compat, they will eventually be modified to use method pointers for performance (and because they dont require a binding for the method), but this is left for step 2.

@Zireael07
Copy link
Contributor

I hope we get a documentation example as soon as this lands?

@reduz
Copy link
Member Author

reduz commented Feb 19, 2020

@Zireael07 I dont think so, gdscript is being reworked a lot the next months, so there wont be doc until the syntax changes are done

Copy link
Contributor

@neikeq neikeq left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@@ -99,6 +99,9 @@ extern void unregister_variant_methods();

void register_core_types() {

//consistency check
ERR_FAIL_COND(sizeof(Callable) > 16);

Copy link
Contributor

Choose a reason for hiding this comment

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

An static_assert would be better to make it a compiler error instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah nice, I thought static assert was C++17 but there is a C++11 version. Can probably do a separate PR later changing a lot of those we have

Copy link
Contributor

Choose a reason for hiding this comment

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

You can use it #36385 or discard if you already did, I spend 30 minutes searching, and I didn't found more.

@akien-mga
Copy link
Member

akien-mga commented Feb 20, 2020

The Mono build will need some custom bindings, mono_glue=yes builds fail:

(CoreCompile target) -> 
  Generated/NativeCalls.cs(3220,94): error CS0246: The type or namespace name 'Callable' could not be found (are you missing a using directive or an assembly reference?) [/home/akien/Projects/godot/godot.git/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj]
  Generated/NativeCalls.cs(3223,95): error CS0246: The type or namespace name 'Callable' could not be found (are you missing a using directive or an assembly reference?) [/home/akien/Projects/godot/godot.git/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj]
  Generated/NativeCalls.cs(3226,95): error CS0246: The type or namespace name 'Callable' could not be found (are you missing a using directive or an assembly reference?) [/home/akien/Projects/godot/godot.git/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj]
  Generated/GodotObjects/Object.cs(471,45): error CS0246: The type or namespace name 'Callable' could not be found (are you missing a using directive or an assembly reference?) [/home/akien/Projects/godot/godot.git/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj]
  Generated/GodotObjects/Object.cs(481,47): error CS0246: The type or namespace name 'Callable' could not be found (are you missing a using directive or an assembly reference?) [/home/akien/Projects/godot/godot.git/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj]
  Generated/GodotObjects/Object.cs(490,48): error CS0246: The type or namespace name 'Callable' could not be found (are you missing a using directive or an assembly reference?) [/home/akien/Projects/godot/godot.git/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj]

Otherwise the rest should build fine now after I've rebased on master and fixed a few missed occurrences of old style connect().

@akien-mga akien-mga requested review from hpvb and removed request for AndreaCatania, BastiaanOlij and JFonS February 20, 2020 08:48
@akien-mga akien-mga merged commit bd61281 into godotengine:master Feb 20, 2020
@akien-mga
Copy link
Member

Thanks!

method = p_method;
}
Callable::Callable(CallableCustom *p_custom) {
if (p_custom->referenced) {
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand this limitation. Why you can't create two Callable with the same custom? The equality function even try to compare them by pointer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants