migueldeicaza / SwiftGodot

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

die if a class name has already been registered #529

Closed mayoff closed 2 months ago

mayoff commented 2 months ago

I noticed this comment:

    // TODO: what happens if the user subclasses but the name conflicts with the Godot type?
    // say "class Sprite2D: Godot.Sprite2D"

The only way SwiftGodot can find out the type for some pointer passed from Godot is by checking the class name, we really can't allow class name conflicts: we could end up casting a pointer to the wrong type, leading to difficult-to-diagnose crashes. I think it's better to crash immediately if the extension tries to register a class name that's already been registered.

migueldeicaza commented 2 months ago

Good call.