Function pointers get converted to `ptr FunctionType` instead of just `FunctionType`
Yardanico opened this issue · 0 comments
Yardanico commented
Futhark converts C definitions of function pointers inside structs that are defined as separate types to ptr FunctionType
instead of just FunctionType
.
For example with this C header:
typedef int PDCallbackFunction(void* userdata); // return 0 when done
struct playdate_sys
{
void (*setUpdateCallback)(PDCallbackFunction* update, void* userdata);
};
Futhark makes this:
from macros import hint
type
Pdcallbackfunction_436207905* = proc (a0: pointer): cint {.cdecl.} ## Generated based on /home/dian/Projects/NimExperiments/api/testheader.h:1:13
structplaydatesys_436207908* = object
setupdatecallback*: proc (a0: ptr Pdcallbackfunction_436207907; a1: pointer): void {.
cdecl.} ## Generated based on /home/dian/Projects/NimExperiments/api/testheader.h:3:8
Pdcallbackfunction_436207907* = (when declared(Pdcallbackfunction):
Pdcallbackfunction
else:
Pdcallbackfunction_436207905)
structplaydatesys_436207909* = (when declared(structplaydatesys):
structplaydatesys
else:
structplaydatesys_436207908)
when not declared(Pdcallbackfunction):
type
Pdcallbackfunction* = Pdcallbackfunction_436207905
else:
static :
hint("Declaration of " & "PDCallbackFunction" &
" already exists, not redeclaring")
when not declared(structplaydatesys):
type
structplaydatesys* = structplaydatesys_436207908
else:
static :
hint("Declaration of " & "struct_playdate_sys" &
" already exists, not redeclaring")