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

Add top-level @export to separate class_name. #63758

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

willnationsdev
Copy link
Contributor

@willnationsdev willnationsdev commented Aug 1, 2022

Closes godotengine/godot-proposals#4493.

Depends on #62411. Can be rebased after it is merged.

It also involves a change to the filesystem cache just like #60606.

Modifies @export annotation in GDScript so that it can be used similarly to @tool, but for the purpose of exposing a given class to the editor. Without it, the class will not be visible in the CreateDialog or EditorResourcePicker. This would be a compatibility-breaking change needed for 4.0 IF we do indeed want the default behavior of class_name to not include editor exposure.

Under the hood, I've added a GlobalScriptFlags enum to global script class information stored by the ScriptServer and EditorFileSystem cache. It can have - for now - either GLOBAL_SCRIPT_NONE or GLOBAL_SCRIPT_EXPORT, with the potential for additional flags to be added over time (perhaps GLOBAL_SCRIPT_ABSTRACT or GLOBAL_SCRIPT_STATIC, etc.). Adding the @export class annotation merely changes what value is exposed for the flags value passed to ScriptServer::get_global_class_name(...).

Edit: I noticed that there was a template for creating VisualScriptNodes using GDScript that relies on class_name definitions. Should that functionality also be dependent on the given GDScript having the @export class annotation?

@willnationsdev willnationsdev requested review from a team as code owners August 1, 2022 05:18
@willnationsdev willnationsdev force-pushed the gdres-classname-export branch from 0e86545 to b1a84b2 Compare August 1, 2022 05:25
@Chaosus Chaosus added this to the 4.0 milestone Aug 1, 2022
@willnationsdev willnationsdev force-pushed the gdres-classname-export branch 3 times, most recently from 35c3ec0 to 655184b Compare August 5, 2022 02:46
@willnationsdev willnationsdev force-pushed the gdres-classname-export branch 2 times, most recently from 760cf20 to d77d84f Compare August 19, 2022 00:00
@willnationsdev willnationsdev force-pushed the gdres-classname-export branch 2 times, most recently from 0c3d59b to 9384d63 Compare August 19, 2022 03:36
@willnationsdev willnationsdev force-pushed the gdres-classname-export branch from 9384d63 to 1cc5db5 Compare August 19, 2022 07:21
@aaronfranke
Copy link
Member

See also my comment here which notes how adding @abstract solves this problem for many of the use cases.

@YuriSizov YuriSizov modified the milestones: 4.0, 4.x Feb 10, 2023
@dalexeev
Copy link
Member

dalexeev commented Jul 22, 2023

I'm not sure if it's a good idea to reuse the @export annotation for this purpose, I would prefer a separate annotation.

Also, this PR implies that by default classes are not displayed in the nodes dialog? Formally, this breaks compatibility. This only affects the editor, though. The alternative is an annotation to hide nodes from the dialog (and by default the current behavior is saved).

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.

Split class_name responsibility into two keywords
5 participants