I tried generating GObject-Bindings with haskell-gi for the wireplumber library, the generated code fails to typecheck, because the bindings slightly off.
The type errors are not especially hard ones. I am unsure about how to proceed, because it is the generated code that failed and I am working for my first time with haskell-gi.
/home/vego/Git/haskell-gi/bindings/WirePlumber/GI/Wp/Structs/Iterator.hs:353:44: error: [GHC-83865]
• Couldn't match type ‘GValue’ with ‘Ptr GValue’
Expected: Ptr (Ptr GValue)
Actual: Ptr GValue
• In the third argument of ‘wp_iterator_fold’, namely ‘ret''’
In a stmt of a 'do' block:
result <- wp_iterator_fold self' func' ret'' data_
In the second argument of ‘($)’, namely
‘do self' <- unsafeManagedPtrGetPtr self
func' <- Wp.Callbacks.mk_IteratorFoldFunc
(Wp.Callbacks.wrap_IteratorFoldFunc Nothing func)
ret' <- disownGValue ret
ret'' <- callocBytes 24 :: IO (Ptr GValue)
....’
|
353 | result <- wp_iterator_fold self' func' ret'' data_
| ^^^^^
Inspecting the error I found that the coressponding function was translated this way:
foreign import ccall "wp_iterator_fold" wp_iterator_fold ::
Ptr Iterator -> -- self : TInterface (Name {namespace = "Wp", name = "Iterator"})
FunPtr Wp.Callbacks.C_IteratorFoldFunc -> -- func : TInterface (Name {namespace = "Wp", name = "IteratorFoldFunc"})
Ptr (Ptr GValue) -> -- ret : TGValue
Ptr () -> -- data : TBasicType TPtr
IO CInt
Where ret
is translated as Ptr Ptr GValue
, but the xml documents the argument this way:
<parameter name="ret"
direction="inout"
caller-allocates="0"
transfer-ownership="full">
<doc xml:space="preserve"
filename="docs/wp-gtkdoc.h"
line="1917">the accumulator data</doc>
<type name="GObject.Value" c:type="GValue*"/>
</parameter>
Which is only a single value, as far as I can tell.
Is this an error in haskell-gi, because of the direction of the parameter? (inout
)
Are these kind of errors common, can I fix them by hand without further problems?
Thank you for any comments!