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

Virtual methods are wrongly marked in docs and for godot's gdscript editor #917

Closed
Yarwin opened this issue Oct 11, 2024 · 2 comments · Fixed by #918
Closed

Virtual methods are wrongly marked in docs and for godot's gdscript editor #917

Yarwin opened this issue Oct 11, 2024 · 2 comments · Fixed by #918
Labels
bug c: register Register classes, functions and other symbols to GDScript

Comments

@Yarwin
Copy link
Contributor

Yarwin commented Oct 11, 2024

Given some virtual method

    #[func(virtual)]
    pub fn my_virtual_method(&self) {
        );
    }

It will display in Godot's internal docs as
image

and in editor as
image
image

Meanwhile the real function call requires end-user to annotate given method name with _
for example, following code, called in rust by something along the lines of my_rust_class.bind().my_virtual_method()

extends MyRustClass
class_name GdscriptClass

func my_virtual_method() -> void:
	print("I am never called!")

func _my_virtual_method() -> void:
	print("hello from gdscript!")

Will output "hello from gdscript".

Excepted behavior: correct names of given methods in docs and editor's autocomplete. Not sure about get_method_list tho

@Yarwin Yarwin changed the title Virtual methods are wrongly marked in docs and for gdscript API Virtual methods are wrongly marked in docs and for godot's gdscript editor Oct 11, 2024
@Yarwin
Copy link
Contributor Author

Yarwin commented Oct 11, 2024

Note – this behavior is properly documented. It is just very confusing for end-end-end users 😬

Note2 – I'm not sure if it is something that should be tackled with godot-rust or in upstream due to some limitations. I could catch this edge case in docs at least tho

@Bromeon
Copy link
Member

Bromeon commented Oct 11, 2024

Thanks! Thats a mistake on our side, I fixed it in #918. Could you maybe check if it works for you too?


A bit of background on method vs _method: there are some known limitations, particularly point 1. From outside Rust, it's not possible to call the virtual function polymorphically -- only the overridden GDScript method.

I was considering to eventually add something like #[func(virtual_pub)] (better naming), which would register the polymorphic version as my_virtual_method. It might even be possible to do that for all methods, but maybe registering an extra non-virtual method isn't necessary in most cases.

@Bromeon Bromeon added bug c: register Register classes, functions and other symbols to GDScript labels Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug c: register Register classes, functions and other symbols to GDScript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants