I'm working with a C code base for which
typedef void(* wl_notify_func_t) (struct wl_listener *listener, void *data)
//...
struct wl_listener {
struct wl_list link;
wl_notify_func_t notify; //<-- I'd like to return this
};
and have used the Haskell code
type NotifyFuncT = FunPtr (Ptr C'WlListener -> Ptr () -> IO ())
initializeMyCtx = C.context $ C.baseCtx <> C.funCtx <> mempty {
C.ctxTypesTable = Data.Map.fromList [
(C.Struct "wl_listener", [t|C'WlListener|])
-- ...
, (C.TypeName "wl_notify_func_t", [t|NotifyFuncT|])
]
}
someHaskellFunction :: Ptr C'WlListener -> IO NotifyFuncT
someHaskellFunction ptrToWlListener = do
funPtr <- [C.block| wl_notify_func_t {return $(struct wl_listener * ptrToWlListener)->notify;}|]
return funPtr
Unfortunately, I get an error from the inline-C code block which essentially says:
unexpected identifier wl_notify_func_t
So is what I'm doing even possible with inline-C?
The code in my question works. I just forgot to include a C context.