pragmagic / godot-nim

Nim bindings for Godot Engine
https://pragmagic.github.io/godot-nim/
Other
497 stars 27 forks source link

Object's get and set methods return nil method pointers and crash. #86

Closed geekrelief closed 3 years ago

geekrelief commented 3 years ago

GDNative's api.json defines Object's get and set methods as "_get" and "_set". When calling these methods, the method pointer returned from GDNative is nil. Changing the method names in objects.nim from "_get" to "get" and "_set" to "set" fixes the issue.

I'm using godot's 3.2 branch commit 354ea90b5

I imagine this must have worked fine in the past and must be a somewhat recent issue.

Filed a bug report with the engine here: https://github.com/godotengine/godot/issues/45516

endragor commented 3 years ago

On the Godot version we use (somewhat dated) objects define both _get/_set and get/set. The former are virtual methods that need to be overridden if you want to define your own behavior for getting/setting properties. The latter is what others should call if they want to get/set properties. Since Nim doesn't support names starting with an underscore, get/set gets renamed to getImpl/setImpl by the wrapper generator.

geekrelief commented 3 years ago

Oh ok! That makes sense! Thanks for the quick reply! Should I close this issue?

endragor commented 3 years ago

I'm not sure what kind of problem you encountered, but if the comment above resolves it, then yes.

geekrelief commented 3 years ago

Basically I tried calling Object.set and got a crash. I see Object.setImpl is using "set" instead of "_set" so closing.