diff --git a/cl/_testmockc/type/in.h b/cl/_testmockc/type/in.h index 1c6e0336..866a5883 100644 --- a/cl/_testmockc/type/in.h +++ b/cl/_testmockc/type/in.h @@ -1,3 +1,7 @@ int sort(void* a, void* b, int elementSize, int count, int (*cmp)(const void*, const void*)); +void f(int (callback)(void)); + void g(void); + +void h(void (**callbackPtr)(void)); diff --git a/cl/_testmockc/type/out.go b/cl/_testmockc/type/out.go index 05977c2e..6dbc50ee 100644 --- a/cl/_testmockc/type/out.go +++ b/cl/_testmockc/type/out.go @@ -8,5 +8,11 @@ import ( //go:linkname Sort C.sort func Sort(a unsafe.Pointer, b unsafe.Pointer, elementSize c.Int, count c.Int, cmp func(_llcppg_param1 unsafe.Pointer, _llcppg_param2 unsafe.Pointer) c.Int) c.Int +//go:linkname F C.f +func F(callback func() c.Int) + //go:linkname G C.g func G() + +//go:linkname H C.h +func H(callbackPtr *func()) diff --git a/cl/type_and_var.go b/cl/type_and_var.go index 0286aea2..bb90f120 100644 --- a/cl/type_and_var.go +++ b/cl/type_and_var.go @@ -48,11 +48,6 @@ func newPointer(typ types.Type) types.Type { if t == tyVoid { return types.Typ[types.UnsafePointer] } - case *types.Signature: - panic("todo: newPointer for signature") - /* if gogen.IsCSignature(t) { - return types.NewSignature(nil, t.Params(), t.Results(), t.Variadic()) - } */ case *types.Named: panic("todo: newPointer for named type") /* if typ == ValistTag { @@ -79,6 +74,8 @@ func toType(ctx *blockCtx, pkg *types.Package, typ lc.Type, flags int) types.Typ return newPointer(pointee) case lc.TypeVoid: return tyVoid + case lc.TypeFunctionProto: + return toFuncType(ctx, pkg, typ) default: log.Println("==> toType: unknown Kind -", typ.Kind) }