Replies: 2 comments 3 replies
-
Edit: not exactly. |
Beta Was this translation helpful? Give feedback.
-
Unfortunately, when making a ptrcall we don't (and in most cases can't) verify the argument types. Firstly, we don't check the argument types because ptrcalls aim to be the most performant way to call a native function, so we don't do any checking, leaving it up to the language binding to check before calling. Otherwise, you can end up checking the types twice: once in the binding (for type safe languages) and once in the call. But, also, arguments in ptrcalls are passed as pointers to the raw value, so |
Beta Was this translation helpful? Give feedback.
-
GDExtension
classdb_get_method_bind
andvariant_get_ptr_utility_function
both require hash values from the JSON. This is meant to guard any forward incompatibility when upgrading Godot version.Howëver,
object_method_bind_call
has aGDExtensionCallError *r_error
return arg that (persumably) knows how to report wrong arg counts or types, so the hash check is redundant here. (It’s good forobject_method_bind_ptrcall
tho.)OTOH,
GDExtensionPtrUtilityFunction
takes anargc
-argv
pair for args, similar to “regular call”; but doesn’t return aGDExtensionCallError *r_error
, similar to “ptrcall”. I much prefer having aGDExtensionCallError
return for a complete and consistent error handling mechanism.Language binders like my WIP currently had to bundle hashes for godot knows how many functions (or at least those of
@GlobalScope
, which rely onvariant_get_ptr_utility_function
) in our GDExtensions.(Better yet, instead of returning function pointers, let us call utility functions directly – function name,
argc
,argv
,return
, etc. all in one go, similar to howMethodBind
hasvariant_call
.)Beta Was this translation helpful? Give feedback.
All reactions