Skip to content

Commit

Permalink
gogensig:block implict incomplete recreate #67
Browse files Browse the repository at this point in the history
  • Loading branch information
luoliwoshang committed Dec 25, 2024
1 parent a0e793a commit d326a0c
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
5 changes: 5 additions & 0 deletions cmd/gogensig/convert/_testdata/receiver/conf/llcppg.symb.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
[
{
"mangle": "ares_dns_pton",
"c++": "ares_dns_pton(const char *, struct ares_addr *, int *)",
"go": "AresDnsPton"
},
{
"mangle": "ares_dns_addr_to_ptr",
"c++": "ares_dns_addr_to_ptr(const struct ares_addr *)",
Expand Down
8 changes: 6 additions & 2 deletions cmd/gogensig/convert/_testdata/receiver/gogensig.expect
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import (
)

type X__Uint32T c.Uint
type InAddrT X__Uint32T
type InAddrT struct {
Unused [8]uint8
}

type InAddr struct {
SAddr InAddrT
Expand All @@ -22,14 +24,16 @@ type AresIn6Addr struct {
===== use.go =====
package receiver

import _ "unsafe"
import "unsafe"

type AresAddr struct {
Family c.Int
Addr struct {
Addr6 AresIn6Addr
}
}
//go:linkname AresDnsPton C.ares_dns_pton
func AresDnsPton(ipaddr *int8, addr *AresAddr, out_len *uintptr) unsafe.Pointer
// llgo:link (*aresAddr).AresDnsAddrToPtr C.ares_dns_addr_to_ptr
func (p *AresAddr) AresDnsAddrToPtr() *int8 {
return nil
Expand Down
1 change: 1 addition & 0 deletions cmd/gogensig/convert/_testdata/receiver/hfile/temp.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <stddef.h>
typedef unsigned int __uint32_t;
typedef __uint32_t in_addr_t;
struct in_addr {
Expand Down
3 changes: 2 additions & 1 deletion cmd/gogensig/convert/_testdata/receiver/hfile/use.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@

// todo(zzy): ares_addr need generate in the temp.go
const void *ares_dns_pton(const char *ipaddr, struct ares_addr *addr, size_t *out_len);
char *ares_dns_addr_to_ptr(const struct ares_addr *addr);
3 changes: 3 additions & 0 deletions cmd/gogensig/convert/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,9 @@ func (p *Package) handleCompleteType(decl *gogen.TypeDecl, typ *ast.RecordType,
// For such declarations, create a empty type decl and store it in the
// incomplete map, but not in the public symbol table.
func (p *Package) handleImplicitForwardDecl(name string) *gogen.TypeDecl {
if decl, ok := p.incomplete[name]; ok {
return decl
}
pubName := p.nameMapper.GetGoName(name, p.trimPrefixes())
decl := p.emptyTypeDecl(pubName, nil)
p.incomplete[name] = decl
Expand Down

0 comments on commit d326a0c

Please sign in to comment.