diff --git a/_cmptest/testdata/libxml2/2.13.6/libxml2/debugXML.go b/_cmptest/testdata/libxml2/2.13.6/libxml2/debugXML.go index 332c6cad..5f9274b0 100644 --- a/_cmptest/testdata/libxml2/2.13.6/libxml2/debugXML.go +++ b/_cmptest/testdata/libxml2/2.13.6/libxml2/debugXML.go @@ -70,7 +70,7 @@ type X_xmlShellCtxt struct { Pctxt XPathContextPtr Loaded c.Int Output *c.FILE - Input ShellReadlineFunc + Input c.Pointer } type ShellCtxt X_xmlShellCtxt type ShellCtxtPtr *ShellCtxt diff --git a/_cmptest/testdata/libxml2/2.13.6/libxml2/encoding.go b/_cmptest/testdata/libxml2/2.13.6/libxml2/encoding.go index d80cb379..593223f4 100644 --- a/_cmptest/testdata/libxml2/2.13.6/libxml2/encoding.go +++ b/_cmptest/testdata/libxml2/2.13.6/libxml2/encoding.go @@ -53,8 +53,8 @@ type CharEncodingOutputFunc func(*c.Char, *c.Int, *c.Char, *c.Int) c.Int type X_xmlCharEncodingHandler struct { Name *c.Char - Input CharEncodingInputFunc - Output CharEncodingOutputFunc + Input c.Pointer + Output c.Pointer } type CharEncodingHandler X_xmlCharEncodingHandler type CharEncodingHandlerPtr *CharEncodingHandler diff --git a/_cmptest/testdata/libxml2/2.13.6/libxml2/parser.go b/_cmptest/testdata/libxml2/2.13.6/libxml2/parser.go index 91cb9e98..c95299b8 100644 --- a/_cmptest/testdata/libxml2/2.13.6/libxml2/parser.go +++ b/_cmptest/testdata/libxml2/2.13.6/libxml2/parser.go @@ -172,33 +172,33 @@ type StartElementNsSAX2Func func(c.Pointer, *Char, *Char, *Char, c.Int, **Char, type EndElementNsSAX2Func func(c.Pointer, *Char, *Char, *Char) type X_xmlSAXHandlerV1 struct { - InternalSubset InternalSubsetSAXFunc - IsStandalone IsStandaloneSAXFunc - HasInternalSubset HasInternalSubsetSAXFunc - HasExternalSubset HasExternalSubsetSAXFunc - ResolveEntity ResolveEntitySAXFunc - GetEntity GetEntitySAXFunc - EntityDecl EntityDeclSAXFunc - NotationDecl NotationDeclSAXFunc - AttributeDecl AttributeDeclSAXFunc - ElementDecl ElementDeclSAXFunc - UnparsedEntityDecl UnparsedEntityDeclSAXFunc - SetDocumentLocator SetDocumentLocatorSAXFunc - StartDocument StartDocumentSAXFunc - EndDocument EndDocumentSAXFunc - StartElement StartElementSAXFunc - EndElement EndElementSAXFunc - Reference ReferenceSAXFunc - Characters CharactersSAXFunc - IgnorableWhitespace IgnorableWhitespaceSAXFunc - ProcessingInstruction ProcessingInstructionSAXFunc - Comment CommentSAXFunc - Warning WarningSAXFunc - Error ErrorSAXFunc - FatalError FatalErrorSAXFunc - GetParameterEntity GetParameterEntitySAXFunc - CdataBlock CdataBlockSAXFunc - ExternalSubset ExternalSubsetSAXFunc + InternalSubset c.Pointer + IsStandalone c.Pointer + HasInternalSubset c.Pointer + HasExternalSubset c.Pointer + ResolveEntity c.Pointer + GetEntity c.Pointer + EntityDecl c.Pointer + NotationDecl c.Pointer + AttributeDecl c.Pointer + ElementDecl c.Pointer + UnparsedEntityDecl c.Pointer + SetDocumentLocator c.Pointer + StartDocument c.Pointer + EndDocument c.Pointer + StartElement c.Pointer + EndElement c.Pointer + Reference c.Pointer + Characters c.Pointer + IgnorableWhitespace c.Pointer + ProcessingInstruction c.Pointer + Comment c.Pointer + Warning c.Pointer + Error c.Pointer + FatalError c.Pointer + GetParameterEntity c.Pointer + CdataBlock c.Pointer + ExternalSubset c.Pointer Initialized c.Uint } type SAXHandlerV1 X_xmlSAXHandlerV1 diff --git a/_cmptest/testdata/libxml2/2.13.6/libxml2/tree.go b/_cmptest/testdata/libxml2/2.13.6/libxml2/tree.go index 70aca250..040c7a30 100644 --- a/_cmptest/testdata/libxml2/2.13.6/libxml2/tree.go +++ b/_cmptest/testdata/libxml2/2.13.6/libxml2/tree.go @@ -10,8 +10,8 @@ const DOCB_DOCUMENT_NODE = 21 type X_xmlParserInputBuffer struct { Context c.Pointer - Readcallback InputReadCallback - Closecallback InputCloseCallback + Readcallback c.Pointer + Closecallback c.Pointer Encoder CharEncodingHandlerPtr Buffer BufPtr Raw BufPtr @@ -24,8 +24,8 @@ type ParserInputBufferPtr *ParserInputBuffer type X_xmlOutputBuffer struct { Context c.Pointer - Writecallback OutputWriteCallback - Closecallback OutputCloseCallback + Writecallback c.Pointer + Closecallback c.Pointer Encoder CharEncodingHandlerPtr Buffer BufPtr Conv BufPtr @@ -46,7 +46,7 @@ type X_xmlParserInput struct { Line c.Int Col c.Int Consumed c.Ulong - Free ParserInputDeallocate + Free c.Pointer Encoding *Char Version *Char Flags c.Int @@ -154,7 +154,7 @@ type X_xmlParserCtxt struct { Nsdb *ParserNsData AttrHashMax c.Uint AttrHash *AttrHashBucket - ErrorHandler StructuredErrorFunc + ErrorHandler c.Pointer ErrorCtxt c.Pointer } type ParserCtxt X_xmlParserCtxt @@ -170,38 +170,38 @@ type SAXLocator X_xmlSAXLocator type SAXLocatorPtr *SAXLocator type X_xmlSAXHandler struct { - InternalSubset InternalSubsetSAXFunc - IsStandalone IsStandaloneSAXFunc - HasInternalSubset HasInternalSubsetSAXFunc - HasExternalSubset HasExternalSubsetSAXFunc - ResolveEntity ResolveEntitySAXFunc - GetEntity GetEntitySAXFunc - EntityDecl EntityDeclSAXFunc - NotationDecl NotationDeclSAXFunc - AttributeDecl AttributeDeclSAXFunc - ElementDecl ElementDeclSAXFunc - UnparsedEntityDecl UnparsedEntityDeclSAXFunc - SetDocumentLocator SetDocumentLocatorSAXFunc - StartDocument StartDocumentSAXFunc - EndDocument EndDocumentSAXFunc - StartElement StartElementSAXFunc - EndElement EndElementSAXFunc - Reference ReferenceSAXFunc - Characters CharactersSAXFunc - IgnorableWhitespace IgnorableWhitespaceSAXFunc - ProcessingInstruction ProcessingInstructionSAXFunc - Comment CommentSAXFunc - Warning WarningSAXFunc - Error ErrorSAXFunc - FatalError FatalErrorSAXFunc - GetParameterEntity GetParameterEntitySAXFunc - CdataBlock CdataBlockSAXFunc - ExternalSubset ExternalSubsetSAXFunc + InternalSubset c.Pointer + IsStandalone c.Pointer + HasInternalSubset c.Pointer + HasExternalSubset c.Pointer + ResolveEntity c.Pointer + GetEntity c.Pointer + EntityDecl c.Pointer + NotationDecl c.Pointer + AttributeDecl c.Pointer + ElementDecl c.Pointer + UnparsedEntityDecl c.Pointer + SetDocumentLocator c.Pointer + StartDocument c.Pointer + EndDocument c.Pointer + StartElement c.Pointer + EndElement c.Pointer + Reference c.Pointer + Characters c.Pointer + IgnorableWhitespace c.Pointer + ProcessingInstruction c.Pointer + Comment c.Pointer + Warning c.Pointer + Error c.Pointer + FatalError c.Pointer + GetParameterEntity c.Pointer + CdataBlock c.Pointer + ExternalSubset c.Pointer Initialized c.Uint X_private c.Pointer - StartElementNs StartElementNsSAX2Func - EndElementNs EndElementNsSAX2Func - Serror StructuredErrorFunc + StartElementNs c.Pointer + EndElementNs c.Pointer + Serror c.Pointer } type SAXHandler X_xmlSAXHandler type SAXHandlerPtr *SAXHandler @@ -559,7 +559,7 @@ type X_xmlDOMWrapCtxt struct { X_private c.Pointer Type c.Int NamespaceMap c.Pointer - GetNsForNodeFunc DOMWrapAcquireNsFunction + GetNsForNodeFunc c.Pointer } type DOMWrapCtxt X_xmlDOMWrapCtxt type DOMWrapCtxtPtr *DOMWrapCtxt diff --git a/_cmptest/testdata/libxml2/2.13.6/libxml2/valid.go b/_cmptest/testdata/libxml2/2.13.6/libxml2/valid.go index 2ca85a79..0124ce0a 100644 --- a/_cmptest/testdata/libxml2/2.13.6/libxml2/valid.go +++ b/_cmptest/testdata/libxml2/2.13.6/libxml2/valid.go @@ -19,8 +19,8 @@ type ValidityWarningFunc func(__llgo_arg_0 c.Pointer, __llgo_arg_1 *c.Char, __ll type X_xmlValidCtxt struct { UserData c.Pointer - Error ValidityErrorFunc - Warning ValidityWarningFunc + Error c.Pointer + Warning c.Pointer Node NodePtr NodeNr c.Int NodeMax c.Int diff --git a/_cmptest/testdata/libxml2/2.13.6/libxml2/xlink.go b/_cmptest/testdata/libxml2/2.13.6/libxml2/xlink.go index 638fc3d5..839a8753 100644 --- a/_cmptest/testdata/libxml2/2.13.6/libxml2/xlink.go +++ b/_cmptest/testdata/libxml2/2.13.6/libxml2/xlink.go @@ -47,9 +47,9 @@ type XlinkExtendedLinkFunk func(c.Pointer, NodePtr, c.Int, *XlinkHRef, *XlinkRol type XlinkExtendedLinkSetFunk func(c.Pointer, NodePtr, c.Int, *XlinkHRef, *XlinkRole, c.Int, *XlinkTitle, **Char) type X_xlinkHandler struct { - Simple XlinkSimpleLinkFunk - Extended XlinkExtendedLinkFunk - Set XlinkExtendedLinkSetFunk + Simple c.Pointer + Extended c.Pointer + Set c.Pointer } type XlinkHandler X_xlinkHandler type XlinkHandlerPtr *XlinkHandler diff --git a/_cmptest/testdata/libxml2/2.13.6/libxml2/xpath.go b/_cmptest/testdata/libxml2/2.13.6/libxml2/xpath.go index 37430ff2..2bc7ce58 100644 --- a/_cmptest/testdata/libxml2/2.13.6/libxml2/xpath.go +++ b/_cmptest/testdata/libxml2/2.13.6/libxml2/xpath.go @@ -33,17 +33,17 @@ type X_xmlXPathContext struct { Here NodePtr Origin NodePtr NsHash HashTablePtr - VarLookupFunc XPathVariableLookupFunc + VarLookupFunc c.Pointer VarLookupData c.Pointer Extra c.Pointer Function *Char FunctionURI *Char - FuncLookupFunc XPathFuncLookupFunc + FuncLookupFunc c.Pointer FuncLookupData c.Pointer TmpNsList *NsPtr TmpNsNr c.Int UserData c.Pointer - Error StructuredErrorFunc + Error c.Pointer LastError Error DebugNode NodePtr Dict DictPtr @@ -142,7 +142,7 @@ type XPathConvertFunc func(XPathObjectPtr, c.Int) c.Int type X_xmlXPathType struct { Name *Char - Func XPathConvertFunc + Func c.Pointer } type XPathType X_xmlXPathType type XPathTypePtr *XPathType @@ -159,7 +159,7 @@ type XPathEvalFunc func(XPathParserContextPtr, c.Int) type X_xmlXPathFunct struct { Name *Char - Func XPathEvalFunc + Func c.Pointer } type XPathFunct X_xmlXPathFunct type XPathFuncPtr *XPathFunct @@ -169,7 +169,7 @@ type XPathAxisFunc func(XPathParserContextPtr, XPathObjectPtr) XPathObjectPtr type X_xmlXPathAxis struct { Name *Char - Func XPathAxisFunc + Func c.Pointer } type XPathAxis X_xmlXPathAxis type XPathAxisPtr *XPathAxis diff --git a/_cmptest/testdata/libxslt/1.1.42/libxslt/xsltInternals.go b/_cmptest/testdata/libxslt/1.1.42/libxslt/xsltInternals.go index 23d36019..56000327 100644 --- a/_cmptest/testdata/libxslt/1.1.42/libxslt/xsltInternals.go +++ b/_cmptest/testdata/libxslt/1.1.42/libxslt/xsltInternals.go @@ -10,7 +10,7 @@ const MAX_SORT = 15 type X_xsltRuntimeExtra struct { Info c.Pointer - Deallocate libxml2.FreeFunc + Deallocate c.Pointer Val struct { Ptr c.Pointer } @@ -200,9 +200,9 @@ type X_xsltTransformContext struct { Extras RuntimeExtraPtr StyleList DocumentPtr Sec c.Pointer - Error libxml2.GenericErrorFunc + Error c.Pointer Errctx c.Pointer - Sortfunc SortFunc + Sortfunc c.Pointer TmpRVT libxml2.DocPtr PersistRVT libxml2.DocPtr Ctxtflags c.Int @@ -232,9 +232,9 @@ type X_xsltTransformContext struct { OpCount c.Ulong SourceDocDirty c.Int CurrentId c.Ulong - NewLocale NewLocaleFunc - FreeLocale FreeLocaleFunc - GenSortKey GenSortKeyFunc + NewLocale c.Pointer + FreeLocale c.Pointer + GenSortKey c.Pointer } type TransformContext X_xsltTransformContext type TransformContextPtr *TransformContext @@ -242,9 +242,9 @@ type TransformContextPtr *TransformContext type X_xsltElemPreComp struct { Next ElemPreCompPtr Type StyleType - Func TransformFunction + Func c.Pointer Inst libxml2.NodePtr - Free ElemPreCompDeallocator + Free c.Pointer } type ElemPreComp X_xsltElemPreComp type ElemPreCompPtr *ElemPreComp @@ -287,7 +287,7 @@ type ElemPreCompDeallocator func(ElemPreCompPtr) type X_xsltStylePreComp struct { Next ElemPreCompPtr Type StyleType - Func TransformFunction + Func c.Pointer Inst libxml2.NodePtr Stype *libxml2.Char HasStype c.Int diff --git a/_cmptest/testdata/zlib/1.3.1/zlib/zlib.go b/_cmptest/testdata/zlib/1.3.1/zlib/zlib.go index 48a051de..60aa0bab 100644 --- a/_cmptest/testdata/zlib/1.3.1/zlib/zlib.go +++ b/_cmptest/testdata/zlib/1.3.1/zlib/zlib.go @@ -55,8 +55,8 @@ type ZStreamS struct { TotalOut ULong Msg *c.Char State *InternalState - Zalloc AllocFunc - Zfree FreeFunc + Zalloc c.Pointer + Zfree c.Pointer Opaque Voidpf DataType c.Int Adler ULong diff --git a/cl/internal/convert/_testdata/funcrefer/gogensig.expect b/cl/internal/convert/_testdata/funcrefer/gogensig.expect index 885a584e..a47e01c0 100644 --- a/cl/internal/convert/_testdata/funcrefer/gogensig.expect +++ b/cl/internal/convert/_testdata/funcrefer/gogensig.expect @@ -29,7 +29,7 @@ type Hooks struct { type Stream struct { F *c.FILE - Cb CallBack + Cb c.Pointer } // llgo:type C diff --git a/cl/internal/convert/type.go b/cl/internal/convert/type.go index ca0a8969..c9822fed 100644 --- a/cl/internal/convert/type.go +++ b/cl/internal/convert/type.go @@ -130,7 +130,6 @@ func (p *TypeConv) handlePointerType(t *ast.PointerType) (types.Type, error) { } } - // llgo with a anonymous function type current only support with pointer if baseFuncType, ok := baseType.(*types.Signature); ok { if p.ctx == Record { return p.typeMap.CType("Pointer"), nil @@ -147,6 +146,13 @@ func (p *TypeConv) handleIdentRefer(t ast.Expr) (types.Type, error) { if err != nil { return nil, err } + if p.ctx == Record { + if named, ok := typ.(*types.Named); ok { + if _, ok := named.Underlying().(*types.Signature); ok { + return p.typeMap.CType("Pointer"), nil + } + } + } return typ, nil } switch t := t.(type) { diff --git a/cmd/gogensig/testdata/lua/gogensig.expect b/cmd/gogensig/testdata/lua/gogensig.expect index 743b1c50..fe17528a 100644 --- a/cmd/gogensig/testdata/lua/gogensig.expect +++ b/cmd/gogensig/testdata/lua/gogensig.expect @@ -23,7 +23,7 @@ type Buffer struct { type Reg struct { Name *c.Char - Func CFunction + Func c.Pointer } //go:linkname Checkversion C.luaL_checkversion_ @@ -163,7 +163,7 @@ func Buffinitsize(L *State, B *Buffer, sz c.SizeT) *c.Char type Stream struct { F *c.FILE - Closef CFunction + Closef c.Pointer } ===== lua.go =====