panno8M / godot-nim

godot 4.x bindings for nim-lang (early stage)
78 stars 5 forks source link

suggestion: add `{.gdclass.}` prgama to automate `isInheritanceOf` call #4

Closed choltreppe closed 9 months ago

choltreppe commented 9 months ago

hi there,

This PR implements a {.gdclass.} pragma to safe 1 line of code

So you can do

type MyNode* {.gdClass.} = ref object of Node

instead of

type MyNode* = ref object of Node
MyNode.isInheritanceOf Node

I know it isnt realy important. but 1 line is 1 line.

One drawback however is that this breaks the order-insensitivity of type sections. So you cant define mutual recursive types that way. But I dont realy think you would ever have mutual recursive gd types. But even if you have, you can still go back to isInheritanceOf