@@ -176,66 +176,36 @@ pub(crate) fn is_excluded_from_default_params(class_name: Option<&TyName>, godot
176176 }
177177}
178178
179+ /// Return `true` if a method should have `&self` receiver in Rust, `false` if `&mut self` and `None` if original qualifier should be kept.
180+ ///
181+ /// In cases where the method falls under some general category (like getters) that have their own const-qualification overrides, `Some`
182+ /// should be returned to take precedence over general rules. Example: `FileAccess::get_pascal_string()` is mut, but would be const-qualified
183+ /// since it looks like a getter.
179184#[ rustfmt:: skip]
180- pub ( crate ) fn keeps_get_prefix ( class_name : & TyName , method : & ClassMethod ) -> bool {
181- // Also list those which have default parameters and can be called with 0 arguments. Those are anyway
182- // excluded at the moment, but this is more robust if the outer logic changes.
183-
184- match ( class_name. godot_ty . as_str ( ) , method. name . as_str ( ) ) {
185- // For Object
186- // https://docs.godotengine.org/en/stable/classes/class_object.html#methods
187- | ( "Object" , "get_class" )
188- | ( "Object" , "get_instance_id" ) // currently removed, but would be shadowed by Gd::instance_id().
189- | ( "Object" , "get_script" )
190- | ( "Object" , "get_script_instance" )
191- // The following ones often have slight variations with parameters, so it's more consistent to have get_signal_list() and
192- // get_signal_connection_list(signal). This may change in the future.
193- | ( "Object" , "get_incoming_connections" )
194- | ( "Object" , "get_meta_list" )
195- | ( "Object" , "get_method_list" )
196- | ( "Object" , "get_property_list" )
197- | ( "Object" , "get_signal_list" )
198-
199- // For Node
200- // https://docs.godotengine.org/en/stable/classes/class_node.html#methods
201- // TODO get_child_count?
202-
203- // https://docs.godotengine.org/en/stable/classes/class_fileaccess.html#methods
185+ #[ cfg( FALSE ) ] // TODO enable this once JSON/domain models are separated.
186+ pub ( crate ) fn is_method_const ( class_name : & TyName , godot_method : & ClassMethod ) -> Option < bool > {
187+ match ( class_name. godot_ty . as_str ( ) , godot_method. name . as_str ( ) ) {
188+ // Changed to mut.
204189 | ( "FileAccess" , "get_16" )
205190 | ( "FileAccess" , "get_32" )
206191 | ( "FileAccess" , "get_64" )
207192 | ( "FileAccess" , "get_8" )
208- | ( "FileAccess" , "get_as_text" )
209193 | ( "FileAccess" , "get_csv_line" )
210- | ( "FileAccess" , "get_double" )
211- | ( "FileAccess" , "get_error" ) // If this has side effects, should definitely keep prefix. Not clear.
212- | ( "FileAccess" , "get_float" )
213- | ( "FileAccess" , "get_line" )
214- | ( "FileAccess" , "get_open_error" )
215- | ( "FileAccess" , "get_pascal_string" )
216194 | ( "FileAccess" , "get_real" )
195+ | ( "FileAccess" , "get_float" )
196+ | ( "FileAccess" , "get_double" )
217197 | ( "FileAccess" , "get_var" )
218-
219- // https://docs.godotengine.org/en/stable/classes/class_streampeer.html#methods
220- // do for 8,16,32,64 and u*
198+ | ( "FileAccess" , "get_line" )
199+ | ( "FileAccess" , "get_pascal_string" ) // already mut.
200+ | ( "StreamPeer" , "get_8" )
221201 | ( "StreamPeer" , "get_16" )
222202 | ( "StreamPeer" , "get_32" )
223203 | ( "StreamPeer" , "get_64" )
224- | ( "StreamPeer" , "get_8" )
225- | ( "StreamPeer" , "get_double" )
226204 | ( "StreamPeer" , "get_float" )
227- | ( "StreamPeer" , "get_string" )
228- | ( "StreamPeer" , "get_u16" )
229- | ( "StreamPeer" , "get_u32" )
230- | ( "StreamPeer" , "get_u64" )
231- | ( "StreamPeer" , "get_u8" )
232- | ( "StreamPeer" , "get_utf8_string" )
233- | ( "StreamPeer" , "get_var" )
234-
235- // Others that conflict with a verb:
236- | ( "AnimationPlayer" , "get_queue" )
205+ | ( "StreamPeer" , "get_double" )
206+ => Some ( false ) ,
237207
238- => true , _ => false ,
208+ _ => None ,
239209 }
240210}
241211
0 commit comments