migueldeicaza / SwiftGodot

New Godot bindings for Swift
https://migueldeicaza.github.io/SwiftGodotDocs/tutorials/swiftgodot-tutorials/
MIT License
985 stars 55 forks source link

Omit parameter labels and deprecate autogenerated methods #484

Closed joeynelson42 closed 1 month ago

joeynelson42 commented 1 month ago

Relates to #483

@migueldeicaza this is more of a POC, not a fully fleshed out solution, am curious to hear your thoughts before I go any further.

A request was made to remove the value parameter label from GArray.append(value: Variant) to imitate Swift's Array.append(_:) signature.

My goal was to add the new, label-omitted signature and add a deprecation warning to the old signature.

The GArray.append method is autogenerated from the extensions_api.json. So in order to achieve the goal I needed to:

  1. Add omitLabel flag to JGodotArgument and if found prepend _ to the argument's label
  2. Add isDuplicateSignature flag to JGodotBuiltinClassMethod to avoid generating any duplicate GDExtensionPtrBuiltInMethod
  3. Add Deprecation object to JGodotBuiltinClassMethod which contains information for the Xcode deprecation warning.

There is still plenty of work to be done, cleaning/tightening things up. The duplicate flag could be handled dynamically (but I kinda like the declaration?). Deprecation object could be generalized. etc etc.

Deprecation warning

Screenshot 2024-05-24 at 12 37 53 PM

Deprecation warning expanded

Screenshot 2024-05-24 at 12 38 21 PM

Deprecation warning in autocomplete

Screenshot 2024-05-24 at 12 38 35 PM