hugopl/gi-crystal

[Feature Request] Unsafe vfunc implementations

BlobCodes opened this issue · 1 comments

I think it would be useful be be able to directly implement vfuncs.
This could be used to pass values to other GObjects which don't need to be directly accessed inside crystal (to avoid mallocs) or to bypass bugs in gi-crystal.
I think something like def do_(vfunc)! or def unsafe_do_(vfunc) would be good.

Something like this:

class TestObject
  def do_example_vfunc!(some_struct : LibGObject::SomeStruct, some_object : Void*)
  end
end

It would be quite easy to implement, but I'd first like to know whether this is something worthwhile or not.

I commented in the PR instead of here (my bad) #38 (comment)

The usecase of bypass gi-crystal bugs IMO isn't a valid use case, since bugs must be fixed. However the usecase of avoid wrapper generation, mallocs, etc... seems valid to me.

I would just wait a bit for the vfunc/interface code stabilize before adding more stuff in it.