Convert Ptr () to SourceCompletionProvider

前端 未结 1 1872
旧巷少年郎
旧巷少年郎 2021-01-24 12:12

I\'ve solved the prev question partially.

Right now I\'m able to register GObject subtype via bindings-gobject (see hpase) I can implement

相关标签:
1条回答
  • 2021-01-24 12:31

    The outer SourceCompletionProvider is required since this is a newtype, and the inner SourceCompletionProvider is just a marker to distinguish this foreign pointer from pointers to other types. If you look at the definition of Ptr a, it's data Ptr a = Ptr Addr# - a is a phantom type that doesn't appear on the right-hand side, so the definition is not actually recursive.

    You can convert a Ptr () to ForeignPtr () using newForeignPtr_ and then cast it to ForeignPtr SourceCompletionProvider with castForeignPtr.

    edit: After looking at this a bit more, I think that to make this work you'll need to first convert your Ptr to GObject with the method outlined above and then use unsafeCastGObject. Not tested, though.

    0 讨论(0)
提交回复
热议问题