[Godot] Implement access modifiers, private and protected, to GDScript to protect a class member from being accessed externally. #734
+367
−53
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is my first contribution to redot. If there is any mistake, please let me know and I'm here to hear that. :)
Trying implementing redot-proposal-#7.
This pr provides RDScript users a way to protect their members accessibility, and prevent any illegal access from external classes.
We will have
@private
and@protected
annotations in RDScript soon:Introduction of new annotations
@private
@private
annotation allows a member (currently a constant, a variable or a method) to be accessible only within the current class scope:@protected
@protected
annotation allows a member (currently a constant, a variable or a method) to be accessible only within the current class scope, or the scope of derived classes:Common features:
@private
or@protected
will hide its documentation from auto-generated doc API, even if you use##
to document it (except@export_*
-ed properties and signals).Remaining WIP
reduce_identifier()
(√) andreduce_call()
. (RDScriptAnalyzer)Discussion about if(Having checked the documentation about whether it is better to use keywords or annotations, I decided to use keywords instead)@private
and@protected
should be keywords or annotations. Allow@export_*
work with@private
and@protected
set()
(Set()
in C#) andget()
(Get()
in C#) unable to access external protected members. (RDScriptCompiler & RDScriptVM)Remaining WIP after being converted into Review
.gd
and.out
files. (Unit test)Tracking after this PR gets merged:
Closes Redot-Engine/redot-proposals#7